Leonardus
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SOS Class Reference

Semantic Object String. More...

#include <sos.h>

+ Inheritance diagram for SOS:
+ Collaboration diagram for SOS:

Public Member Functions

 SOS (const std::string &p_str)
 Ctor from string reference.
 
 SOS (const SOS &p_other)
 Copy ctor.
 
 ~SOS () override
 Dtor.
 
 SOS (SOS &&)=delete
 
SOS & operator= (const SOS &)=delete
 
SOS & operator= (SOS &&)=delete
 
std::string getString () const
 Getter for the string value.
 
std::string & getStringRef ()
 Getter for reference to the string value.
 
SOS * dup () const override
 Creates a new instance as copy following the red book definition.
 
SOS * clone () const override
 Creates a new instance as copy with deep cloning.
 
std::string opequal () const override
 String representation of object for operators '=', 'cvs' and 'stack'.
 
std::string opequalequal () const override
 String representation for operators '==' and 'pstack'.
 
OTCode ot () const override
 Returns an OTCode.
 
std::string type () const override
 Returns a type name.
 
bool equal (const SO *p_other) const override
 Checks if this SO is equal to another SO.
 
bool gt (OpError &p_ec, const SO *p_other) const override
 Greater than.
 
bool ge (OpError &p_ec, const SO *p_other) const override
 Greater or equal.
 
size_t getSize () const override
 Returns the size of the SO.
 
void putCh (size_t p_index, int p_char)
 Sets a single character within the string.
 
void erase0 ()
 Erases the fist character of the String.
 
void replace (size_t p_pos, const std::string &p_src)
 Replaces characters at position p_pos.
 
- Public Member Functions inherited from SOcomposite
virtual size_t treeheight (size_t p_myheigth) const
 Tree Height.
 
 SO ()
 Ctor.
 
 SO (bool p_exec)
 Ctor.
 
 SO (const SO &p_other)
 Copy ctor.
 
 SO (SO &&)=delete
 
- Public Member Functions inherited from SO
 SO ()
 Ctor.
 
 SO (bool p_exec)
 Ctor.
 
 SO (const SO &p_other)
 Copy ctor.
 
virtual ~SO ()
 Virtual dtor.
 
 SO (SO &&)=delete
 
SO & operator= (const SO &)=delete
 
SO & operator= (SO &&)=delete
 
bool getExec () const
 Getter for exec_.
 
void setExec (bool p_exec)
 Setter for exec_.
 
- Public Member Functions inherited from Counter< SO >
 Counter (Counter< SO > &&)=delete
 
Counter< SO > & operator= (const Counter< SO > &)=delete
 
Counter< SO > & operator= (Counter< SO > &&)=delete
 

Protected Member Functions

bool invariant () const noexcept override
 Checks class invariants.
 
- Protected Member Functions inherited from Counter< SO >
 Counter ()
 Ctor.
 
 Counter (const Counter< SO > &)
 Copy ctor.
 
 ~Counter ()
 Dtor.
 
- Protected Member Functions inherited from DbC
 ~DbC ()=default
 Protected dtor.
 

Private Attributes

std::shared_ptr< std::string > str_
 The string value.
 

Additional Inherited Members

- Static Public Member Functions inherited from Counter< SO >
static size_t getTotalCounter ()
 Static getter for totaly created objects.
 
static size_t getAliveCounter ()
 Static getter for objects alive.
 
static size_t getWatermarkCounter ()
 Static getter for the object counter watermark.
 

Detailed Description

Semantic Object String.

Invariant
shared pointer is not null.

Constructor & Destructor Documentation

◆ SOS()

SOS::SOS ( const std::string &  p_str)
inlineexplicit

Ctor from string reference.

Parameters
[in]p_strSource.

Member Function Documentation

◆ clone()

SOS * SOS::clone ( ) const
inlineoverridevirtual

Creates a new instance as copy with deep cloning.

Default implementation falls back to dup().
Subclasses must override this if deep cloning is required.

Returns
SO * ... A deep copy.
Postcondition
return value != nullptr
return value maintains invariants

Reimplemented from SO.

◆ dup()

SOS * SOS::dup ( ) const
inlineoverridevirtual

Creates a new instance as copy following the red book definition.

Returns
SO * ... A copy.

Implements SO.

◆ equal()

bool SOS::equal ( const SO *  p_other) const
inlineoverridevirtual

Checks if this SO is equal to another SO.

Equality means:
SOL und SOM are always equal.
For SOD, SOF and SOK, share_ptr<> points to the same object.
For SOA, share_ptr<> points to the same object, but empty arrays are equal nonetheless.
For SOO and SOo the function pointer must be the same.
Otherwise the value must be the same, even for SOS with shared_ptr<>.

Returns
bool ... true if the SO's are of the same type and equal
See also
Will be used directly and unchanged as operator eq
Parameters
[in]p_otherThe object to compare with.

Implements SO.

◆ ge()

bool SOS::ge ( OpError &  p_ec,
const SO *  p_other 
) const
inlineoverridevirtual

Greater or equal.

The redundancy between equal(), gt() and ge() is a matter of performance.

Parameters
[out]p_ecError code.
Returns
bool ... true is comparable and ge.
Parameters
[in]p_otherThe object to compare with.

Reimplemented from SO.

◆ getSize()

size_t SOS::getSize ( ) const
inlineoverridevirtual

Returns the size of the SO.

Default implementation returns 1 (for simple objects).
Override in subclasses to return the actual size (e.g., length of a string, number of elements in a composite).

Reimplemented from SO.

◆ getStringRef()

std::string & SOS::getStringRef ( )
inline

Getter for reference to the string value.

Returns
std::string & ... Reference to the internal string. The caller must not delete it.

◆ gt()

bool SOS::gt ( OpError &  p_ec,
const SO *  p_other 
) const
inlineoverridevirtual

Greater than.

The redundancy between equal(), gt() and ge() is a matter of performance.

Parameters
[out]p_ecError code.
Returns
bool ... true is comparable and gt.
Parameters
[in]p_otherThe object to compare with.

Reimplemented from SO.

◆ invariant()

bool SOS::invariant ( ) const
inlineoverrideprotectedvirtualnoexcept

Checks class invariants.

Returns
bool ... Indicates whether the class invariants are maintained.

Reimplemented from DbC.

◆ opequal()

std::string SOS::opequal ( ) const
inlineoverridevirtual

String representation of object for operators '=', 'cvs' and 'stack'.

Returns
std::string ... The representation.

Reimplemented from SOcomposite.

◆ opequalequal()

std::string SOS::opequalequal ( ) const
inlineoverridevirtual

String representation for operators '==' and 'pstack'.

This function attempts to produce a result that resembles the red book syntax
for creating the object.

Returns
std::string ... The representation.

Reimplemented from SO.

◆ ot()

OTCode SOS::ot ( ) const
inlineoverridevirtual

Returns an OTCode.

A "manual" implementation of polymorphism, where C++-polymorphisms fail

Returns
OTCode ... The OTCode of the instance.

Implements SO.

◆ putCh()

void SOS::putCh ( size_t  p_index,
int  p_char 
)

Sets a single character within the string.

Precondition
p_index < stringsize
Parameters
[in]p_indexThe index. No rangecheck takes place.
[in]p_charThe character.

◆ replace()

void SOS::replace ( size_t  p_pos,
const std::string &  p_src 
)
inline

Replaces characters at position p_pos.

Precondition
p_pos+p_src.size() <= this->size()
Parameters
[in]p_posPosition of the replacement.
[in]p_srcThe new characters.

◆ type()

std::string SOS::type ( ) const
inlineoverridevirtual

Returns a type name.

Returns
std::string ... The type name of the instance.

Implements SO.


The documentation for this class was generated from the following files: