GdaRenderer

GdaRenderer — Interface to get representations of objects as SQL statements, XML nodes or human readable text

Synopsis




                    GdaRenderer;
enum                GdaRendererOptions;
gchar*              gda_renderer_render_as_sql          (GdaRenderer *iface,
                                                         GdaParameterList *context,
                                                         GSList **out_params_used,
                                                         GdaRendererOptions options,
                                                         GError **error);
gchar*              gda_renderer_render_as_str          (GdaRenderer *iface,
                                                         GdaParameterList *context);
gboolean            gda_renderer_is_valid               (GdaRenderer *iface,
                                                         GdaParameterList *context,
                                                         GError **error);

Object Hierarchy


  GInterface
   +----GdaRenderer

Prerequisites

GdaRenderer requires GObject.

Known Implementations

GdaRenderer is implemented by GdaQueryFieldFunc, GdaQueryFieldAgg, GdaQueryFieldValue, GdaQueryCondition, GdaQueryFieldAll, GdaQueryTarget, GdaDictField, GdaQuery and GdaQueryFieldField.

Description

Details

GdaRenderer

typedef struct _GdaRenderer GdaRenderer;


enum GdaRendererOptions

typedef enum {
	GDA_RENDERER_EXTRA_PRETTY_SQL       = 1 << 0,
	GDA_RENDERER_PARAMS_AS_DETAILED     = 1 << 1,
	GDA_RENDERER_ERROR_IF_DEFAULT       = 1 << 2,
	GDA_RENDERER_FIELDS_NO_TARGET_ALIAS = 1 << 3,
	GDA_RENDERER_PARAMS_AS_COLON        = 1 << 4,/* params as :param_name, replacing any char not in [0-9A-Za-z] by '_' */
	GDA_RENDERER_PARAMS_AS_DOLLAR       = 1 << 5,/* params as $1, $2, etc (starts at $1) */
	GDA_RENDERER_PARAMS_AS_QMARK        = 1 << 6 /* params as ?1, ?2, etc (starts at ?1) */
} GdaRendererOptions;

GDA_RENDERER_EXTRA_PRETTY_SQL The rendered statement will output easy to read SQL
GDA_RENDERER_PARAMS_AS_DETAILED
GDA_RENDERER_ERROR_IF_DEFAULT
GDA_RENDERER_FIELDS_NO_TARGET_ALIAS
GDA_RENDERER_PARAMS_AS_COLON parameters will be rendered using the :param_name notation (the parameter is "encoded" using gda_parameter_get_alphanum_name(), use gda_alphanum_to_text() to get the unencoded version
GDA_RENDERER_PARAMS_AS_DOLLAR parameters will be rendered using the ?NNN notation where NNN is the prrameter index
GDA_RENDERER_PARAMS_AS_QMARK parameters will be rendered using the ?NNN notation where NNN is the prrameter index

gda_renderer_render_as_sql ()

gchar*              gda_renderer_render_as_sql          (GdaRenderer *iface,
                                                         GdaParameterList *context,
                                                         GSList **out_params_used,
                                                         GdaRendererOptions options,
                                                         GError **error);

Build a SQL statement representing the object, in the specified context.

If context is NULL, then no error related to missing parameters (which should be in the context) is returned, and missing values are replaced by 'human readable' SQL.

If out_params_used is not NULL, then pointers to the GdaParameter objects used to actually render the SQL statement are appended to the list (in case a parameter object is used several times, it is only once listed in the resulting list).

iface : an object which implements the GdaRenderer interface
context : a GdaParameterList containing values for iface's parameters, or NULL
out_params_used : a place to append GdaParameter which have been used during the rendering process, or NULL
options : OR'ed flags from GdaRendererOptions to give some rendering options
error : location to store error, or NULL
Returns : the new SQL statement (new string), or NULL in case of error

gda_renderer_render_as_str ()

gchar*              gda_renderer_render_as_str          (GdaRenderer *iface,
                                                         GdaParameterList *context);

Build a human readable string representing the object, in the specified context.

iface : an object which implements the GdaRenderer interface
context : rendering context
Returns : the new string

gda_renderer_is_valid ()

gboolean            gda_renderer_is_valid               (GdaRenderer *iface,
                                                         GdaParameterList *context,
                                                         GError **error);

Tells if iface has all the necessary information in context to be rendered into a valid statement (which can be executed).

iface : an object which implements the GdaRenderer interface
context : rendering context
error : location to store error, or NULL
Returns : TRUE if iface can be rendered with context