| libxexpr Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <libxexpr/xexpr.h> #define XEXPR_EVAL_ERROR enum XexprEvalError; GQuark xexpr_eval_error_quark (void); gboolean xexpr_register_extension (XexprExtension *extension); XexprConstant * xexpr_constant_evaluate (Xexpr *xexpr, XexprConstant *constant, GError **err); Xexpr * xexpr_evaluate (Xexpr *xexpr, GError **err); gboolean xexpr_constant_cast (XexprConstant *constant, XexprType to); gboolean xexpr_test (Xexpr *xexpr, GError **err);
#define XEXPR_EVAL_ERROR xexpr_eval_error_quark()
Used to get the GError quark for libxexpr evaluator errors.
typedef enum
{
XEXPR_EVAL_ERROR_FAILED
} XexprEvalError;
Enum values for evaluator errors.
GQuark xexpr_eval_error_quark (void);
Registers an error quark for the libxexpr evaluator if necessary.
Returns : |
The error quark used for libxexpr evaluator errors. |
gboolean xexpr_register_extension (XexprExtension *extension);
Registers an extension to handle the evaluation of functions and retrieval of variables in a new namespace.
|
an XexprExtension. transfer none. |
Returns : |
TRUE if the extension was successfully registered
|
XexprConstant * xexpr_constant_evaluate (Xexpr *xexpr,
XexprConstant *constant,
GError **err);
Evaluate an XEXPR expression. Typically, an expression will evaluate to
one of the basic types: string, integer or float. However, the XEXPR
language specification states that <define> returns a function
object (ie., an XexprConstant with type XEXPR_TYPE_FUNCTION).
If such a function object is passed to xexpr_constant_evaluate(), then
the function definition will be evaluated. If the function takes
arguments, then these will be taken as <nil>.
The returned expresion should be freed with xexpr_constant_free()
when no longer needed.
|
an Xexpr |
|
the XexprConstant to evaluate |
|
location to store error, or NULL. allow-none. |
Returns : |
The evaluated result, or NULL on error. transfer full. |
Xexpr * xexpr_evaluate (Xexpr *xexpr,
GError **err);
Evaluate an XEXPR expression. Typically, an expression will evaluate to
one of the basic types: string, integer or float. However, the XEXPR
language specification states that <define> returns a function
object (ie., an XexprConstant with type XEXPR_TYPE_FUNCTION).
If such a function object is passed to xexpr_evaluate(), then
the function definition will be evaluated. If the function takes
arguments, then these will be taken as <nil>.
The returned expresion should be freed with xexpr_free()
when no longer needed.
|
an Xexpr to evaluate |
|
location to store error, or NULL. allow-none. |
Returns : |
The evaluated result, or NULL on error. transfer full. |
gboolean xexpr_constant_cast (XexprConstant *constant, XexprType to);
Attempt to perform an implicit cast of constant to the given type to.
Implicit casting can only be performed between the two numeric types
and then only where the quantity can be represented without loss of
precision.
|
an XexprConstant to cast |
|
type to cast constant to
|
Returns : |
TRUE if constant is now of type to.
|
gboolean xexpr_test (Xexpr *xexpr, GError **err);
Test an expression by looking at the last constant in the expression. Numerical constants are treated as <true> if they are non-zero, string constants are treated as <true> if they are non-empty, function invocations are treated as <true> unless they are <false> or <nil>, function definitions are recursively evaluated before they are tested.
|
an Xexpr to test |
|
location to store error, or NULL. allow-none. |
Returns : |
TRUE if the expression is equivalent to <true>.
|