mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
Compile LibQOF as C++
This is a minimal change to get LibQOF and only LibQOF to compile as C++. There are no functional changes, just casts to satisfy the rather pickier C++ compiler and wrapping declarations with extern "C" { } to maintain C mangling so that the libgncmod_qof will work with the rest of the program. A note about renaming gnc-numeric.c to gnc-numeric.cpp: Dunno if it's a clang bug, but it wouldn't link test-math with the -xc++ flag; renaming the one file got around the problem. We'll likely have to do the same for other test programs and for gnucash-bin.c.
This commit is contained in:
parent
3abf8b47f6
commit
bedf00a160
@ -428,7 +428,7 @@ src/import-export/qif/qif-context.c
|
||||
src/import-export/qif/qif-file.c
|
||||
src/import-export/qif/qif-objects.c
|
||||
src/libqof/qof/gnc-date.c
|
||||
src/libqof/qof/gnc-numeric.c
|
||||
src/libqof/qof/gnc-numeric.cpp
|
||||
src/libqof/qof/guid.c
|
||||
src/libqof/qof/kvp_frame.c
|
||||
src/libqof/qof/kvp-util.c
|
||||
|
@ -363,7 +363,8 @@ add_kvp_value_node(xmlNodePtr node, gchar *tag, kvp_value* val)
|
||||
add_kvp_slot, val_node, (GCompareFunc)strcmp);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,8 @@ gnc_scm2KvpValue (SCM value_scm)
|
||||
kvp_frame_delete (frame);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -108,9 +108,9 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
|
||||
|
||||
/* FIXME: handle types below */
|
||||
case KVP_TYPE_BINARY:
|
||||
break;
|
||||
case KVP_TYPE_GLIST:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ noinst_LTLIBRARIES = \
|
||||
|
||||
libutest_Split_la_SOURCES = \
|
||||
utest-Split.c \
|
||||
${top_srcdir}/src/libqof/qof/gnc-numeric.c
|
||||
|
||||
${top_srcdir}/src/libqof/qof/gnc-numeric.cpp
|
||||
libutest_Split_la_CFLAGS = -xc++ -Wno-deprecated-writable-strings
|
||||
|
||||
libutest_Split_la_LIBADD = $(LDADD)
|
||||
|
||||
|
@ -21,6 +21,11 @@
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
********************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
@ -44,6 +49,10 @@
|
||||
static const gchar *suitename = "/engine/Split";
|
||||
void test_suite_split ( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Split *split;
|
||||
@ -75,8 +84,8 @@ setup (Fixture *fixture, gconstpointer pData)
|
||||
xaccSplitSetParent (fixture->split, txn);
|
||||
xaccTransCommitEdit (txn);
|
||||
gnc_lot_set_account (lot, acc);
|
||||
fixture->split->action = CACHE_INSERT ("foo");
|
||||
fixture->split->memo = CACHE_INSERT ("bar");
|
||||
fixture->split->action = static_cast<char*>(CACHE_INSERT ("foo"));
|
||||
fixture->split->memo = static_cast<char*>(CACHE_INSERT ("bar"));
|
||||
fixture->split->acc = acc;
|
||||
fixture->split->lot = lot;
|
||||
fixture->split->parent = txn;
|
||||
@ -122,7 +131,7 @@ gnc_split_init(Split* split)*/
|
||||
static void
|
||||
test_gnc_split_init ()
|
||||
{
|
||||
Split *split = g_object_new (GNC_TYPE_SPLIT, NULL);
|
||||
Split *split = static_cast<Split*>(g_object_new (GNC_TYPE_SPLIT, NULL));
|
||||
g_assert (split->acc == NULL);
|
||||
g_assert (split->orig_acc == NULL);
|
||||
g_assert (split->parent == NULL);
|
||||
@ -158,7 +167,7 @@ test_gnc_split_dispose ()
|
||||
* Transaction objects, a Split object, and a GNCLot object. All of
|
||||
* these should be unreffed in gnc_split_dispose.
|
||||
*/
|
||||
Split *split = g_object_new (GNC_TYPE_SPLIT, NULL);
|
||||
Split *split = static_cast<Split*>(g_object_new (GNC_TYPE_SPLIT, NULL));
|
||||
QofInstance *instance = QOF_INSTANCE (split);
|
||||
QofBook *book = qof_book_new ();
|
||||
|
||||
@ -384,7 +393,8 @@ static void
|
||||
test_xaccSplitEqualCheckBal (Fixture *fixture, gconstpointer pData)
|
||||
{
|
||||
gchar *msg = "[xaccSplitEqualCheckBal] test balances differ: 123/100 vs 456/100";
|
||||
guint loglevel = G_LOG_LEVEL_INFO, hdlr;
|
||||
GLogLevelFlags loglevel = G_LOG_LEVEL_INFO;
|
||||
guint hdlr;
|
||||
TestErrorStruct check = { loglevel, "gnc.engine", msg, 0 };
|
||||
|
||||
gnc_numeric foo = gnc_numeric_create (123, 100);
|
||||
@ -423,7 +433,7 @@ test_xaccSplitEqual (Fixture *fixture, gconstpointer pData)
|
||||
gchar *msg13 = "[xaccSplitEqualCheckBal] cleared balances differ: 321/1000 vs 0/1";
|
||||
gchar *msg14 = "[xaccSplitEqualCheckBal] reconciled balances differ: 321/1000 vs 0/1";
|
||||
gchar *logdomain = "gnc.engine";
|
||||
guint loglevel = G_LOG_LEVEL_INFO;
|
||||
GLogLevelFlags loglevel = G_LOG_LEVEL_INFO;
|
||||
TestErrorStruct checkA = { loglevel, logdomain, msg01, 0 };
|
||||
TestErrorStruct checkB = { loglevel, logdomain, msg10, 0 };
|
||||
TestErrorStruct checkC = { loglevel, logdomain, msg11, 0 };
|
||||
@ -542,7 +552,7 @@ typedef struct
|
||||
static void
|
||||
test_error_callback (gpointer pdata, QofBackendError errcode)
|
||||
{
|
||||
TestErr *data = pdata;
|
||||
TestErr *data = static_cast<TestErr*>(pdata);
|
||||
++(data->hits);
|
||||
data->lasterr = errcode;
|
||||
}
|
||||
@ -553,7 +563,7 @@ test_xaccSplitCommitEdit (Fixture *fixture, gconstpointer pData)
|
||||
gchar *msg1 = "[xaccSplitCommitEdit()] Account lost track of moved or deleted split.";
|
||||
gchar *msg2 = "[xaccSplitCommitEdit()] Account grabbed split prematurely.";
|
||||
gchar *logdomain = "gnc.engine";
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
GLogLevelFlags loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
|
||||
guint infolevel = G_LOG_LEVEL_INFO;
|
||||
guint hdlr;
|
||||
TestErrorStruct checkA = { loglevel, logdomain, msg1, 0 };
|
||||
@ -883,7 +893,7 @@ test_xaccSplitSetBaseValue (Fixture *fixture, gconstpointer pData)
|
||||
gchar *fmt = "[xaccSplitSetBaseValue()] inappropriate base currency %s "
|
||||
"given split currency=%s and commodity=%s\n";
|
||||
gchar *logdomain = "gnc.engine";
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
GLogLevelFlags loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
|
||||
TestErrorStruct check = { loglevel, logdomain, msg1, 0 };
|
||||
gnc_numeric value = { 360, 240 };
|
||||
gnc_numeric old_val = fixture->split->value;
|
||||
@ -983,7 +993,7 @@ test_xaccSplitConvertAmount (void)
|
||||
gnc_numeric result;
|
||||
|
||||
gchar *logdomain = "gnc.engine";
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
GLogLevelFlags loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
|
||||
TestErrorStruct check = { loglevel, logdomain, NULL, 0 };
|
||||
GLogFunc oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
|
||||
|
||||
@ -1276,7 +1286,7 @@ test_get_corr_account_split (Fixture *fixture, gconstpointer pData)
|
||||
#endif
|
||||
gchar *msg = _func ": assertion " _Q "sa' failed";
|
||||
#undef _func
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
GLogLevelFlags loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
|
||||
TestErrorStruct *check = test_error_struct_new ("gnc.engine",
|
||||
loglevel, msg);
|
||||
fixture->hdlrs = test_log_set_fatal_handler (fixture->hdlrs, check,
|
||||
@ -1598,7 +1608,7 @@ test_xaccSplitSetParent (Fixture *fixture, gconstpointer pData)
|
||||
Split *split = fixture->split;
|
||||
TestSignal sig1, sig2;
|
||||
gchar *logdomain = "gnc.engine";
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
GLogLevelFlags loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
|
||||
/* FIXME: This error doesn't actually stop execution, so we need to test for it happening. */
|
||||
gchar *msg = "[xaccSplitSetParent()] You may not add the split to more"
|
||||
" than one transaction during the BeginEdit/CommitEdit block.";
|
||||
@ -1638,7 +1648,7 @@ test_xaccSplitGetSharePrice (Fixture *fixture, gconstpointer pData)
|
||||
/* Warning: this is a define in Split.c */
|
||||
const guint PRICE_SIGFIGS = 6;
|
||||
char *logdomain = "gnc.engine";
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
GLogLevelFlags loglevel = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
|
||||
TestErrorStruct check = { loglevel, logdomain, NULL, 0 };
|
||||
guint hdlr = g_log_set_handler (logdomain, loglevel,
|
||||
(GLogFunc)test_checked_handler, &check);
|
||||
|
@ -18,7 +18,7 @@ AM_CPPFLAGS = \
|
||||
|
||||
libgnc_qof_la_SOURCES = \
|
||||
gnc-date.c \
|
||||
gnc-numeric.c \
|
||||
gnc-numeric.cpp \
|
||||
guid.c \
|
||||
kvp-util.c \
|
||||
kvp_frame.c \
|
||||
@ -83,8 +83,10 @@ noinst_HEADERS = \
|
||||
# gets "dereferencing type-punned pointer will break strict-aliasing rules"
|
||||
noinst_LTLIBRARIES = libmd5.la
|
||||
libmd5_la_SOURCES = md5.c
|
||||
libmd5_la_CFLAGS=-fno-strict-aliasing
|
||||
libmd5_la_CFLAGS = -fno-strict-aliasing
|
||||
|
||||
libgnc_qof_la_LIBADD += libmd5.la
|
||||
libgnc_qof_la_CFLAGS = -xc++
|
||||
|
||||
EXTRA_DIST += \
|
||||
qofmath128.c
|
||||
@ -98,9 +100,9 @@ endif
|
||||
## For testing the qofmath128 routines
|
||||
# run "make check" (to build the test program) and then run test-qofmath
|
||||
check_PROGRAMS = test-qofmath
|
||||
test_qofmath_SOURCES=gnc-numeric.c
|
||||
test_qofmath_CPPFLAGS=$(AM_CPPFLAGS) -DTEST_128_BIT_MULT
|
||||
test_qofmath_LDFLAGS=$(libgnc_qof_la_LDFLAGS)
|
||||
test_qofmath_LDADD=$(libgnc_qof_common_libs)
|
||||
test_qofmath_SOURCES = gnc-numeric.cpp
|
||||
test_qofmath_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_128_BIT_MULT
|
||||
test_qofmath_LDFLAGS = $(libgnc_qof_la_LDFLAGS)
|
||||
test_qofmath_LDADD = $(libgnc_qof_common_libs)
|
||||
|
||||
AM_CPPFLAGS += -DG_LOG_DOMAIN=\"qof\"
|
||||
|
@ -25,6 +25,10 @@
|
||||
\********************************************************************/
|
||||
|
||||
#define __EXTENSIONS__
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
@ -58,6 +62,9 @@
|
||||
#ifdef G_OS_WIN32
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LANGINFO_D_FMT
|
||||
# define GNC_D_FMT (nl_langinfo (D_FMT))
|
||||
@ -300,6 +307,11 @@ typedef struct
|
||||
GDateTime *(*to_local)(GDateTime *);
|
||||
} _GncDateTime;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void _gnc_date_time_init(_GncDateTime*);
|
||||
void
|
||||
_gnc_date_time_init (_GncDateTime *gncdt)
|
||||
@ -312,6 +324,10 @@ _gnc_date_time_init (_GncDateTime *gncdt)
|
||||
gncdt->to_local = gnc_g_date_time_to_local;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************** Posix Replacement Functions ***************************/
|
||||
void
|
||||
gnc_tm_free (struct tm* time)
|
||||
@ -339,13 +355,13 @@ gnc_g_date_time_fill_struct_tm (GDateTime *gdt, struct tm* time)
|
||||
struct tm*
|
||||
gnc_localtime (const time64 *secs)
|
||||
{
|
||||
struct tm *time = g_slice_alloc0 (sizeof (struct tm));
|
||||
if (gnc_localtime_r (secs, time) == NULL)
|
||||
{
|
||||
gnc_tm_free (time);
|
||||
return NULL;
|
||||
}
|
||||
return time;
|
||||
struct tm *time = static_cast<struct tm*>(g_slice_alloc0 (sizeof (struct tm)));
|
||||
if (gnc_localtime_r (secs, time) == NULL)
|
||||
{
|
||||
gnc_tm_free (time);
|
||||
return NULL;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
/* Linux, Darwin, and MSWindows implementations of this function set the
|
||||
@ -381,7 +397,7 @@ gnc_gmtime (const time64 *secs)
|
||||
struct tm *time;
|
||||
GDateTime *gdt = g_date_time_new_from_unix_utc (*secs);
|
||||
g_return_val_if_fail (gdt != NULL, NULL);
|
||||
time = g_slice_alloc0 (sizeof (struct tm));
|
||||
time = static_cast<struct tm*>(g_slice_alloc0 (sizeof (struct tm)));
|
||||
gnc_g_date_time_fill_struct_tm (gdt, time);
|
||||
g_date_time_unref (gdt);
|
||||
return time;
|
||||
@ -1088,7 +1104,7 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year,
|
||||
/* Use strtok to find delimiters */
|
||||
if (tmp)
|
||||
{
|
||||
static char *delims = ".,-+/\\()년월年月 ";
|
||||
static const char *delims = ".,-+/\\()년월年月 ";
|
||||
|
||||
first_field = strtok (tmp, delims);
|
||||
if (first_field)
|
||||
@ -1406,7 +1422,7 @@ qof_format_time(const gchar *format, const struct tm *tm)
|
||||
tmpbufsize = MAX(128, strlen(locale_format) * 2);
|
||||
while (TRUE)
|
||||
{
|
||||
tmpbuf = g_malloc(tmpbufsize);
|
||||
tmpbuf = static_cast<gchar*>(g_malloc(tmpbufsize));
|
||||
|
||||
/* Set the first byte to something other than '\0', to be able to
|
||||
* recognize whether strftime actually failed or just returned "".
|
||||
@ -1549,7 +1565,7 @@ gnc_iso8601_to_timespec_gmt(const char *str)
|
||||
char *
|
||||
gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
|
||||
{
|
||||
gchar *fmt1 = "%Y-%m-%d %H:%M", *fmt2 = "%s:%02d.%06d %s";
|
||||
const gchar *fmt1 = "%Y-%m-%d %H:%M", *fmt2 = "%s:%02d.%06d %s";
|
||||
GDateTime *gdt;
|
||||
gchar *time_base, *tz;
|
||||
|
||||
@ -1687,7 +1703,7 @@ GDate timespec_to_gdate (Timespec ts)
|
||||
|
||||
g_date_clear (&result, 1);
|
||||
gnc_timespec2dmy (ts, &day, &month, &year);
|
||||
g_date_set_dmy (&result, day, month, year);
|
||||
g_date_set_dmy (&result, day, static_cast<GDateMonth>(month), year);
|
||||
g_assert(g_date_valid (&result));
|
||||
|
||||
return result;
|
||||
@ -1700,7 +1716,7 @@ GDate* gnc_g_date_new_today ()
|
||||
GDate *result;
|
||||
|
||||
g_date_time_get_ymd (gdt, &year, &month, &day);
|
||||
result = g_date_new_dmy (day, month, year);
|
||||
result = g_date_new_dmy (day, static_cast<GDateMonth>(month), year);
|
||||
g_date_time_unref (gdt);
|
||||
g_assert(g_date_valid (result));
|
||||
|
||||
@ -1808,7 +1824,7 @@ timespec_boxed_copy_func( gpointer in_timespec )
|
||||
{
|
||||
Timespec* newvalue;
|
||||
|
||||
newvalue = g_malloc( sizeof( Timespec ) );
|
||||
newvalue = static_cast<Timespec*>(g_malloc (sizeof (Timespec)));
|
||||
memcpy( newvalue, in_timespec, sizeof( Timespec ) );
|
||||
|
||||
return newvalue;
|
||||
|
@ -67,7 +67,11 @@
|
||||
|
||||
#ifndef GNC_DATE_H
|
||||
#define GNC_DATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <time.h>
|
||||
|
||||
@ -666,4 +670,8 @@ void gnc_dow_abbrev(gchar *buf, int buf_len, int dow);
|
||||
|
||||
//@}
|
||||
//@}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DATE_H */
|
||||
|
@ -21,6 +21,10 @@
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
*******************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -29,6 +33,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "gnc-numeric.h"
|
||||
|
||||
@ -74,7 +81,7 @@ pwr64 (gint64 op, int exp)
|
||||
/* This function is small, simple, and used everywhere below,
|
||||
* lets try to inline it.
|
||||
*/
|
||||
inline GNCNumericErrorCode
|
||||
GNCNumericErrorCode
|
||||
gnc_numeric_check(gnc_numeric in)
|
||||
{
|
||||
if (G_LIKELY(in.denom != 0))
|
||||
@ -1395,7 +1402,7 @@ gnc_numeric_boxed_copy_func( gpointer in_gnc_numeric )
|
||||
{
|
||||
gnc_numeric* newvalue;
|
||||
|
||||
newvalue = g_malloc( sizeof( gnc_numeric ) );
|
||||
newvalue = static_cast<gnc_numeric*>(g_malloc (sizeof (gnc_numeric)));
|
||||
memcpy( newvalue, in_gnc_numeric, sizeof( gnc_numeric ) );
|
||||
|
||||
return newvalue;
|
@ -49,6 +49,10 @@ See \ref gncnumericexample
|
||||
|
||||
#ifndef GNC_NUMERIC_H
|
||||
#define GNC_NUMERIC_H
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
@ -520,4 +524,8 @@ GType gnc_numeric_get_type( void );
|
||||
*/
|
||||
gint64 pwr64 (gint64 op, int exp);
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -21,6 +21,11 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
@ -47,6 +52,10 @@
|
||||
#include "qof.h"
|
||||
#include "md5.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifndef P_tmpdir
|
||||
# define P_tmpdir "/tmp"
|
||||
# endif
|
||||
@ -677,10 +686,10 @@ guid_to_string(const GncGUID * guid)
|
||||
static GPrivate guid_buffer_key = G_PRIVATE_INIT(g_free);
|
||||
gchar *string;
|
||||
|
||||
string = g_private_get (&guid_buffer_key);
|
||||
string = static_cast<char*>(g_private_get (&guid_buffer_key));
|
||||
if (string == NULL)
|
||||
{
|
||||
string = malloc(GUID_ENCODING_LENGTH + 1);
|
||||
string = static_cast<char*>(malloc(GUID_ENCODING_LENGTH + 1));
|
||||
g_private_set (&guid_buffer_key, string);
|
||||
}
|
||||
#endif
|
||||
@ -739,7 +748,7 @@ guid_compare(const GncGUID *guid_1, const GncGUID *guid_2)
|
||||
guint
|
||||
guid_hash_to_guint (gconstpointer ptr)
|
||||
{
|
||||
const GncGUID *guid = ptr;
|
||||
const GncGUID *guid = static_cast<const GncGUID*>(ptr);
|
||||
|
||||
if (!guid)
|
||||
{
|
||||
@ -772,7 +781,8 @@ guid_hash_to_guint (gconstpointer ptr)
|
||||
gint
|
||||
guid_g_hash_table_equal (gconstpointer guid_a, gconstpointer guid_b)
|
||||
{
|
||||
return guid_equal (guid_a, guid_b);
|
||||
return guid_equal (static_cast<const GncGUID*>(guid_a),
|
||||
static_cast<const GncGUID*>(guid_b));
|
||||
}
|
||||
|
||||
GHashTable *
|
||||
|
@ -24,6 +24,11 @@
|
||||
#ifndef GUID_H
|
||||
#define GUID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
@ -180,4 +185,8 @@ GHashTable *guid_hash_table_new(void);
|
||||
|
||||
/* @} */
|
||||
/* @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -68,6 +68,11 @@
|
||||
* NULL if an error occured.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
KvpFrame * gnc_kvp_bag_add (KvpFrame *kvp_root, const char *path, time64 secs,
|
||||
const char *first_name, ...);
|
||||
|
||||
@ -103,4 +108,8 @@ void gnc_kvp_bag_remove_frame (KvpFrame *root, const char *path,
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* XACC_KVP_UTIL_P_H */
|
||||
|
@ -21,11 +21,20 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "kvp_frame.h"
|
||||
#include "kvp-util.h"
|
||||
#include "kvp-util-p.h"
|
||||
@ -113,7 +122,7 @@ gnc_kvp_bag_find_by_guid (KvpFrame *root, const char * path,
|
||||
|
||||
for (node = kvp_value_get_glist(arr); node; node = node->next)
|
||||
{
|
||||
KvpValue *va = node->data;
|
||||
KvpValue *va = static_cast<KvpValue*>(node->data);
|
||||
MATCH_GUID (va);
|
||||
}
|
||||
return NULL;
|
||||
@ -147,7 +156,7 @@ gnc_kvp_bag_remove_frame (KvpFrame *root, const char *path, KvpFrame *fr)
|
||||
listhead = kvp_value_get_glist(arr);
|
||||
for (node = listhead; node; node = node->next)
|
||||
{
|
||||
KvpValue *va = node->data;
|
||||
KvpValue *va = static_cast<KvpValue*>(node->data);
|
||||
if (fr == kvp_value_get_frame (va))
|
||||
{
|
||||
listhead = g_list_remove_link (listhead, node);
|
||||
@ -182,7 +191,7 @@ gnc_kvp_bag_get_first (KvpFrame *root, const char * path)
|
||||
node = kvp_value_get_glist(arr);
|
||||
if (NULL == node) return NULL;
|
||||
|
||||
va = node->data;
|
||||
va = static_cast<KvpValue*>(node->data);
|
||||
return kvp_value_get_frame(va);
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,18 @@ typedef struct
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
GSList *g_hash_table_key_value_pairs(GHashTable *table);
|
||||
void g_hash_table_kv_pair_free_gfunc(gpointer data, gpointer user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/** @} */
|
||||
|
@ -22,6 +22,11 @@
|
||||
* *
|
||||
********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
@ -30,6 +35,10 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
|
||||
/* Note that we keep the keys for this hash table in the
|
||||
@ -144,7 +153,7 @@ kvp_frame_copy_worker(gpointer key, gpointer value, gpointer user_data)
|
||||
KvpFrame * dest = (KvpFrame *)user_data;
|
||||
g_hash_table_insert(dest->hash,
|
||||
qof_string_cache_insert(key),
|
||||
(gpointer)kvp_value_copy(value));
|
||||
static_cast<void*>(kvp_value_copy(static_cast<KvpValue*>(value))));
|
||||
}
|
||||
|
||||
KvpFrame *
|
||||
@ -601,7 +610,7 @@ kvp_frame_get_slot(const KvpFrame * frame, const char * slot)
|
||||
KvpValue *v;
|
||||
if (!frame) return NULL;
|
||||
if (!frame->hash) return NULL; /* Error ... */
|
||||
v = g_hash_table_lookup(frame->hash, slot);
|
||||
v = static_cast<KvpValue*>(g_hash_table_lookup(frame->hash, slot));
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -667,7 +676,7 @@ kvp_frame_set_slot_path_gslist (KvpFrame *frame,
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
const char *key = key_path->data;
|
||||
const char *key = static_cast<char*>(key_path->data);
|
||||
KvpValue *value;
|
||||
|
||||
if (!key)
|
||||
@ -824,7 +833,7 @@ kvp_frame_get_slot_path_gslist (KvpFrame *frame,
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
const char *key = key_path->data;
|
||||
const char *key = static_cast<const char*>(key_path->data);
|
||||
KvpValue *value;
|
||||
|
||||
if (!key) break;
|
||||
@ -854,7 +863,7 @@ kvp_glist_delete(GList * list)
|
||||
/* Delete the data in the list */
|
||||
for (node = list; node; node = node->next)
|
||||
{
|
||||
KvpValue *val = node->data;
|
||||
KvpValue *val = static_cast<KvpValue*>(node->data);
|
||||
kvp_value_delete(val);
|
||||
}
|
||||
|
||||
@ -877,7 +886,7 @@ kvp_glist_copy(const GList * list)
|
||||
/* This step deep-copies the values */
|
||||
for (lptr = retval; lptr; lptr = lptr->next)
|
||||
{
|
||||
lptr->data = kvp_value_copy(lptr->data);
|
||||
lptr->data = kvp_value_copy(static_cast<KvpValue*>(lptr->data));
|
||||
}
|
||||
|
||||
return retval;
|
||||
@ -1083,11 +1092,7 @@ kvp_value_delete(KvpValue * value)
|
||||
kvp_frame_delete(value->value.frame);
|
||||
break;
|
||||
|
||||
case KVP_TYPE_GINT64:
|
||||
case KVP_TYPE_DOUBLE:
|
||||
case KVP_TYPE_NUMERIC:
|
||||
case KVP_TYPE_TIMESPEC:
|
||||
case KVP_TYPE_GDATE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
g_free(value);
|
||||
@ -1096,7 +1101,7 @@ kvp_value_delete(KvpValue * value)
|
||||
KvpValueType
|
||||
kvp_value_get_type(const KvpValue * value)
|
||||
{
|
||||
if (!value) return -1;
|
||||
if (!value) return KVP_TYPE_INVALID;
|
||||
return value->type;
|
||||
}
|
||||
|
||||
@ -1311,6 +1316,8 @@ kvp_value_copy(const KvpValue * value)
|
||||
case KVP_TYPE_FRAME:
|
||||
return kvp_value_new_frame(value->value.frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -1392,6 +1399,8 @@ kvp_value_compare(const KvpValue * kva, const KvpValue * kvb)
|
||||
case KVP_TYPE_FRAME:
|
||||
return kvp_frame_compare(kva->value.frame, kvb->value.frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
PERR ("reached unreachable code.");
|
||||
return FALSE;
|
||||
@ -1496,8 +1505,17 @@ kvp_value_glist_to_string(const GList *list)
|
||||
}
|
||||
|
||||
/* struct for kvp frame static funtion testing*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void init_static_test_pointers( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
KvpFrame* ( *p_get_trailer_make )( KvpFrame *frame, const char *key_path, char **end_key );
|
||||
gchar* ( *p_kvp_value_glist_to_string )( const GList *list );
|
||||
KvpFrame* ( *p_get_or_make )( KvpFrame *fr, const char * key );
|
||||
@ -1593,6 +1611,8 @@ kvp_value_to_string(const KvpValue *val)
|
||||
g_date_get_year(&val->value.gdate),
|
||||
g_date_get_month(&val->value.gdate),
|
||||
g_date_get_day(&val->value.gdate));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
g_assert(FALSE); /* must not be reached */
|
||||
return g_strdup("");
|
||||
|
@ -61,6 +61,11 @@
|
||||
#ifndef KVP_FRAME_H
|
||||
#define KVP_FRAME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "gnc-date.h"
|
||||
#include "gnc-numeric.h"
|
||||
#include "guid.h"
|
||||
@ -87,6 +92,7 @@ typedef struct _KvpValue KvpValue;
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
KVP_TYPE_INVALID = -1,
|
||||
KVP_TYPE_GINT64 = 1, /**< QOF_TYPE_INT64 gint64 */
|
||||
KVP_TYPE_DOUBLE, /**< QOF_TYPE_DOUBLE gdouble */
|
||||
KVP_TYPE_NUMERIC, /**< QOF_TYPE_NUMERIC */
|
||||
@ -589,4 +595,8 @@ gchar* binary_to_string(const void *data, guint32 size);
|
||||
GHashTable* kvp_frame_get_hash(const KvpFrame *frame);
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,11 @@
|
||||
* Author: Phil Longstaff (phil.longstaff@yahoo.ca) *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@ -34,6 +39,10 @@
|
||||
#include <string.h>
|
||||
#include "qof.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Uncomment if you need to log anything.
|
||||
static QofLogModule log_module = QOF_MOD_UTIL;
|
||||
*/
|
||||
@ -119,8 +128,8 @@ qof_string_cache_insert(gconstpointer key)
|
||||
}
|
||||
else
|
||||
{
|
||||
gpointer new_key = g_strdup(key);
|
||||
guint* refcount = g_malloc(sizeof(guint));
|
||||
gpointer new_key = g_strdup(static_cast<const char*>(key));
|
||||
guint* refcount = static_cast<unsigned int*>(g_malloc(sizeof(guint)));
|
||||
*refcount = 1;
|
||||
g_hash_table_insert(cache, new_key, refcount);
|
||||
return new_key;
|
||||
|
@ -33,6 +33,11 @@
|
||||
#ifndef QOF_STRING_UTIL_H
|
||||
#define QOF_STRING_UTIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define QOF_MOD_UTIL "qof.utilities"
|
||||
|
||||
/** The QOF String Cache:
|
||||
@ -99,5 +104,9 @@ gpointer qof_string_cache_insert(gconstpointer key);
|
||||
|
||||
#define QOF_CACHE_NEW(void) qof_string_cache_insert("")
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_STRING_CACHE_H */
|
||||
/** @} */
|
||||
|
@ -21,6 +21,11 @@
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
@ -29,6 +34,10 @@
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static GHashTable *picture_to_format = NULL;
|
||||
G_LOCK_DEFINE_STATIC(picture_to_format);
|
||||
|
||||
|
@ -344,6 +344,11 @@ struct QofBackend_s
|
||||
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Let the sytem know about a new provider of backends. This function
|
||||
* is typically called by the provider library at library load time.
|
||||
* This function allows the backend library to tell the QOF infrastructure
|
||||
@ -385,4 +390,8 @@ void qof_book_set_version (QofBook *book, gint32 version);
|
||||
/* @} */
|
||||
/* @} */
|
||||
/* @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_BACKEND_P_H */
|
||||
|
@ -21,6 +21,10 @@
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
@ -33,6 +37,10 @@
|
||||
#include "qof.h"
|
||||
#include "qofbackend-p.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
G_GNUC_UNUSED static QofLogModule log_module = QOF_MOD_BACKEND;
|
||||
|
||||
#define QOF_CONFIG_DESC "desc"
|
||||
@ -242,7 +250,7 @@ qof_load_backend_library (const char *directory, const char* module_name)
|
||||
return FALSE;
|
||||
}
|
||||
if (g_module_symbol (backend, "qof_backend_module_init",
|
||||
(gpointer)&module_init_func))
|
||||
reinterpret_cast<void**>(&module_init_func)))
|
||||
module_init_func ();
|
||||
|
||||
g_module_make_resident (backend);
|
||||
@ -262,7 +270,7 @@ qof_finalize_backend_libraries(void)
|
||||
backend = (GModule*)node->data;
|
||||
|
||||
if (g_module_symbol(backend, "qof_backend_module_finalize",
|
||||
(gpointer)&module_finalize_func))
|
||||
reinterpret_cast<void**>(&module_finalize_func)))
|
||||
module_finalize_func();
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,10 @@
|
||||
#define QOF_BACKEND_H
|
||||
|
||||
#include "qofinstance.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define QOF_MOD_BACKEND "qof.backend"
|
||||
|
||||
@ -187,6 +191,10 @@ QofBackend* qof_book_get_backend (const QofBook *book);
|
||||
|
||||
void qof_book_set_backend (QofBook *book, QofBackend *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_BACKEND_H */
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -43,6 +43,11 @@
|
||||
#include "qofid-p.h"
|
||||
#include "qofinstance-p.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* qof_book_set_backend() is used by backends to
|
||||
* initialize the pointers in the book structure to
|
||||
@ -78,4 +83,8 @@ void qof_book_print_dirty (const QofBook *book);
|
||||
/* @} */
|
||||
/* @} */
|
||||
/* @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_BOOK_P_H */
|
||||
|
@ -33,6 +33,11 @@
|
||||
* Copyright (c) 2007 David Hampton <hampton@employees.org>
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -40,6 +45,10 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofevent-p.h"
|
||||
#include "qofbackend-p.h"
|
||||
@ -87,7 +96,7 @@ qof_book_new (void)
|
||||
QofBook *book;
|
||||
|
||||
ENTER (" ");
|
||||
book = g_object_new(QOF_TYPE_BOOK, NULL);
|
||||
book = static_cast<QofBook*>(g_object_new(QOF_TYPE_BOOK, NULL));
|
||||
qof_object_book_begin (book);
|
||||
|
||||
qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL);
|
||||
@ -98,8 +107,8 @@ qof_book_new (void)
|
||||
static void
|
||||
book_final (gpointer key, gpointer value, gpointer booq)
|
||||
{
|
||||
QofBookFinalCB cb = value;
|
||||
QofBook *book = booq;
|
||||
QofBookFinalCB cb = reinterpret_cast<QofBookFinalCB>(value);
|
||||
QofBook *book = static_cast<QofBook*>(booq);
|
||||
|
||||
gpointer user_data = g_hash_table_lookup (book->data_tables, key);
|
||||
(*cb) (book, key, user_data);
|
||||
@ -275,7 +284,8 @@ qof_book_set_data_fin (QofBook *book, const char *key, gpointer data, QofBookFin
|
||||
g_hash_table_insert (book->data_tables, (gpointer)key, data);
|
||||
|
||||
if (!cb) return;
|
||||
g_hash_table_insert (book->data_table_finalizers, (gpointer)key, cb);
|
||||
g_hash_table_insert (book->data_table_finalizers, (gpointer)key,
|
||||
reinterpret_cast<void*>(cb));
|
||||
}
|
||||
|
||||
gpointer
|
||||
@ -308,7 +318,7 @@ qof_book_get_collection (const QofBook *book, QofIdType entity_type)
|
||||
|
||||
if (!book || !entity_type) return NULL;
|
||||
|
||||
col = g_hash_table_lookup (book->hash_of_collections, entity_type);
|
||||
col = static_cast<QofCollection*>(g_hash_table_lookup (book->hash_of_collections, entity_type));
|
||||
if (!col)
|
||||
{
|
||||
col = qof_collection_new (entity_type);
|
||||
@ -328,8 +338,8 @@ struct _iterate
|
||||
static void
|
||||
foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct _iterate *iter = arg;
|
||||
QofCollection *col = item;
|
||||
struct _iterate *iter = static_cast<_iterate*>(arg);
|
||||
QofCollection *col = static_cast<QofCollection*>(item);
|
||||
|
||||
iter->fn (col, iter->data);
|
||||
}
|
||||
@ -406,7 +416,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
|
||||
KvpFrame *kvp;
|
||||
KvpValue *value;
|
||||
gint64 counter;
|
||||
gchar* format;
|
||||
const char* format;
|
||||
|
||||
if (!book)
|
||||
{
|
||||
@ -459,11 +469,11 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
|
||||
return g_strdup_printf(format, counter);
|
||||
}
|
||||
|
||||
gchar *
|
||||
const gchar *
|
||||
qof_book_get_counter_format(const QofBook *book, const char *counter_name)
|
||||
{
|
||||
KvpFrame *kvp;
|
||||
gchar *format;
|
||||
const char *format;
|
||||
KvpValue *value;
|
||||
gchar *error;
|
||||
|
||||
|
@ -40,6 +40,11 @@
|
||||
#ifndef QOF_BOOK_H
|
||||
#define QOF_BOOK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* We only want a few things exported to Guile */
|
||||
#ifndef SWIG
|
||||
|
||||
@ -332,7 +337,8 @@ gchar * qof_book_validate_counter_format(const gchar *format);
|
||||
* The return value is NULL on error or the format string of the
|
||||
* counter. The string should not be freed.
|
||||
*/
|
||||
gchar *qof_book_get_counter_format (const QofBook *book, const char *counter_name);
|
||||
const char *qof_book_get_counter_format (const QofBook *book,
|
||||
const char *counter_name);
|
||||
|
||||
const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
|
||||
void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
|
||||
@ -344,6 +350,9 @@ void qof_book_commit_edit(QofBook *book);
|
||||
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))
|
||||
|
||||
#endif /* SWIG */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_BOOK_H */
|
||||
/** @} */
|
||||
|
@ -21,8 +21,18 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofchoice.h"
|
||||
|
||||
@ -101,8 +111,8 @@ GList* qof_object_get_choices(QofIdType type, QofParam *param)
|
||||
g_return_val_if_fail(type != NULL, NULL);
|
||||
g_return_val_if_fail(qof_choice_is_initialized() == TRUE, FALSE);
|
||||
choices = NULL;
|
||||
param_table = g_hash_table_lookup(qof_choice_table, type);
|
||||
choices = g_hash_table_lookup(param_table, param->param_name);
|
||||
param_table = static_cast<GHashTable*>(g_hash_table_lookup(qof_choice_table, type));
|
||||
choices = static_cast<GList*>(g_hash_table_lookup(param_table, param->param_name));
|
||||
return choices;
|
||||
}
|
||||
|
||||
@ -115,8 +125,8 @@ gboolean qof_choice_check(const char* choice_obj,
|
||||
|
||||
choices = result = NULL;
|
||||
g_return_val_if_fail(qof_object_is_choice(choice_obj), FALSE);
|
||||
param_table = g_hash_table_lookup(qof_choice_table, choice_obj);
|
||||
choices = g_hash_table_lookup(param_table, param_name);
|
||||
param_table = static_cast<GHashTable*>(g_hash_table_lookup(qof_choice_table, choice_obj));
|
||||
choices = static_cast<GList*>(g_hash_table_lookup(param_table, param_name));
|
||||
result = g_list_find(choices, choice);
|
||||
if (!result)
|
||||
{
|
||||
|
@ -93,6 +93,11 @@ the object must return a single entity matching one of the choice types.
|
||||
#include "qofclass.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define QOF_MOD_CHOICE "qof.choice"
|
||||
|
||||
/** \note Choice
|
||||
@ -156,4 +161,8 @@ gboolean qof_choice_check(const char* choice_obj,
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _QOFCHOICE_H */
|
||||
|
@ -21,10 +21,19 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofclass-p.h"
|
||||
|
||||
@ -36,7 +45,7 @@ static gboolean initialized = FALSE;
|
||||
|
||||
static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_hash_table_destroy (value);
|
||||
g_hash_table_destroy (static_cast<GHashTable*>(value));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -76,7 +85,8 @@ QofSortFunc
|
||||
qof_class_get_default_sort (QofIdTypeConst obj_name)
|
||||
{
|
||||
if (!obj_name) return NULL;
|
||||
return g_hash_table_lookup (sortTable, obj_name);
|
||||
return reinterpret_cast<QofSortFunc>(g_hash_table_lookup (sortTable,
|
||||
obj_name));
|
||||
}
|
||||
|
||||
/* *******************************************************************/
|
||||
@ -95,10 +105,11 @@ qof_class_register (QofIdTypeConst obj_name,
|
||||
|
||||
if (default_sort_function)
|
||||
{
|
||||
g_hash_table_insert (sortTable, (char *)obj_name, default_sort_function);
|
||||
g_hash_table_insert (sortTable, (char *)obj_name,
|
||||
reinterpret_cast<void*>(default_sort_function));
|
||||
}
|
||||
|
||||
ht = g_hash_table_lookup (classTable, obj_name);
|
||||
ht = static_cast<GHashTable*>(g_hash_table_lookup (classTable, obj_name));
|
||||
|
||||
/* If it doesn't already exist, create a new table for this object */
|
||||
if (!ht)
|
||||
@ -141,14 +152,14 @@ qof_class_get_parameter (QofIdTypeConst obj_name,
|
||||
g_return_val_if_fail (parameter, NULL);
|
||||
if (!check_init()) return NULL;
|
||||
|
||||
ht = g_hash_table_lookup (classTable, obj_name);
|
||||
ht = static_cast<GHashTable*>(g_hash_table_lookup (classTable, obj_name));
|
||||
if (!ht)
|
||||
{
|
||||
PWARN ("no object of type %s", obj_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (g_hash_table_lookup (ht, parameter));
|
||||
return static_cast<QofParam*>(g_hash_table_lookup (ht, parameter));
|
||||
}
|
||||
|
||||
QofAccessFunc
|
||||
@ -208,8 +219,8 @@ struct class_iterate
|
||||
static void
|
||||
class_foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct class_iterate *iter = arg;
|
||||
QofIdTypeConst id = key;
|
||||
struct class_iterate *iter = static_cast<class_iterate*>(arg);
|
||||
QofIdTypeConst id = static_cast<QofIdTypeConst>(key);
|
||||
|
||||
iter->fcn (id, iter->data);
|
||||
}
|
||||
@ -239,8 +250,8 @@ struct parm_iterate
|
||||
static void
|
||||
param_foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct parm_iterate *iter = arg;
|
||||
QofParam *parm = item;
|
||||
struct parm_iterate *iter = static_cast<parm_iterate*>(arg);
|
||||
QofParam *parm = static_cast<QofParam*>(item);
|
||||
|
||||
iter->fcn (parm, iter->data);
|
||||
}
|
||||
@ -254,7 +265,7 @@ qof_class_param_foreach (QofIdTypeConst obj_name,
|
||||
|
||||
if (!obj_name || !cb) return;
|
||||
if (!classTable) return;
|
||||
param_ht = g_hash_table_lookup (classTable, obj_name);
|
||||
param_ht = static_cast<GHashTable*>(g_hash_table_lookup (classTable, obj_name));
|
||||
if (!param_ht) return;
|
||||
|
||||
iter.fcn = cb;
|
||||
|
@ -71,6 +71,11 @@
|
||||
|
||||
#include "qofid.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define QOF_MOD_CLASS "qof.class"
|
||||
|
||||
/** \name Core types
|
||||
@ -272,6 +277,10 @@ Used for partial QofBook support, see ::QofInstanceReference
|
||||
GList* qof_class_get_referenceList(QofIdTypeConst type);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_CLASS_H */
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -22,8 +22,18 @@
|
||||
* *
|
||||
********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofevent-p.h"
|
||||
|
||||
@ -52,7 +62,7 @@ find_next_handler_id(void)
|
||||
|
||||
while (node)
|
||||
{
|
||||
hi = node->data;
|
||||
hi = static_cast<HandlerInfo*>(node->data);
|
||||
|
||||
if (hi->handler_id == handler_id)
|
||||
{
|
||||
@ -106,7 +116,7 @@ qof_event_unregister_handler (gint handler_id)
|
||||
ENTER ("(handler_id=%d)", handler_id);
|
||||
for (node = handlers; node; node = node->next)
|
||||
{
|
||||
HandlerInfo *hi = node->data;
|
||||
HandlerInfo *hi = static_cast<HandlerInfo*>(node->data);
|
||||
|
||||
if (hi->handler_id != handler_id)
|
||||
continue;
|
||||
@ -184,7 +194,7 @@ qof_event_generate_internal (QofInstance *entity, QofEventId event_id,
|
||||
handler_run_level++;
|
||||
for (node = handlers; node; node = next_node)
|
||||
{
|
||||
HandlerInfo *hi = node->data;
|
||||
HandlerInfo *hi = static_cast<HandlerInfo*>(node->data);
|
||||
|
||||
next_node = node->next;
|
||||
if (hi->handler)
|
||||
@ -203,7 +213,7 @@ qof_event_generate_internal (QofInstance *entity, QofEventId event_id,
|
||||
{
|
||||
for (node = handlers; node; node = next_node)
|
||||
{
|
||||
HandlerInfo *hi = node->data;
|
||||
HandlerInfo *hi = static_cast<HandlerInfo*>(node->data);
|
||||
next_node = node->next;
|
||||
if (hi->handler == NULL)
|
||||
{
|
||||
|
@ -36,6 +36,11 @@
|
||||
|
||||
#include "qof.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Define the type of events allowed. */
|
||||
typedef gint QofEventId;
|
||||
|
||||
@ -134,5 +139,9 @@ void qof_event_suspend (void);
|
||||
/** Resume engine event generation. */
|
||||
void qof_event_resume (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/** @} */
|
||||
|
@ -32,6 +32,11 @@
|
||||
|
||||
#include "qofid.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* This file defines an engine-only API for using QOF entity
|
||||
* identifiers. */
|
||||
|
||||
@ -49,4 +54,8 @@ void qof_collection_print_dirty (const QofCollection *col, gpointer dummy);
|
||||
/* @} */
|
||||
/* @} */
|
||||
/* @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_ID_P_H */
|
||||
|
@ -22,11 +22,20 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofid-p.h"
|
||||
|
||||
@ -63,7 +72,7 @@ qof_collection_new (QofIdType type)
|
||||
{
|
||||
QofCollection *col;
|
||||
col = g_new0(QofCollection, 1);
|
||||
col->e_type = CACHE_INSERT (type);
|
||||
col->e_type = static_cast<QofIdType>(CACHE_INSERT (type));
|
||||
col->hash_of_entities = guid_hash_table_new();
|
||||
col->data = NULL;
|
||||
return col;
|
||||
@ -234,7 +243,8 @@ qof_collection_lookup_entity (const QofCollection *col, const GncGUID * guid)
|
||||
QofInstance *ent;
|
||||
g_return_val_if_fail (col, NULL);
|
||||
if (guid == NULL) return NULL;
|
||||
ent = g_hash_table_lookup (col->hash_of_entities, guid);
|
||||
ent = static_cast<QofInstance*>(g_hash_table_lookup (col->hash_of_entities,
|
||||
guid));
|
||||
return ent;
|
||||
}
|
||||
|
||||
@ -328,8 +338,8 @@ struct _iterate
|
||||
static void
|
||||
foreach_cb (gpointer item, gpointer arg)
|
||||
{
|
||||
struct _iterate *iter = arg;
|
||||
QofInstance *ent = item;
|
||||
struct _iterate *iter = static_cast<_iterate*>(arg);
|
||||
QofInstance *ent = static_cast<QofInstance*>(item);
|
||||
|
||||
iter->fcn (ent, iter->data);
|
||||
}
|
||||
|
@ -23,6 +23,11 @@
|
||||
#ifndef QOF_ID_H
|
||||
#define QOF_ID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** @addtogroup Entity
|
||||
@{ */
|
||||
/** @addtogroup Entities
|
||||
@ -251,6 +256,10 @@ qof_collection_from_glist (QofIdType type, const GList *glist);
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_ID_H */
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -32,6 +32,11 @@
|
||||
|
||||
#include "qofinstance.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Set the collection this instance belongs to. This function should never
|
||||
* be called by user code. Instead call the qof_collection_insert_entity()
|
||||
* function. */
|
||||
@ -49,4 +54,8 @@ void qof_instance_set_last_update (QofInstance *inst, Timespec ts);
|
||||
* collection flag at all. */
|
||||
void qof_instance_set_dirty_flag (gconstpointer inst, gboolean flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_INSTANCE_P_H */
|
||||
|
@ -28,8 +28,18 @@
|
||||
* Copyright (c) 2007 David Hampton <hampton@employees.org>
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "kvp-util-p.h"
|
||||
#include "qofbook-p.h"
|
||||
@ -115,6 +125,8 @@ typedef struct QofInstancePrivate
|
||||
|
||||
QOF_GOBJECT_GET_TYPE(QofInstance, qof_instance, G_TYPE_OBJECT, {});
|
||||
QOF_GOBJECT_FINALIZE(qof_instance);
|
||||
#undef G_PARAM_READWRITE
|
||||
#define G_PARAM_READWRITE static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)
|
||||
|
||||
static void qof_instance_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -303,7 +315,7 @@ qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book)
|
||||
return;
|
||||
}
|
||||
priv = GET_PRIVATE(inst);
|
||||
inst->e_type = CACHE_INSERT (type);
|
||||
inst->e_type = static_cast<QofIdType>(CACHE_INSERT (type));
|
||||
|
||||
do
|
||||
{
|
||||
@ -433,19 +445,21 @@ qof_instance_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_GUID:
|
||||
qof_instance_set_guid(inst, g_value_get_boxed(value));
|
||||
qof_instance_set_guid(inst,
|
||||
static_cast<GncGUID*>(g_value_get_boxed(value)));
|
||||
break;
|
||||
case PROP_COLLECTION:
|
||||
qof_instance_set_collection(inst, g_value_get_pointer(value));
|
||||
qof_instance_set_collection(inst, static_cast<QofCollection*>(g_value_get_pointer(value)));
|
||||
break;
|
||||
case PROP_BOOK:
|
||||
qof_instance_set_book(inst, g_value_get_object(value));
|
||||
qof_instance_set_book(inst,
|
||||
static_cast<QofBook*>(g_value_get_object(value)));
|
||||
break;
|
||||
case PROP_KVP_DATA:
|
||||
qof_instance_set_slots(inst, g_value_get_pointer(value));
|
||||
qof_instance_set_slots(inst, static_cast<KvpFrame*>(g_value_get_pointer(value)));
|
||||
break;
|
||||
case PROP_LAST_UPDATE:
|
||||
ts = g_value_get_pointer(value);
|
||||
ts = static_cast<Timespec*>(g_value_get_pointer(value));
|
||||
qof_instance_set_last_update(inst, *ts);
|
||||
break;
|
||||
case PROP_DESTROYING:
|
||||
|
@ -25,6 +25,11 @@
|
||||
* 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
@ -47,6 +52,10 @@
|
||||
#include "localtime_r.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qoflog.h"
|
||||
|
||||
@ -99,7 +108,8 @@ log4glib_handler(const gchar *log_domain,
|
||||
const gchar *message,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (G_LIKELY(!qof_log_check(log_domain, log_level)))
|
||||
QofLogLevel level = static_cast<QofLogLevel>(log_level);
|
||||
if (G_LIKELY(!qof_log_check(log_domain, level)))
|
||||
return;
|
||||
|
||||
{
|
||||
@ -113,7 +123,7 @@ log4glib_handler(const gchar *log_domain,
|
||||
"%T"
|
||||
#endif
|
||||
;
|
||||
gchar *level_str = qof_log_level_to_string(log_level);
|
||||
const char *level_str = qof_log_level_to_string(level);
|
||||
now = gnc_time (NULL);
|
||||
gnc_localtime_r (&now, &now_tm);
|
||||
qof_strftime(timestamp_buf, 9, format_24hour, &now_tm);
|
||||
@ -415,10 +425,10 @@ qof_log_set_default(QofLogLevel log_level)
|
||||
qof_log_set_level("qof", log_level);
|
||||
}
|
||||
|
||||
gchar*
|
||||
const gchar*
|
||||
qof_log_level_to_string(QofLogLevel log_level)
|
||||
{
|
||||
gchar *level_str = "unknw";
|
||||
const char *level_str;
|
||||
switch (log_level)
|
||||
{
|
||||
case G_LOG_LEVEL_ERROR:
|
||||
|
@ -84,6 +84,11 @@
|
||||
#ifndef _QOF_LOG_H
|
||||
#define _QOF_LOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <glib.h>
|
||||
@ -101,8 +106,8 @@
|
||||
|
||||
DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST)
|
||||
|
||||
gchar* qof_log_level_to_string(QofLogLevel lvl);
|
||||
QofLogLevel qof_log_level_from_string(const gchar *str);
|
||||
const char* qof_log_level_to_string(QofLogLevel lvl);
|
||||
QofLogLevel qof_log_level_from_string(const char *str);
|
||||
|
||||
/** Indents one level; see ENTER macro. **/
|
||||
void qof_log_indent(void);
|
||||
@ -289,6 +294,10 @@ void qof_log_set_default(QofLogLevel log_level);
|
||||
} while (0);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _QOF_LOG_H */
|
||||
|
||||
/** @} */
|
||||
|
@ -36,6 +36,11 @@
|
||||
#include "qofbook.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** To be called from within the book */
|
||||
void qof_object_book_begin (QofBook *book);
|
||||
void qof_object_book_end (QofBook *book);
|
||||
@ -55,6 +60,10 @@ calling more than once, pass FALSE.
|
||||
gboolean
|
||||
qof_object_compliance (QofIdTypeConst type_name, gboolean warn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_OBJECT_P_H_ */
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -24,10 +24,19 @@
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofobject-p.h"
|
||||
|
||||
@ -43,11 +52,20 @@ static GHashTable *backend_data = NULL;
|
||||
* They should be removed when no longer needed
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
gboolean get_object_is_initialized( void );
|
||||
GList* get_object_modules( void );
|
||||
GList* get_book_list( void );
|
||||
GHashTable* get_backend_data( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
get_object_is_initialized( void )
|
||||
{
|
||||
@ -98,7 +116,7 @@ void qof_object_book_begin (QofBook *book)
|
||||
ENTER (" ");
|
||||
for (l = object_modules; l; l = l->next)
|
||||
{
|
||||
QofObject *obj = l->data;
|
||||
QofObject *obj = static_cast<QofObject*>(l->data);
|
||||
if (obj->book_begin)
|
||||
obj->book_begin (book);
|
||||
}
|
||||
@ -116,7 +134,7 @@ void qof_object_book_end (QofBook *book)
|
||||
ENTER (" ");
|
||||
for (l = object_modules; l; l = l->next)
|
||||
{
|
||||
QofObject *obj = l->data;
|
||||
QofObject *obj = static_cast<QofObject*>(l->data);
|
||||
if (obj->book_end)
|
||||
obj->book_end (book);
|
||||
}
|
||||
@ -134,7 +152,7 @@ qof_object_is_dirty (const QofBook *book)
|
||||
if (!book) return FALSE;
|
||||
for (l = object_modules; l; l = l->next)
|
||||
{
|
||||
QofObject *obj = l->data;
|
||||
QofObject *obj = static_cast<QofObject*>(l->data);
|
||||
if (obj->is_dirty)
|
||||
{
|
||||
QofCollection *col;
|
||||
@ -153,7 +171,7 @@ qof_object_mark_clean (QofBook *book)
|
||||
if (!book) return;
|
||||
for (l = object_modules; l; l = l->next)
|
||||
{
|
||||
QofObject *obj = l->data;
|
||||
QofObject *obj = static_cast<QofObject*>(l->data);
|
||||
if (obj->mark_clean)
|
||||
{
|
||||
QofCollection *col;
|
||||
@ -171,7 +189,7 @@ void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data)
|
||||
|
||||
for (l = object_modules; l; l = l->next)
|
||||
{
|
||||
QofObject *obj = l->data;
|
||||
QofObject *obj = static_cast<QofObject*>(l->data);
|
||||
(cb) (obj, user_data);
|
||||
}
|
||||
}
|
||||
@ -228,7 +246,7 @@ qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
|
||||
static void
|
||||
do_prepend (QofInstance *qof_p, gpointer list_p)
|
||||
{
|
||||
GList **list = list_p;
|
||||
GList **list = static_cast<GList**>(list_p);
|
||||
*list = g_list_prepend(*list, qof_p);
|
||||
}
|
||||
|
||||
@ -244,7 +262,7 @@ qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book, QofInstanceF
|
||||
|
||||
for (iter = list; iter; iter = iter->next)
|
||||
{
|
||||
cb(iter->data, user_data);
|
||||
cb(static_cast<QofInstance*>(iter->data), user_data);
|
||||
}
|
||||
|
||||
g_list_free(list);
|
||||
@ -287,7 +305,7 @@ const char * qof_object_get_type_label (QofIdTypeConst type_name)
|
||||
|
||||
static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_hash_table_destroy (value);
|
||||
g_hash_table_destroy (static_cast<GHashTable*>(value));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -337,7 +355,7 @@ gboolean qof_object_register (const QofObject *object)
|
||||
{
|
||||
GList *node;
|
||||
for (node = book_list; node; node = node->next)
|
||||
object->book_begin (node->data);
|
||||
object->book_begin (static_cast<QofBook*>(node->data));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -354,7 +372,7 @@ const QofObject * qof_object_lookup (QofIdTypeConst name)
|
||||
|
||||
for (iter = object_modules; iter; iter = iter->next)
|
||||
{
|
||||
obj = iter->data;
|
||||
obj = static_cast<QofObject*>(iter->data);
|
||||
if (!g_strcmp0 (obj->e_type, name))
|
||||
return obj;
|
||||
}
|
||||
@ -373,7 +391,7 @@ gboolean qof_object_register_backend (QofIdTypeConst type_name,
|
||||
!be_data)
|
||||
return FALSE;
|
||||
|
||||
ht = g_hash_table_lookup (backend_data, backend_name);
|
||||
ht = static_cast<GHashTable*>(g_hash_table_lookup (backend_data, backend_name));
|
||||
|
||||
/* If it doesn't already exist, create a new table for this backend */
|
||||
if (!ht)
|
||||
@ -397,7 +415,7 @@ gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
|
||||
!backend_name || *backend_name == '\0')
|
||||
return NULL;
|
||||
|
||||
ht = g_hash_table_lookup (backend_data, (char *)backend_name);
|
||||
ht = static_cast<GHashTable*>(g_hash_table_lookup (backend_data, (char *)backend_name));
|
||||
if (!ht)
|
||||
return NULL;
|
||||
|
||||
@ -412,8 +430,8 @@ struct foreach_data
|
||||
|
||||
static void foreach_backend (gpointer key, gpointer be_item, gpointer arg)
|
||||
{
|
||||
char *data_type = key;
|
||||
struct foreach_data *cb_data = arg;
|
||||
char *data_type = static_cast<char*>(key);
|
||||
struct foreach_data *cb_data = static_cast<struct foreach_data*>(arg);
|
||||
|
||||
g_return_if_fail (key && be_item && arg);
|
||||
|
||||
@ -431,7 +449,7 @@ void qof_object_foreach_backend (const char *backend_name,
|
||||
if (!backend_name || *backend_name == '\0' || !cb)
|
||||
return;
|
||||
|
||||
ht = g_hash_table_lookup (backend_data, (char *)backend_name);
|
||||
ht = static_cast<GHashTable*>(g_hash_table_lookup (backend_data, (char *)backend_name));
|
||||
if (!ht)
|
||||
return;
|
||||
|
||||
|
@ -52,6 +52,11 @@
|
||||
#include "qofid.h"
|
||||
#include "qofchoice.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/** Defines the version of the core object object registration
|
||||
* interface. Only object modules compiled against this version
|
||||
* of the interface will load properly
|
||||
@ -179,6 +184,10 @@ void qof_object_foreach_backend (const char *backend_name,
|
||||
QofForeachBackendTypeCB cb,
|
||||
gpointer user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_OBJECT_H_ */
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -29,6 +29,11 @@
|
||||
typedef struct _QofQueryTerm QofQueryTerm;
|
||||
typedef struct _QofQuerySort QofQuerySort;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Functions to get Query information */
|
||||
int qof_query_get_max_results (const QofQuery *q);
|
||||
|
||||
@ -66,4 +71,8 @@ QofQueryParamList * qof_query_sort_get_param_path (const QofQuerySort *querysort
|
||||
gint qof_query_sort_get_sort_options (const QofQuerySort *querysort);
|
||||
gboolean qof_query_sort_get_increasing (const QofQuerySort *querysort);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_QUERY_P_H */
|
||||
|
@ -21,6 +21,11 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -29,6 +34,10 @@
|
||||
#include <regex.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook-p.h"
|
||||
@ -113,16 +122,16 @@ typedef struct _QofQueryCB
|
||||
/* initial_term will be owned by the new Query */
|
||||
static void query_init (QofQuery *q, QofQueryTerm *initial_term)
|
||||
{
|
||||
GList * or = NULL;
|
||||
GList *and = NULL;
|
||||
GList * _or_ = NULL;
|
||||
GList *_and_ = NULL;
|
||||
GHashTable *ht;
|
||||
|
||||
if (initial_term)
|
||||
{
|
||||
or = g_list_alloc ();
|
||||
and = g_list_alloc ();
|
||||
and->data = initial_term;
|
||||
or->data = and;
|
||||
_or_ = g_list_alloc ();
|
||||
_and_ = g_list_alloc ();
|
||||
_and_->data = initial_term;
|
||||
_or_->data = _and_;
|
||||
}
|
||||
|
||||
if (q->terms)
|
||||
@ -143,11 +152,12 @@ static void query_init (QofQuery *q, QofQueryTerm *initial_term)
|
||||
memset (q, 0, sizeof (*q));
|
||||
q->be_compiled = ht;
|
||||
|
||||
q->terms = or;
|
||||
q->terms = _or_;
|
||||
q->changed = 1;
|
||||
q->max_results = -1;
|
||||
|
||||
q->primary_sort.param_list = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
|
||||
q->primary_sort.param_list = g_slist_prepend (static_cast<GSList*>(NULL),
|
||||
static_cast<void*>(const_cast<char*>(QUERY_DEFAULT_SORT)));
|
||||
q->primary_sort.increasing = TRUE;
|
||||
q->secondary_sort.increasing = TRUE;
|
||||
q->tertiary_sort.increasing = TRUE;
|
||||
@ -196,29 +206,29 @@ static QofQueryTerm * copy_query_term (const QofQueryTerm *qt)
|
||||
|
||||
static GList * copy_and_terms (const GList *and_terms)
|
||||
{
|
||||
GList *and = NULL;
|
||||
GList *_and_ = NULL;
|
||||
const GList *cur_and;
|
||||
|
||||
for (cur_and = and_terms; cur_and; cur_and = cur_and->next)
|
||||
{
|
||||
and = g_list_prepend(and, copy_query_term (cur_and->data));
|
||||
_and_ = g_list_prepend(_and_, copy_query_term (static_cast<QofQueryTerm*>(cur_and->data)));
|
||||
}
|
||||
|
||||
return g_list_reverse(and);
|
||||
return g_list_reverse(_and_);
|
||||
}
|
||||
|
||||
static GList *
|
||||
copy_or_terms(const GList * or_terms)
|
||||
{
|
||||
GList * or = NULL;
|
||||
GList * _or_ = NULL;
|
||||
const GList * cur_or;
|
||||
|
||||
for (cur_or = or_terms; cur_or; cur_or = cur_or->next)
|
||||
{
|
||||
or = g_list_prepend(or, copy_and_terms(cur_or->data));
|
||||
_or_ = g_list_prepend(_or_, copy_and_terms(static_cast<GList*>(cur_or->data)));
|
||||
}
|
||||
|
||||
return g_list_reverse(or);
|
||||
return g_list_reverse(_or_);
|
||||
}
|
||||
|
||||
static void copy_sort (QofQuerySort *dst, const QofQuerySort *src)
|
||||
@ -247,13 +257,14 @@ static void free_members (QofQuery *q)
|
||||
{
|
||||
GList * cur_and;
|
||||
|
||||
for (cur_and = cur_or->data; cur_and; cur_and = cur_and->next)
|
||||
for (cur_and = static_cast<GList*>(cur_or->data); cur_and;
|
||||
cur_and = static_cast<GList*>(cur_and->next))
|
||||
{
|
||||
free_query_term(cur_and->data);
|
||||
free_query_term(static_cast<QofQueryTerm*>(cur_and->data));
|
||||
cur_and->data = NULL;
|
||||
}
|
||||
|
||||
g_list_free(cur_or->data);
|
||||
g_list_free(static_cast<GList*>(cur_or->data));
|
||||
cur_or->data = NULL;
|
||||
}
|
||||
|
||||
@ -296,9 +307,10 @@ static int cmp_func (const QofQuerySort *sort, QofSortFunc default_sort,
|
||||
/* Do the list of conversions */
|
||||
conva = (gpointer)a;
|
||||
convb = (gpointer)b;
|
||||
for (node = sort->param_fcns; node; node = node->next)
|
||||
for (node = static_cast<GSList*>(sort->param_fcns); node;
|
||||
node = static_cast<GSList*>(node->next))
|
||||
{
|
||||
param = node->data;
|
||||
param = static_cast<QofParam*>(node->data);
|
||||
|
||||
/* The last term is really the "parameter getter",
|
||||
* unless we're comparing objects ;) */
|
||||
@ -320,10 +332,11 @@ static int cmp_func (const QofQuerySort *sort, QofSortFunc default_sort,
|
||||
return sort->obj_cmp (conva, convb);
|
||||
}
|
||||
|
||||
static int sort_func (const gconstpointer a, const gconstpointer b, const gpointer q)
|
||||
static int
|
||||
sort_func (const gconstpointer a, const gconstpointer b, const gpointer q)
|
||||
{
|
||||
int retval;
|
||||
const QofQuery *sortQuery = q;
|
||||
const QofQuery *sortQuery = static_cast<const QofQuery*>(q);
|
||||
|
||||
g_return_val_if_fail (sortQuery, 0);
|
||||
|
||||
@ -366,7 +379,8 @@ check_object (const QofQuery *q, gpointer object)
|
||||
for (or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next)
|
||||
{
|
||||
and_terms_ok = 1;
|
||||
for (and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next)
|
||||
for (and_ptr = static_cast<GList*>(or_ptr->data); and_ptr;
|
||||
and_ptr = static_cast<GList*>(and_ptr->next))
|
||||
{
|
||||
qt = (QofQueryTerm *)(and_ptr->data);
|
||||
if (qt->param_fcns && qt->pred_fcn)
|
||||
@ -378,7 +392,7 @@ check_object (const QofQuery *q, gpointer object)
|
||||
/* iterate through the conversions */
|
||||
for (node = qt->param_fcns; node; node = node->next)
|
||||
{
|
||||
param = node->data;
|
||||
param = static_cast<QofParam*>(node->data);
|
||||
|
||||
/* The last term is the actual parameter getter */
|
||||
if (!node->next) break;
|
||||
@ -432,7 +446,7 @@ compile_params (QofQueryParamList *param_list, QofIdType start_obj,
|
||||
|
||||
for (; param_list; param_list = param_list->next)
|
||||
{
|
||||
QofIdType param_name = param_list->data;
|
||||
QofIdType param_name = static_cast<QofIdType>(param_list->data);
|
||||
objDef = qof_class_get_parameter (start_obj, param_name);
|
||||
|
||||
/* If it doesn't exist, then we've reached the end */
|
||||
@ -492,7 +506,8 @@ compile_sort (QofQuerySort *sort, QofIdType obj)
|
||||
if (sort->comp_fcn == NULL)
|
||||
sort->obj_cmp = qof_class_get_default_sort (resObj->param_type);
|
||||
}
|
||||
else if (!g_strcmp0 (sort->param_list->data, QUERY_DEFAULT_SORT))
|
||||
else if (!g_strcmp0 (static_cast<char*>(sort->param_list->data),
|
||||
QUERY_DEFAULT_SORT))
|
||||
{
|
||||
sort->use_default = TRUE;
|
||||
}
|
||||
@ -509,10 +524,11 @@ static void compile_terms (QofQuery *q)
|
||||
*/
|
||||
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 = static_cast<GList*>(or_ptr->data); and_ptr;
|
||||
and_ptr = static_cast<GList*>(and_ptr->next))
|
||||
{
|
||||
QofQueryTerm *qt = and_ptr->data;
|
||||
const QofParam *resObj = NULL;
|
||||
QofQueryTerm* qt = static_cast<QofQueryTerm*>(and_ptr->data);
|
||||
const QofParam* resObj = NULL;
|
||||
|
||||
g_slist_free (qt->param_fcns);
|
||||
qt->param_fcns = NULL;
|
||||
@ -542,8 +558,8 @@ static void compile_terms (QofQuery *q)
|
||||
/* Now compile the backend instances */
|
||||
for (node = q->books; node; node = node->next)
|
||||
{
|
||||
QofBook *book = node->data;
|
||||
QofBackend *be = book->backend;
|
||||
QofBook* book = static_cast<QofBook*>(node->data);
|
||||
QofBackend* be = book->backend;
|
||||
|
||||
if (be && be->compile_query)
|
||||
{
|
||||
@ -557,7 +573,7 @@ static void compile_terms (QofQuery *q)
|
||||
|
||||
static void check_item_cb (gpointer object, gpointer user_data)
|
||||
{
|
||||
QofQueryCB *ql = user_data;
|
||||
QofQueryCB* ql = static_cast<QofQueryCB*>(user_data);
|
||||
|
||||
if (!object || !ql) return;
|
||||
|
||||
@ -581,7 +597,8 @@ static int param_list_cmp (const QofQueryParamList *l1, const QofQueryParamList
|
||||
if (!l1 && l2) return -1;
|
||||
if (l1 && !l2) return 1;
|
||||
|
||||
ret = g_strcmp0 (l1->data, l2->data);
|
||||
ret = g_strcmp0 (static_cast<char*>(l1->data),
|
||||
static_cast<char*>(l2->data));
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
@ -610,7 +627,7 @@ static GList * merge_books (GList *l1, GList *l2)
|
||||
static gboolean
|
||||
query_free_compiled (gpointer key, gpointer value, gpointer not_used)
|
||||
{
|
||||
QofBook* book = key;
|
||||
QofBook* book = static_cast<QofBook*>(key);
|
||||
QofBackend* be = book->backend;
|
||||
|
||||
if (be && be->free_query)
|
||||
@ -675,36 +692,37 @@ void qof_query_add_term (QofQuery *q, QofQueryParamList *param_list,
|
||||
void qof_query_purge_terms (QofQuery *q, QofQueryParamList *param_list)
|
||||
{
|
||||
QofQueryTerm *qt;
|
||||
GList *or, *and;
|
||||
GList *_or_, *_and_;
|
||||
|
||||
if (!q || !param_list) return;
|
||||
|
||||
for (or = q->terms; or; or = or->next)
|
||||
for (_or_ = q->terms; _or_; _or_ = _or_->next)
|
||||
{
|
||||
for (and = or->data; and; and = and->next)
|
||||
for (_and_ = static_cast<GList*>(_or_->data); _and_;
|
||||
_and_ = static_cast<GList*>(_and_->next))
|
||||
{
|
||||
qt = and->data;
|
||||
qt = static_cast<QofQueryTerm*>(_and_->data);
|
||||
if (!param_list_cmp (qt->param_list, param_list))
|
||||
{
|
||||
if (g_list_length (or->data) == 1)
|
||||
if (g_list_length (static_cast<GList*>(_or_->data)) == 1)
|
||||
{
|
||||
q->terms = g_list_remove_link (q->terms, or);
|
||||
g_list_free_1 (or);
|
||||
or = q->terms;
|
||||
q->terms = g_list_remove_link (static_cast<GList*>(q->terms), _or_);
|
||||
g_list_free_1 (_or_);
|
||||
_or_ = q->terms;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
or->data = g_list_remove_link (or->data, and);
|
||||
g_list_free_1 (and);
|
||||
and = or->data;
|
||||
if (!and) break;
|
||||
_or_->data = g_list_remove_link (static_cast<GList*>(_or_->data), _and_);
|
||||
g_list_free_1 (_and_);
|
||||
_and_ = static_cast<GList*>(_or_->data);
|
||||
if (!_and_) break;
|
||||
}
|
||||
q->changed = 1;
|
||||
free_query_term (qt);
|
||||
}
|
||||
}
|
||||
if (!or) break;
|
||||
if (!_or_) break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -809,8 +827,8 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
|
||||
|
||||
for (node = qcb->query->books; node; node = node->next)
|
||||
{
|
||||
QofBook *book = node->data;
|
||||
QofBackend *be = book->backend;
|
||||
QofBook* book = static_cast<QofBook*>(node->data);
|
||||
QofBackend* be = book->backend;
|
||||
|
||||
/* run the query in the backend */
|
||||
if (be)
|
||||
@ -838,7 +856,7 @@ GList * qof_query_run (QofQuery *q)
|
||||
|
||||
static void qof_query_run_subq_cb(QofQueryCB* qcb, gpointer cb_arg)
|
||||
{
|
||||
QofQuery* pq = cb_arg;
|
||||
QofQuery* pq = static_cast<QofQuery*>(cb_arg);
|
||||
|
||||
g_return_if_fail(pq);
|
||||
g_list_foreach(qof_query_last_run(pq), check_item_cb, qcb);
|
||||
@ -925,23 +943,24 @@ int qof_query_num_terms (QofQuery *q)
|
||||
int n = 0;
|
||||
if (!q) return 0;
|
||||
for (o = q->terms; o; o = o->next)
|
||||
n += g_list_length(o->data);
|
||||
n += g_list_length(static_cast<GList*>(o->data));
|
||||
return n;
|
||||
}
|
||||
|
||||
gboolean qof_query_has_term_type (QofQuery *q, QofQueryParamList *term_param)
|
||||
{
|
||||
GList *or;
|
||||
GList *and;
|
||||
GList *_or_;
|
||||
GList *_and_;
|
||||
|
||||
if (!q || !term_param)
|
||||
return FALSE;
|
||||
|
||||
for (or = q->terms; or; or = or->next)
|
||||
for (_or_ = q->terms; _or_; _or_ = _or_->next)
|
||||
{
|
||||
for (and = or->data; and; and = and->next)
|
||||
for (_and_ = static_cast<GList*>(_or_->data); _and_;
|
||||
_and_ = static_cast<GList*>(_and_->next))
|
||||
{
|
||||
QofQueryTerm *qt = and->data;
|
||||
QofQueryTerm* qt = static_cast<QofQueryTerm*>(_and_->data);
|
||||
if (!param_list_cmp (term_param, qt->param_list))
|
||||
return TRUE;
|
||||
}
|
||||
@ -952,18 +971,19 @@ gboolean qof_query_has_term_type (QofQuery *q, QofQueryParamList *term_param)
|
||||
|
||||
GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param)
|
||||
{
|
||||
GList *or;
|
||||
GList *and;
|
||||
GList *_or_;
|
||||
GList *_and_;
|
||||
GSList *results = NULL;
|
||||
|
||||
if (!q || !term_param)
|
||||
return FALSE;
|
||||
|
||||
for (or = q->terms; or; or = or->next)
|
||||
for (_or_ = q->terms; _or_; _or_ = _or_->next)
|
||||
{
|
||||
for (and = or->data; and; and = and->next)
|
||||
for (_and_ = static_cast<GList*>(_or_->data); _and_;
|
||||
_and_ = static_cast<GList*>(_and_->next))
|
||||
{
|
||||
QofQueryTerm *qt = and->data;
|
||||
QofQueryTerm *qt = static_cast<QofQueryTerm*>(_and_->data);
|
||||
if (!param_list_cmp (term_param, qt->param_list))
|
||||
results = g_slist_append(results, qt->pdata);
|
||||
}
|
||||
@ -1044,11 +1064,11 @@ QofQuery * qof_query_invert (QofQuery *q)
|
||||
retval->search_for = q->search_for;
|
||||
retval->changed = 1;
|
||||
|
||||
aterms = g_list_nth_data(q->terms, 0);
|
||||
aterms = static_cast<GList*>(g_list_nth_data(q->terms, 0));
|
||||
new_oterm = NULL;
|
||||
for (cur = aterms; cur; cur = cur->next)
|
||||
{
|
||||
qt = copy_query_term(cur->data);
|
||||
qt = copy_query_term(static_cast<QofQueryTerm*>(cur->data));
|
||||
qt->invert = !(qt->invert);
|
||||
new_oterm = g_list_append(NULL, qt);
|
||||
retval->terms = g_list_prepend(retval->terms, new_oterm);
|
||||
@ -1065,7 +1085,7 @@ QofQuery * qof_query_invert (QofQuery *q)
|
||||
|
||||
left = qof_query_create();
|
||||
left->terms = g_list_append(NULL,
|
||||
copy_and_terms(g_list_nth_data(q->terms, 0)));
|
||||
copy_and_terms(static_cast<GList*>(g_list_nth_data(q->terms, 0))));
|
||||
|
||||
iright = qof_query_invert(right);
|
||||
ileft = qof_query_invert(left);
|
||||
@ -1153,8 +1173,8 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
|
||||
retval->terms =
|
||||
g_list_prepend(retval->terms,
|
||||
g_list_concat
|
||||
(copy_and_terms(i->data),
|
||||
copy_and_terms(j->data)));
|
||||
(copy_and_terms(static_cast<GList*>(i->data)),
|
||||
copy_and_terms(static_cast<GList*>(j->data))));
|
||||
}
|
||||
}
|
||||
retval->terms = g_list_reverse(retval->terms);
|
||||
@ -1297,8 +1317,8 @@ void qof_query_set_book (QofQuery *q, QofBook *book)
|
||||
if (g_list_index (q->books, book) == -1)
|
||||
q->books = g_list_prepend (q->books, book);
|
||||
|
||||
slist = g_slist_prepend (slist, QOF_PARAM_GUID);
|
||||
slist = g_slist_prepend (slist, QOF_PARAM_BOOK);
|
||||
slist = g_slist_prepend (slist, static_cast<void*>(const_cast<char*>(QOF_PARAM_GUID)));
|
||||
slist = g_slist_prepend (slist, static_cast<void*>(const_cast<char*>(QOF_PARAM_BOOK)));
|
||||
qof_query_add_guid_match (q, slist,
|
||||
qof_instance_get_guid(book), QOF_QUERY_AND);
|
||||
}
|
||||
@ -1449,13 +1469,14 @@ gboolean qof_query_equal (const QofQuery *q1, const QofQuery *q2)
|
||||
{
|
||||
GList *and1, *and2;
|
||||
|
||||
and1 = or1->data;
|
||||
and2 = or2->data;
|
||||
and1 = static_cast<GList*>(or1->data);
|
||||
and2 = static_cast<GList*>(or2->data);
|
||||
|
||||
if (g_list_length (and1) != g_list_length (and2)) return FALSE;
|
||||
|
||||
for ( ; and1; and1 = and1->next, and2 = and2->next)
|
||||
if (!qof_query_term_equal (and1->data, and2->data))
|
||||
if (!qof_query_term_equal (static_cast<QofQueryTerm*>(and1->data),
|
||||
static_cast<QofQueryTerm*>(and2->data)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1479,12 +1500,12 @@ static GList *qof_query_printTerms (QofQuery * query, GList * output);
|
||||
static GList *qof_query_printSorts (QofQuerySort *s[], const gint numSorts,
|
||||
GList * output);
|
||||
static GList *qof_query_printAndTerms (GList * terms, GList * output);
|
||||
static gchar *qof_query_printStringForHow (QofQueryCompare how);
|
||||
static gchar *qof_query_printStringMatch (QofStringMatch s);
|
||||
static gchar *qof_query_printDateMatch (QofDateMatch d);
|
||||
static gchar *qof_query_printNumericMatch (QofNumericMatch n);
|
||||
static gchar *qof_query_printGuidMatch (QofGuidMatch g);
|
||||
static gchar *qof_query_printCharMatch (QofCharMatch c);
|
||||
static const char *qof_query_printStringForHow (QofQueryCompare how);
|
||||
static const char *qof_query_printStringMatch (QofStringMatch s);
|
||||
static const char *qof_query_printDateMatch (QofDateMatch d);
|
||||
static const char *qof_query_printNumericMatch (QofNumericMatch n);
|
||||
static const char *qof_query_printGuidMatch (QofGuidMatch g);
|
||||
static const char *qof_query_printCharMatch (QofCharMatch c);
|
||||
static GList *qof_query_printPredData (QofQueryPredData *pd, GList *lst);
|
||||
static GString *qof_query_printParamPath (QofQueryParamList * parmList);
|
||||
static void qof_query_printValueForParam (QofQueryPredData *pd, GString * gs);
|
||||
@ -1588,7 +1609,8 @@ qof_query_printTerms (QofQuery * query, GList * output)
|
||||
|
||||
if (lst->data)
|
||||
{
|
||||
output = qof_query_printAndTerms (lst->data, output);
|
||||
output = qof_query_printAndTerms (static_cast<GList*>(lst->data),
|
||||
output);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1625,7 +1647,7 @@ qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output)
|
||||
if (gsl) g_string_append_printf (gs, " Param: ");
|
||||
for (n = gsl; n; n = n->next)
|
||||
{
|
||||
QofIdType param_name = n->data;
|
||||
QofIdType param_name = static_cast<QofIdType>(n->data);
|
||||
if (gsl != n) g_string_append_printf (gs, " ");
|
||||
g_string_append_printf (gs, "%s", param_name);
|
||||
}
|
||||
@ -1721,7 +1743,7 @@ qof_query_printPredData (QofQueryPredData *pd, GList *lst)
|
||||
Get a string representation for the
|
||||
QofCompareFunc enum type.
|
||||
*/
|
||||
static gchar *
|
||||
static const char *
|
||||
qof_query_printStringForHow (QofQueryCompare how)
|
||||
{
|
||||
|
||||
@ -1843,7 +1865,7 @@ qof_query_printValueForParam (QofQueryPredData *pd, GString * gs)
|
||||
* Print out a string representation of the
|
||||
* QofStringMatch enum
|
||||
*/
|
||||
static gchar *
|
||||
static const char *
|
||||
qof_query_printStringMatch (QofStringMatch s)
|
||||
{
|
||||
switch (s)
|
||||
@ -1860,7 +1882,7 @@ qof_query_printStringMatch (QofStringMatch s)
|
||||
* Print out a string representation of the
|
||||
* QofDateMatch enum
|
||||
*/
|
||||
static gchar *
|
||||
static const char *
|
||||
qof_query_printDateMatch (QofDateMatch d)
|
||||
{
|
||||
switch (d)
|
||||
@ -1877,7 +1899,7 @@ qof_query_printDateMatch (QofDateMatch d)
|
||||
* Print out a string representation of the
|
||||
* QofNumericMatch enum
|
||||
*/
|
||||
static gchar *
|
||||
static const char *
|
||||
qof_query_printNumericMatch (QofNumericMatch n)
|
||||
{
|
||||
switch (n)
|
||||
@ -1896,7 +1918,7 @@ qof_query_printNumericMatch (QofNumericMatch n)
|
||||
* Print out a string representation of the
|
||||
* QofGuidMatch enum
|
||||
*/
|
||||
static gchar *
|
||||
static const char *
|
||||
qof_query_printGuidMatch (QofGuidMatch g)
|
||||
{
|
||||
switch (g)
|
||||
@ -1920,7 +1942,7 @@ qof_query_printGuidMatch (QofGuidMatch g)
|
||||
* Print out a string representation of the
|
||||
* QofCharMatch enum
|
||||
*/
|
||||
static gchar *
|
||||
static const char *
|
||||
qof_query_printCharMatch (QofCharMatch c)
|
||||
{
|
||||
switch (c)
|
||||
|
@ -79,6 +79,11 @@ probably optimize.
|
||||
#include "qofquerycore.h"
|
||||
#include "qofchoice.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define QOF_MOD_QUERY "qof.query"
|
||||
|
||||
/** A Query */
|
||||
@ -380,4 +385,8 @@ GList * qof_query_get_books (QofQuery *q);
|
||||
|
||||
// @}
|
||||
/* @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_QUERYNEW_H */
|
||||
|
@ -371,7 +371,7 @@ date_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
ta = ((query_date_getter)getter->param_getfcn) (a, getter);
|
||||
tb = ((query_date_getter)getter->param_getfcn) (b, getter);
|
||||
|
||||
return date_compare (ta, tb, options);
|
||||
return date_compare (ta, tb, static_cast<QofDateMatch>(options));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -596,10 +596,11 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
/* See if this GncGUID matches the object's guid */
|
||||
for (o_list = object; o_list; o_list = o_list->next)
|
||||
for (o_list = static_cast<GList*>(object); o_list;
|
||||
o_list = static_cast<GList*>(o_list->next))
|
||||
{
|
||||
guid = ((query_guid_getter)getter->param_getfcn) (o_list->data, getter);
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data), guid))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -635,7 +636,8 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
/* Search the predicate data for a match */
|
||||
for (node2 = pdata->guids; node2; node2 = node2->next)
|
||||
{
|
||||
if (guid_equal (node->data, node2->data))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data),
|
||||
static_cast<GncGUID*>(node2->data)))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -661,7 +663,7 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
guid = ((query_guid_getter)getter->param_getfcn) (object, getter);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data), guid))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -693,7 +695,7 @@ guid_free_pdata (QofQueryPredData *pd)
|
||||
VERIFY_PDATA (query_guid_type);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
guid_free (node->data);
|
||||
guid_free (static_cast<GncGUID*>(node->data));
|
||||
}
|
||||
g_list_free (pdata->guids);
|
||||
g_free (pdata);
|
||||
@ -718,7 +720,8 @@ guid_predicate_equal (const QofQueryPredData *p1, const QofQueryPredData *p2)
|
||||
if (g_list_length (l1) != g_list_length (l2)) return FALSE;
|
||||
for ( ; l1 ; l1 = l1->next, l2 = l2->next)
|
||||
{
|
||||
if (!guid_equal (l1->data, l2->data))
|
||||
if (!guid_equal (static_cast<GncGUID*>(l1->data),
|
||||
static_cast<GncGUID*>(l2->data)))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@ -1277,7 +1280,8 @@ kvp_predicate_equal (const QofQueryPredData *p1, const QofQueryPredData *p2)
|
||||
|
||||
for ( ; n1 && n2; n1 = n1->next, n2 = n2->next)
|
||||
{
|
||||
if (g_strcmp0 (n1->data, n2->data) != 0)
|
||||
if (g_strcmp0 (static_cast<char*>(n1->data),
|
||||
static_cast<char*>(n2->data)) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1302,7 +1306,7 @@ qof_query_kvp_predicate (QofQueryCompare how,
|
||||
pdata->value = kvp_value_copy (value);
|
||||
pdata->path = g_slist_copy (path);
|
||||
for (node = pdata->path; node; node = node->next)
|
||||
node->data = g_strdup (node->data);
|
||||
node->data = g_strdup (static_cast<char*>(node->data));
|
||||
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
@ -1358,11 +1362,12 @@ collect_match_predicate (gpointer object, QofParam *getter,
|
||||
{
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
for (o_list = object; o_list; o_list = o_list->next)
|
||||
for (o_list = static_cast<GList*>(object); o_list;
|
||||
o_list = static_cast<GList*>(o_list->next))
|
||||
{
|
||||
guid = ((query_guid_getter)getter->param_getfcn)
|
||||
(o_list->data, getter);
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data), guid))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -1381,7 +1386,8 @@ collect_match_predicate (gpointer object, QofParam *getter,
|
||||
{
|
||||
for (node2 = pdata->guids; node2; node2 = node2->next)
|
||||
{
|
||||
if (guid_equal (node->data, node2->data))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data),
|
||||
static_cast<GncGUID*>(node2->data)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -1399,7 +1405,7 @@ collect_match_predicate (gpointer object, QofParam *getter,
|
||||
guid = ((query_guid_getter)getter->param_getfcn) (object, getter);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data), guid))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -1457,7 +1463,7 @@ collect_free_pdata (QofQueryPredData *pd)
|
||||
VERIFY_PDATA (query_collect_type);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
guid_free (node->data);
|
||||
guid_free (static_cast<GncGUID*>(node->data));
|
||||
}
|
||||
qof_collection_destroy(pdata->coll);
|
||||
g_list_free (pdata->guids);
|
||||
@ -1540,10 +1546,11 @@ choice_match_predicate (gpointer object, QofParam *getter,
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
/* See if this GncGUID matches the object's guid */
|
||||
for (o_list = object; o_list; o_list = o_list->next)
|
||||
for (o_list = static_cast<GList*>(object); o_list;
|
||||
o_list = static_cast<GList*>(o_list->next))
|
||||
{
|
||||
guid = ((query_choice_getter)getter->param_getfcn) (o_list->data, getter);
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data), guid))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1573,7 +1580,8 @@ choice_match_predicate (gpointer object, QofParam *getter,
|
||||
|
||||
for (node2 = pdata->guids; node2; node2 = node2->next)
|
||||
{
|
||||
if (guid_equal (node->data, node2->data))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data),
|
||||
static_cast<GncGUID*>(node2->data)))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1594,7 +1602,7 @@ choice_match_predicate (gpointer object, QofParam *getter,
|
||||
guid = ((query_choice_getter)getter->param_getfcn) (object, getter);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (static_cast<GncGUID*>(node->data), guid))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1626,7 +1634,7 @@ choice_free_pdata (QofQueryPredData *pd)
|
||||
VERIFY_PDATA (query_choice_type);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
guid_free (node->data);
|
||||
guid_free (static_cast<GncGUID*>(node->data));
|
||||
}
|
||||
g_list_free (pdata->guids);
|
||||
g_free (pdata);
|
||||
@ -1651,7 +1659,8 @@ choice_predicate_equal (const QofQueryPredData *p1, const QofQueryPredData *p2)
|
||||
if (g_list_length (l1) != g_list_length (l2)) return FALSE;
|
||||
for ( ; l1 ; l1 = l1->next, l2 = l2->next)
|
||||
{
|
||||
if (!guid_equal (l1->data, l2->data))
|
||||
if (!guid_equal (static_cast<GncGUID*>(l1->data),
|
||||
static_cast<GncGUID*>(l2->data)))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@ -1706,22 +1715,28 @@ qof_query_register_core_object (QofType core_name,
|
||||
g_return_if_fail (*core_name != '\0');
|
||||
|
||||
if (pred)
|
||||
g_hash_table_insert (predTable, (char *)core_name, pred);
|
||||
g_hash_table_insert (predTable, (char *)core_name,
|
||||
reinterpret_cast<void*>(pred));
|
||||
|
||||
if (comp)
|
||||
g_hash_table_insert (cmpTable, (char *)core_name, comp);
|
||||
g_hash_table_insert (cmpTable, (char *)core_name,
|
||||
reinterpret_cast<void*>(comp));
|
||||
|
||||
if (copy)
|
||||
g_hash_table_insert (copyTable, (char *)core_name, copy);
|
||||
g_hash_table_insert (copyTable, (char *)core_name,
|
||||
reinterpret_cast<void*>(copy));
|
||||
|
||||
if (pd_free)
|
||||
g_hash_table_insert (freeTable, (char *)core_name, pd_free);
|
||||
g_hash_table_insert (freeTable, (char *)core_name,
|
||||
reinterpret_cast<void*>(pd_free));
|
||||
|
||||
if (toString)
|
||||
g_hash_table_insert (toStringTable, (char *)core_name, toString);
|
||||
g_hash_table_insert (toStringTable, (char *)core_name,
|
||||
reinterpret_cast<void*>(toString));
|
||||
|
||||
if (pred_equal)
|
||||
g_hash_table_insert (predEqualTable, (char *)core_name, pred_equal);
|
||||
g_hash_table_insert (predEqualTable, (char *)core_name,
|
||||
reinterpret_cast<void*>(pred_equal));
|
||||
}
|
||||
|
||||
static void init_tables (void)
|
||||
@ -1821,7 +1836,7 @@ qof_query_copy_predicate (QofType type)
|
||||
{
|
||||
QueryPredicateCopyFunc rc;
|
||||
g_return_val_if_fail (type, NULL);
|
||||
rc = g_hash_table_lookup (copyTable, type);
|
||||
rc = reinterpret_cast<QueryPredicateCopyFunc>(g_hash_table_lookup (copyTable, type));
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1829,7 +1844,7 @@ static QueryPredDataFree
|
||||
qof_query_predicate_free (QofType type)
|
||||
{
|
||||
g_return_val_if_fail (type, NULL);
|
||||
return g_hash_table_lookup (freeTable, type);
|
||||
return reinterpret_cast<QueryPredDataFree>(g_hash_table_lookup (freeTable, type));
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
@ -1869,14 +1884,14 @@ QofQueryPredicateFunc
|
||||
qof_query_core_get_predicate (QofType type)
|
||||
{
|
||||
g_return_val_if_fail (type, NULL);
|
||||
return g_hash_table_lookup (predTable, type);
|
||||
return reinterpret_cast<QofQueryPredicateFunc>(g_hash_table_lookup (predTable, type));
|
||||
}
|
||||
|
||||
QofCompareFunc
|
||||
qof_query_core_get_compare (QofType type)
|
||||
{
|
||||
g_return_val_if_fail (type, NULL);
|
||||
return g_hash_table_lookup (cmpTable, type);
|
||||
return reinterpret_cast<QofCompareFunc>(g_hash_table_lookup (cmpTable, type));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1913,7 +1928,7 @@ qof_query_core_to_string (QofType type, gpointer object,
|
||||
g_return_val_if_fail (object, NULL);
|
||||
g_return_val_if_fail (getter, NULL);
|
||||
|
||||
toString = g_hash_table_lookup (toStringTable, type);
|
||||
toString = reinterpret_cast<QueryToString>(g_hash_table_lookup (toStringTable, type));
|
||||
g_return_val_if_fail (toString, NULL);
|
||||
|
||||
return toString (object, getter);
|
||||
@ -1930,7 +1945,7 @@ qof_query_core_predicate_equal (const QofQueryPredData *p1, const QofQueryPredDa
|
||||
if (p1->how != p2->how) return FALSE;
|
||||
if (g_strcmp0 (p1->type_name, p2->type_name)) return FALSE;
|
||||
|
||||
pred_equal = g_hash_table_lookup (predEqualTable, p1->type_name);
|
||||
pred_equal = reinterpret_cast<QueryPredicateEqual>(g_hash_table_lookup (predEqualTable, p1->type_name));
|
||||
g_return_val_if_fail (pred_equal, FALSE);
|
||||
|
||||
return pred_equal (p1, p2);
|
||||
|
@ -37,6 +37,11 @@
|
||||
#include "kvp_frame.h"
|
||||
#include "qofclass.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PREDICATE DATA TYPES: All the predicate data types are rolled up into
|
||||
* the union type PredicateData. The "type" field specifies which type
|
||||
@ -205,6 +210,10 @@ int qof_string_number_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofParam *this_param);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_QUERYCORE_H */
|
||||
/* @} */
|
||||
/* @} */
|
||||
|
@ -77,8 +77,17 @@ typedef struct qof_instance_copy_data
|
||||
gboolean error;
|
||||
} QofInstanceCopyData;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
QofBackend * qof_session_get_backend (const QofSession *session);
|
||||
|
||||
void qof_session_push_error (QofSession *session, QofBackendError err,
|
||||
const char *message);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -62,11 +62,20 @@ static gboolean qof_providers_initialized = FALSE;
|
||||
* They should be removed when no longer needed
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
GHookList* get_session_closed_hooks (void );
|
||||
GSList* get_provider_list (void );
|
||||
gboolean get_qof_providers_initialized (void );
|
||||
void unregister_all_providers (void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
GHookList*
|
||||
get_session_closed_hooks (void)
|
||||
{
|
||||
@ -112,7 +121,7 @@ qof_backend_get_registered_access_method_list(void)
|
||||
|
||||
for ( node = provider_list; node != NULL; node = node->next )
|
||||
{
|
||||
QofBackendProvider *prov = node->data;
|
||||
QofBackendProvider *prov = static_cast<QofBackendProvider*>(node->data);
|
||||
list = g_list_append( list, (gchar*)prov->access_method );
|
||||
}
|
||||
|
||||
@ -130,7 +139,7 @@ qof_session_add_close_hook (GFunc fn, gpointer data)
|
||||
|
||||
if (session_closed_hooks == NULL)
|
||||
{
|
||||
session_closed_hooks = malloc(sizeof(GHookList)); /* LEAKED */
|
||||
session_closed_hooks = static_cast<GHookList*>(malloc(sizeof(GHookList))); /* LEAKED */
|
||||
g_hook_list_init (session_closed_hooks, sizeof(GHook));
|
||||
}
|
||||
|
||||
@ -138,7 +147,7 @@ qof_session_add_close_hook (GFunc fn, gpointer data)
|
||||
if (!hook)
|
||||
return;
|
||||
|
||||
hook->func = (GHookFunc)fn;
|
||||
hook->func = reinterpret_cast<void*>(fn);
|
||||
hook->data = data;
|
||||
g_hook_append(session_closed_hooks, hook);
|
||||
}
|
||||
@ -351,7 +360,7 @@ qof_session_load_backend(QofSession * session, const char * access_method)
|
||||
p = provider_list;
|
||||
while (p != NULL)
|
||||
{
|
||||
prov = p->data;
|
||||
prov = static_cast<QofBackendProvider*>(p->data);
|
||||
/* Does this provider handle the desired access method? */
|
||||
if (0 == g_ascii_strcasecmp (access_method, prov->access_method))
|
||||
{
|
||||
@ -495,7 +504,7 @@ qof_session_begin (QofSession *session, const char * book_id,
|
||||
if (session->backend->session_begin)
|
||||
{
|
||||
char *msg;
|
||||
int err;
|
||||
QofBackendError err;
|
||||
|
||||
(session->backend->session_begin)(session->backend, session,
|
||||
session->book_id, ignore_lock,
|
||||
@ -610,7 +619,7 @@ qof_session_load (QofSession *session,
|
||||
static gboolean
|
||||
save_error_handler(QofBackend *be, QofSession *session)
|
||||
{
|
||||
int err;
|
||||
QofBackendError err;
|
||||
err = qof_backend_get_error(be);
|
||||
|
||||
if (ERR_BACKEND_NO_ERR != err)
|
||||
@ -689,7 +698,7 @@ void
|
||||
qof_session_safe_save(QofSession *session, QofPercentageFunc percentage_func)
|
||||
{
|
||||
QofBackend *be = session->backend;
|
||||
gint err;
|
||||
QofBackendError err;
|
||||
char *msg = NULL;
|
||||
g_return_if_fail( be != NULL );
|
||||
g_return_if_fail( be->safe_sync != NULL );
|
||||
@ -858,12 +867,21 @@ qof_session_export (QofSession *tmp_session,
|
||||
|
||||
/* ================= Static function access for testing ================= */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void init_static_qofsession_pointers (void);
|
||||
|
||||
void (*p_qof_session_load_backend) (QofSession * session, const char * access_method);
|
||||
void (*p_qof_session_clear_error) (QofSession *session);
|
||||
void (*p_qof_session_destroy_backend) (QofSession *session);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
init_static_qofsession_pointers (void)
|
||||
{
|
||||
|
@ -103,6 +103,11 @@
|
||||
#include "qofclass.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define QOF_MOD_SESSION "qof.session"
|
||||
|
||||
/* PROTOTYPES ******************************************************/
|
||||
@ -311,5 +316,9 @@ GList* qof_backend_get_registered_access_method_list(void);
|
||||
*/
|
||||
void qof_session_ensure_all_data_loaded(QofSession* session);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_SESSION_H */
|
||||
/** @} */
|
||||
|
@ -32,6 +32,11 @@
|
||||
#ifndef QOF_UTIL_H
|
||||
#define QOF_UTIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include "qof.h"
|
||||
#include "qoflog.h"
|
||||
@ -258,5 +263,9 @@ qof_commit_edit_part2(QofInstance *inst,
|
||||
void (*on_done)(QofInstance *),
|
||||
void (*on_free)(QofInstance *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* QOF_UTIL_H */
|
||||
/** @} */
|
||||
|
@ -21,12 +21,21 @@
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
********************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <unittest-support.h>
|
||||
/* Add specific headers for this class */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "../gnc-date.h"
|
||||
#include "../gnc-date-p.h"
|
||||
#include <locale.h>
|
||||
@ -55,8 +64,17 @@ typedef struct
|
||||
} _GncDateTime;
|
||||
|
||||
static _GncDateTime gncdt;
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void _gnc_date_time_init (_GncDateTime *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* gnc_localtime just creates a tm on the heap and calls
|
||||
* gnc_localtime_r with it, so this suffices to test both.
|
||||
*/
|
||||
@ -1719,7 +1737,7 @@ test_gnc_timespec_to_iso8601_buff (void)
|
||||
gchar *logdomain = "qof";
|
||||
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
#ifdef __clang__
|
||||
#define _func "gchar *gnc_timespec_to_iso8601_buff(Timespec, char *)"
|
||||
#define _func "char *gnc_timespec_to_iso8601_buff(Timespec, char *)"
|
||||
#else
|
||||
#define _func "gnc_timespec_to_iso8601_buff"
|
||||
#endif
|
||||
|
@ -19,10 +19,20 @@
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
********************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "unittest-support.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "qof.h"
|
||||
|
||||
static const gchar *suitename = "/qof/kvp_frame";
|
||||
|
@ -19,10 +19,19 @@
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <unittest-support.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "../qof.h"
|
||||
#include "../qofbook-p.h"
|
||||
#include "../qofbookslots.h"
|
||||
@ -271,7 +280,7 @@ test_book_get_counter_format ( Fixture *fixture, gconstpointer pData )
|
||||
const char *counter_name = "Counter name";
|
||||
const char *err_no_book = "No book";
|
||||
const char *err_invalid_cnt = "Invalid counter name";
|
||||
gchar *r;
|
||||
const char *r;
|
||||
|
||||
/* need this as long as we have fatal warnings enabled */
|
||||
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )handle_faults, NULL );
|
||||
@ -309,8 +318,8 @@ test_book_increment_and_format_counter ( Fixture *fixture, gconstpointer pData )
|
||||
const char *counter_name = "Counter name";
|
||||
const char *err_no_book = "No book";
|
||||
const char *err_invalid_cnt = "Invalid counter name";
|
||||
gchar *format;
|
||||
gchar *r;
|
||||
const char *format;
|
||||
char *r;
|
||||
gint64 counter;
|
||||
|
||||
/* need this as long as we have fatal warnings enabled */
|
||||
|
@ -19,10 +19,19 @@
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
********************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <unittest-support.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "../qof.h"
|
||||
#include "../qofobject-p.h"
|
||||
|
||||
@ -76,11 +85,20 @@ new_object( QofIdType e_type, const char *type_label, MockFields field)
|
||||
return object;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern gboolean get_object_is_initialized( void );
|
||||
extern GList* get_object_modules( void );
|
||||
extern GList* get_book_list( void );
|
||||
extern GHashTable* get_backend_data( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
setup( Fixture *fixture, gconstpointer pData )
|
||||
{
|
||||
|
@ -20,9 +20,19 @@
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
#include <unittest-support.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "../qof.h"
|
||||
#include "../qofbackend-p.h"
|
||||
#include "../qofsession-p.h"
|
||||
@ -31,6 +41,11 @@
|
||||
static const gchar *suitename = "/qof/qofsession";
|
||||
void test_suite_qofsession ( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern GHookList* get_session_closed_hooks (void);
|
||||
extern GSList* get_provider_list (void);
|
||||
extern gboolean get_qof_providers_initialized (void);
|
||||
@ -42,6 +57,10 @@ extern void (*p_qof_session_destroy_backend) (QofSession * session);
|
||||
|
||||
extern void init_static_qofsession_pointers (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
QofSession *session;
|
||||
@ -464,11 +483,10 @@ test_qof_session_save (Fixture *fixture, gconstpointer pData)
|
||||
QofBackend *be = NULL;
|
||||
QofBackendProvider *prov = NULL, *reg_prov = NULL;
|
||||
|
||||
g_test_message ("Test when book not partial and backend not set");
|
||||
g_test_message ("Test when backend not set");
|
||||
g_assert (fixture->session->backend == NULL);
|
||||
book = qof_session_get_book (fixture->session);
|
||||
g_assert (book);
|
||||
qof_book_set_data (book, PARTIAL_QOFBOOK, GINT_TO_POINTER (FALSE));
|
||||
qof_session_push_error (fixture->session, ERR_BACKEND_DATA_CORRUPT, "push any error");
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
qof_session_save (fixture->session, NULL);
|
||||
@ -476,7 +494,7 @@ test_qof_session_save (Fixture *fixture, gconstpointer pData)
|
||||
g_assert_cmpstr (qof_session_get_error_message (fixture->session), == , "failed to load backend");
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
|
||||
g_test_message ("Test when book not partial and backend set; imitate error");
|
||||
g_test_message ("Test when backend set; imitate error");
|
||||
be = g_new0 (QofBackend, 1);
|
||||
g_assert (be);
|
||||
be->sync = mock_sync;
|
||||
@ -495,7 +513,7 @@ test_qof_session_save (Fixture *fixture, gconstpointer pData)
|
||||
g_assert_cmpint (qof_session_get_error (fixture->session), == , ERR_BACKEND_DATA_CORRUPT);
|
||||
g_assert_cmpstr (qof_session_get_error_message (fixture->session), == , "");
|
||||
|
||||
g_test_message ("Test when book not partial and backend set; successful save");
|
||||
g_test_message ("Test when backend set; successful save");
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
session_save_struct.sync_called = FALSE;
|
||||
qof_session_save (fixture->session, percentage_fn);
|
||||
@ -509,49 +527,6 @@ test_qof_session_save (Fixture *fixture, gconstpointer pData)
|
||||
* code probably should be moved to separate routine or some existing code can be reused
|
||||
* for example: qof_session_load_backend
|
||||
*/
|
||||
g_test_message ("Test when book is partial and current backend supports it; successful save backend not changed");
|
||||
prov = g_new0 (QofBackendProvider, 1);
|
||||
prov->partial_book_supported = TRUE;
|
||||
fixture->session->backend->provider = prov;
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
qof_book_set_data (book, PARTIAL_QOFBOOK, GINT_TO_POINTER (TRUE));
|
||||
session_save_struct.sync_called = FALSE;
|
||||
qof_session_save (fixture->session, percentage_fn);
|
||||
g_assert (fixture->session->backend == be);
|
||||
g_assert (fixture->session->backend->provider == prov);
|
||||
g_assert (qof_book_get_backend (book) == be);
|
||||
g_assert (be->percentage == percentage_fn);
|
||||
g_assert (session_save_struct.sync_called);
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
g_assert_cmpint (qof_session_get_error (fixture->session), == , ERR_BACKEND_NO_ERR);
|
||||
|
||||
g_test_message ("Test when book is partial and current backend does not support it; backend should be changed");
|
||||
prov->partial_book_supported = FALSE;
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
reg_prov = g_new0 (QofBackendProvider, 1);
|
||||
reg_prov->partial_book_supported = TRUE;
|
||||
reg_prov->backend_new = mock_backend_new_for_save;
|
||||
qof_backend_register_provider (reg_prov);
|
||||
g_assert_cmpint (g_slist_length (get_provider_list ()), == , 1);
|
||||
session_save_struct.book = book;
|
||||
session_save_struct.session = fixture->session;
|
||||
fixture->session->book_id = g_strdup ("my book");
|
||||
session_save_struct.book_id = "my book";
|
||||
session_save_struct.sync_called = FALSE;
|
||||
session_save_struct.backend_new_called = FALSE;
|
||||
session_save_struct.session_begin_called = FALSE;
|
||||
|
||||
qof_session_save (fixture->session, percentage_fn);
|
||||
|
||||
g_assert (session_save_struct.backend_new_called);
|
||||
g_assert (fixture->session->backend == session_save_struct.be);
|
||||
g_assert (fixture->session->backend->provider == reg_prov);
|
||||
g_assert (fixture->session->book_id == NULL);
|
||||
g_assert (session_save_struct.session_begin_called);
|
||||
g_assert (qof_book_get_backend (book) == session_save_struct.be);
|
||||
g_assert (session_save_struct.sync_called);
|
||||
g_assert_cmpint (fixture->session->lock, == , 1);
|
||||
g_assert_cmpint (qof_session_get_error (fixture->session), == , ERR_BACKEND_NO_ERR);
|
||||
|
||||
unregister_all_providers ();
|
||||
g_free (prov);
|
||||
|
Loading…
Reference in New Issue
Block a user