90 lines
2.9 KiB
C
90 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2012 - Juan Ferrer Toribio
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef SQL_RENDER_H
|
|
#define SQL_RENDER_H
|
|
|
|
#include <glib-object.h>
|
|
|
|
#define SQL_RENDER_LOG_DOMAIN (g_quark_from_string ("SqlRender"))
|
|
|
|
#define SQL_TYPE_RENDER (sql_render_get_type ())
|
|
#define SQL_RENDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_RENDER, SqlRender))
|
|
#define SQL_IS_RENDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_RENDER))
|
|
|
|
#define T TRUE
|
|
#define F FALSE
|
|
#define SQL_BUFFER_SIZE 500
|
|
|
|
typedef struct _SqlRender SqlRender;
|
|
typedef struct _SqlRenderClass SqlRenderClass;
|
|
|
|
typedef void (* SqlRenderFunc) (gpointer obj, SqlRender * render);
|
|
|
|
#include "sql-object.h"
|
|
|
|
/**
|
|
* SqlRender:
|
|
* @symbol_table: (element-type GType Sql.RenderFunc):
|
|
**/
|
|
struct _SqlRender
|
|
{
|
|
GObject parent;
|
|
GError * error;
|
|
GString * buffer;
|
|
gpointer object;
|
|
gpointer data;
|
|
GHashTable * symbol_table;
|
|
gint8 delimiter;
|
|
};
|
|
|
|
struct _SqlRenderClass
|
|
{
|
|
/* <private> */
|
|
GObjectClass parent;
|
|
};
|
|
|
|
/**
|
|
* SqlRenderError:
|
|
* @SQL_RENDER_ERROR: an error from an #SqlRender
|
|
*
|
|
* Identifies the error codes for #SqlRender
|
|
**/
|
|
typedef enum
|
|
{
|
|
SQL_RENDER_ERROR
|
|
}
|
|
SqlRenderError;
|
|
|
|
GType sql_render_get_type ();
|
|
SqlRender * sql_render_new (gchar delimiter);
|
|
gchar * sql_render_get_string (SqlRender * obj, gpointer object, gpointer data, GError ** err);
|
|
void sql_render_register_function (SqlRender * obj, GType type, SqlRenderFunc function);
|
|
void sql_render_add_espace (SqlRender * obj);
|
|
void sql_render_printf (SqlRender * obj, const gchar * string, ...);
|
|
void sql_render_append (SqlRender * obj, const gchar * string);
|
|
void sql_render_append_with_delimiter (SqlRender * obj, const gchar * string, gchar delimiter);
|
|
void sql_render_add_token (SqlRender * obj, const gchar * token);
|
|
void sql_render_add_identifier (SqlRender * obj, const gchar * identifier);
|
|
void sql_render_add_object (SqlRender * obj, gpointer object);
|
|
void sql_render_add_item (SqlRender * obj, gboolean required, const gchar * token, gpointer item);
|
|
void sql_render_add_list (SqlRender * obj, gboolean required, const gchar * token, GSList * list, const gchar * separator);
|
|
void sql_render_add_list_with_func (SqlRender * obj, gboolean required, const gchar * token, GSList * list, const gchar * separator, SqlRenderFunc function);
|
|
void sql_render_set_error (SqlRender * obj);
|
|
|
|
#endif
|