GebrIExpr Interface

GebrIExpr Interface — Interface for defining expressions and validate them.

Functions

#define GEBR_IEXPR_ERROR
GQuark gebr_iexpr_error_quark ()
gboolean gebr_iexpr_set_var ()
gboolean gebr_iexpr_is_valid ()
void gebr_iexpr_reset ()
GList * gebr_iexpr_extract_vars ()
gboolean gebr_iexpr_eval ()

Types and Values

Object Hierarchy

    GInterface
    ╰── GebrIExpr

Description

The GebrIExpr interface defines methods for creating and validating expressions. There are two kinds of expressions in GeBR: GebrArithmeticExpr and GebrStringExpr.

Functions

GEBR_IEXPR_ERROR

#define GEBR_IEXPR_ERROR (gebr_iexpr_error_quark())

Error domain for handling expressions. Errors in this domain will be from GebrIExprError enumeration.


gebr_iexpr_error_quark ()

GQuark
gebr_iexpr_error_quark (void);

gebr_iexpr_set_var ()

gboolean
gebr_iexpr_set_var (GebrIExpr *self,
                    const gchar *name,
                    GebrGeoXmlParameterType type,
                    const gchar *value,
                    GError **error);

Parameters

expr

a GebrIExpr

 

name

the name of the variable

 

type

one of GebrGeoXmlParameterType

 

value

the value of the variable

 

error

return location for an GEBR_IEXPR_ERROR, or NULL

 

Returns

TRUE if variable was successfully set, FALSE otherwise.


gebr_iexpr_is_valid ()

gboolean
gebr_iexpr_is_valid (GebrIExpr *self,
                     const gchar *expr,
                     GError **error);

Parameters

expr

a GebrIExpr

 

expression

the expression to check for validity

 

error

return location for an GEBR_IEXPR_ERROR, or NULL

 

Returns

TRUE if expression is valid, FALSE otherwise.


gebr_iexpr_reset ()

void
gebr_iexpr_reset (GebrIExpr *self);

Resets the state of this evaluator.

Parameters

expr

A GebrIExpr

 

gebr_iexpr_extract_vars ()

GList *
gebr_iexpr_extract_vars (GebrIExpr *self,
                         const gchar *expr);

Returns

A list of strings containing the variable names. You must free all strings and the list itself.


gebr_iexpr_eval ()

gboolean
gebr_iexpr_eval (GebrIExpr *self,
                 const gchar *expr,
                 gchar **value,
                 GError **error);

Parameters

expr

a GebrIExpr

 

expr

expression to be evaluated.

 

value

returns the value of the expression.

 

error

return location for an GEBR_IEXPR_ERROR, or NULL

 

Returns

TRUE if expression is valid, FALSE otherwise.

Types and Values

enum GebrIExprError

Error codes returned by expression handling functions.

Members

GEBR_IEXPR_ERROR_INITIALIZE

The validator failed to initialize.

 

GEBR_IEXPR_ERROR_EMPTY_EXPR

   

GEBR_IEXPR_ERROR_INVAL_PATH

   

GEBR_IEXPR_ERROR_TOOBIG

   

GEBR_IEXPR_ERROR_RUNTIME

   

GEBR_IEXPR_ERROR_SYNTAX

The expression syntax is invalid.

 

GEBR_IEXPR_ERROR_UNDEF_VAR

An undefined variable was found.

 

GEBR_IEXPR_ERROR_UNDEF_REFERENCE

   

GEBR_IEXPR_ERROR_BAD_REFERENCE

Variable use another variable not well defined

 

GEBR_IEXPR_ERROR_INVAL_VAR

An invalid variable name was found.

 

GEBR_IEXPR_ERROR_INVAL_TYPE

Variable type not supported.

 

GEBR_IEXPR_ERROR_CYCLE

The variable has cycle dependencies.

 

GEBR_IEXPR_ERROR_TYPE_MISMATCH

The numeric variable uses a string one.

 

GEBR_IEXPR_ERROR_BAD_MOVE

   

GEBR_IEXPR_ERROR_PATH

   

struct GebrIExprInterface

struct GebrIExprInterface {
	GTypeInterface parent;

	gboolean (*set_var)     (GebrIExpr              *self,
				 const gchar            *name,
				 GebrGeoXmlParameterType type,
				 const gchar            *value,
				 GError                **error);

	gboolean (*is_valid)     (GebrIExpr   *self,
				  const gchar *expr,
				  GError     **error);

	void     (*reset)        (GebrIExpr   *self);

	GList *  (*extract_vars) (GebrIExpr   *self,
				  const gchar *expr);

	gboolean (*eval)         (GebrIExpr   *self,
				  const gchar *expr,
				  gchar      **value,
				  GError     **error);
};