PDI 0.6.1

Data exchange made easy

PDI::Expression Class Reference

Public Member Functions

 Expression ()
 Builds an empty expression. More...
 
 Expression (const Expression &expr)
 Copies an expression. More...
 
 Expression (Expression &&expr)
 Moves an expression. More...
 
 Expression (const char *expr)
 Builds (i.e. More...
 
 Expression (const std::string &expr)
 Builds (i.e. More...
 
 Expression (long expr)
 Builds an expression that represents an integer. More...
 
 Expression (double expr)
 Builds an expression that represents a float. More...
 
 ~Expression ()
 Destroys an expression. More...
 
Expressionoperator= (const Expression &expr)
 Copies an expression. More...
 
Expressionoperator= (Expression &&expr)
 Moves an expression. More...
 
 operator bool () const
 Checks whether this is an empty expression. More...
 
long to_long (Context &ctx) const
 Evaluates an expression as an integer. More...
 
double to_double (Context &ctx) const
 Evaluates an expression as a float. More...
 
std::string to_string (Context &ctx) const
 Evaluates an expression as a string. More...
 
Ref to_ref (Context &ctx) const
 Evaluates an expression as a data reference. More...
 

Friends

struct Impl
 

Constructor & Destructor Documentation

◆ Expression() [1/7]

PDI::Expression::Expression ( )

Builds an empty expression.

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

◆ Expression() [2/7]

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

Copies an expression.

Parameters
[in]exprthe expression to copy

◆ Expression() [3/7]

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

Moves an expression.

Parameters
[in]exprthe expression to move

◆ Expression() [4/7]

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 ']' )*
INT_LITERAL ~= (0x)? [0-9]+ ( \. )
ID ~= [a-zA-Z_][a-zA-Z0-9_]*
CHAR ~= [^$\\]
OPERATOR ~= [|&=<>+\-\*/%]
Parameters
[in]exprthe string to parse

◆ Expression() [5/7]

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 ']' )*
INT_LITERAL ~= (0x)? [0-9]+ ( \. )
ID ~= [a-zA-Z_][a-zA-Z0-9_]*
CHAR ~= [^$\\]
OPERATOR ~= [|&=<>+\-\*/%]
Parameters
[in]exprthe string to parse

◆ Expression() [6/7]

PDI::Expression::Expression ( long  expr)

Builds an expression that represents an integer.

Parameters
[in]exprthe integer value

◆ Expression() [7/7]

PDI::Expression::Expression ( double  expr)

Builds an expression that represents a float.

Parameters
[in]exprthe flaot 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 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()

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

Evaluates an expression as a data reference.

Returns
the data reference

Friends And Related Function Documentation

◆ Impl

friend struct Impl
friend

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