30 std::shared_ptr<std::string>
str_;
38 return str_ !=
nullptr;
44 explicit SOS(
const std::string & p_str ) :
str_(std::make_shared<std::string>(p_str)) {
54 void setch(
size_t p_index,
int p_char );
57 [[nodiscard]]
SOS *
dup()
const override {
return new SOS( *
this ); }
77 std::string
type()
const override {
return "stringtype"; }
79 bool equal(
const SO * p_other )
const override {
80 auto o =
dynamic_cast<const SOS *
>( p_other );
81 return o ? *
str_ == *(
o->str_) :
false;
84 bool gt(
const SO * p_other )
const override {
85 auto o =
dynamic_cast<const SOS *
>( p_other );
88 return *
str_ > *(
o->str_);
91 bool ge(
const SO * p_other )
const override {
92 auto o =
dynamic_cast<const SOS *
>( p_other );
95 return *
str_ >= *(
o->str_);
110 void replace(
size_t p_pos,
const std::string & p_src ) {
113 str_->replace( p_pos, p_src.size(), p_src );
Semantic Object String.
Definition: sos.h:29
std::string getString() const
Getter for the string value.
Definition: sos.h:50
SOS * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sos.h:57
SOS * clone() const override
Creates a new instance as copy with deep cloning.
Definition: sos.h:62
bool ge(const SO *p_other) const override
Greater or equal.
Definition: sos.h:91
bool gt(const SO *p_other) const override
Greater than.
Definition: sos.h:84
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sos.h:71
bool invariant() const noexcept override
Checks class invariants.
Definition: sos.h:37
void replace(size_t p_pos, const std::string &p_src)
Replaces characters at position p_pos.
Definition: sos.h:110
void setch(size_t p_index, int p_char)
Sets a single character within the string.
Definition: sos.cpp:24
bool equal(const SO *p_other) const override
Equality.
Definition: sos.h:79
void erase0()
Erases the fist character of the String.
Definition: sos.h:102
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sos.h:98
std::string type() const override
Returns a type name.
Definition: sos.h:77
std::shared_ptr< std::string > str_
The string value.
Definition: sos.h:30
OTCode ot() const override
Returns an OTCode.
Definition: sos.h:75
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition: sos.h:73
SOS(const std::string &p_str)
Ctor.
Definition: sos.h:44
Semantic Object.
Definition: so.h:54
bool getExec() const
Getter for exec_.
Definition: so.h:70
Composite Semantic Object.
Definition: so.h:161
Helpers for design by contract idioms.
#define DBC_POST(XXX)
Assert for postconditions.
Definition: dbc.h:80
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition: dbc.h:88
#define DBC_INV
Assert for invariant checks in member functions.
Definition: dbc.h:83
#define DBC_PRE(XXX)
Assert for preconditions.
Definition: dbc.h:77
void opErrExit(OpError p_err, const std::string &p_details, const std::source_location p_location)
Operator error message to interpreter cout_ and exit( EC_OPERATOR ).
Definition: error.cpp:28
@ typecheck
PS operator error typecheck.
Definition: error.h:33
Miscellaneous definitions and functions.
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition: so.h:29