mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
rename QofQueryObject to QofParam to better describe what this thing
really is git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9421 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c87ddd7293
commit
9ad623b96e
@ -3007,7 +3007,7 @@ static QofObject account_object_def = {
|
|||||||
|
|
||||||
gboolean xaccAccountRegister (void)
|
gboolean xaccAccountRegister (void)
|
||||||
{
|
{
|
||||||
static QofQueryObject params[] = {
|
static QofParam params[] = {
|
||||||
{ ACCOUNT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccAccountGetSlots },
|
{ ACCOUNT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccAccountGetSlots },
|
||||||
{ ACCOUNT_NAME_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetName },
|
{ ACCOUNT_NAME_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetName },
|
||||||
{ ACCOUNT_CODE_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetCode },
|
{ ACCOUNT_CODE_, QOF_TYPE_STRING, (QofAccessFunc)xaccAccountGetCode },
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#include "qofqueryobject.h"
|
#include "qofqueryobject.h"
|
||||||
|
|
||||||
#define query_object_def _QofQueryObject
|
#define query_object_def _QofParam
|
||||||
#define QueryObjectDef QofQueryObject
|
#define QueryObjectDef QofParam
|
||||||
#define QuerySort QofSortFunc
|
#define QuerySort QofSortFunc
|
||||||
|
|
||||||
#define gncQueryObjectRegister qof_query_object_register
|
#define gncQueryObjectRegister qof_query_object_register
|
||||||
|
@ -3432,7 +3432,7 @@ static gpointer no_op (gpointer obj)
|
|||||||
|
|
||||||
gboolean xaccSplitRegister (void)
|
gboolean xaccSplitRegister (void)
|
||||||
{
|
{
|
||||||
static const QofQueryObject params[] = {
|
static const QofParam params[] = {
|
||||||
{ SPLIT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccSplitGetSlots },
|
{ SPLIT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccSplitGetSlots },
|
||||||
{ SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
|
{ SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccSplitRetDateReconciledTS },
|
(QofAccessFunc)xaccSplitRetDateReconciledTS },
|
||||||
@ -3513,7 +3513,7 @@ trans_is_balanced_p (const Transaction *txn)
|
|||||||
|
|
||||||
gboolean xaccTransRegister (void)
|
gboolean xaccTransRegister (void)
|
||||||
{
|
{
|
||||||
static QofQueryObject params[] = {
|
static QofParam params[] = {
|
||||||
{ TRANS_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccTransGetSlots },
|
{ TRANS_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccTransGetSlots },
|
||||||
{ TRANS_NUM, QOF_TYPE_STRING, (QofAccessFunc)xaccTransGetNum },
|
{ TRANS_NUM, QOF_TYPE_STRING, (QofAccessFunc)xaccTransGetNum },
|
||||||
{ TRANS_DESCRIPTION, QOF_TYPE_STRING, (QofAccessFunc)xaccTransGetDescription },
|
{ TRANS_DESCRIPTION, QOF_TYPE_STRING, (QofAccessFunc)xaccTransGetDescription },
|
||||||
|
@ -378,7 +378,7 @@ gnc_lot_get_latest_split (GNCLot *lot)
|
|||||||
|
|
||||||
void gnc_lot_register (void)
|
void gnc_lot_register (void)
|
||||||
{
|
{
|
||||||
static const QofQueryObject params[] = {
|
static const QofParam params[] = {
|
||||||
{ QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)gnc_lot_get_book },
|
{ QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)gnc_lot_get_book },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)gnc_lot_get_guid },
|
{ QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)gnc_lot_get_guid },
|
||||||
{ LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed },
|
{ LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed },
|
||||||
|
@ -2151,7 +2151,7 @@ static QofObject pricedb_object_def =
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_pricedb_register (void)
|
gnc_pricedb_register (void)
|
||||||
{
|
{
|
||||||
static QofQueryObject params[] = {
|
static QofParam params[] = {
|
||||||
{ PRICE_COMMODITY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_commodity },
|
{ PRICE_COMMODITY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_commodity },
|
||||||
{ PRICE_CURRENCY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_currency },
|
{ PRICE_CURRENCY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_currency },
|
||||||
{ PRICE_DATE, QOF_TYPE_DATE, (QofAccessFunc)gnc_price_get_time },
|
{ PRICE_DATE, QOF_TYPE_DATE, (QofAccessFunc)gnc_price_get_time },
|
||||||
|
@ -285,7 +285,7 @@ qof_book_get_counter (QofBook *book, const char *counter_name)
|
|||||||
/* QofObject function implementation and registration */
|
/* QofObject function implementation and registration */
|
||||||
gboolean qof_book_register (void)
|
gboolean qof_book_register (void)
|
||||||
{
|
{
|
||||||
static QofQueryObject params[] = {
|
static QofParam params[] = {
|
||||||
{ QOF_BOOK_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_book_get_slots },
|
{ QOF_BOOK_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_book_get_slots },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_book_get_guid },
|
{ QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_book_get_guid },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
|
@ -429,9 +429,9 @@ check_object (QofQuery *q, gpointer object)
|
|||||||
* returns NULL if the first parameter is bad (and final is unchanged).
|
* returns NULL if the first parameter is bad (and final is unchanged).
|
||||||
*/
|
*/
|
||||||
static GSList * compile_params (GSList *param_list, QofIdType start_obj,
|
static GSList * compile_params (GSList *param_list, QofIdType start_obj,
|
||||||
QofQueryObject const **final)
|
QofParam const **final)
|
||||||
{
|
{
|
||||||
const QofQueryObject *objDef = NULL;
|
const QofParam *objDef = NULL;
|
||||||
GSList *fcns = NULL;
|
GSList *fcns = NULL;
|
||||||
|
|
||||||
ENTER ("param_list=%p id=%s", param_list, start_obj);
|
ENTER ("param_list=%p id=%s", param_list, start_obj);
|
||||||
@ -464,7 +464,7 @@ static GSList * compile_params (GSList *param_list, QofIdType start_obj,
|
|||||||
static void
|
static void
|
||||||
compile_sort (QofQuerySort *sort, QofIdType obj)
|
compile_sort (QofQuerySort *sort, QofIdType obj)
|
||||||
{
|
{
|
||||||
const QofQueryObject *resObj = NULL;
|
const QofParam *resObj = NULL;
|
||||||
|
|
||||||
ENTER ("sort=%p id=%s params=%p", sort, obj, sort->param_list);
|
ENTER ("sort=%p id=%s params=%p", sort, obj, sort->param_list);
|
||||||
sort->use_default = FALSE;
|
sort->use_default = FALSE;
|
||||||
@ -511,7 +511,7 @@ static void compile_terms (QofQuery *q)
|
|||||||
for (or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next) {
|
for (or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next) {
|
||||||
for (and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) {
|
for (and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) {
|
||||||
QofQueryTerm *qt = and_ptr->data;
|
QofQueryTerm *qt = and_ptr->data;
|
||||||
const QofQueryObject *resObj = NULL;
|
const QofParam *resObj = NULL;
|
||||||
|
|
||||||
g_slist_free (qt->param_fcns);
|
g_slist_free (qt->param_fcns);
|
||||||
qt->param_fcns = NULL;
|
qt->param_fcns = NULL;
|
||||||
|
@ -47,7 +47,7 @@ static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
|||||||
|
|
||||||
void qof_query_object_register (QofIdTypeConst obj_name,
|
void qof_query_object_register (QofIdTypeConst obj_name,
|
||||||
QofSortFunc default_sort_function,
|
QofSortFunc default_sort_function,
|
||||||
const QofQueryObject *params)
|
const QofParam *params)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ void qof_query_object_shutdown (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QofQueryObject * qof_query_object_get_parameter (QofIdTypeConst obj_name,
|
const QofParam * qof_query_object_get_parameter (QofIdTypeConst obj_name,
|
||||||
const char *parameter)
|
const char *parameter)
|
||||||
{
|
{
|
||||||
GHashTable *ht;
|
GHashTable *ht;
|
||||||
@ -112,14 +112,14 @@ const QofQueryObject * qof_query_object_get_parameter (QofIdTypeConst obj_name,
|
|||||||
QofAccessFunc qof_query_object_get_parameter_getter (QofIdTypeConst obj_name,
|
QofAccessFunc qof_query_object_get_parameter_getter (QofIdTypeConst obj_name,
|
||||||
const char *parameter)
|
const char *parameter)
|
||||||
{
|
{
|
||||||
const QofQueryObject *obj;
|
const QofParam *prm;
|
||||||
|
|
||||||
g_return_val_if_fail (obj_name, NULL);
|
g_return_val_if_fail (obj_name, NULL);
|
||||||
g_return_val_if_fail (parameter, NULL);
|
g_return_val_if_fail (parameter, NULL);
|
||||||
|
|
||||||
obj = qof_query_object_get_parameter (obj_name, parameter);
|
prm = qof_query_object_get_parameter (obj_name, parameter);
|
||||||
if (obj)
|
if (prm)
|
||||||
return obj->param_getfcn;
|
return prm->param_getfcn;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -127,14 +127,14 @@ QofAccessFunc qof_query_object_get_parameter_getter (QofIdTypeConst obj_name,
|
|||||||
QofType qof_query_object_parameter_type (QofIdTypeConst obj_name,
|
QofType qof_query_object_parameter_type (QofIdTypeConst obj_name,
|
||||||
const char *param_name)
|
const char *param_name)
|
||||||
{
|
{
|
||||||
const QofQueryObject *obj;
|
const QofParam *prm;
|
||||||
|
|
||||||
if (!obj_name || !param_name) return NULL;
|
if (!obj_name || !param_name) return NULL;
|
||||||
|
|
||||||
obj = qof_query_object_get_parameter (obj_name, param_name);
|
prm = qof_query_object_get_parameter (obj_name, param_name);
|
||||||
if (!obj) return NULL;
|
if (!prm) return NULL;
|
||||||
|
|
||||||
return (obj->param_type);
|
return (prm->param_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
QofSortFunc
|
QofSortFunc
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#ifndef QOF_QUERYOBJECT_H
|
#ifndef QOF_QUERYOBJECT_H
|
||||||
#define QOF_QUERYOBJECT_H
|
#define QOF_QUERYOBJECT_H
|
||||||
|
|
||||||
// #include "qofquery.h"
|
|
||||||
#include "qofid.h"
|
#include "qofid.h"
|
||||||
|
|
||||||
#define QOF_TYPE_STRING "string"
|
#define QOF_TYPE_STRING "string"
|
||||||
@ -62,12 +61,12 @@ typedef gpointer (*QofAccessFunc)(gpointer);
|
|||||||
* object or it can be a core data type.
|
* object or it can be a core data type.
|
||||||
* -- param_getgcn is the function to actually obtain the parameter
|
* -- param_getgcn is the function to actually obtain the parameter
|
||||||
*/
|
*/
|
||||||
typedef struct _QofQueryObject
|
typedef struct _QofParam
|
||||||
{
|
{
|
||||||
const char * param_name;
|
const char * param_name;
|
||||||
QofType param_type;
|
QofType param_type;
|
||||||
QofAccessFunc param_getfcn;
|
QofAccessFunc param_getfcn;
|
||||||
} QofQueryObject;
|
} QofParam;
|
||||||
|
|
||||||
/** This function is the default sort function for a particular object type */
|
/** This function is the default sort function for a particular object type */
|
||||||
typedef int (*QofSortFunc)(gpointer, gpointer);
|
typedef int (*QofSortFunc)(gpointer, gpointer);
|
||||||
@ -80,7 +79,7 @@ typedef int (*QofSortFunc)(gpointer, gpointer);
|
|||||||
*/
|
*/
|
||||||
void qof_query_object_register (QofIdTypeConst obj_name,
|
void qof_query_object_register (QofIdTypeConst obj_name,
|
||||||
QofSortFunc default_sort_fcn,
|
QofSortFunc default_sort_fcn,
|
||||||
const QofQueryObject *params);
|
const QofParam *params);
|
||||||
|
|
||||||
/** An example:
|
/** An example:
|
||||||
*
|
*
|
||||||
@ -90,7 +89,7 @@ void qof_query_object_register (QofIdTypeConst obj_name,
|
|||||||
* #define MY_QUERY_OBJ_ACCOUNT "account"
|
* #define MY_QUERY_OBJ_ACCOUNT "account"
|
||||||
* #define MY_QUERY_OBJ_TRANS "trans"
|
* #define MY_QUERY_OBJ_TRANS "trans"
|
||||||
*
|
*
|
||||||
* static QofQueryObject myQueryObjectParams[] = {
|
* static QofParam myParams[] = {
|
||||||
* { MY_QUERY_OBJ_MEMO, QOF_TYPE_STRING, myMemoGetter },
|
* { MY_QUERY_OBJ_MEMO, QOF_TYPE_STRING, myMemoGetter },
|
||||||
* { MY_QUERY_OBJ_VALUE, QOF_TYPE_NUMERIC, myValueGetter },
|
* { MY_QUERY_OBJ_VALUE, QOF_TYPE_NUMERIC, myValueGetter },
|
||||||
* { MY_QUERY_OBJ_DATE, QOF_TYPE_DATE, myDateGetter },
|
* { MY_QUERY_OBJ_DATE, QOF_TYPE_DATE, myDateGetter },
|
||||||
@ -99,15 +98,15 @@ void qof_query_object_register (QofIdTypeConst obj_name,
|
|||||||
* NULL };
|
* NULL };
|
||||||
*
|
*
|
||||||
* qof_query_object_register ("myObjectName", myQueryObjectCompare,
|
* qof_query_object_register ("myObjectName", myQueryObjectCompare,
|
||||||
* &myQueryObjectParams);
|
* &myParams);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Return the core datatype of the specified object's parameter */
|
/** Return the core datatype of the specified object's parameter */
|
||||||
QofType qof_query_object_parameter_type (QofIdTypeConst obj_name,
|
QofType qof_query_object_parameter_type (QofIdTypeConst obj_name,
|
||||||
const char *param_name);
|
const char *param_name);
|
||||||
|
|
||||||
/** Return the registered Object Definition for the requested parameter */
|
/** Return the registered Parameter Definition for the requested parameter */
|
||||||
const QofQueryObject * qof_query_object_get_parameter (QofIdTypeConst obj_name,
|
const QofParam * qof_query_object_get_parameter (QofIdTypeConst obj_name,
|
||||||
const char *parameter);
|
const char *parameter);
|
||||||
|
|
||||||
/** Return the object's parameter getter function */
|
/** Return the object's parameter getter function */
|
||||||
|
@ -31,12 +31,12 @@ static int test_core_param (gpointer a)
|
|||||||
|
|
||||||
static void test_query_object (void)
|
static void test_query_object (void)
|
||||||
{
|
{
|
||||||
static QofQueryObject params[] = {
|
static QofParam params[] = {
|
||||||
{ TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param },
|
{ TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf (stderr, "\tTesting the QueryObject interface. \n"
|
fprintf (stderr, "\tTesting the qof_query_object interface. \n"
|
||||||
"\tYou may see some \"** CRITICAL **\" messages, which you can safely ignore\n");
|
"\tYou may see some \"** CRITICAL **\" messages, which you can safely ignore\n");
|
||||||
|
|
||||||
qof_query_object_register (TEST_MODULE_NAME, (QofSortFunc)test_sort, params);
|
qof_query_object_register (TEST_MODULE_NAME, (QofSortFunc)test_sort, params);
|
||||||
@ -44,13 +44,13 @@ static void test_query_object (void)
|
|||||||
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, TEST_PARAM)
|
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, TEST_PARAM)
|
||||||
== ¶ms[0], "qof_query_object_get_parameter");
|
== ¶ms[0], "qof_query_object_get_parameter");
|
||||||
do_test (qof_query_object_get_parameter (NULL, NULL) == NULL,
|
do_test (qof_query_object_get_parameter (NULL, NULL) == NULL,
|
||||||
"gncQueryObjectGetParamter (NULL, NULL)");
|
"qof_query_object_get_parameter (NULL, NULL)");
|
||||||
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, NULL) == NULL,
|
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, NULL) == NULL,
|
||||||
"gncQueryObjectGetParamter (TEST_MODULE_NAME, NULL)");
|
"qof_query_object_get_parameter (TEST_MODULE_NAME, NULL)");
|
||||||
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, BAD_PARAM) == NULL,
|
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, BAD_PARAM) == NULL,
|
||||||
"gncQueryObjectGetParamter (TEST_MODULE_NAME, BAD_PARAM)");
|
"qof_query_object_get_parameter (TEST_MODULE_NAME, BAD_PARAM)");
|
||||||
do_test (qof_query_object_get_parameter (NULL, TEST_PARAM) == NULL,
|
do_test (qof_query_object_get_parameter (NULL, TEST_PARAM) == NULL,
|
||||||
"gncQueryObjectGetParamter (NULL, TEST_PARAM)");
|
"qof_query_object_get_parameter (NULL, TEST_PARAM)");
|
||||||
|
|
||||||
do_test (qof_query_object_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM)
|
do_test (qof_query_object_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM)
|
||||||
== (QofAccessFunc)test_core_param,
|
== (QofAccessFunc)test_core_param,
|
||||||
|
Loading…
Reference in New Issue
Block a user