Kryptostack
Macros | Typedefs | Enumerations | Functions
helper.h File Reference

Miscellaneous definitions and functions. More...

#include <string>
Include dependency graph for helper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define public_accessor
 accessor functions

 
#define public_virtual
 virtual member functions

 
#define public_other
 other member functions

 

Typedefs

using OTCode = char
 OTCode - the Object Type Code. More...
 
using KSNCode = char
 KSNCode - the KryptoStack Normalized Code. More...
 

Enumerations

enum  OpError {
  invalidexit , rangecheck , stackunderflow , typecheck ,
  unmatchedmark , dictstackunderflow , undefinedresult , undefined
}
 Operator error code enum.
 
enum  InError {
  unknownoption , parsererror , helptext , quit ,
  internal , other
}
 Interpreter error code enum.
 

Functions

std::string to_string (__int128 p_z)
 We need a dedicated function, because __int128 isn't supported by to_string(). More...
 
std::string to_string (__float128)
 We need a dedicated function, because __float128 isn't supported by to_string(). More...
 
__int128 stoint128 (const std::string &p_s)
 We need a dedicated function, because __float128 isn't supported by the standard library. More...
 
__float128 stofloat128 (const std::string &p_s)
 We need a dedicated function, because __float128 isn't supported by the standard library. More...
 
void opErrExit (const OpError p_err, const std::string &p_details="")
 Operator Error Message to cout and exit(1).
 
void inErrExit (const InError p_err, const std::string &p_details="")
 Interpreter Error Message to cout and exit(1).
 
std::string strescape (const std::string &p_s)
 Substitutes double backslashes by single backslashes and sequences backslash + 'n' by the ASCII CR code.
 
void statistics ()
 Dumps statistics data. More...
 
void snap ()
 Snapshot of system state to cout.
 

Detailed Description

Miscellaneous definitions and functions.

Typedef Documentation

◆ KSNCode

using KSNCode = char

KSNCode - the KryptoStack Normalized Code.

Note
IDEA: migrate to an enum

◆ OTCode

using OTCode = char

OTCode - the Object Type Code.

Note
IDEA: migrate to an enum

Function Documentation

◆ statistics()

void statistics ( )

Dumps statistics data.

Dumps it only if there are open memory allocations.

Note
IDEA: a parameter "forcestatistics" and a command line option for ks to set it

◆ stofloat128()

__float128 stofloat128 ( const std::string &  p_s)

We need a dedicated function, because __float128 isn't supported by the standard library.

Implemented with GNU quadmath.

Note
IDEA: detailed description
Returns
__float128 the IEEE float

◆ stoint128()

__int128 stoint128 ( const std::string &  p_s)

We need a dedicated function, because __float128 isn't supported by the standard library.

Has no syntax check. A leading '+' is not allowed. No overflow check

Note
IDEA: define prerequisites.
Returns
__int128 ... the parsed integer

◆ to_string() [1/2]

std::string to_string ( __float128  r_)

We need a dedicated function, because __float128 isn't supported by to_string().

Implementation with GNU quadmath

Returns
std::string ... the string-representation of p_z

◆ to_string() [2/2]

std::string to_string ( __int128  p_z)

We need a dedicated function, because __int128 isn't supported by to_string().

Returns
std::string ... the string-representation of p_z
Parameters
[in]p_zwe need a representation for this number