Leonardus
|
Semantic Object stacK. More...
#include <sok.h>
Classes | |
struct | SOKDeque |
Semantic Object Stack - deque member class. More... | |
Public Member Functions | |
SOK () | |
Ctor. | |
SOK * | dup () const override |
Creates a new instance as copy following the red book definition. More... | |
SOK * | clone () const override |
Creates a new instance as copy with deep cloning. More... | |
std::string | opequalequal () const override |
For operators '==' and 'pstack'. More... | |
OTCode | ot () const override |
Returns an OTCode. More... | |
std::string | type () const override |
Returns a type name. More... | |
bool | equal (const SO *p_other) const override |
Equality. More... | |
size_t | getSize () const override |
Getter for the number of characters or number of objects. More... | |
size_t | treeheight (size_t p_myheight) const override |
Tree Height. More... | |
size_t | getWatermark () const |
Returns the watermark. | |
void | setSO (size_t p_index, SOp p_sop) |
Setter for a stack object. More... | |
SOp | at (size_t p_pos) const |
Returns a copy of the SOp at the given position. More... | |
SOp | peek () const |
Returns a copy of the SOp of the top most position. More... | |
SOp | pop () |
Returns a copy of the top SOp, removes the SOp from the SOK. More... | |
void | pop_delete () |
Removes the top most object from SOK, and the referenced SO will be deleted. More... | |
void | push (SOp p_o1) |
Pushes the object onto the SOK and transfers ownership to the SOK. More... | |
void | push (std::initializer_list< SOp > p_list) |
Pushes n objects onto the SOK and transfers ownership to the SOK. More... | |
void | push_front (SOp p_obj) |
Pushes the object onto the front side of the SOK and transfers ownership to the SOK. More... | |
bool | underflowcheck (size_t p_size) const |
Checks SOK against given size. | |
bool | otchecker (std::initializer_list< OTCode > p_list) const |
Checks SO classes on the operand stack against a list of given OTCodes. More... | |
bool | otchecker (OTCode p_code) const |
Checks SO classes on the operand stack against an OTCode. More... | |
bool | countto (size_t &p_retval, OTCode p_code) const |
Count the objects on the SOK down to but excluding the object from the given type. More... | |
SOp | findValue (const SO *p_key) const |
Finds the given key within the whole stack, assuming a stack with dictionaries only. More... | |
SOp | findDict (const SO *p_key) const |
Finds the dictionary storing the given key within the whole stack, assuming a stack with dictionaries only. More... | |
__int128 | getI () |
I from SOK. More... | |
__float128 | getR () |
R from SOK. More... | |
__float128 | getIorRasR () |
I or R from SOK as R Deletes the top object after reading its value. More... | |
size_t | getISize_t () |
I from SOK as size_t. More... | |
![]() | |
std::string | opequal () const override |
For operators '=', 'cvs' and 'stack'. More... | |
virtual size_t | treeheight (size_t p_myheigth) const |
Tree Height. More... | |
SO (bool p_exec=false) | |
Ctor. | |
![]() | |
SO (bool p_exec=false) | |
Ctor. | |
virtual | ~SO ()=default |
Virtual dtor. More... | |
bool | getExec () const |
Getter for exec_. | |
void | setExec (bool p_exec) |
Setter for exec_. | |
virtual size_t | getSize () const |
Getter for the number of characters or number of objects. More... | |
virtual SO * | dup () const =0 |
Creates a new instance as copy following the red book definition. More... | |
virtual SO * | clone () const |
Creates a new instance as copy with deep cloning. More... | |
virtual std::string | opequal () const =0 |
For operators '=', 'cvs' and 'stack'. More... | |
virtual std::string | opequalequal () const |
For operators '==' and 'pstack'. More... | |
virtual OTCode | ot () const =0 |
Returns an OTCode. More... | |
virtual std::string | type () const =0 |
Returns a type name. More... | |
virtual bool | equal (const SO *) const =0 |
Equality. More... | |
virtual bool | gt (const SO *) const |
Greater than. More... | |
virtual bool | ge (const SO *) const |
Greater or equal. More... | |
![]() | |
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. More... | |
![]() | |
Counter () | |
Ctor. | |
Counter (const Counter< SO > &) | |
Copy ctor. | |
~Counter () | |
Dtor. | |
virtual bool | invariant () const noexcept |
Checks the invariants of the class in which it is defined. More... | |
Private Attributes | |
std::shared_ptr< SOKDeque > | deque_ |
The shared deque. | |
Additional Inherited Members | |
![]() | |
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. | |
Semantic Object stacK.
Our own container adapter to std::deque to build a stack. It's a stack of pointers to SO. The bottom object has position 0. The top most object has position size-1.
|
inline |
Returns a copy of the SOp at the given position.
The SOK keeps ownership.
[in] | p_pos | position, which is not checked. |
|
overridevirtual |
Creates a new instance as copy with deep cloning.
Reimplemented from SO.
bool SOK::countto | ( | size_t & | p_retval, |
OTCode | p_code | ||
) | const |
Count the objects on the SOK down to but excluding the object from the given type.
Implemented without C++ polymorphisms.
[out] | p_retval | number of objects |
[in] | p_code | OTCode to find |
|
inlineoverridevirtual |
Creates a new instance as copy following the red book definition.
Implements SO.
|
inlineoverridevirtual |
Equality.
Equality means: SOL und SOM are always equal.
For SOD 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<>.
Implements SO.
Finds the dictionary storing the given key within the whole stack, assuming a stack with dictionaries only.
Equality is determined by SO::equal(). We return a SOp instead of a SOD * to reduce coupling.
Finds the given key within the whole stack, assuming a stack with dictionaries only.
Equality is determined by SO::equal().
__int128 SOK::getI | ( | ) |
I from SOK.
Deletes the top object after reading its integer value. Checks the type of the operand stack object. Does not check for stack underflow.
__float128 SOK::getIorRasR | ( | ) |
I or R from SOK as R Deletes the top object after reading its value.
Checks the type of the operand stack object. Does not check for stack underflow.
size_t SOK::getISize_t | ( | ) |
I from SOK as size_t.
Deletes the top object after reading its integer value. Exits with rangecheck, if the integer from stack can not be converted to size_t. Checks the type of the operand stack object. Does not check for stack underflow.
__float128 SOK::getR | ( | ) |
R from SOK.
Deletes the top object after reading its real value. Checks the type of the operand stack object. Does not check for stack underflow.
|
inlineoverridevirtual |
Getter for the number of characters or number of objects.
Reimplemented from SO.
|
inlineoverrideprotectedvirtualnoexcept |
Checks class invariants.
Reimplemented from DbC.
|
overridevirtual |
For operators '==' and 'pstack'.
This function attempts to produce a result that resembles the red book syntax for creating the object.
Reimplemented from SO.
|
inlineoverridevirtual |
Returns an OTCode.
A "manual" implementation of polymorphism, where C++-polymorphisms fail
Implements SO.
|
inline |
Checks SO classes on the operand stack against an OTCode.
bool SOK::otchecker | ( | std::initializer_list< OTCode > | p_list | ) | const |
Checks SO classes on the operand stack against a list of given OTCodes.
OTC::X in p_list matches all object types on the stack.
|
inline |
Returns a copy of the SOp of the top most position.
The SOK keeps ownership. Calling peek on an empty stack causes undefined behavior.
|
inline |
Returns a copy of the top SOp, removes the SOp from the SOK.
The returned SOp becomes the owner.
|
inline |
void SOK::push | ( | SOp | p_o1 | ) |
void SOK::push | ( | std::initializer_list< SOp > | p_list | ) |
void SOK::push_front | ( | SOp | p_obj | ) |
|
inline |
|
overridevirtual |
Tree Height.
The composite semantic objects can contain other composite semantic objects.
This creates a tree of objects. treeheigth() calculates the height of this tree
starting at this
.
Loops will be dedected by an heuristics. We stop the recursion if the heigth exceeds
maxtreeheight
.
[in] | p_myheigth | ... Call with value 0. Used internally for recursion. |
Reimplemented from SOcomposite.
|
inlineoverridevirtual |