1) Rename col_type_handler_t -> GncSqlColumnTypeHandler

2) More doxygen comments



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17450 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff 2008-08-02 18:57:13 +00:00
parent eab2cba9f5
commit 4a4c1b6190
12 changed files with 73 additions and 36 deletions

View File

@ -341,7 +341,7 @@ load_account_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t account_guid_handler static GncSqlColumnTypeHandler account_guid_handler
= { load_account_guid, = { load_account_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -989,7 +989,7 @@ add_gvalue_string_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t string_handler static GncSqlColumnTypeHandler string_handler
= { load_string, = { load_string,
add_string_col_info_to_list, add_string_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1072,7 +1072,7 @@ add_gvalue_int_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t int_handler static GncSqlColumnTypeHandler int_handler
= { load_int, = { load_int,
add_int_col_info_to_list, add_int_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1155,7 +1155,7 @@ add_gvalue_boolean_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t boolean_handler static GncSqlColumnTypeHandler boolean_handler
= { load_boolean, = { load_boolean,
add_boolean_col_info_to_list, add_boolean_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1231,7 +1231,7 @@ add_gvalue_int64_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t int64_handler static GncSqlColumnTypeHandler int64_handler
= { load_int64, = { load_int64,
add_int64_col_info_to_list, add_int64_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1311,7 +1311,7 @@ add_gvalue_double_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t double_handler static GncSqlColumnTypeHandler double_handler
= { load_double, = { load_double,
add_double_col_info_to_list, add_double_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1391,7 +1391,7 @@ add_gvalue_guid_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t guid_handler static GncSqlColumnTypeHandler guid_handler
= { load_guid, = { load_guid,
add_guid_col_info_to_list, add_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1538,7 +1538,7 @@ add_gvalue_timespec_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t timespec_handler static GncSqlColumnTypeHandler timespec_handler
= { load_timespec, = { load_timespec,
add_timespec_col_info_to_list, add_timespec_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1631,7 +1631,7 @@ add_gvalue_date_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), value ); (*pList) = g_slist_append( (*pList), value );
} }
static col_type_handler_t date_handler static GncSqlColumnTypeHandler date_handler
= { load_date, = { load_date,
add_date_col_info_to_list, add_date_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,
@ -1751,7 +1751,7 @@ add_gvalue_numeric_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
(*pList) = g_slist_append( (*pList), denom_value ); (*pList) = g_slist_append( (*pList), denom_value );
} }
static col_type_handler_t numeric_handler static GncSqlColumnTypeHandler numeric_handler
= { load_numeric, = { load_numeric,
add_numeric_col_info_to_list, add_numeric_col_info_to_list,
add_numeric_colname_to_list, add_numeric_colname_to_list,
@ -1761,7 +1761,7 @@ static col_type_handler_t numeric_handler
static GHashTable* g_columnTypeHash = NULL; static GHashTable* g_columnTypeHash = NULL;
void void
gnc_sql_register_col_type_handler( const gchar* colType, const col_type_handler_t* handler ) gnc_sql_register_col_type_handler( const gchar* colType, const GncSqlColumnTypeHandler* handler )
{ {
g_return_if_fail( colType != NULL ); g_return_if_fail( colType != NULL );
g_return_if_fail( handler != NULL ); g_return_if_fail( handler != NULL );
@ -1774,10 +1774,10 @@ gnc_sql_register_col_type_handler( const gchar* colType, const col_type_handler_
DEBUG( "Col type %s registered\n", colType ); DEBUG( "Col type %s registered\n", colType );
} }
static col_type_handler_t* static GncSqlColumnTypeHandler*
get_handler( const GncSqlColumnTableEntry* table_row ) get_handler( const GncSqlColumnTableEntry* table_row )
{ {
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
g_return_val_if_fail( table_row != NULL, NULL ); g_return_val_if_fail( table_row != NULL, NULL );
g_return_val_if_fail( table_row->col_type != NULL, NULL ); g_return_val_if_fail( table_row->col_type != NULL, NULL );
@ -1864,7 +1864,7 @@ gnc_sql_load_object( const GncSqlBackend* be, GncSqlRow* row,
{ {
int col; int col;
QofSetterFunc setter; QofSetterFunc setter;
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
g_return_if_fail( be != NULL ); g_return_if_fail( be != NULL );
g_return_if_fail( row != NULL ); g_return_if_fail( row != NULL );
@ -2043,7 +2043,7 @@ gnc_sql_object_is_it_in_db( GncSqlBackend* be, const gchar* table_name,
{ {
GncSqlStatement* sqlStmt; GncSqlStatement* sqlStmt;
int count; int count;
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
GSList* list = NULL; GSList* list = NULL;
g_return_val_if_fail( be != NULL, FALSE ); g_return_val_if_fail( be != NULL, FALSE );
@ -2109,7 +2109,7 @@ create_gslist_from_values( GncSqlBackend* be,
const GncSqlColumnTableEntry* table ) const GncSqlColumnTableEntry* table )
{ {
GSList* list = NULL; GSList* list = NULL;
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
const GncSqlColumnTableEntry* table_row; const GncSqlColumnTableEntry* table_row;
for( table_row = table; table_row->col_name != NULL; table_row++ ) { for( table_row = table; table_row->col_name != NULL; table_row++ ) {
@ -2222,7 +2222,7 @@ build_update_statement( GncSqlBackend* be,
// Get all col names and all values // Get all col names and all values
for( ; table_row->col_name != NULL; table_row++ ) { for( ; table_row->col_name != NULL; table_row++ ) {
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
// Add col names to the list // Add col names to the list
pHandler = get_handler( table_row ); pHandler = get_handler( table_row );
@ -2270,7 +2270,7 @@ build_delete_statement( GncSqlBackend* be,
{ {
GncSqlStatement* stmt; GncSqlStatement* stmt;
GString* sql; GString* sql;
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
GSList* list = NULL; GSList* list = NULL;
gchar* sqlbuf; gchar* sqlbuf;
@ -2334,7 +2334,7 @@ create_table( const GncSqlBackend* be, const gchar* table_name,
g_return_val_if_fail( col_table != NULL, FALSE ); g_return_val_if_fail( col_table != NULL, FALSE );
for( ; col_table->col_name != NULL; col_table++ ) { for( ; col_table->col_name != NULL; col_table++ ) {
col_type_handler_t* pHandler; GncSqlColumnTypeHandler* pHandler;
pHandler = get_handler( col_table ); pHandler = get_handler( col_table );
pHandler->add_col_info_to_list_fn( be, col_table, &col_info_list ); pHandler->add_col_info_to_list_fn( be, col_table, &col_info_list );

View File

@ -237,7 +237,7 @@ struct GncSqlResult
* @struct GncSqlObjectBackend * @struct GncSqlObjectBackend
* *
* Struct used to handle a specific engine object type for an SQL backend. * Struct used to handle a specific engine object type for an SQL backend.
* This * handler should be registered with qof_object_register_backend(). * This handler should be registered with qof_object_register_backend().
* *
* commit() - commit an object to the db * commit() - commit an object to the db
* initial_load() - load stuff when new db opened * initial_load() - load stuff when new db opened
@ -271,6 +271,9 @@ typedef struct
/** /**
* @struct GncSqlColumnInfo * @struct GncSqlColumnInfo
*
* The GncSqlColumnInfo structure contains information required to create
* a column in a table.
*/ */
typedef struct { typedef struct {
const gchar* name; /**< Column name */ const gchar* name; /**< Column name */
@ -299,7 +302,17 @@ typedef struct {
* @struct GncSqlColumnTableEntry * @struct GncSqlColumnTableEntry
* *
* The GncSqlColumnTableEntry struct contains all of the information * The GncSqlColumnTableEntry struct contains all of the information
* required to copy information between an object and the database. * required to copy information between an object and the database for a
* specific object property.
*
* If an entry contains a gobj_param_name value, this string is used as the
* property name for a call to g_object_get() or g_object_set(). If the
* gobj_param_name value is NULL but qof_param_name is not NULL, this value
* is used as the parameter name for a call to
* qof_class_get_parameter_getter(). If both of these values are NULL, getter
* and setter are the addresses of routines to return or set the parameter
* value, respectively.
*
* The database description for an object consists of an array of * The database description for an object consists of an array of
* GncSqlColumnTableEntry objects, with a final member having col_name == NULL. * GncSqlColumnTableEntry objects, with a final member having col_name == NULL.
*/ */
@ -307,10 +320,10 @@ struct GncSqlColumnTableEntry {
const gchar* col_name; /**< Column name */ const gchar* col_name; /**< Column name */
const gchar* col_type; /**< Column type */ const gchar* col_type; /**< Column type */
gint size; /**< Column size in bytes, for string columns */ gint size; /**< Column size in bytes, for string columns */
#define COL_PKEY 0x01 #define COL_PKEY 0x01 /**< The column is a primary key */
#define COL_NNUL 0x02 #define COL_NNUL 0x02 /**< The column may not contain a NULL value */
#define COL_UNIQUE 0x04 #define COL_UNIQUE 0x04 /**< The column must contain unique values */
#define COL_AUTOINC 0x08 #define COL_AUTOINC 0x08 /**< The column is an auto-incrementing int */
gint flags; /**< Column flags */ gint flags; /**< Column flags */
const gchar* gobj_param_name; /**< If non-null, g_object param name */ const gchar* gobj_param_name; /**< If non-null, g_object param name */
const gchar* qof_param_name; /**< If non-null, qof parameter name */ const gchar* qof_param_name; /**< If non-null, qof parameter name */
@ -336,12 +349,36 @@ typedef void (*GNC_SQL_ADD_GVALUE_TO_SLIST_FN)( const GncSqlBackend* be,
QofIdTypeConst obj_name, const gpointer pObject, QofIdTypeConst obj_name, const gpointer pObject,
const GncSqlColumnTableEntry* table_row, GSList** pList ); const GncSqlColumnTableEntry* table_row, GSList** pList );
/**
* @struct GncSqlColumnTypeHandler
*
* The GncSqlColumnTypeHandler struct contains pointers to routines to handle
* different options for a specific column type.
*
* A column type maps a property value to one or more columns in the database.
*/
typedef struct { typedef struct {
/**
* Routine to load a value into an object from the database row.
*/
GNC_SQL_LOAD_FN load_fn; GNC_SQL_LOAD_FN load_fn;
/**
* Routine to add a GncSqlColumnInfo structure for the column type to a
* GList.
*/
GNC_SQL_ADD_COL_INFO_TO_LIST_FN add_col_info_to_list_fn; GNC_SQL_ADD_COL_INFO_TO_LIST_FN add_col_info_to_list_fn;
/**
* Routine to add a column name string for the column type to a GList.
*/
GNC_SQL_ADD_COLNAME_TO_LIST_FN add_colname_to_list_fn; GNC_SQL_ADD_COLNAME_TO_LIST_FN add_colname_to_list_fn;
/**
* Routine to add a GValue for the property to a GSList.
*/
GNC_SQL_ADD_GVALUE_TO_SLIST_FN add_gvalue_to_slist_fn; GNC_SQL_ADD_GVALUE_TO_SLIST_FN add_gvalue_to_slist_fn;
} col_type_handler_t; } GncSqlColumnTypeHandler;
/** /**
* Returns the QOF access function for a column. * Returns the QOF access function for a column.
@ -502,7 +539,7 @@ GncSqlStatement* gnc_sql_create_select_statement( const GncSqlBackend* be,
* @param colType Column type * @param colType Column type
* @param handler Column handler * @param handler Column handler
*/ */
void gnc_sql_register_col_type_handler( const gchar* colType, const col_type_handler_t* handler ); void gnc_sql_register_col_type_handler( const gchar* colType, const GncSqlColumnTypeHandler* handler );
/** /**
* Adds a GValue for an object reference GUID to the end of a GSList. * Adds a GValue for an object reference GUID to the end of a GSList.

View File

@ -236,7 +236,7 @@ load_commodity_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t commodity_guid_handler static GncSqlColumnTypeHandler commodity_guid_handler
= { load_commodity_guid, = { load_commodity_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -221,7 +221,7 @@ load_lot_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t lot_guid_handler static GncSqlColumnTypeHandler lot_guid_handler
= { load_lot_guid, = { load_lot_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -714,7 +714,7 @@ load_tx_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t tx_guid_handler static GncSqlColumnTypeHandler tx_guid_handler
= { load_tx_guid, = { load_tx_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -197,7 +197,7 @@ add_gvalue_address_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
} }
} }
static col_type_handler_t address_handler static GncSqlColumnTypeHandler address_handler
= { load_address, = { load_address,
add_address_col_info_to_list, add_address_col_info_to_list,
add_address_colname_to_list, add_address_colname_to_list,

View File

@ -215,7 +215,7 @@ load_billterm_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t billterm_guid_handler static GncSqlColumnTypeHandler billterm_guid_handler
= { load_billterm_guid, = { load_billterm_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -261,7 +261,7 @@ load_invoice_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t invoice_guid_handler static GncSqlColumnTypeHandler invoice_guid_handler
= { load_invoice_guid, = { load_invoice_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -217,7 +217,7 @@ load_order_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t order_guid_handler static GncSqlColumnTypeHandler order_guid_handler
= { load_order_guid, = { load_order_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,

View File

@ -269,7 +269,7 @@ add_gvalue_owner_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
} }
} }
static col_type_handler_t owner_handler static GncSqlColumnTypeHandler owner_handler
= { load_owner, = { load_owner,
add_owner_col_info_to_list, add_owner_col_info_to_list,
add_colname_to_list, add_colname_to_list,

View File

@ -386,7 +386,7 @@ load_taxtable_guid( const GncSqlBackend* be, GncSqlRow* row,
} }
} }
static col_type_handler_t taxtable_guid_handler static GncSqlColumnTypeHandler taxtable_guid_handler
= { load_taxtable_guid, = { load_taxtable_guid,
gnc_sql_add_objectref_guid_col_info_to_list, gnc_sql_add_objectref_guid_col_info_to_list,
gnc_sql_add_colname_to_list, gnc_sql_add_colname_to_list,