SXEval 1.0.3
A generic s-expression interpreter library.
Loading...
Searching...
No Matches
sxeval Namespace Reference

Namespaces

namespace  operations
 

Classes

class  AOperation
 The AOperation class is an abstract base class for operations in the SXEval library. More...
 
class  EncapsulatedVariable
 The EncapsulatedVariable class represents a variable that can be encapsulated in an unaccessible Object. More...
 
class  IInstruction
 The IInstruction class is an interface for any instructions. More...
 
class  IOperand
 The IOperand class is an interface for operands. More...
 
class  SXEval
 The SXEval class is used to evaluate s-expressions. More...
 
class  Value
 The Value class represents a constant value in the SXEval library. More...
 
class  Variable
 The Variable class represents a variable in the SXEval library. More...
 

Typedefs

template<typename T >
using resolveVariable_t = std::function< T &(const std::string &)>
 
template<typename T >
using resolveEncapsulated_t = std::function< std::function< T(void)>(const std::string &)>
 

Functions

template<typename T >
std::ostream & operator<< (std::ostream &os, const IInstruction< T > &obj)
 Output stream operator for AInstruction.
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const SXEval< T > &obj)
 Output stream operator for SXEval.
 
template<typename T >
T StringToType (const std::string &s)
 Convert a string to a type T.
 
template<typename T >
bool Greater (const T &a, const T &b)
 Check if a is greater than b.
 
template<typename T >
std::enable_if< std::is_integral< T >::value, bool >::type Equal (const T &a, const T &b)
 Check if a is equal to b.
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, bool >::type Equal (const T &a, const T &b)
 Check if a is equal to b.
 
template<typename T >
bool NotEqual (const T &a, const T &b)
 Check if a is not equal to b.
 
template<typename T >
bool GreaterOrEqual (const T &a, const T &b)
 Check if a is greater than or equal to b.
 
template<typename T >
bool Less (const T &a, const T &b)
 Check if a is less than b.
 
template<typename T >
bool LessOrEqual (const T &a, const T &b)
 Check if a is less than or equal to b.
 
template<typename T >
std::enable_if< std::is_integral< T >::value, bool >::type TypeToBool (const T &val)
 Convert a type T to a boolean value.
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, bool >::type TypeToBool (const T &val)
 Convert a type T to a boolean value.
 
template<typename T >
bool LogicalAnd (const T &a, const T &b)
 Perform a logical and operations on types T.
 
template<typename T >
bool LogicalOr (const T &a, const T &b)
 Perform a logical or operation on types T.
 
template<typename T >
bool LogicalNot (const T &a)
 Perform a logical not operation on type T.
 
template<typename T >
bool LogicalXor (const T &a, const T &b)
 Perform a logical xor operation on types T.
 
template<typename T >
bool LogicalNand (const T &a, const T &b)
 Perform a logical nand operation on types T.
 
template<typename T >
bool LogicalNor (const T &a, const T &b)
 Perform a logical nor operation on types T.
 
template<typename T >
bool LogicalXnor (const T &a, const T &b)
 Perform a logical xnor operation on types T.
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type Modulo (const T &a, const T &b)
 Perform a modulo operation on types T.
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type Modulo (const T &a, const T &b)
 Perform a modulo operation on types T.
 
template<typename T >
std::enable_if< std::is_unsigned< T >::value, T >::type Absolute (const T &a)
 Perform an absolute value operation on types T.
 
template<typename T >
std::enable_if< std::is_integral< T >::value &&!std::is_unsigned< T >::value, T >::type Absolute (const T &a)
 Perform an absolute value operation on types T.
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value &&!std::is_unsigned< T >::value, T >::type Absolute (const T &a)
 Perform an absolute value operation on types T.
 

Typedef Documentation

◆ resolveEncapsulated_t

template<typename T >
using sxeval::resolveEncapsulated_t = typedef std::function< std::function<T(void)>(const std::string&)>

◆ resolveVariable_t

template<typename T >
using sxeval::resolveVariable_t = typedef std::function<T&(const std::string&)>

Function Documentation

◆ Absolute() [1/3]

template<typename T >
std::enable_if< std::is_unsigned< T >::value, T >::type sxeval::Absolute ( const T &  a)
inline

Perform an absolute value operation on types T.

Template Parameters
TThe type of the value.
Parameters
aThe value to get the absolute value of.
Returns
The absolute value of a.
Note
For unsigned types, it returns the value itself. For integral types, it uses std::abs, and for floating point types, it uses std::fabs.

◆ Absolute() [2/3]

template<typename T >
std::enable_if< std::is_integral< T >::value &&!std::is_unsigned< T >::value, T >::type sxeval::Absolute ( const T &  a)
inline

Perform an absolute value operation on types T.

Template Parameters
TThe type of the value.
Parameters
aThe value to get the absolute value of.
Returns
The absolute value of a.
Note
For unsigned types, it returns the value itself. For integral types, it uses std::abs, and for floating point types, it uses std::fabs.

◆ Absolute() [3/3]

template<typename T >
std::enable_if< std::is_floating_point< T >::value &&!std::is_unsigned< T >::value, T >::type sxeval::Absolute ( const T &  a)
inline

Perform an absolute value operation on types T.

Template Parameters
TThe type of the value.
Parameters
aThe value to get the absolute value of.
Returns
The absolute value of a.
Note
For unsigned types, it returns the value itself. For integral types, it uses std::abs, and for floating point types, it uses std::fabs.

◆ Equal() [1/2]

template<typename T >
std::enable_if< std::is_integral< T >::value, bool >::type sxeval::Equal ( const T a,
const T b 
)
inline

Check if a is equal to b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is equal to b, false otherwise.

◆ Equal() [2/2]

template<typename T >
std::enable_if< std::is_floating_point< T >::value, bool >::type sxeval::Equal ( const T a,
const T b 
)
inline

Check if a is equal to b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is equal to b, false otherwise.

◆ Greater()

template<typename T >
bool sxeval::Greater ( const T a,
const T b 
)
inline

Check if a is greater than b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is greater than b, false otherwise.

◆ GreaterOrEqual()

template<typename T >
bool sxeval::GreaterOrEqual ( const T a,
const T b 
)
inline

Check if a is greater than or equal to b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is greater than or equal to b, false otherwise.

◆ Less()

template<typename T >
bool sxeval::Less ( const T a,
const T b 
)
inline

Check if a is less than b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is less than b, false otherwise.

◆ LessOrEqual()

template<typename T >
bool sxeval::LessOrEqual ( const T a,
const T b 
)
inline

Check if a is less than or equal to b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is less than or equal to b, false otherwise.

◆ LogicalAnd()

template<typename T >
bool sxeval::LogicalAnd ( const T a,
const T b 
)
inline

Perform a logical and operations on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
The result of the logical and operation.

◆ LogicalNand()

template<typename T >
bool sxeval::LogicalNand ( const T a,
const T b 
)
inline

Perform a logical nand operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a and b are not both true, false otherwise.

◆ LogicalNor()

template<typename T >
bool sxeval::LogicalNor ( const T a,
const T b 
)
inline

Perform a logical nor operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a and b are not both true, false otherwise.

◆ LogicalNot()

template<typename T >
bool sxeval::LogicalNot ( const T a)
inline

Perform a logical not operation on type T.

Template Parameters
TThe type of the value.
Parameters
aThe value to negate.
Returns
The negated value.

◆ LogicalOr()

template<typename T >
bool sxeval::LogicalOr ( const T a,
const T b 
)
inline

Perform a logical or operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
The result of the logical or operation.

◆ LogicalXnor()

template<typename T >
bool sxeval::LogicalXnor ( const T a,
const T b 
)
inline

Perform a logical xnor operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a and b are both true or both false, false otherwise.

◆ LogicalXor()

template<typename T >
bool sxeval::LogicalXor ( const T a,
const T b 
)
inline

Perform a logical xor operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a and b are different, false otherwise.

◆ Modulo() [1/2]

template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type sxeval::Modulo ( const T a,
const T b 
)
inline

Perform a modulo operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
The result of the modulo operation.
Exceptions
std::invalid_argumentif b is zero.

◆ Modulo() [2/2]

template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type sxeval::Modulo ( const T a,
const T b 
)
inline

Perform a modulo operation on types T.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
The result of the modulo operation.
Exceptions
std::invalid_argumentif b is zero.

◆ NotEqual()

template<typename T >
bool sxeval::NotEqual ( const T a,
const T b 
)
inline

Check if a is not equal to b.

Template Parameters
TThe type of the values.
Parameters
aThe first value.
bThe second value.
Returns
True if a is not equal to b, false otherwise.

◆ operator<<() [1/2]

template<typename T >
std::ostream & sxeval::operator<< ( std::ostream &  os,
const IInstruction< T > &  obj 
)
inline

Output stream operator for AInstruction.

Parameters
osThe output stream.
objThe AInstruction object to output.
Returns
The output stream.

◆ operator<<() [2/2]

template<typename T >
std::ostream & sxeval::operator<< ( std::ostream &  os,
const SXEval< T > &  obj 
)
inline

Output stream operator for SXEval.

Parameters
osThe output stream.
objThe SXEval object to output.
Returns
The output stream.
Note
This operator outputs the string representation of the expression tree of the SXEval object.

◆ StringToType()

template<typename T >
T sxeval::StringToType ( const std::string &  s)

Convert a string to a type T.

Template Parameters
TThe type to convert to.
Parameters
sThe string to convert.
Returns
The converted value of type T.
Exceptions
std::invalid_argumentif the string cannot be converted to the type T.

◆ TypeToBool() [1/2]

template<typename T >
std::enable_if< std::is_integral< T >::value, bool >::type sxeval::TypeToBool ( const T val)
inline

Convert a type T to a boolean value.

Template Parameters
TThe type to convert.
Parameters
valThe value to convert.
Returns
True if the value is non-zero, false otherwise.
Note
For floating point types, it checks if the absolute value is greater than the machine epsilon.

◆ TypeToBool() [2/2]

template<typename T >
std::enable_if< std::is_floating_point< T >::value, bool >::type sxeval::TypeToBool ( const T val)
inline

Convert a type T to a boolean value.

Template Parameters
TThe type to convert.
Parameters
valThe value to convert.
Returns
True if the value is non-zero, false otherwise.
Note
For floating point types, it checks if the absolute value is greater than the machine epsilon.