Standardise on gint and gchar. libqof 0.6.4 release.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13747 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Neil Williams
2006-04-07 18:50:08 +00:00
parent 8edd35d84d
commit 68ac06b219
34 changed files with 256 additions and 499 deletions
+21
View File
@@ -23,6 +23,7 @@
#include "config.h" #include "config.h"
#ifndef QOF_DISABLE_DEPRECATED #ifndef QOF_DISABLE_DEPRECATED
#include <glib.h>
#include "qof.h" #include "qof.h"
/* Don't be fooled: gnc_trace_num_spaces has external linkage and /* Don't be fooled: gnc_trace_num_spaces has external linkage and
@@ -103,6 +104,26 @@ qof_book_mergeRuleForeach(QofBookMergeData *mergeData,
{ {
qof_book_merge_rule_foreach(mergeData, cb, mergeResult); qof_book_merge_rule_foreach(mergeData, cb, mergeResult);
} }
gpointer gnc_string_cache_insert(gconstpointer key)
{
return (gpointer)qof_util_string_cache_insert(key);
}
gchar * gnc_stpcpy (gchar *dest, const gchar *src)
{
return g_stpcpy(dest, src);
}
GCache* gnc_engine_get_string_cache(void)
{
return qof_util_get_string_cache();
}
void gnc_engine_string_cache_destroy (void)
{
qof_util_string_cache_destroy();
}
void gnc_string_cache_remove(gconstpointer key)
{
qof_util_string_cache_remove(key);
}
/* ==================================================================== */ /* ==================================================================== */
#endif /* QOF_DISABLE_DEPRECATED */ #endif /* QOF_DISABLE_DEPRECATED */
+44 -5
View File
@@ -24,6 +24,7 @@
#ifndef _DEPRECATED_H #ifndef _DEPRECATED_H
#define _DEPRECATED_H #define _DEPRECATED_H
#include <glib.h> /* deprecated */
#include "qof.h" #include "qof.h"
/** @file deprecated.h /** @file deprecated.h
@@ -141,11 +142,49 @@ void qof_book_mergeRuleForeach(QofBookMergeData* mergeData,
QofBookMergeRuleForeachCB callback , QofBookMergeRuleForeachCB callback ,
QofBookMergeResult mergeResult); QofBookMergeResult mergeResult);
/** \deprecated use qof_book_merge_update_result instead. */ /** \deprecated use qof_book_merge_update_result instead. */
QofBookMergeData* QofBookMergeData* qof_book_mergeUpdateResult(QofBookMergeData *mergeData,
qof_book_mergeUpdateResult(QofBookMergeData *mergeData, QofBookMergeResult tag); QofBookMergeResult tag);
/** \deprecated use qof_book_merge_commit instead. */ /** \deprecated use qof_book_merge_commit instead. */
gint gint qof_book_mergeCommit(QofBookMergeData *mergeData );
qof_book_mergeCommit(QofBookMergeData *mergeData ); /** \deprecated Use the function versions, safe_strcmp() and
safe_strcasecmp() instead. */
#define SAFE_STRCMP_REAL(fcn,da,db) { \
if ((da) && (db)) { \
if ((da) != (db)) { \
gint retval = fcn ((da), (db)); \
/* if strings differ, return */ \
if (retval) return retval; \
} \
} else \
if ((!(da)) && (db)) { \
return -1; \
} else \
if ((da) && (!(db))) { \
return +1; \
} \
}
/** \deprecated use safe_strcmp() */
#define SAFE_STRCMP(da,db) SAFE_STRCMP_REAL(strcmp,(da),(db))
/** \deprecated use safe_strcasecmp() */
#define SAFE_STRCASECMP(da,db) SAFE_STRCMP_REAL(strcasecmp,(da),(db))
/** \deprecated use qof_util_string_cache_insert instead. */
gpointer gnc_string_cache_insert(gconstpointer key);
#if HAVE_SCANF_LLD
# define GNC_SCANF_LLD "%lld" /**< \deprecated use G_GINT64_FORMAT instead. */
#else
# define GNC_SCANF_LLD "%qd" /**< \deprecated use G_GINT64_FORMAT instead. */
#endif
/** \deprecated use qof_util_stpcpy instead. */
gchar * gnc_stpcpy (gchar *dest, const gchar *src);
/** \deprecated use qof_init instead. */
GCache* gnc_engine_get_string_cache(void);
/** \deprecated use qof_init instead. */
GCache* qof_util_get_string_cache(void);
/** \deprecated use qof_close instead. */
void gnc_engine_string_cache_destroy (void);
/** \deprecated use qof_util_string_cache_remove instead. */
void gnc_string_cache_remove(gconstpointer key);
/** \deprecated no replacement. */
void qof_book_set_schedxactions( QofBook *book, GList *newList );
#endif /* _DEPRECATED_H */ #endif /* _DEPRECATED_H */
#endif /* QOF_DISABLE_DEPRECATED */ #endif /* QOF_DISABLE_DEPRECATED */
+1
View File
@@ -28,6 +28,7 @@
#define __EXTENSIONS__ #define __EXTENSIONS__
#include "config.h" #include "config.h"
#include <glib.h>
/* to be renamed qofdate.c */ /* to be renamed qofdate.c */
#include <ctype.h> #include <ctype.h>
+27 -33
View File
@@ -67,7 +67,6 @@
#ifndef GNC_DATE_H #ifndef GNC_DATE_H
#define GNC_DATE_H #define GNC_DATE_H
#include <glib.h>
#include <time.h> #include <time.h>
/** The maximum length of a string created by the date printers */ /** The maximum length of a string created by the date printers */
@@ -119,59 +118,54 @@ typedef enum {
//@{ //@{
/** \brief The string->value versions return FALSE on success and TRUE on failure */ /** \brief The string->value versions return FALSE on success and TRUE on failure */
const char* gnc_date_dateformat_to_string(QofDateFormat format); const gchar* gnc_date_dateformat_to_string(QofDateFormat format);
/** \brief Converts the date format to a printable string. /** \brief Converts the date format to a printable string.
Note the reversed return values! Note the reversed return values!
@return FALSE on success, TRUE on failure. @return FALSE on success, TRUE on failure.
*/ */
gboolean gnc_date_string_to_dateformat(const char* format_string, gboolean gnc_date_string_to_dateformat(const gchar* format_string,
QofDateFormat *format); QofDateFormat *format);
const char* gnc_date_monthformat_to_string(GNCDateMonthFormat format); const gchar* gnc_date_monthformat_to_string(GNCDateMonthFormat format);
/** \brief Converts the month format to a printable string. /** \brief Converts the month format to a printable string.
Note the reversed return values! Note the reversed return values!
@return FALSE on success, TRUE on failure. @return FALSE on success, TRUE on failure.
*/ */
gboolean gnc_date_string_to_monthformat(const char *format_string, gboolean gnc_date_string_to_monthformat(const gchar *format_string,
GNCDateMonthFormat *format); GNCDateMonthFormat *format);
// @} // @}
/* Datatypes *******************************************************/ /* Datatypes *******************************************************/
/** \brief Use a 64-bit signed int timespec /** \brief Use a 64-bit unsigned int timespec
* *
* struct timespec64 is just like the unix 'struct timespec' except * struct timespec64 is just like the unix 'struct timespec' except
* that we use a 64-bit * that we use a 64-bit
* signed int to store the seconds. This should adequately cover * unsigned int to store the seconds. This should adequately cover
* dates in the distant future as well as the distant past, as long as * dates in the distant future as well as the distant past, as long as
* they're not more than a couple dozen times the age of the universe. * they're not more than a couple dozen times the age of the universe.
* Note that both gcc and the IBM Toronto xlC compiler (aka CSet, * Values of this type can range from 0 to 18,446,744,073,709,551,615.
* VisualAge, etc) correctly handle long long as a 64 bit quantity, */
* even on the 32-bit Intel x86 and PowerPC architectures. I'm
* assuming that all the other modern compilers are clean on this
* issue too. */
#ifndef SWIG /* swig 1.1p5 can't hack the long long type */ #ifndef SWIG /* swig 1.1p5 can't hack the long long type */
struct timespec64 struct timespec64
{ {
long long int tv_sec; guint64 tv_sec;
long int tv_nsec; glong tv_nsec;
}; };
#endif /* SWIG */ #endif /* SWIG */
/** The Timespec is just like the unix 'struct timespec' /** The Timespec is just like the unix 'struct timespec'
* except that we use a 64-bit signed int to * except that we use a 64-bit unsigned int to
* store the seconds. This should adequately cover dates in the * store the seconds. This should adequately cover dates in the
* distant future as well as the distant past, as long as they're not * distant future as well as the distant past, as long as they're not
* more than a couple dozen times the age of the universe. Note that * more than a couple dozen times the age of the universe
* both gcc and the IBM Toronto xlC compiler (aka CSet, VisualAge, * Values of this type can range from 0 to 18,446,744,073,709,551,615.
* etc) correctly handle long long as a 64 bit quantity, even on the */
* 32-bit Intel x86 and PowerPC architectures. I'm assuming that all
* the other modern compilers are clean on this issue too. */
typedef struct timespec64 Timespec; typedef struct timespec64 Timespec;
@@ -183,7 +177,7 @@ typedef struct timespec64 Timespec;
gboolean timespec_equal(const Timespec *ta, const Timespec *tb); gboolean timespec_equal(const Timespec *ta, const Timespec *tb);
/** comparison: if (ta < tb) -1; else if (ta > tb) 1; else 0; */ /** comparison: if (ta < tb) -1; else if (ta > tb) 1; else 0; */
int timespec_cmp(const Timespec *ta, const Timespec *tb); gint timespec_cmp(const Timespec *ta, const Timespec *tb);
/** difference between ta and tb, results are normalised /** difference between ta and tb, results are normalised
* ie tv_sec and tv_nsec of the result have the same size * ie tv_sec and tv_nsec of the result have the same size
@@ -204,10 +198,10 @@ void timespecFromTime_t( Timespec *ts, time_t t );
time_t timespecToTime_t (Timespec ts); time_t timespecToTime_t (Timespec ts);
/** Convert a day, month, and year to a Timespec */ /** Convert a day, month, and year to a Timespec */
Timespec gnc_dmy2timespec (int day, int month, int year); Timespec gnc_dmy2timespec (gint day, gint month, gint year);
/** Same as gnc_dmy2timespec, but last second of the day */ /** Same as gnc_dmy2timespec, but last second of the day */
Timespec gnc_dmy2timespec_end (int day, int month, int year); Timespec gnc_dmy2timespec_end (gint day, gint month, gint year);
/** The gnc_iso8601_to_timespec_gmt() routine converts an ISO-8601 style /** The gnc_iso8601_to_timespec_gmt() routine converts an ISO-8601 style
* date/time string to Timespec. Please note that ISO-8601 strings * date/time string to Timespec. Please note that ISO-8601 strings
@@ -225,7 +219,7 @@ Timespec gnc_dmy2timespec_end (int day, int month, int year);
* XXX Caution: this routine does not handle strings that specify * XXX Caution: this routine does not handle strings that specify
* times before January 1 1970. * times before January 1 1970.
*/ */
Timespec gnc_iso8601_to_timespec_gmt(const char *); Timespec gnc_iso8601_to_timespec_gmt(const gchar *);
/** The gnc_timespec_to_iso8601_buff() routine takes the input /** The gnc_timespec_to_iso8601_buff() routine takes the input
* UTC Timespec value and prints it as an ISO-8601 style string. * UTC Timespec value and prints it as an ISO-8601 style string.
@@ -243,11 +237,11 @@ Timespec gnc_iso8601_to_timespec_gmt(const char *);
* The string generated by this routine uses the local timezone * The string generated by this routine uses the local timezone
* on the machine on which it is executing to create the timestring. * on the machine on which it is executing to create the timestring.
*/ */
char * gnc_timespec_to_iso8601_buff (Timespec ts, char * buff); gchar * gnc_timespec_to_iso8601_buff (Timespec ts, gchar * buff);
/** DOCUMENT ME! FIXME: Probably similar to xaccDMYToSec() this date /** DOCUMENT ME! FIXME: Probably similar to xaccDMYToSec() this date
* routine might return incorrect values for dates before 1970. */ * routine might return incorrect values for dates before 1970. */
void gnc_timespec2dmy (Timespec ts, int *day, int *month, int *year); void gnc_timespec2dmy (Timespec ts, gint *day, gint *month, gint *year);
/** \brief Add a number of days to a Timespec and normalise. /** \brief Add a number of days to a Timespec and normalise.
@@ -269,7 +263,7 @@ gboolean qof_date_add_months(Timespec *ts, gint months, gboolean track_last_day)
/** \deprecated Add a number of months to a time value and normalize. Optionally /** \deprecated Add a number of months to a time value and normalize. Optionally
* also track the last day of the month, i.e. 1/31 -> 2/28 -> 3/31. */ * also track the last day of the month, i.e. 1/31 -> 2/28 -> 3/31. */
void date_add_months (struct tm *tm, int months, gboolean track_last_day); void date_add_months (struct tm *tm, gint months, gboolean track_last_day);
/** \warning hack alert XXX FIXME -- these date routines return incorrect /** \warning hack alert XXX FIXME -- these date routines return incorrect
* values for dates before 1970. Most of them are good only up * values for dates before 1970. Most of them are good only up
@@ -279,7 +273,7 @@ void date_add_months (struct tm *tm, int months, gboolean track_last_day);
* the user wanted the time at noon, localtime. The returned * the user wanted the time at noon, localtime. The returned
* time_t should be seconds (at GMT) of the local noon-time. * time_t should be seconds (at GMT) of the local noon-time.
*/ */
time_t xaccDMYToSec (int day, int month, int year); time_t xaccDMYToSec (gint day, gint month, gint year);
/** The gnc_timezone function returns the number of seconds *west* /** The gnc_timezone function returns the number of seconds *west*
* of UTC represented by the tm argument, adjusted for daylight * of UTC represented by the tm argument, adjusted for daylight
@@ -293,7 +287,7 @@ time_t xaccDMYToSec (int day, int month, int year);
* daylight savings time! Timezone stuff under unix is not * daylight savings time! Timezone stuff under unix is not
* standardized and is a big mess. * standardized and is a big mess.
*/ */
long int gnc_timezone (struct tm *tm); glong gnc_timezone (struct tm *tm);
// @} // @}
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@@ -343,7 +337,7 @@ const gchar *qof_date_text_format_get_string(QofDateFormat df);
* *
* Globals: global dateFormat value * Globals: global dateFormat value
*/ */
char dateSeparator(void); gchar dateSeparator(void);
/** \name Date Printing/Scanning functions /** \name Date Printing/Scanning functions
*/ */
@@ -371,7 +365,7 @@ char dateSeparator(void);
* *
* Globals: global dateFormat value * Globals: global dateFormat value
**/ **/
size_t qof_print_date_dmy_buff (char * buff, size_t buflen, int day, int month, int year); size_t qof_print_date_dmy_buff (gchar * buff, size_t buflen, int day, int month, int year);
/** Convenience: calls through to qof_print_date_dmy_buff(). **/ /** Convenience: calls through to qof_print_date_dmy_buff(). **/
size_t qof_print_date_buff (char * buff, size_t buflen, time_t secs); size_t qof_print_date_buff (char * buff, size_t buflen, time_t secs);
@@ -463,7 +457,7 @@ void gnc_tm_set_day_start (struct tm *tm)
tm->tm_isdst = -1; tm->tm_isdst = -1;
} }
/** The gnc_tm_set_day_middle() inline routine will set the appropriate /** The gnc_tm_set_day_start() inline routine will set the appropriate
* fields in the struct tm to indicate noon of that day. This * fields in the struct tm to indicate noon of that day. This
* routine assumes that the contents of the data structure is already * routine assumes that the contents of the data structure is already
* in normalized form.*/ * in normalized form.*/
@@ -477,7 +471,7 @@ void gnc_tm_set_day_middle (struct tm *tm)
tm->tm_isdst = -1; tm->tm_isdst = -1;
} }
/** The gnc_tm_set_day_end() inline routine will set the appropriate /** The gnc_tm_set_day_start() inline routine will set the appropriate
* fields in the struct tm to indicate the last second of that day. * fields in the struct tm to indicate the last second of that day.
* This routine assumes that the contents of the data structure is * This routine assumes that the contents of the data structure is
* already in normalized form.*/ * already in normalized form.*/
+4 -50
View File
@@ -36,51 +36,7 @@
addition and multiplication, but 64-bit rationals do not have addition and multiplication, but 64-bit rationals do not have
the dynamic range of floating point numbers. the dynamic range of floating point numbers.
EXAMPLE\n See \ref gncnumericexample
-------\n
The following program finds the best ::gnc_numeric approximation to
the \a math.h constant \a M_PI given a maximum denominator. For
large denominators, the ::gnc_numeric approximation is accurate to
more decimal places than will generally be needed, but in some cases
this may not be good enough. For example,
@verbatim
M_PI = 3.14159265358979323846
245850922 / 78256779 = 3.14159265358979311599 (16 sig figs)
3126535 / 995207 = 3.14159265358865047446 (12 sig figs)
355 / 113 = 3.14159292035398252096 (7 sig figs)
@endverbatim
@verbatim
#include <glib.h>
#include <qof.h>
#include <math.h>
int
main(int argc, char ** argv)
{
gnc_numeric approx, best;
double err, best_err=1.0;
double m_pi = M_PI;
gint64 denom;
gint64 max;
sscanf(argv[1], "%Ld", &max);
for (denom = 1; denom < max; denom++)
{
approx = double_to_gnc_numeric (m_pi, denom, GNC_RND_ROUND);
err = m_pi - gnc_numeric_to_double (approx);
if (fabs (err) < fabs (best_err))
{
best = approx;
best_err = err;
printf ("%Ld / %Ld = %.30f\n", gnc_numeric_num (best),
gnc_numeric_denom (best), gnc_numeric_to_double (best));
}
}
}
@endverbatim
@{ */ @{ */
/** @file gnc-numeric.h /** @file gnc-numeric.h
@@ -94,8 +50,6 @@ main(int argc, char ** argv)
#ifndef GNC_NUMERIC_H #ifndef GNC_NUMERIC_H
#define GNC_NUMERIC_H #define GNC_NUMERIC_H
#include <glib.h>
struct _gnc_numeric struct _gnc_numeric
{ {
gint64 num; gint64 num;
@@ -325,7 +279,7 @@ static inline
gint64 gnc_numeric_denom(gnc_numeric a) { return a.denom; } gint64 gnc_numeric_denom(gnc_numeric a) { return a.denom; }
/** Convert numeric to floating-point value. */ /** Convert numeric to floating-point value. */
double gnc_numeric_to_double(gnc_numeric in); gdouble gnc_numeric_to_double(gnc_numeric in);
/** Convert to string. The returned buffer is to be g_free'd by the /** Convert to string. The returned buffer is to be g_free'd by the
* caller (it was allocated through g_strdup) */ * caller (it was allocated through g_strdup) */
@@ -346,7 +300,7 @@ gchar * gnc_num_dbg_to_string(gnc_numeric n);
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a); GNCNumericErrorCode gnc_numeric_check(gnc_numeric a);
/** Returns 1 if a>b, -1 if b>a, 0 if a == b */ /** Returns 1 if a>b, -1 if b>a, 0 if a == b */
int gnc_numeric_compare(gnc_numeric a, gnc_numeric b); gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b);
/** Returns 1 if the given gnc_numeric is 0 (zero), else returns 0. */ /** Returns 1 if the given gnc_numeric is 0 (zero), else returns 0. */
gboolean gnc_numeric_zero_p(gnc_numeric a); gboolean gnc_numeric_zero_p(gnc_numeric a);
@@ -380,7 +334,7 @@ gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b);
because 7/16 rounds to 1/2 under unbiased rounding but 3/4 rounds because 7/16 rounds to 1/2 under unbiased rounding but 3/4 rounds
to 2/2. to 2/2.
*/ */
int gnc_numeric_same(gnc_numeric a, gnc_numeric b, gint gnc_numeric_same(gnc_numeric a, gnc_numeric b,
gint64 denom, gint how); gint64 denom, gint how);
/** @} */ /** @} */
+5 -6
View File
@@ -24,7 +24,6 @@
#ifndef GUID_H #ifndef GUID_H
#define GUID_H #define GUID_H
#include <glib.h>
#include <stddef.h> #include <stddef.h>
/** @addtogroup Entity /** @addtogroup Entity
@@ -53,9 +52,9 @@
#define GUID_DATA_SIZE 16 #define GUID_DATA_SIZE 16
typedef union _GUID typedef union _GUID
{ {
unsigned char data[GUID_DATA_SIZE]; guchar data[GUID_DATA_SIZE];
int __align_me; /* this just ensures that GUIDs are 32-bit gint __align_me; /* this just ensures that GUIDs are 32-bit
* aligned on systems that need them to be. */ * aligned on systems that need them to be. */
} GUID; } GUID;
@@ -160,7 +159,7 @@ void guid_free (GUID *guid);
* returned memory is owned by this routine and may not be freed by * returned memory is owned by this routine and may not be freed by
* the caller. * the caller.
*/ */
const char * guid_to_string (const GUID * guid); const gchar * guid_to_string (const GUID * guid);
/** The guid_to_string_buff() routine puts a null-terminated string /** The guid_to_string_buff() routine puts a null-terminated string
* encoding of the id into the memory pointed at by buff. The * encoding of the id into the memory pointed at by buff. The
@@ -175,7 +174,7 @@ const char * guid_to_string (const GUID * guid);
* *
* @return A pointer to the terminating null character of the string. * @return A pointer to the terminating null character of the string.
*/ */
char * guid_to_string_buff (const GUID * guid, char *buff); gchar * guid_to_string_buff (const GUID * guid, gchar *buff);
/** Given a string, decode the id into the guid if guid is non-NULL. /** Given a string, decode the id into the guid if guid is non-NULL.
@@ -183,7 +182,7 @@ char * guid_to_string_buff (const GUID * guid, char *buff);
* hexadecimal number. This function accepts both upper and lower case * hexadecimal number. This function accepts both upper and lower case
* hex digits. If the return value is FALSE, the effect on guid is * hex digits. If the return value is FALSE, the effect on guid is
* undefined. */ * undefined. */
gboolean string_to_guid(const char * string, GUID * guid); gboolean string_to_guid(const gchar * string, GUID * guid);
/** Given two GUIDs, return TRUE if they are non-NULL and equal. /** Given two GUIDs, return TRUE if they are non-NULL and equal.
+5 -5
View File
@@ -34,7 +34,7 @@
#include "qof.h" #include "qof.h"
/* Note that we keep the keys for this hash table in a GCache /* Note that we keep the keys for this hash table in a GCache
* (gnc_string_cache), as it is very likely we will see the * (qof_util_string_cache), as it is very likely we will see the
* same keys over and over again */ * same keys over and over again */
struct _KvpFrame struct _KvpFrame
@@ -107,7 +107,7 @@ kvp_frame_new(void)
static void static void
kvp_frame_delete_worker(gpointer key, gpointer value, gpointer user_data) kvp_frame_delete_worker(gpointer key, gpointer value, gpointer user_data)
{ {
gnc_string_cache_remove(key); qof_util_string_cache_remove(key);
kvp_value_delete((KvpValue *)value); kvp_value_delete((KvpValue *)value);
} }
@@ -142,7 +142,7 @@ kvp_frame_copy_worker(gpointer key, gpointer value, gpointer user_data)
{ {
KvpFrame * dest = (KvpFrame *)user_data; KvpFrame * dest = (KvpFrame *)user_data;
g_hash_table_insert(dest->hash, g_hash_table_insert(dest->hash,
gnc_string_cache_insert(key), qof_util_string_cache_insert(key),
(gpointer)kvp_value_copy(value)); (gpointer)kvp_value_copy(value));
} }
@@ -183,7 +183,7 @@ kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot,
if(key_exists) if(key_exists)
{ {
g_hash_table_remove(frame->hash, slot); g_hash_table_remove(frame->hash, slot);
gnc_string_cache_remove(orig_key); qof_util_string_cache_remove(orig_key);
} }
else else
{ {
@@ -193,7 +193,7 @@ kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot,
if(new_value) if(new_value)
{ {
g_hash_table_insert(frame->hash, g_hash_table_insert(frame->hash,
gnc_string_cache_insert((gpointer) slot), qof_util_string_cache_insert((gpointer) slot),
new_value); new_value);
} }
+40 -42
View File
@@ -61,8 +61,6 @@
#ifndef KVP_FRAME_H #ifndef KVP_FRAME_H
#define KVP_FRAME_H #define KVP_FRAME_H
#include <glib.h>
#include "gnc-date.h" #include "gnc-date.h"
#include "gnc-numeric.h" #include "gnc-numeric.h"
#include "guid.h" #include "guid.h"
@@ -141,13 +139,13 @@ gboolean kvp_frame_is_empty(KvpFrame * frame);
* the path exist, they are created. * the path exist, they are created.
* *
*/ */
void kvp_frame_set_gint64(KvpFrame * frame, const char * path, gint64 ival); void kvp_frame_set_gint64(KvpFrame * frame, const gchar * path, gint64 ival);
/** /**
* store the value of the * store the value of the
* double at the indicated path. If not all frame components of * double at the indicated path. If not all frame components of
* the path exist, they are created. * the path exist, they are created.
*/ */
void kvp_frame_set_double(KvpFrame * frame, const char * path, double dval); void kvp_frame_set_double(KvpFrame * frame, const gchar * path, double dval);
/** \deprecated /** \deprecated
@@ -159,13 +157,13 @@ Use kvp_frame_set_numeric instead of kvp_frame_set_gnc_numeric
* If not all frame components of * If not all frame components of
* the path exist, they are created. * the path exist, they are created.
*/ */
void kvp_frame_set_numeric(KvpFrame * frame, const char * path, gnc_numeric nval); void kvp_frame_set_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nval);
/** store the value of the /** store the value of the
* Timespec at the indicated path. * Timespec at the indicated path.
* If not all frame components of * If not all frame components of
* the path exist, they are created. * the path exist, they are created.
*/ */
void kvp_frame_set_timespec(KvpFrame * frame, const char * path, Timespec ts); void kvp_frame_set_timespec(KvpFrame * frame, const gchar * path, Timespec ts);
/** \deprecated /** \deprecated
@@ -185,11 +183,11 @@ Use kvp_frame_set_string instead of kvp_frame_set_str
* The kvp_frame_set_frame_nc() routine works as above, but does * The kvp_frame_set_frame_nc() routine works as above, but does
* *NOT* copy the frame. * *NOT* copy the frame.
*/ */
void kvp_frame_set_string(KvpFrame * frame, const char * path, const char* str); void kvp_frame_set_string(KvpFrame * frame, const gchar * path, const char* str);
void kvp_frame_set_guid(KvpFrame * frame, const char * path, const GUID *guid); void kvp_frame_set_guid(KvpFrame * frame, const gchar * path, const GUID *guid);
void kvp_frame_set_frame(KvpFrame *frame, const char *path, KvpFrame *chld); void kvp_frame_set_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
void kvp_frame_set_frame_nc(KvpFrame *frame, const char *path, KvpFrame *chld); void kvp_frame_set_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
/** The kvp_frame_set_value() routine copies the value into the frame, /** The kvp_frame_set_value() routine copies the value into the frame,
* at the location 'path'. If the path contains slashes '/', these * at the location 'path'. If the path contains slashes '/', these
@@ -202,7 +200,7 @@ void kvp_frame_set_frame_nc(KvpFrame *frame, const char *path, KvpFrame *chld);
* of the caller; the pointers are *not* taken over or managed. * of the caller; the pointers are *not* taken over or managed.
*/ */
KvpFrame * kvp_frame_set_value(KvpFrame * frame, KvpFrame * kvp_frame_set_value(KvpFrame * frame,
const char * path, const KvpValue * value); const gchar * path, const KvpValue * value);
/** /**
* The kvp_frame_set_value_nc() routine puts the value (without copying * The kvp_frame_set_value_nc() routine puts the value (without copying
* it) into the frame, putting it at the location 'path'. If the path * it) into the frame, putting it at the location 'path'. If the path
@@ -217,7 +215,7 @@ KvpFrame * kvp_frame_set_value(KvpFrame * frame,
* unless you remove the key as well (or unless you replace the value). * unless you remove the key as well (or unless you replace the value).
*/ */
KvpFrame * kvp_frame_set_value_nc(KvpFrame * frame, KvpFrame * kvp_frame_set_value_nc(KvpFrame * frame,
const char * path, KvpValue * value); const gchar * path, KvpValue * value);
/** The kvp_frame_replace_value_nc() routine places the new value /** The kvp_frame_replace_value_nc() routine places the new value
* at the indicated path. It returns the old value, if any. * at the indicated path. It returns the old value, if any.
@@ -227,7 +225,7 @@ KvpFrame * kvp_frame_set_value_nc(KvpFrame * frame,
* effect of deleting the trailing slot (i.e. the trailing path * effect of deleting the trailing slot (i.e. the trailing path
* element). * element).
*/ */
KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const char * slot, KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const gchar * slot,
KvpValue * new_value); KvpValue * new_value);
/** @} */ /** @} */
/** @name KvpFrame URL handling /** @name KvpFrame URL handling
@@ -245,7 +243,7 @@ KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const char * slot,
* This routine treats all values as strings; it does *not* attempt * This routine treats all values as strings; it does *not* attempt
* to perform any type-conversion. * to perform any type-conversion.
* */ * */
void kvp_frame_add_url_encoding (KvpFrame *frame, const char *enc); void kvp_frame_add_url_encoding (KvpFrame *frame, const gchar *enc);
/** @} */ /** @} */
/** @name KvpFrame Glist Bag Storing /** @name KvpFrame Glist Bag Storing
@@ -263,16 +261,16 @@ void kvp_frame_add_url_encoding (KvpFrame *frame, const char *enc);
* routines perform the same function, for each of the respective * routines perform the same function, for each of the respective
* types. * types.
*/ */
void kvp_frame_add_gint64(KvpFrame * frame, const char * path, gint64 ival); void kvp_frame_add_gint64(KvpFrame * frame, const gchar * path, gint64 ival);
void kvp_frame_add_double(KvpFrame * frame, const char * path, double dval); void kvp_frame_add_double(KvpFrame * frame, const gchar * path, double dval);
/** \deprecated /** \deprecated
Use kvp_frame_add_numeric instead of kvp_frame_add_gnc_numeric Use kvp_frame_add_numeric instead of kvp_frame_add_gnc_numeric
*/ */
#define kvp_frame_add_gnc_numeric kvp_frame_add_numeric #define kvp_frame_add_gnc_numeric kvp_frame_add_numeric
void kvp_frame_add_numeric(KvpFrame * frame, const char * path, gnc_numeric nval); void kvp_frame_add_numeric(KvpFrame * frame, const gchar * path, gnc_numeric nval);
void kvp_frame_add_timespec(KvpFrame * frame, const char * path, Timespec ts); void kvp_frame_add_timespec(KvpFrame * frame, const gchar * path, Timespec ts);
/** \deprecated /** \deprecated
@@ -294,11 +292,11 @@ Use kvp_frame_add_string instead of kvp_frame_add_str
* The kvp_frame_add_frame_nc() routine works as above, but does * The kvp_frame_add_frame_nc() routine works as above, but does
* *NOT* copy the frame. * *NOT* copy the frame.
*/ */
void kvp_frame_add_string(KvpFrame * frame, const char * path, const char* str); void kvp_frame_add_string(KvpFrame * frame, const gchar * path, const gchar* str);
void kvp_frame_add_guid(KvpFrame * frame, const char * path, const GUID *guid); void kvp_frame_add_guid(KvpFrame * frame, const gchar * path, const GUID *guid);
void kvp_frame_add_frame(KvpFrame *frame, const char *path, KvpFrame *chld); void kvp_frame_add_frame(KvpFrame *frame, const gchar *path, KvpFrame *chld);
void kvp_frame_add_frame_nc(KvpFrame *frame, const char *path, KvpFrame *chld); void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld);
/* The kvp_frame_add_value() routine will add a copy of the value /* The kvp_frame_add_value() routine will add a copy of the value
* to the glist bag at the indicated path. If not all frame components * to the glist bag at the indicated path. If not all frame components
@@ -312,8 +310,8 @@ void kvp_frame_add_frame_nc(KvpFrame *frame, const char *path, KvpFrame *chld);
* The *_nc() routine is analogous, except that it doesn't copy the * The *_nc() routine is analogous, except that it doesn't copy the
* value. * value.
*/ */
KvpFrame * kvp_frame_add_value(KvpFrame * frame, const char * path, KvpValue *value); KvpFrame * kvp_frame_add_value(KvpFrame * frame, const gchar * path, KvpValue *value);
KvpFrame * kvp_frame_add_value_nc(KvpFrame * frame, const char * path, KvpValue *value); KvpFrame * kvp_frame_add_value_nc(KvpFrame * frame, const gchar * path, KvpValue *value);
/** @} */ /** @} */
@@ -347,15 +345,15 @@ KvpFrame * kvp_frame_add_value_nc(KvpFrame * frame, const char * path, KvpValue
@{ @{
*/ */
gint64 kvp_frame_get_gint64(const KvpFrame *frame, const char *path); gint64 kvp_frame_get_gint64(const KvpFrame *frame, const gchar *path);
double kvp_frame_get_double(const KvpFrame *frame, const char *path); double kvp_frame_get_double(const KvpFrame *frame, const gchar *path);
gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const char *path); gnc_numeric kvp_frame_get_numeric(const KvpFrame *frame, const gchar *path);
char * kvp_frame_get_string(const KvpFrame *frame, const char *path); gchar * kvp_frame_get_string(const KvpFrame *frame, const gchar *path);
GUID * kvp_frame_get_guid(const KvpFrame *frame, const char *path); GUID * kvp_frame_get_guid(const KvpFrame *frame, const gchar *path);
void * kvp_frame_get_binary(const KvpFrame *frame, const char *path, void * kvp_frame_get_binary(const KvpFrame *frame, const gchar *path,
guint64 * size_return); guint64 * size_return);
Timespec kvp_frame_get_timespec(const KvpFrame *frame, const char *path); Timespec kvp_frame_get_timespec(const KvpFrame *frame, const gchar *path);
KvpValue * kvp_frame_get_value(const KvpFrame *frame, const char *path); KvpValue * kvp_frame_get_value(const KvpFrame *frame, const gchar *path);
/** Value accessor. Takes a unix-style slash-separated path as an /** Value accessor. Takes a unix-style slash-separated path as an
* argument, and return the KvpFrame stored at that location. If the * argument, and return the KvpFrame stored at that location. If the
@@ -375,7 +373,7 @@ KvpValue * kvp_frame_get_value(const KvpFrame *frame, const char *path);
* @return The KvpFrame at the specified path, or NULL if it doesn't * @return The KvpFrame at the specified path, or NULL if it doesn't
* exist. * exist.
*/ */
KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const char *path); KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path);
/** This routine returns the last frame of the path. /** This routine returns the last frame of the path.
* If the frame path doesn't exist, it is created. * If the frame path doesn't exist, it is created.
@@ -390,7 +388,7 @@ KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const char *path);
* kvp_frame_get_frame_path(). This happened on 2003-09-14, revision * kvp_frame_get_frame_path(). This happened on 2003-09-14, revision
* 1.31. * 1.31.
*/ */
KvpFrame * kvp_frame_get_frame_path (KvpFrame *frame, const char *,...); KvpFrame * kvp_frame_get_frame_path (KvpFrame *frame, const gchar *,...);
/** This routine returns the last frame of the path. /** This routine returns the last frame of the path.
* If the frame path doesn't exist, it is created. * If the frame path doesn't exist, it is created.
@@ -411,7 +409,7 @@ KvpFrame * kvp_frame_get_frame_gslist (KvpFrame *frame,
* (This is a bug that needs fixing). * (This is a bug that needs fixing).
*/ */
KvpFrame * kvp_frame_get_frame_slash (KvpFrame *frame, KvpFrame * kvp_frame_get_frame_slash (KvpFrame *frame,
const char *path); const gchar *path);
/** @} */ /** @} */
/** @name KvpFrame KvpValue low-level storing routines. /** @name KvpFrame KvpValue low-level storing routines.
@@ -435,7 +433,7 @@ You probably shouldn't be using these low-level routines
* Passing in a NULL new_value has the effect of deleting that * Passing in a NULL new_value has the effect of deleting that
* slot. * slot.
*/ */
KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot, KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const gchar * slot,
KvpValue * new_value); KvpValue * new_value);
@@ -446,7 +444,7 @@ KvpValue * kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot,
* this location, if any, is destroyed. * this location, if any, is destroyed.
*/ */
void kvp_frame_set_slot(KvpFrame * frame, void kvp_frame_set_slot(KvpFrame * frame,
const char * key, const KvpValue * value); const gchar * key, const KvpValue * value);
/** /**
* The kvp_frame_set_slot_nc() routine puts the value (without copying * The kvp_frame_set_slot_nc() routine puts the value (without copying
* it) into the frame, associating it with a copy of 'key'. This * it) into the frame, associating it with a copy of 'key'. This
@@ -456,7 +454,7 @@ void kvp_frame_set_slot(KvpFrame * frame,
* The old value at this location, if any, is destroyed. * The old value at this location, if any, is destroyed.
*/ */
void kvp_frame_set_slot_nc(KvpFrame * frame, void kvp_frame_set_slot_nc(KvpFrame * frame,
const char * key, KvpValue * value); const gchar * key, KvpValue * value);
/** The kvp_frame_set_slot_path() routine walks the hierarchy, /** The kvp_frame_set_slot_path() routine walks the hierarchy,
* using the key values to pick each branch. When the terminal * using the key values to pick each branch. When the terminal
@@ -465,7 +463,7 @@ void kvp_frame_set_slot_nc(KvpFrame * frame,
*/ */
void kvp_frame_set_slot_path (KvpFrame *frame, void kvp_frame_set_slot_path (KvpFrame *frame,
const KvpValue *value, const KvpValue *value,
const char *first_key, ...); const gchar *first_key, ...);
/** The kvp_frame_set_slot_path_gslist() routine walks the hierarchy, /** The kvp_frame_set_slot_path_gslist() routine walks the hierarchy,
* using the key values to pick each branch. When the terminal node * using the key values to pick each branch. When the terminal node
@@ -492,13 +490,13 @@ void kvp_frame_set_slot_path_gslist (KvpFrame *frame,
kvp_frame. Make copies as needed. kvp_frame. Make copies as needed.
@{ @{
*/ */
KvpValue * kvp_frame_get_slot(const KvpFrame * frame, const char * key); KvpValue * kvp_frame_get_slot(const KvpFrame * frame, const gchar * key);
/** This routine return the value at the end of the /** This routine return the value at the end of the
* path, or NULL if any portion of the path doesn't exist. * path, or NULL if any portion of the path doesn't exist.
*/ */
KvpValue * kvp_frame_get_slot_path (KvpFrame *frame, KvpValue * kvp_frame_get_slot_path (KvpFrame *frame,
const char *first_key, ...); const gchar *first_key, ...);
/** This routine return the value at the end of the /** This routine return the value at the end of the
* path, or NULL if any portion of the path doesn't exist. * path, or NULL if any portion of the path doesn't exist.
@@ -559,7 +557,7 @@ Use kvp_value_new_numeric instead of kvp_value_new_gnc_numeric
*/ */
#define kvp_value_new_gnc_numeric kvp_value_new_numeric #define kvp_value_new_gnc_numeric kvp_value_new_numeric
KvpValue * kvp_value_new_numeric(gnc_numeric value); KvpValue * kvp_value_new_numeric(gnc_numeric value);
KvpValue * kvp_value_new_string(const char * value); KvpValue * kvp_value_new_string(const gchar * value);
KvpValue * kvp_value_new_guid(const GUID * guid); KvpValue * kvp_value_new_guid(const GUID * guid);
KvpValue * kvp_value_new_timespec(Timespec timespec); KvpValue * kvp_value_new_timespec(Timespec timespec);
KvpValue * kvp_value_new_binary(const void * data, guint64 datasize); KvpValue * kvp_value_new_binary(const void * data, guint64 datasize);
-204
View File
@@ -1,204 +0,0 @@
/********************************************************************\
* qof-be-utils.h: api for data storage backend *
* 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 2 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, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
* *
\********************************************************************/
/** @addtogroup Object
@{ */
/** @addtogroup Backend
@{ */
/** @file qof-be-utils.h
@brief QOF Backend Utilities
@author Derek Atkins <derek@ihtfp.com>
@author Neil Williams <linux@codehelp.co.uk>
Common code used by objects to define begin_edit() and
commit_edit() functions.
*/
#ifndef QOF_BE_UTILS_H
#define QOF_BE_UTILS_H
#include "qoflog.h"
#include "gnc-engine-util.h"
#include "qofbackend-p.h"
#include "qofbook.h"
#include "qofinstance.h"
/** begin_edit helper
*
* @param inst: an instance of QofInstance
*
* The caller should use this macro first and then perform any other operations.
Uses newly created functions to allow the macro to be used
when QOF is linked as a library. qofbackend-p.h is a private header.
*/
#define QOF_BEGIN_EDIT(inst) \
if (!(inst)) return; \
\
(inst)->editlevel++; \
if (1 < (inst)->editlevel) return; \
\
if (0 >= (inst)->editlevel) \
{ \
PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
(inst)->editlevel = 1; \
} \
ENTER ("(inst=%p)", (inst)); \
\
/* See if there's a backend. If there is, invoke it. */ \
{ \
QofBackend * be; \
be = qof_book_get_backend ((inst)->book); \
if (be && qof_backend_begin_exists(be)) { \
qof_backend_run_begin(be, (inst)); \
} else { \
/* We tried and failed to start transaction! */ \
(inst)->dirty = TRUE; \
} \
} \
LEAVE (" ");
/** \brief function version of QOF_BEGIN_EDIT
The macro cannot be used in a function that returns a value,
this function can be used instead.
*/
gboolean qof_begin_edit(QofInstance *inst);
/**
* commit_edit helpers
*
* The caller should call PART1 as the first thing, then
* perform any local operations prior to calling the backend.
* Then call PART2.
*/
/**
* part1 -- deal with the editlevel
*
* @param inst: an instance of QofInstance
*/
#define QOF_COMMIT_EDIT_PART1(inst) { \
if (!(inst)) return; \
\
(inst)->editlevel--; \
if (0 < (inst)->editlevel) return; \
\
/* The pricedb suffers from delayed update... */ \
/* This may be setting a bad precedent for other types, I fear. */ \
/* Other types probably really should handle begin like this. */ \
if ((-1 == (inst)->editlevel) && (inst)->dirty) \
{ \
QofBackend * be; \
be = qof_book_get_backend ((inst)->book); \
if (be && qof_backend_begin_exists(be)) { \
qof_backend_run_begin(be, (inst)); \
} \
(inst)->editlevel = 0; \
} \
if (0 > (inst)->editlevel) \
{ \
PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
(inst)->editlevel = 0; \
} \
ENTER ("(inst=%p) dirty=%d do-free=%d", \
(inst), (inst)->dirty, (inst)->do_free); \
}
/** \brief function version of QOF_COMMIT_EDIT_PART1
The macro cannot be used in a function that returns a value,
this function can be used instead. Only Part1 is implemented.
*/
gboolean qof_commit_edit(QofInstance *inst);
/**
* part2 -- deal with the backend
*
* @param inst: an instance of QofInstance
* @param on_error: a function called if there is a backend error.
* void (*on_error)(inst, QofBackendError)
* @param on_done: a function called after the commit is completed
* successfully for an object which remained valid.
* void (*on_done)(inst)
* @param on_free: a function called if the commit succeeded and the instance
* is to be freed.
* void (*on_free)(inst)
*
* Note that only *one* callback will be called (or zero, if that
* callback is NULL). In particular, 'on_done' will not be called for
* an object which is to be freed.
*
* Returns TRUE, if the commit succeeded, FALSE otherwise.
*/
gboolean
qof_commit_edit_part2(QofInstance *inst,
void (*on_error)(QofInstance *, QofBackendError),
void (*on_done)(QofInstance *),
void (*on_free)(QofInstance *));
/** \brief Macro version of ::qof_commit_edit_part2
\note This macro changes programme flow if the instance is freed.
*/
#define QOF_COMMIT_EDIT_PART2(inst,on_error,on_done,on_free) { \
QofBackend * be; \
\
/* See if there's a backend. If there is, invoke it. */ \
be = qof_book_get_backend ((inst)->book); \
if (be && qof_backend_commit_exists(be)) \
{ \
QofBackendError errcode; \
\
/* clear errors */ \
do { \
errcode = qof_backend_get_error (be); \
} while (ERR_BACKEND_NO_ERR != errcode); \
\
qof_backend_run_commit(be, (inst)); \
errcode = qof_backend_get_error (be); \
if (ERR_BACKEND_NO_ERR != errcode) \
{ \
/* XXX Should perform a rollback here */ \
(inst)->do_free = FALSE; \
\
/* Push error back onto the stack */ \
qof_backend_set_error (be, errcode); \
(on_error)((inst), errcode); \
} \
/* XXX the backend commit code should clear dirty!! */ \
(inst)->dirty = FALSE; \
} \
(on_done)(inst); \
\
LEAVE ("inst=%p, dirty=%d do-free=%d", \
(inst), (inst)->dirty, (inst)->do_free); \
if ((inst)->do_free) { \
(on_free)(inst); \
return; \
} \
}
#endif /* QOF_BE_UTILS_H */
/** @} */
/** @} */
-1
View File
@@ -41,7 +41,6 @@
#ifndef QOF_BACKEND_P_H #ifndef QOF_BACKEND_P_H
#define QOF_BACKEND_P_H #define QOF_BACKEND_P_H
#include "qof-be-utils.h"
#include "qofbackend.h" #include "qofbackend.h"
#include "qofbook.h" #include "qofbook.h"
#include "qofinstance-p.h" #include "qofinstance-p.h"
+43 -84
View File
@@ -193,7 +193,7 @@ void qof_backend_prepare_option(QofBackend *be, QofBackendOption *option)
switch (option->type) switch (option->type)
{ {
case KVP_TYPE_GINT64 : { case KVP_TYPE_GINT64 : {
value = kvp_value_new_gint64(GPOINTER_TO_INT(option->value)); value = kvp_value_new_gint64(*(gint64*)&option->value);
break; break;
} }
case KVP_TYPE_DOUBLE : { case KVP_TYPE_DOUBLE : {
@@ -246,6 +246,10 @@ struct config_iterate {
KvpFrame *recursive; KvpFrame *recursive;
}; };
/* Set the option with the default KvpValue,
manipulate the option in the supplied callback routine
then set the value of the option into the KvpValue
in the configuration frame. */
static void static void
config_foreach_cb (const char *key, KvpValue *value, gpointer data) config_foreach_cb (const char *key, KvpValue *value, gpointer data)
{ {
@@ -268,11 +272,11 @@ config_foreach_cb (const char *key, KvpValue *value, gpointer data)
option.type = kvp_value_get_type(value); option.type = kvp_value_get_type(value);
if(!option.type) { return; } if(!option.type) { return; }
switch (option.type) switch (option.type)
{ { /* set the KvpFrame value into the option */
case KVP_TYPE_GINT64 : { case KVP_TYPE_GINT64 : {
int64 = kvp_value_get_gint64(value); int64 = kvp_value_get_gint64(value);
option.value = (gpointer)&int64; option.value = (gpointer)&int64;
break; break;
} }
case KVP_TYPE_DOUBLE : { case KVP_TYPE_DOUBLE : {
db = kvp_value_get_double(value); db = kvp_value_get_double(value);
@@ -288,12 +292,12 @@ config_foreach_cb (const char *key, KvpValue *value, gpointer data)
option.value = (gpointer)kvp_value_get_string(value); option.value = (gpointer)kvp_value_get_string(value);
break; break;
} }
case KVP_TYPE_GUID : { break; } /* unsupported */
case KVP_TYPE_TIMESPEC : { case KVP_TYPE_TIMESPEC : {
ts = kvp_value_get_timespec(value); ts = kvp_value_get_timespec(value);
option.value = (gpointer)&ts; option.value = (gpointer)&ts;
break; break;
} }
case KVP_TYPE_GUID : { break; } /* unsupported */
case KVP_TYPE_BINARY : { break; } /* unsupported */ case KVP_TYPE_BINARY : { break; } /* unsupported */
case KVP_TYPE_GLIST : { break; } /* unsupported */ case KVP_TYPE_GLIST : { break; } /* unsupported */
case KVP_TYPE_FRAME : { break; } /* unsupported */ case KVP_TYPE_FRAME : { break; } /* unsupported */
@@ -303,9 +307,43 @@ config_foreach_cb (const char *key, KvpValue *value, gpointer data)
g_free(parent); g_free(parent);
parent = g_strdup_printf("/%s/%s", QOF_CONFIG_TIP, key); parent = g_strdup_printf("/%s/%s", QOF_CONFIG_TIP, key);
option.tooltip = kvp_frame_get_string(helper->recursive, parent); option.tooltip = kvp_frame_get_string(helper->recursive, parent);
g_free(parent);
helper->count++; helper->count++;
/* manipulate the option */
helper->fcn (&option, helper->data); helper->fcn (&option, helper->data);
LEAVE (" desc=%s tip=%s", option.description, option.tooltip); switch (option.type)
{ /* set the option value into the KvpFrame */
case KVP_TYPE_GINT64 : {
kvp_frame_set_gint64(helper->recursive, key,
(*(gint64*)option.value));
break;
}
case KVP_TYPE_DOUBLE : {
kvp_frame_set_double(helper->recursive, key,
(*(double*)option.value));
break;
}
case KVP_TYPE_NUMERIC : {
kvp_frame_set_numeric(helper->recursive, key,
(*(gnc_numeric*)option.value));
break;
}
case KVP_TYPE_STRING : {
kvp_frame_set_string(helper->recursive, key,
(gchar*)option.value);
break;
}
case KVP_TYPE_TIMESPEC : {
kvp_frame_set_timespec(helper->recursive, key,
(*(Timespec*)option.value));
break;
}
case KVP_TYPE_GUID : { break; } /* unsupported */
case KVP_TYPE_BINARY : { break; } /* unsupported */
case KVP_TYPE_GLIST : { break; } /* unsupported */
case KVP_TYPE_FRAME : { break; } /* unsupported */
}
LEAVE (" ");
} }
void qof_backend_option_foreach(KvpFrame *config, QofBackendOptionCB cb, gpointer data) void qof_backend_option_foreach(KvpFrame *config, QofBackendOptionCB cb, gpointer data)
@@ -346,85 +384,6 @@ qof_backend_commit_exists(QofBackend *be)
else { return FALSE; } else { return FALSE; }
} }
gboolean
qof_begin_edit(QofInstance *inst)
{
QofBackend * be;
if (!inst) { return FALSE; }
(inst->editlevel)++;
if (1 < inst->editlevel) { return FALSE; }
if (0 >= inst->editlevel) { inst->editlevel = 1; }
be = qof_book_get_backend (inst->book);
if (be && qof_backend_begin_exists(be)) {
qof_backend_run_begin(be, inst);
} else { inst->dirty = TRUE; }
return TRUE;
}
gboolean qof_commit_edit(QofInstance *inst)
{
QofBackend * be;
if (!inst) { return FALSE; }
(inst->editlevel)--;
if (0 < inst->editlevel) { return FALSE; }
if ((-1 == inst->editlevel) && inst->dirty)
{
be = qof_book_get_backend ((inst)->book);
if (be && qof_backend_begin_exists(be)) {
qof_backend_run_begin(be, inst);
}
inst->editlevel = 0;
}
if (0 > inst->editlevel) { inst->editlevel = 0; }
return TRUE;
}
gboolean
qof_commit_edit_part2(QofInstance *inst,
void (*on_error)(QofInstance *, QofBackendError),
void (*on_done)(QofInstance *),
void (*on_free)(QofInstance *))
{
QofBackend * be;
/* See if there's a backend. If there is, invoke it. */
be = qof_book_get_backend(inst->book);
if (be && qof_backend_commit_exists(be)) {
QofBackendError errcode;
/* clear errors */
do {
errcode = qof_backend_get_error(be);
} while (ERR_BACKEND_NO_ERR != errcode);
qof_backend_run_commit(be, inst);
errcode = qof_backend_get_error(be);
if (ERR_BACKEND_NO_ERR != errcode) {
/* XXX Should perform a rollback here */
inst->do_free = FALSE;
/* Push error back onto the stack */
qof_backend_set_error (be, errcode);
if (on_error)
on_error(inst, errcode);
return FALSE;
}
/* XXX the backend commit code should clear dirty!! */
inst->dirty = FALSE;
}
if (inst->do_free) {
if (on_free)
on_free(inst);
return TRUE;
}
if (on_done)
on_done(inst);
return TRUE;
}
gboolean gboolean
qof_load_backend_library (const char *directory, qof_load_backend_library (const char *directory,
const char* filename, const char* init_fcn) const char* filename, const char* init_fcn)
+11 -7
View File
@@ -18,6 +18,9 @@
* Boston, MA 02110-1301, USA gnu@gnu.org * * Boston, MA 02110-1301, USA gnu@gnu.org *
* * * *
\********************************************************************/ \********************************************************************/
/** @addtogroup Object
@{
*/
/** @addtogroup Backend /** @addtogroup Backend
The QOF Backend is a pseudo-object providing an interface between the The QOF Backend is a pseudo-object providing an interface between the
@@ -195,11 +198,11 @@ backend is fully configured and ready for use.
/** A single Backend Configuration Option. */ /** A single Backend Configuration Option. */
typedef struct QofBackendOption_s { typedef struct QofBackendOption_s {
KvpValueType type; /**< Only GINT64, DOUBLE, NUMERIC, STRING and TIMESPEC supported. */ KvpValueType type; /**< Only GINT64, DOUBLE, NUMERIC, STRING and TIMESPEC supported. */
const char *option_name; /**< non-translated, key. */ const gchar *option_name; /**< non-translated, key. */
const char *description; /**< translatable description. */ const gchar *description; /**< translatable description. */
const char *tooltip; /**< translatable tooltip */ const gchar *tooltip; /**< translatable tooltip */
gpointer value; /**< The value of the option. */ gpointer value; /**< The value of the option. */
}QofBackendOption; }QofBackendOption;
/** Initialise the backend_configuration */ /** Initialise the backend_configuration */
@@ -258,8 +261,8 @@ KvpFrame* qof_backend_get_config(QofBackend *be);
\return FALSE in case or error, otherwise TRUE. \return FALSE in case or error, otherwise TRUE.
*/ */
gboolean gboolean
qof_load_backend_library (const char *directory, qof_load_backend_library (const gchar *directory,
const char* filename, const char* init_fcn); const gchar* filename, const gchar* init_fcn);
/** \brief Retrieve the backend used by this book */ /** \brief Retrieve the backend used by this book */
QofBackend* qof_book_get_backend (QofBook *book); QofBackend* qof_book_get_backend (QofBook *book);
@@ -268,3 +271,4 @@ void qof_book_set_backend (QofBook *book, QofBackend *);
#endif /* QOF_BACKEND_H */ #endif /* QOF_BACKEND_H */
/** @} */ /** @} */
/** @} */
-3
View File
@@ -99,9 +99,6 @@ struct _QofBook
*/ */
void qof_book_set_backend (QofBook *book, QofBackend *be); void qof_book_set_backend (QofBook *book, QofBackend *be);
/** \deprecated */
void qof_book_set_schedxactions( QofBook *book, GList *newList );
/* Register books with the engine */ /* Register books with the engine */
gboolean qof_book_register (void); gboolean qof_book_register (void);
+2 -2
View File
@@ -63,7 +63,7 @@ qof_book_init (QofBook *book)
book->hash_of_collections = g_hash_table_new_full( book->hash_of_collections = g_hash_table_new_full(
g_str_hash, g_str_equal, g_str_hash, g_str_equal,
(GDestroyNotify)gnc_string_cache_remove, /* key_destroy_func */ (GDestroyNotify)qof_util_string_cache_remove, /* key_destroy_func */
coll_destroy); /* value_destroy_func */ coll_destroy); /* value_destroy_func */
qof_instance_init (&book->inst, QOF_ID_BOOK, book); qof_instance_init (&book->inst, QOF_ID_BOOK, book);
@@ -239,7 +239,7 @@ qof_book_get_collection (QofBook *book, QofIdType entity_type)
col = qof_collection_new (entity_type); col = qof_collection_new (entity_type);
g_hash_table_insert( g_hash_table_insert(
book->hash_of_collections, book->hash_of_collections,
gnc_string_cache_insert((gpointer) entity_type), col); qof_util_string_cache_insert((gpointer) entity_type), col);
} }
return col; return col;
} }
+3 -4
View File
@@ -40,7 +40,6 @@
#ifndef QOF_BOOK_H #ifndef QOF_BOOK_H
#define QOF_BOOK_H #define QOF_BOOK_H
#include <glib.h>
#include "qofid.h" #include "qofid.h"
#include "kvp_frame.h" #include "kvp_frame.h"
@@ -124,17 +123,17 @@ void qof_book_foreach_collection (QofBook *, QofCollectionForeachCB, gpointer);
* of the book KVP are persistent (are saved and restored to file * of the book KVP are persistent (are saved and restored to file
* or database), whereas the data pointers exist only at runtime. * or database), whereas the data pointers exist only at runtime.
*/ */
void qof_book_set_data (QofBook *book, const char *key, gpointer data); void qof_book_set_data (QofBook *book, const gchar *key, gpointer data);
/** Same as qof_book_set_data(), except that the callback will be called /** Same as qof_book_set_data(), except that the callback will be called
* when the book is destroyed. The argument to the callback will be * when the book is destroyed. The argument to the callback will be
* the book followed by the data pointer. * the book followed by the data pointer.
*/ */
void qof_book_set_data_fin (QofBook *book, const char *key, gpointer data, void qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data,
QofBookFinalCB); QofBookFinalCB);
/** Retrieves arbitrary pointers to structs stored by qof_book_set_data. */ /** Retrieves arbitrary pointers to structs stored by qof_book_set_data. */
gpointer qof_book_get_data (QofBook *book, const char *key); gpointer qof_book_get_data (QofBook *book, const gchar *key);
/** Is the book shutting down? */ /** Is the book shutting down? */
gboolean qof_book_shutting_down (QofBook *book); gboolean qof_book_shutting_down (QofBook *book);
+1
View File
@@ -21,6 +21,7 @@
* * * *
********************************************************************/ ********************************************************************/
#include <glib.h>
#include "qof.h" #include "qof.h"
static QofLogModule log_module = QOF_MOD_MERGE; static QofLogModule log_module = QOF_MOD_MERGE;
+1 -2
View File
@@ -79,8 +79,7 @@ make sure this is non-NULL to know that the Init has been successful.
@author Copyright (c) 2004-2005 Neil Williams <linux@codehelp.co.uk> @author Copyright (c) 2004-2005 Neil Williams <linux@codehelp.co.uk>
*/ */
#include <glib.h> #include "qofutil.h"
#include "gnc-engine-util.h"
#include "qofbook.h" #include "qofbook.h"
#include "qofclass.h" #include "qofclass.h"
#include "qofobject.h" #include "qofobject.h"
+1 -1
View File
@@ -178,7 +178,7 @@ struct _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)(gconstpointer, gconstpointer);
/** This function registers a new object class with the Qof subsystem. /** This function registers a new object class with the Qof subsystem.
* In particular, it registers the set of setters and getters for * In particular, it registers the set of setters and getters for
+3 -2
View File
@@ -23,6 +23,7 @@
********************************************************************/ ********************************************************************/
#include "config.h" #include "config.h"
#include <glib.h>
#include "qof.h" #include "qof.h"
#include "qofevent-p.h" #include "qofevent-p.h"
@@ -259,9 +260,9 @@ qof_event_generate_internal (QofEntity *entity, QofEventId event_id,
next_node = node->next; next_node = node->next;
if ((hi->handler == NULL) if ((hi->handler == NULL)
#ifndef QOF_DISABLE_DEPRECATED #ifndef QOF_DISABLE_DEPRECATED
&&(hi->old_handler == NULL) &&(hi->old_handler == NULL)
#endif #endif
) )
{ {
/* remove this node from the list, then free this node */ /* remove this node from the list, then free this node */
handlers = g_list_remove_link (handlers, node); handlers = g_list_remove_link (handlers, node);
-1
View File
@@ -34,7 +34,6 @@
#ifndef QOF_EVENT_H #ifndef QOF_EVENT_H
#define QOF_EVENT_H #define QOF_EVENT_H
#include <glib.h>
#include "qof.h" #include "qof.h"
/** Define the type of events allowed. */ /** Define the type of events allowed. */
+1
View File
@@ -21,6 +21,7 @@
\********************************************************************/ \********************************************************************/
#include "config.h" #include "config.h"
#include <glib.h>
#include "qof.h" #include "qof.h"
#include "qofgobj.h" #include "qofgobj.h"
-2
View File
@@ -30,8 +30,6 @@
#ifndef QOF_ID_P_H #ifndef QOF_ID_P_H
#define QOF_ID_P_H #define QOF_ID_P_H
#include <glib.h>
#include "qofid.h" #include "qofid.h"
/* This file defines an engine-only API for using QOF entity /* This file defines an engine-only API for using QOF entity
+3 -3
View File
@@ -77,9 +77,9 @@
#include "guid.h" #include "guid.h"
/** QofIdType declaration */ /** QofIdType declaration */
typedef const char * QofIdType; typedef const gchar * QofIdType;
/** QofIdTypeConst declaration */ /** QofIdTypeConst declaration */
typedef const char * QofIdTypeConst; typedef const gchar * QofIdTypeConst;
/** QofLogModule declaration */ /** QofLogModule declaration */
typedef const gchar* QofLogModule; typedef const gchar* QofLogModule;
@@ -94,7 +94,7 @@ typedef const gchar* QofLogModule;
/** Inline string comparision; compiler will optimize away most of this */ /** Inline string comparision; compiler will optimize away most of this */
#define QSTRCMP(da,db) ({ \ #define QSTRCMP(da,db) ({ \
int val = 0; \ gint val = 0; \
if ((da) && (db)) { \ if ((da) && (db)) { \
if ((da) != (db)) { \ if ((da) != (db)) { \
val = strcmp ((da), (db)); \ val = strcmp ((da), (db)); \
+1
View File
@@ -28,6 +28,7 @@
*/ */
#include "config.h" #include "config.h"
#include <glib.h>
#include "qof.h" #include "qof.h"
#include "kvp-util-p.h" #include "kvp-util-p.h"
#include "qofbook-p.h" #include "qofbook-p.h"
+1 -1
View File
@@ -15,7 +15,7 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
+1
View File
@@ -334,6 +334,7 @@ void qof_log_set_default(QofLogLevel log_level)
qof_log_set_level(QOF_MOD_QUERY, log_level); qof_log_set_level(QOF_MOD_QUERY, log_level);
qof_log_set_level(QOF_MOD_SESSION, log_level); qof_log_set_level(QOF_MOD_SESSION, log_level);
qof_log_set_level(QOF_MOD_CHOICE, log_level); qof_log_set_level(QOF_MOD_CHOICE, log_level);
qof_log_set_level(QOF_MOD_UTIL, log_level);
} }
struct hash_s struct hash_s
+10 -11
View File
@@ -34,10 +34,9 @@
#ifndef _QOF_LOG_H #ifndef _QOF_LOG_H
#define _QOF_LOG_H #define _QOF_LOG_H
#include <glib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "gnc-engine-util.h" #include "qofutil.h"
#define QOF_MOD_ENGINE "qof-engine" #define QOF_MOD_ENGINE "qof-engine"
@@ -138,7 +137,7 @@ void qof_log_shutdown (void);
/** qof_log_prettify() cleans up subroutine names. AIX/xlC has the habit /** qof_log_prettify() cleans up subroutine names. AIX/xlC has the habit
* of printing signatures not names; clean this up. On other operating * of printing signatures not names; clean this up. On other operating
* systems, truncate name to QOF_LOG_MAX_CHARS chars. */ * systems, truncate name to QOF_LOG_MAX_CHARS chars. */
const char * qof_log_prettify (const char *name); const gchar * qof_log_prettify (const gchar *name);
/** Do not log log_modules that have not been enabled. */ /** Do not log log_modules that have not been enabled. */
gboolean qof_log_check(QofLogModule log_module, QofLogLevel log_level); gboolean qof_log_check(QofLogModule log_module, QofLogLevel log_level);
@@ -250,20 +249,20 @@ gint qof_log_module_count(void);
* of code. Used for only for performance tuning & debugging. * of code. Used for only for performance tuning & debugging.
*/ */
void qof_start_clock (int clockno, QofLogModule log_module, QofLogLevel log_level, void qof_start_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
const char *function_name, const char *format, ...); const gchar *function_name, const gchar *format, ...);
void qof_report_clock (int clockno, void qof_report_clock (gint clockno,
QofLogModule log_module, QofLogModule log_module,
QofLogLevel log_level, QofLogLevel log_level,
const char *function_name, const gchar *function_name,
const char *format, ...); const gchar *format, ...);
void qof_report_clock_total (int clockno, void qof_report_clock_total (gint clockno,
QofLogModule log_module, QofLogModule log_module,
QofLogLevel log_level, QofLogLevel log_level,
const char *function_name, const gchar *function_name,
const char *format, ...); const gchar *format, ...);
/** start a particular timer */ /** start a particular timer */
#define START_CLOCK(clockno,format, args...) do { \ #define START_CLOCK(clockno,format, args...) do { \
+4 -4
View File
@@ -88,7 +88,7 @@ struct _QofQuery
QofSortFunc defaultSort; /* <- Computed from search_for */ QofSortFunc defaultSort; /* <- Computed from search_for */
/* The maximum number of results to return */ /* The maximum number of results to return */
int max_results; gint max_results;
/* list of books that will be participating in the query */ /* list of books that will be participating in the query */
GList * books; GList * books;
@@ -98,7 +98,7 @@ struct _QofQuery
/* cache the results so we don't have to run the whole search /* cache the results so we don't have to run the whole search
* again until it's really necessary */ * again until it's really necessary */
int changed; gint changed;
GList * results; GList * results;
}; };
@@ -107,7 +107,7 @@ typedef struct _QofQueryCB
{ {
QofQuery * query; QofQuery * query;
GList * list; GList * list;
int count; gint count;
} QofQueryCB; } QofQueryCB;
/* initial_term will be owned by the new Query */ /* initial_term will be owned by the new Query */
@@ -282,7 +282,7 @@ static int cmp_func (QofQuerySort *sort, QofSortFunc default_sort,
/* See if this is a default sort */ /* See if this is a default sort */
if (sort->use_default) if (sort->use_default)
{ {
if (default_sort) return default_sort ((gpointer)a, (gpointer)b); if (default_sort) return default_sort (a, b);
return 0; return 0;
} }
+6 -7
View File
@@ -26,7 +26,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <glib.h>
#include <regex.h> #include <regex.h>
#include <string.h> #include <string.h>
@@ -42,7 +41,7 @@ void qof_query_core_shutdown (void);
* the Query internals), compare the object's parameter to the * the Query internals), compare the object's parameter to the
* predicate data. * predicate data.
*/ */
typedef int (*QofQueryPredicateFunc) (gpointer object, typedef gint (*QofQueryPredicateFunc) (gpointer object,
QofParam *getter, QofParam *getter,
QofQueryPredData *pdata); QofQueryPredData *pdata);
@@ -50,13 +49,13 @@ typedef int (*QofQueryPredicateFunc) (gpointer object,
* common getter (parameter member), using the provided comparison * common getter (parameter member), using the provided comparison
* options (which are the type-specific options). * options (which are the type-specific options).
*/ */
typedef int (*QofCompareFunc) (gpointer a, gpointer b, typedef gint (*QofCompareFunc) (gpointer a, gpointer b,
gint compare_options, gint compare_options,
QofParam *getter); QofParam *getter);
/* Lookup functions */ /* Lookup functions */
QofQueryPredicateFunc qof_query_core_get_predicate (char const *type); QofQueryPredicateFunc qof_query_core_get_predicate (gchar const *type);
QofCompareFunc qof_query_core_get_compare (char const *type); QofCompareFunc qof_query_core_get_compare (gchar const *type);
/* Compare two predicates */ /* Compare two predicates */
gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2); gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2);
@@ -75,7 +74,7 @@ typedef struct {
QofQueryPredData pd; QofQueryPredData pd;
QofStringMatch options; QofStringMatch options;
gboolean is_regex; gboolean is_regex;
char * matchstring; gchar * matchstring;
regex_t compiled; regex_t compiled;
} query_string_def, *query_string_t; } query_string_def, *query_string_t;
@@ -120,7 +119,7 @@ typedef struct {
typedef struct { typedef struct {
QofQueryPredData pd; QofQueryPredData pd;
QofCharMatch options; QofCharMatch options;
char * char_list; gchar * char_list;
} query_char_def, *query_char_t; } query_char_def, *query_char_t;
typedef struct { typedef struct {
+3 -5
View File
@@ -32,8 +32,6 @@
#ifndef QOF_QUERYCORE_H #ifndef QOF_QUERYCORE_H
#define QOF_QUERYCORE_H #define QOF_QUERYCORE_H
#include <glib.h>
#include "gnc-numeric.h" #include "gnc-numeric.h"
#include "gnc-date.h" #include "gnc-date.h"
#include "kvp_frame.h" #include "kvp_frame.h"
@@ -139,7 +137,7 @@ struct _QofQueryPredData {
/** @name Core Data Type Predicates /** @name Core Data Type Predicates
@{ */ @{ */
QofQueryPredData *qof_query_string_predicate (QofQueryCompare how, QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
const char *str, const gchar *str,
QofStringMatch options, QofStringMatch options,
gboolean is_regex); gboolean is_regex);
@@ -157,7 +155,7 @@ QofQueryPredData *qof_query_int64_predicate (QofQueryCompare how, gint64 val);
QofQueryPredData *qof_query_double_predicate (QofQueryCompare how, double val); QofQueryPredData *qof_query_double_predicate (QofQueryCompare how, double val);
QofQueryPredData *qof_query_boolean_predicate (QofQueryCompare how, gboolean val); QofQueryPredData *qof_query_boolean_predicate (QofQueryCompare how, gboolean val);
QofQueryPredData *qof_query_char_predicate (QofCharMatch options, QofQueryPredData *qof_query_char_predicate (QofCharMatch options,
const char *chars); const gchar *chars);
QofQueryPredData *qof_query_collect_predicate (QofGuidMatch options, QofQueryPredData *qof_query_collect_predicate (QofGuidMatch options,
QofCollection *coll); QofCollection *coll);
QofQueryPredData *qof_query_choice_predicate (QofGuidMatch options, GList *guids); QofQueryPredData *qof_query_choice_predicate (QofGuidMatch options, GList *guids);
@@ -173,7 +171,7 @@ QofQueryPredData *qof_query_kvp_predicate (QofQueryCompare how,
/** Same predicate as above, except that 'path' is assumed to be /** Same predicate as above, except that 'path' is assumed to be
* a string containing slash-separated pathname. */ * a string containing slash-separated pathname. */
QofQueryPredData *qof_query_kvp_predicate_path (QofQueryCompare how, QofQueryPredData *qof_query_kvp_predicate_path (QofQueryCompare how,
const char *path, const gchar *path,
const KvpValue *value); const KvpValue *value);
/** Copy a predicate. */ /** Copy a predicate. */
+2 -1
View File
@@ -20,8 +20,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "config.h" #include "config.h"
#include <glib.h>
#include "qofreference.h" #include "qofreference.h"
static void static void
+1 -1
View File
@@ -209,7 +209,7 @@ QofBook * qof_session_get_book (QofSession *session);
* filepath is derived from the url by substituting commas for * filepath is derived from the url by substituting commas for
* slashes). * slashes).
* *
* The qof_session_get_url() routine returns the url that was opened. * The qof_session_get_url() routine returns the url that was opened.
* URL's for local files take the form of * URL's for local files take the form of
* file:/some/where/some/file.gml * file:/some/where/some/file.gml
*/ */
+6 -6
View File
@@ -882,19 +882,19 @@ qof_sql_query_run (QofSqlQuery *query, const char *str)
if (!query) return NULL; if (!query) return NULL;
qof_sql_query_parse (query, str); qof_sql_query_parse (query, str);
if (NULL == query->qof_query) return NULL; if (NULL == query->qof_query) { PINFO (" Null query"); return NULL; }
qof_query_set_book (query->qof_query, query->book); qof_query_set_book (query->qof_query, query->book);
if(SQL_insert == query->parse_result->type){
results = NULL;
results = g_list_append(results, qof_query_insert(query));
return results;
}
/* Maybe log this sucker */ /* Maybe log this sucker */
if (gnc_should_log (log_module, GNC_LOG_DETAIL)) if (gnc_should_log (log_module, GNC_LOG_DETAIL))
{ {
qof_query_print (query->qof_query); qof_query_print (query->qof_query);
} }
if(SQL_insert == query->parse_result->type){
results = NULL;
results = g_list_append(results, qof_query_insert(query));
return results;
}
results = qof_query_run (query->qof_query); results = qof_query_run (query->qof_query);
+5 -6
View File
@@ -31,10 +31,9 @@
#ifndef QOF_SQL_QUERY_H #ifndef QOF_SQL_QUERY_H
#define QOF_SQL_QUERY_H #define QOF_SQL_QUERY_H
#include <glib.h> #include "kvp_frame.h"
#include <kvp_frame.h> #include "qofbook.h"
#include <qofbook.h> #include "qofquery.h"
#include <qofquery.h>
/** @addtogroup SQL SQL Interface to Query /** @addtogroup SQL SQL Interface to Query
@@ -150,14 +149,14 @@ void qof_sql_query_set_book (QofSqlQuery *q, QofBook *book);
* *
*/ */
GList * qof_sql_query_run (QofSqlQuery *query, const char * str); GList * qof_sql_query_run (QofSqlQuery *query, const gchar * str);
/** Same ::qof_sql_query_run, but just parse/pre-process the query; do /** Same ::qof_sql_query_run, but just parse/pre-process the query; do
not actually run it over the dataset. The QofBook does not not actually run it over the dataset. The QofBook does not
need to be set before calling this function. need to be set before calling this function.
*/ */
void qof_sql_query_parse (QofSqlQuery *query, const char * str); void qof_sql_query_parse (QofSqlQuery *query, const gchar * str);
/** Return the QofQuery form of the previously parsed query. */ /** Return the QofQuery form of the previously parsed query. */
QofQuery * qof_sql_query_get_query (QofSqlQuery *); QofQuery * qof_sql_query_get_query (QofSqlQuery *);