31 string opequal()
const override {
return "--nostringval--"; }
34 bool equal(
const SO* p_other )
const override {
35 return dynamic_cast<const SOM*
>( p_other) !=
nullptr;
46 string opequal()
const override {
return "--nostringval--"; }
49 bool equal(
const SO* p_other )
const override {
50 return dynamic_cast<const SO0*
>( p_other) !=
nullptr;
65 explicit SOI( __int128 p_i ) :
i_(p_i) {}
77 bool equal(
const SO* p_other )
const override {
78 const SOI* o =
dynamic_cast<const SOI*
>( p_other);
79 if( o )
return i_ == o->
i_;
92 explicit SOB(
const string& p_s ) {
b_ = p_s ==
"true"; }
94 explicit SOB(
bool p_b ) :
b_(p_b) {}
104 string opequal()
const override {
return b_ ?
"true" :
"false"; }
106 bool equal(
const SO* p_other )
const override {
107 const SOB* o =
dynamic_cast<const SOB*
>( p_other);
108 if( o )
return b_ == o->
b_;
129 explicit SOR( __float128 p_r ) :
r_(p_r) {}
141 bool equal(
const SO* p_other )
const override {
142 const SOR* o =
dynamic_cast<const SOR*
>( p_other);
143 if( o )
return r_ == o->
r_;
156 explicit SON(
const string& p_n,
bool p_exec =
false ) :
SO(p_exec),
n_(p_n) { }
165 bool equal(
const SO* p_other )
const override {
166 const SON* o =
dynamic_cast<const SON*
>( p_other);
167 if( o )
return n_ == o->
n_;
188 explicit SOO(
void (*p_f)(
Context & ),
const string& p_s ) :
f_(p_f),
s_(p_s) { }
192 string opequal()
const override {
return "--"+
s_+
"--"; }
194 bool equal(
const SO* p_other )
const override {
195 const SOO* o =
dynamic_cast<const SOO*
>( p_other);
196 if( o )
return f_ == o->
f_;
215 SOo(
void (*p_f)(
Context & ),
const string & p_s,
size_t p_stackusage )
236 shared_ptr<string>
s_;
239 explicit SOS( shared_ptr<string> p_s ) :
s_(p_s) {}
243 explicit SOS(
string p_s ) :
s_(make_shared<string>(p_s)) { }
258 bool equal(
const SO* p_other )
const override {
259 const SOS* o =
dynamic_cast<const SOS*
>( p_other);
260 if( o )
return *
s_ == *(o->
s_);
269 void setch(
size_t index,
int ch ) { (*s_)[index] = ch; }
290 shared_ptr<SOAArray>
v_;
293 SOA( shared_ptr<SOAArray> p_v,
bool p_exec ) :
SO(p_exec),
v_(p_v) {}
297 explicit SOA(
size_t p_l = 0,
bool p_exec =
false ) :
SO(p_exec) {
298 v_ = make_shared<SOAArray>();
299 for(
size_t i = 1; i <= p_l; i++ )
300 v_->a_.push_back(
new SO0 );
308 delete v_->a_[p_index];
309 v_->a_[p_index] = p_o;
315 SOp at(
size_t p_pos )
const {
return v_->a_.at( p_pos ); }
321 for(
size_t i = 0; i <
getSize(); i++ )
325 string opequal()
const override {
return "--nostringval--"; }
328 bool equal(
const SO* p_other )
const override {
329 const SOA* o =
dynamic_cast<const SOA*
>( p_other);
336 size_t getSize()
const override {
return v_->a_.size(); }
347 SOp last =
v_->a_.at( s-1 );
355 for(
size_t s =
getSize(); s>0; s-- )
362 SOp retval =
v_->a_.at(0);
363 v_->a_.erase(
v_->a_.begin() );
378 ~SODMap() {
for(
const auto& ptr :
a_ ) {
delete ptr.first;
delete ptr.second; } }
380 shared_ptr<SODMap>
d_;
383 explicit SOD( shared_ptr<SODMap> p_d ) :
d_(p_d) {}
387 SOD() {
d_ = make_shared<SODMap>(); }
393 for(
auto& ptr :
d_->a_ ) rv->
insert( ptr.first->clone(), ptr.second->clone() );
396 string opequal()
const override {
return "--nostringval--"; }
399 bool equal(
const SO* p_other )
const override {
400 const SOD* o =
dynamic_cast<const SOD*
>( p_other);
401 if( o )
return d_ == o->
d_;
404 size_t getSize()
const override {
return d_->a_.size(); }
413 bool p_forcebegin =
false
426 auto it =
d_->a_.begin();
427 pair<SOp,SOp> retval( *it );
The context of execution.
Definition: context.h:17
Stack & exst()
Access to the execution stack.
Definition: context.h:47
Semantic Object Null.
Definition: sox.h:43
public_virtual SO0 * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:45
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:49
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:46
string opequalequal(Context &) const override
For operators '==' and 'pstack'.
Definition: sox.h:47
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:48
Semantic Object Array.
Definition: sox.h:280
shared_ptr< SOAArray > v_
The shared array.
Definition: sox.h:290
public_virtual SOA * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:318
SOA(size_t p_l=0, bool p_exec=false)
ctor.
Definition: sox.h:297
SOp front_pop()
Returns a copy of the SOp at position 0 and removes this first position from the array.
Definition: sox.h:361
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sox.h:336
void unfold2exec(Context &k) const
Unfolds duplicates of the array-content to the execution stack.
Definition: sox.h:354
SOA * clone() const override
Creates a new instance as copy with deep cloning.
Definition: sox.h:319
SOp at(size_t p_pos) const
Returns a copy of the SOp at the given position.
Definition: sox.h:315
SOA(shared_ptr< SOAArray > p_v, bool p_exec)
Private ctor for dup().
Definition: sox.h:293
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:328
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:327
public_other void reduce()
Reduces the array by one SO at the end.
Definition: sox.h:344
public_accessor void setSO(size_t p_index, SOp p_o)
Setter for an array object.
Definition: sox.h:307
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:325
string opequalequal(Context &) const override
For operators '==' and 'pstack'.
Definition: sox.cpp:31
Semantic Object Boolean.
Definition: sox.h:87
SOB(bool p_b)
ctor.
Definition: sox.h:94
public_accessor bool getB() const
Getter for boolean value.
Definition: sox.h:98
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:105
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:104
SOB(const string &p_s)
ctor.
Definition: sox.h:92
public_other void negation()
Negation.
Definition: sox.h:114
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:106
void setB(bool p_b)
Setter for boolean value.
Definition: sox.h:100
public_virtual SOB * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:103
bool b_
The boolean value.
Definition: sox.h:88
Semantic Object Dictionary.
Definition: sox.h:371
string opequalequal(Context &k) const override
For operators '==' and 'pstack'.
Definition: sox.cpp:52
public_other void insert(SOp p_key, SOp p_value, bool p_forcebegin=false)
Insert with PostScript definition of equal.
Definition: sox.cpp:73
SOD(shared_ptr< SODMap > p_d)
Private ctor for dup().
Definition: sox.h:383
pair< SOp, SOp > any_pop()
Returns a pair from the dictionary.
Definition: sox.h:425
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sox.h:404
SOD * clone() const override
Creates a new instance as copy with deep cloning.
Definition: sox.h:391
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:398
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:396
SOp find(const SO *p_key) const
Searches for p_key in the dictionary.
Definition: sox.cpp:92
shared_ptr< SODMap > d_
The shared dictionary.
Definition: sox.h:380
SOD()
Ctor.
Definition: sox.h:387
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:399
public_virtual SOD * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:390
Semantic Object Integer.
Definition: sox.h:58
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:77
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:76
SOI(const string &p_s)
ctor.
Definition: sox.h:63
public_virtual SOI * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:74
void setInteger(__int128 p_i)
Setter for the integer value.
Definition: sox.h:71
__int128 i_
The 128 bit integer.
Definition: sox.h:59
SOI(__int128 p_i)
ctor.
Definition: sox.h:65
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:75
public_accessor __int128 getInteger() const
Getter for the integer value.
Definition: sox.h:69
Semantic Object Mark.
Definition: sox.h:28
public_virtual SOM * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:30
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:34
string opequalequal(Context &) const override
For operators '==' and 'pstack'.
Definition: sox.h:32
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:33
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:31
Semantic Object Name.
Definition: sox.h:151
string n_
The name.
Definition: sox.h:152
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:160
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sox.h:170
public_virtual SON * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:159
SON(const string &p_n, bool p_exec=false)
ctor.
Definition: sox.h:156
public_other void load(Context &k) const
Search for the name on the dictionary stack and push the value onto the execution stack.
Definition: sox.cpp:11
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:164
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:165
Semantic Object Operator.
Definition: sox.h:182
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:193
SOO(void(*p_f)(Context &), const string &p_s)
Ctor.
Definition: sox.h:188
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:192
string s_
A name just for representation.
Definition: sox.h:184
public_virtual SOO * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:191
public_other void exec(Context &k)
Call the implementation of the operator.
Definition: sox.h:202
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:194
void(* f_)(Context &)
The C++ implementation of the operator.
Definition: sox.h:183
Semantic Object Real.
Definition: sox.h:122
public_accessor __float128 getReal() const
Getter for real value.
Definition: sox.h:133
void setReal(__float128 p_r)
Setter for real value.
Definition: sox.h:135
public_virtual SOR * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:138
__float128 r_
The real value as decimal number.
Definition: sox.h:123
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:141
SOR(const string &p_s)
ctor.
Definition: sox.h:127
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:139
SOR(__float128 p_r)
ctor.
Definition: sox.h:129
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:140
Semantic Object String.
Definition: sox.h:235
public_accessor string getString() const
Getter for the string value.
Definition: sox.h:250
SOS(string p_s)
ctor.
Definition: sox.h:243
string opequalequal(Context &) const override
For operators '==' and 'pstack'.
Definition: sox.h:256
SOS * clone() const override
Creates a new instance as copy with deep cloning.
Definition: sox.h:254
SOS(shared_ptr< string > p_s)
Private ctor for dup()
Definition: sox.h:239
bool equal(const SO *p_other) const override
Equality.
Definition: sox.h:258
void erase0()
Erases the fist character of the String.
Definition: sox.h:272
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sox.h:263
public_virtual SOS * dup() const override
Creates a new instance as copy following the PostScript definition.
Definition: sox.h:253
public_other void setch(size_t index, int ch)
Sets a single character within the string.
Definition: sox.h:269
string opequal() const override
For operators '=' and 'stack'.
Definition: sox.h:255
OTCode ot() const override
Returns an OTCode.
Definition: sox.h:257
shared_ptr< string > s_
the string value
Definition: sox.h:236
Semantic Object.
Definition: so.h:17
public_accessor bool getExec() const
Getter for exec_.
Definition: so.h:31
virtual SO * clone() const
Creates a new instance as copy with deep cloning.
Definition: so.h:44
bool exec_
All SOs have executive vs.
Definition: so.h:19
Semantic Object Operator unregistered section.
Definition: sox.h:210
public_accessor size_t getStackusage() const
Getter for stackusage_.
Definition: sox.h:220
public_virtual OTCode ot() const override
Returns an OTCode.
Definition: sox.h:223
size_t stackusage_
The number of objects needed on stack for execution.
Definition: sox.h:211
SOo(void(*p_f)(Context &), const string &p_s, size_t p_stackusage)
ctor.
Definition: sox.h:215
void push(SOp p_s)
Pushes the object onto the Stack and transfers ownership to the Stack.
Definition: stack.h:67
#define public_virtual
virtual member functions
Definition: helper.h:15
#define public_other
other member functions
Definition: helper.h:16
#define public_accessor
accessor functions
Definition: helper.h:14
std::string to_string(__int128 p_z)
We need a dedicated function, because __int128 isn't supported by to_string().
Definition: helper.cpp:18
__int128 stoint128(const std::string &p_s)
We need a dedicated function, because __float128 isn't supported by the standard library.
Definition: helper.cpp:52
__float128 stofloat128(const std::string &p_s)
We need a dedicated function, because __float128 isn't supported by the standard library.
Definition: helper.cpp:59
Miscellaneous definitions and functions.
char OTCode
OTCode - the Object Type Code.
Definition: helper.h:22
Semantic Object Array - array member class.
Definition: sox.h:285
~SOAArray()
Dtor.
Definition: sox.h:288
vector< SOp > a_
The inner array.
Definition: sox.h:286
Semantic Object Dictionary - map member class.
Definition: sox.h:375
map< SOp, SOp > a_
The map.
Definition: sox.h:376
~SODMap()
Dtor.
Definition: sox.h:378