36 std::shared_ptr<std::string>
str_;
46 return str_ !=
nullptr;
54 explicit SOS(
const std::string & p_str )
56 str_(std::make_shared<std::string>(p_str)) {
75 SOS & operator=(
const SOS & ) =
delete;
76 SOS & operator=(
SOS && ) =
delete;
90 [[nodiscard]]
SOS *
dup()
const override {
return new SOS( *
this ); }
115 std::string
type()
const override {
return "stringtype"; }
120 bool equal(
const SO * p_other )
const override {
121 auto o =
dynamic_cast<const SOS *
>( p_other );
122 return o ? *
str_ == *(
o->str_) :
false;
129 auto o =
dynamic_cast<const SOS *
>( p_other );
135 return *
str_ > *(
o->str_);
142 auto o =
dynamic_cast<const SOS *
>( p_other );
148 return *
str_ >= *(
o->str_);
161 void putCh(
size_t p_index,
int p_char );
177 void replace(
size_t p_pos,
const std::string & p_src ) {
180 str_->replace( p_pos, p_src.size(), p_src );
Semantic Object String.
Definition sos.h:33
std::string getString() const
Getter for the string value.
Definition sos.h:81
SOS * dup() const override
Creates a new instance as copy following the red book definition.
Definition sos.h:90
SOS * clone() const override
Creates a new instance as copy with deep cloning.
Definition sos.h:96
std::string & getStringRef()
Getter for reference to the string value.
Definition sos.h:86
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sos.h:106
bool invariant() const noexcept override
Checks class invariants.
Definition sos.h:45
void replace(size_t p_pos, const std::string &p_src)
Replaces characters at position p_pos.
Definition sos.h:177
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sos.h:120
void erase0()
Erases the fist character of the String.
Definition sos.h:165
~SOS() override
Dtor.
Definition sos.h:68
size_t getSize() const override
Returns the size of the SO.
Definition sos.h:152
std::string type() const override
Returns a type name.
Definition sos.h:115
std::shared_ptr< std::string > str_
The string value.
Definition sos.h:36
bool ge(OpError &p_ec, const SO *p_other) const override
Greater or equal.
Definition sos.h:141
OTCode ot() const override
Returns an OTCode.
Definition sos.h:112
void putCh(size_t p_index, int p_char)
Sets a single character within the string.
Definition sos.cpp:28
std::string opequalequal() const override
String representation for operators '==' and 'pstack'.
Definition sos.h:109
SOS(const SOS &p_other)
Copy ctor.
Definition sos.h:62
bool gt(OpError &p_ec, const SO *p_other) const override
Greater than.
Definition sos.h:128
SOS(const std::string &p_str)
Ctor from string reference.
Definition sos.h:54
Semantic Object.
Definition so.h:60
bool getExec() const
Getter for exec_.
Definition so.h:93
Composite Semantic Object.
Definition so.h:198
Helpers for design by contract idioms.
#define DBC_POST(XXX)
Assert for postconditions.
Definition dbc.h:109
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition dbc.h:121
#define DBC_INV
Assert for invariant checks in member functions.
Definition dbc.h:113
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:103
OpError
Operator error code enum.
Definition error.h:30
@ success
No operator error.
Definition error.h:32
@ typecheck
operator error typecheck
Definition error.h:36
Miscellaneous definitions and functions.
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:35