34 std::shared_ptr<std::string>
str_;
42 return str_ !=
nullptr;
48 explicit SOS(
const std::string & p_str ) :
str_(std::make_shared<std::string>(p_str)) {
58 void setch(
size_t p_index,
int p_char );
61 [[nodiscard]]
SOS *
dup()
const override {
return new SOS( *
this ); }
81 std::string
type()
const override {
return "stringtype"; }
83 bool equal(
const SO * p_other )
const override {
84 auto o =
dynamic_cast<const SOS *
>( p_other );
85 return o ? *
str_ == *(
o->str_) :
false;
88 bool gt(
const SO * p_other )
const override {
89 auto o =
dynamic_cast<const SOS *
>( p_other );
92 return *
str_ > *(
o->str_);
95 bool ge(
const SO * p_other )
const override {
96 auto o =
dynamic_cast<const SOS *
>( p_other );
99 return *
str_ >= *(
o->str_);
114 void replace(
size_t p_pos,
const std::string & p_src ) {
117 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:54
SOS * dup() const override
Creates a new instance as copy following the red book definition.
Definition sos.h:61
SOS * clone() const override
Creates a new instance as copy with deep cloning.
Definition sos.h:66
bool ge(const SO *p_other) const override
Greater or equal.
Definition sos.h:95
bool gt(const SO *p_other) const override
Greater than.
Definition sos.h:88
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sos.h:75
bool invariant() const noexcept override
Checks class invariants.
Definition sos.h:41
void replace(size_t p_pos, const std::string &p_src)
Replaces characters at position p_pos.
Definition sos.h:114
void setch(size_t p_index, int p_char)
Sets a single character within the string.
Definition sos.cpp:27
bool equal(const SO *p_other) const override
Equality.
Definition sos.h:83
void erase0()
Erases the fist character of the String.
Definition sos.h:106
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition sos.h:102
std::string type() const override
Returns a type name.
Definition sos.h:81
std::shared_ptr< std::string > str_
The string value.
Definition sos.h:34
OTCode ot() const override
Returns an OTCode.
Definition sos.h:79
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition sos.h:77
SOS(const std::string &p_str)
Ctor.
Definition sos.h:48
Semantic Object.
Definition so.h:58
bool getExec() const
Getter for exec_.
Definition so.h:74
Composite Semantic Object.
Definition so.h:165
Helpers for design by contract idioms.
#define DBC_POST(XXX)
Assert for postconditions.
Definition dbc.h:81
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition dbc.h:89
#define DBC_INV
Assert for invariant checks in member functions.
Definition dbc.h:84
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:78
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:31
@ typecheck
PS operator error typecheck.
Definition error.h:34
Miscellaneous definitions and functions.
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:33