PDI 1.7.1

the PDI data interface

PDI::Expression Class Reference

Public Member Functions

 Expression ()
 Builds an empty expression.
 
 Expression (const Expression &expr)
 Copies an expression.
 
 Expression (Expression &&expr)
 Moves an expression.
 
 Expression (const char *expr)
 Builds (i.e.
 
 Expression (const std::string &expr)
 Builds (i.e.
 
 Expression (long expr)
 Builds an expression that represents an integer.
 
 Expression (double expr)
 Builds an expression that represents a float.
 
 Expression (PC_tree_t expr)
 Builds an expression that is parsed from PC_tree_t.
 
 ~Expression ()
 Destroys an expression.
 
Expressionoperator= (const Expression &expr)
 Copies an expression.
 
Expressionoperator= (Expression &&expr)
 Moves an expression.
 
Expression operator+ (const Expression &expr) const
 Summation operator of an expression.
 
Expression operator* (const Expression &expr) const
 Multiplication operator of an expression.
 
Expression operator- (const Expression &expr) const
 Subtraction operator of an expression.
 
Expression operator/ (const Expression &expr) const
 Division operator of an expression.
 
Expression operator% (const Expression &expr) const
 Modulo operator of an expression.
 
 operator bool () const
 Checks whether this is an empty expression.
 
long to_long (Context &ctx) const
 Evaluates an expression as an integer.
 
double to_double (Context &ctx) const
 Evaluates an expression as a float.
 
std::string to_string (Context &ctx) const
 Evaluates an expression as a string.
 
Ref to_ref (Context &ctx) const
 Evaluates an expression as a data reference.
 
Ref to_ref (Context &ctx, Datatype_sptr type) const
 Evaluates an expression as a data reference.
 

Static Public Member Functions

static std::pair< Expression, long > parse_reference (const char *reference_str)
 Parses a string that starts with $ and represents a reference expression.
 

Constructor & Destructor Documentation

◆ Expression() [1/8]

PDI::Expression::Expression ( )

Builds an empty expression.

No operation can be used on an empty expression, it can only be assigned to

◆ Expression() [2/8]

PDI::Expression::Expression ( const Expression expr)

Copies an expression.

Parameters
[in]exprthe expression to copy

◆ Expression() [3/8]

PDI::Expression::Expression ( Expression &&  expr)

Moves an expression.

Parameters
[in]exprthe expression to move

◆ Expression() [4/8]

PDI::Expression::Expression ( const char *  expr)

Builds (i.e.

parse) an expression from a string

The grammar of an expression is as follow:

/* parsing as a REFERENCE is preferred over OPERATION
parsing as an OPERATION is preferred over STRING_LITERAL
*/
EXPRESSION := REFERENCE | OPERATION | STRING_LITERAL
STRING_LITERAL := ( CHAR | '\' '\' | '\' '$'
| REFERENCE
| '$' '(' OPERATION ')'
)*
/* The operator descending precedence order is:
1. *, /, %: multiplication, division and modulo,
2. +, -: addition and subtraction,
3. <, >: less than and greater than,
4. =: equality,
5. &: logical AND,
6. |: logical OR.
*/
OPERATION := TERM ( OPERATOR TERM )*
TERM := ( INT_LITERAL | REFERENCE | '(' OPERATION ')' )
REFERENCE := '$' ( IREFERENCE | '{' IREFERENCE '}' )
IREFERENCE := ID ( '[' OPERATION ']' | '.' ID )*
INT_LITERAL ~= (0x)? [0-9]+ ( \. )
ID ~= [a-zA-Z_][a-zA-Z0-9_]*
CHAR ~= [^$\\]
OPERATOR ~= [|&=<>+\-\*/%]
Parameters
[in]exprthe string to parse

◆ Expression() [5/8]

PDI::Expression::Expression ( const std::string &  expr)

Builds (i.e.

parse) an expression from a string

The grammar of an expression is as follow:

/* parsing as a REFERENCE is preferred over OPERATION
parsing as an OPERATION is preferred over STRING_LITERAL
*/
EXPRESSION := REFERENCE | OPERATION | STRING_LITERAL
STRING_LITERAL := ( CHAR | '\' '\' | '\' '$'
| REFERENCE
| '$' '(' OPERATION ')'
)*
/* The operator descending precedence order is:
1. *, /, %: multiplication, division and modulo,
2. +, -: addition and subtraction,
3. <, >: less than and greater than,
4. =: equality,
5. &: logical AND,
6. |: logical OR.
*/
OPERATION := TERM ( OPERATOR TERM )*
TERM := ( INT_LITERAL | REFERENCE | '(' OPERATION ')' )
REFERENCE := '$' ( IREFERENCE | '{' IREFERENCE '}' )
IREFERENCE := ID ( '[' OPERATION ']' | '.' ID )*
INT_LITERAL ~= (0x)? [0-9]+ ( \. )
ID ~= [a-zA-Z_][a-zA-Z0-9_]*
CHAR ~= [^$\\]
OPERATOR ~= [|&=<>+\-\*/%]
Parameters
[in]exprthe string to parse

◆ Expression() [6/8]

PDI::Expression::Expression ( long  expr)

Builds an expression that represents an integer.

Parameters
[in]exprthe integer value

◆ Expression() [7/8]

PDI::Expression::Expression ( double  expr)

Builds an expression that represents a float.

Parameters
[in]exprthe flaot value

◆ Expression() [8/8]

PDI::Expression::Expression ( PC_tree_t  expr)

Builds an expression that is parsed from PC_tree_t.

Parameters
[in]exprthe PC_tree_t value

◆ ~Expression()

PDI::Expression::~Expression ( )

Destroys an expression.

Member Function Documentation

◆ operator=() [1/2]

Expression & PDI::Expression::operator= ( const Expression expr)

Copies an expression.

Parameters
[in]exprthe expression to copy
Returns
*this

◆ operator=() [2/2]

Expression & PDI::Expression::operator= ( Expression &&  expr)

Moves an expression.

Parameters
[in]exprthe expression to move`
Returns
*this

◆ operator+()

Expression PDI::Expression::operator+ ( const Expression expr) const

Summation operator of an expression.

Parameters
[in]exprthe expression to add
Returns
Expression as a result of sum

◆ operator*()

Expression PDI::Expression::operator* ( const Expression expr) const

Multiplication operator of an expression.

Parameters
[in]exprthe expression to multiply
Returns
Expression as a result of multiplication

◆ operator-()

Expression PDI::Expression::operator- ( const Expression expr) const

Subtraction operator of an expression.

Parameters
[in]exprthe expression to subtract
Returns
Expression as a result of subtraction

◆ operator/()

Expression PDI::Expression::operator/ ( const Expression expr) const

Division operator of an expression.

Parameters
[in]exprthe expression to divide
Returns
Expression as a result of division

◆ operator%()

Expression PDI::Expression::operator% ( const Expression expr) const

Modulo operator of an expression.

Parameters
[in]exprthe expression to use modulo
Returns
Expression as a result of modulo

◆ operator bool()

PDI::Expression::operator bool ( ) const

Checks whether this is an empty expression.

Returns
true if the expression is non-empty

◆ to_long()

long PDI::Expression::to_long ( Context ctx) const

Evaluates an expression as an integer.

Returns
the integer value

◆ to_double()

double PDI::Expression::to_double ( Context ctx) const

Evaluates an expression as a float.

Returns
the float value

◆ to_string()

std::string PDI::Expression::to_string ( Context ctx) const

Evaluates an expression as a string.

Returns
the string value

◆ to_ref() [1/2]

Ref PDI::Expression::to_ref ( Context ctx) const

Evaluates an expression as a data reference.

Parameters
ctxthe context in which to evaluate the expression
Returns
the data reference

◆ to_ref() [2/2]

Ref PDI::Expression::to_ref ( Context ctx,
Datatype_sptr  type 
) const

Evaluates an expression as a data reference.

Parameters
ctxthe context in which to evaluate the expression
typethe type of the created Ref
Returns
the data reference

◆ parse_reference()

static std::pair< Expression, long > PDI::Expression::parse_reference ( const char *  reference_str)
static

Parses a string that starts with $ and represents a reference expression.

Parameters
[in]reference_strstring that represents a reference expression
Returns
resulted reference exrpession and number of bytes read from reference_str

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