ORIGINAL
Loading...
Searching...
No Matches
wrapper.h
Go to the documentation of this file.
1#ifndef WRAPPER_H
2#define WRAPPER_H
3#pragma once
4#include <sstream>
5#include <string>
6#include "printable.h"
7
14
15namespace original {
16
27template <typename TYPE>
28class wrapper : public printable {
29public:
34 virtual TYPE& getVal() = 0;
35
40 virtual const TYPE& getVal() const = 0;
41
47 virtual void setVal(TYPE data) = 0;
48
53 virtual wrapper* getPPrev() const = 0;
54
59 virtual wrapper* getPNext() const = 0;
60
67 ~wrapper() override = default;
68
79 [[nodiscard]] std::string className() const override;
80
92 [[nodiscard]] std::string toString(bool enter) const override;
93};
94
95} // namespace original
96
97// ----------------- Definitions of wrapper.h -----------------
98
99template <typename TYPE>
100auto original::wrapper<TYPE>::className() const -> std::string
101{
102 return "wrapper";
103}
104
105template<typename TYPE>
106auto original::wrapper<TYPE>::toString(const bool enter) const -> std::string
107{
108 std::stringstream ss;
109 ss << this->className() << "("
110 << formatString(this) << ", "
111 << formatString(this->getVal()) << ")";
112 if (enter) ss << "\n";
113 return ss.str();
114}
115
116#endif // WRAPPER_H
Base class providing polymorphic string conversion capabilities.
Definition printable.h:25
static std::string formatString(const TYPE &t)
Universal value-to-string conversion.
Base class for linked value containers with formatted output.
Definition wrapper.h:28
virtual wrapper * getPNext() const =0
Retrieves next node in container sequence.
virtual wrapper * getPPrev() const =0
Retrieves previous node in container sequence.
virtual const TYPE & getVal() const =0
Accesses the contained value (immutable).
virtual TYPE & getVal()=0
Accesses the contained value (mutable).
virtual void setVal(TYPE data)=0
Updates the contained value.
std::string className() const override
Provides class identifier for diagnostics. See original::printable::className()
Definition wrapper.h:100
~wrapper() override=default
Destructor for the wrapper class.
std::string toString(bool enter) const override
Generates formatted diagnostic string. See original::printable::toString()
Definition wrapper.h:106
Main namespace for the project Original.
Definition algorithms.h:21
Interface for polymorphic string formatting and output.