| CTPL Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <ctpl/ctpl.h> #define CTPL_EVAL_ERROR enum CtplEvalError; gboolean ctpl_eval_value (const CtplTokenExpr *expr,CtplEnviron *env,CtplValue *value,GError **error); gboolean ctpl_eval_bool (const CtplTokenExpr *expr,CtplEnviron *env,gboolean *result,GError **error);
Computes a CtplTokenExpr against a CtplEnviron. It is the equivalent of the parser for expressions.
Theses functions computes an expressions and flattens it to a single value:
the result.
To evaluate an expression, use ctpl_eval_value(). You can evaluate an
expression to a boolean with ctpl_eval_bool().
typedef enum _CtplEvalError
{
CTPL_EVAL_ERROR_INVALID_OPERAND,
CTPL_EVAL_ERROR_SYMBOL_NOT_FOUND,
CTPL_EVAL_ERROR_FAILED
} CtplEvalError;
Error codes that eval functions can throw, from the CTPL_EVAL_ERROR domain.
gboolean ctpl_eval_value (const CtplTokenExpr *expr,CtplEnviron *env,CtplValue *value,GError **error);
Computes the given CtplTokenExpr with the environ env, storing the resutl
in value.
|
The CtplTokenExpr to evaluate |
|
The expression's environment, where lookup symbols |
|
CtplValue where store the evaluation result on success |
|
Return location for errors, or NULL to ignore them
|
Returns : |
TRUE on success, FALSE otherwise.
|
Since 0.2
gboolean ctpl_eval_bool (const CtplTokenExpr *expr,CtplEnviron *env,gboolean *result,GError **error);
Computes the given expression to a boolean. Computing to a boolean means computing the expression's value and then check if this value should be considered as false or true.
|
The CtplTokenExpr to evaluate |
|
The expression's environment, where lookup symbols |
|
Return location for the expression result,
or NULL. [out][allow-none]
|
|
Return location for errors, or NULL to ignore them
|
Returns : |
TRUE on success, FALSE otherwise.
|
Since 0.2