GebrIExpr Interface

GebrIExpr Interface — Interface for defining expressions and validate them.

Synopsis

#define             GEBR_IEXPR_ERROR
GQuark              gebr_iexpr_error_quark              (void);
enum                GebrIExprError;
                    GebrIExpr;
                    GebrIExprInterface;
gboolean            gebr_iexpr_set_var                  (GebrIExpr *self,
                                                         const gchar *name,
                                                         GebrGeoXmlParameterType type,
                                                         const gchar *value,
                                                         GError **error);
gboolean            gebr_iexpr_is_valid                 (GebrIExpr *self,
                                                         const gchar *expr,
                                                         GError **error);
void                gebr_iexpr_reset                    (GebrIExpr *self);
GList *             gebr_iexpr_extract_vars             (GebrIExpr *self,
                                                         const gchar *expr);
gboolean            gebr_iexpr_eval                     (GebrIExpr *self,
                                                         const gchar *expr,
                                                         gchar **value,
                                                         GError **error);

Object Hierarchy

  GInterface
   +----GebrIExpr

Prerequisites

GebrIExpr requires GObject.

Known Implementations

GebrIExpr is implemented by GebrArithExpr.

Description

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

Details

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);

enum GebrIExprError

typedef enum {
	GEBR_IEXPR_ERROR_INITIALIZE,
	GEBR_IEXPR_ERROR_EMPTY_EXPR,
	GEBR_IEXPR_ERROR_INVAL_PATH,
	GEBR_IEXPR_ERROR_TOOBIG,
	GEBR_IEXPR_ERROR_RUNTIME,
	GEBR_IEXPR_ERROR_SYNTAX,
	GEBR_IEXPR_ERROR_UNDEF_VAR,
	GEBR_IEXPR_ERROR_UNDEF_REFERENCE,
	GEBR_IEXPR_ERROR_BAD_REFERENCE,
	GEBR_IEXPR_ERROR_INVAL_VAR,
	GEBR_IEXPR_ERROR_INVAL_TYPE,
	GEBR_IEXPR_ERROR_CYCLE,
	GEBR_IEXPR_ERROR_TYPE_MISMATCH,
	GEBR_IEXPR_ERROR_BAD_MOVE,
	GEBR_IEXPR_ERROR_PATH,
} GebrIExprError;

Error codes returned by expression handling functions.

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


GebrIExpr

typedef struct _GebrIExpr GebrIExpr;

GebrIExprInterface

typedef struct {
	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);
} GebrIExprInterface;

gebr_iexpr_set_var ()

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

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);

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.

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);

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.