38 std::shared_ptr<std::string>
str_;
42 void *
shptr()
const override {
return static_cast<void *
>(
str_.get() ); }
48 explicit SOS(
const std::string & p_str )
50 str_(std::make_shared<std::string>(p_str)) {
66 SOS(
const SOshptr & p_other,
const std::string & p_str )
68 str_( std::make_shared<std::string>(p_str) ) {
81 SOS & operator=(
const SOS & ) =
delete;
82 SOS & operator=(
SOS && ) =
delete;
96 [[nodiscard]]
SOS *
dup()
const override {
return new SOS( *
this ); }
121 std::string_view
type()
const override {
return "stringtype"; }
126 bool equal(
const SO * p_other )
const override {
129 if( p_other->
ot() !=
ot() )
131 const auto o =
static_cast<const SOS *
>( p_other );
147 const auto o =
static_cast<const SOS *
>( p_other );
149 return *
str_ > *(
o->str_);
163 const auto o =
static_cast<const SOS *
>( p_other );
165 return *
str_ >= *(
o->str_);
178 void putCh(
size_t p_index,
int p_char );
194 void replace(
size_t p_pos,
const std::string & p_src ) {
197 str_->replace( p_pos, p_src.size(), p_src );
Semantic Object String.
Definition sos.h:35
std::string getString() const
Getter for the string value.
Definition sos.h:87
SOS * dup() const override
Creates a new instance as copy following the red book definition.
Definition sos.h:96
SOS * clone() const override
Creates a new instance as copy with deep cloning.
Definition sos.h:103
std::string & getStringRef()
Getter for reference to the string value.
Definition sos.h:92
void * shptr() const override
Pointer to the shared object.
Definition sos.h:42
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sos.h:112
SOS(const SOshptr &p_other, const std::string &p_str)
Ctor from parent class.
Definition sos.h:66
void replace(size_t p_pos, const std::string &p_src)
Replaces characters at position p_pos.
Definition sos.h:194
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sos.h:126
void erase0()
Erases the fist character of the String.
Definition sos.h:182
~SOS() override
Dtor.
Definition sos.h:74
size_t getSize() const override
Returns the size of the SO.
Definition sos.h:169
std::shared_ptr< std::string > str_
The string value.
Definition sos.h:38
bool ge(OpError &p_ec, const SO *p_other) const override
Greater or equal.
Definition sos.h:156
OTCode ot() const override
Returns an OTCode.
Definition sos.h:118
void putCh(size_t p_index, int p_char)
Sets a single character within the string.
Definition sos.cpp:27
std::string_view type() const override
Returns a type name.
Definition sos.h:121
std::string opequalequal() const override
String representation for operators '==' and 'pstack'.
Definition sos.h:115
SOS(const SOS &p_other)
Copy ctor.
Definition sos.h:56
bool gt(OpError &p_ec, const SO *p_other) const override
Greater than.
Definition sos.h:140
SOS(const std::string &p_str)
Ctor from string reference.
Definition sos.h:48
Semantic Object.
Definition so.h:67
virtual OTCode ot() const =0
Returns an OTCode.
Semantic Object with shared pointer to data.
Definition so.h:210
Helpers for design by contract idioms.
#define DBC_POST(XXX)
Assert for postconditions.
Definition dbc.h:110
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition dbc.h:122
#define DBC_INV
Assert for invariant checks in member functions.
Definition dbc.h:114
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:104
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:38