mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
reverting lib/libqof changes to prepare for svn move
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@11885 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
2005-11-07 Neil Williams <linux@codehelp.co.uk>
|
||||
|
||||
* configure.in : Adapt internal QOF build
|
||||
variables for new locations.
|
||||
* src/backend/Makefile.am : remove qsf/
|
||||
* src/engine/Makefile.am : remove QOF files.
|
||||
* lib/Makefile.am : New directory.
|
||||
|
||||
2005-11-07 Neil Williams <linux@codehelp.co.uk>
|
||||
|
||||
* src/engine/gnc-budget.c : Remove unnecessary
|
||||
|
18
configure.in
18
configure.in
@@ -417,13 +417,11 @@ else
|
||||
fi
|
||||
if test x$QOF_XML_DIR = x; then
|
||||
AC_MSG_RESULT([no, will use internal QOF code])
|
||||
QOF_LIB_DIR=`eval echo $libdir | sed "s%^NONE%$prefix%"`
|
||||
QOF_LIB_DIR=`eval echo $QOF_LIB_DIR | sed "s%^NONE%$prefix%"`
|
||||
QOF_CFLAGS="-I\${top_srcdir}/lib/libqof/qof"
|
||||
QOF_LIBS="\${top_srcdir}/lib/libqof/qof/libqof.la"
|
||||
# QOF_LIB_DIR=`eval echo ${libdir}`
|
||||
QOF_CFLAGS="-I\${top_srcdir}/src/engine"
|
||||
QOF_LIBS="\${top_srcdir}/src/engine/libqof.la"
|
||||
QOF_LIB_DIR="${libdir}"
|
||||
QOF_PREFIX="internal"
|
||||
QOF_XML_DIR=`eval echo ${datadir}/xml/qsf`
|
||||
QOF_XML_DIR="$QSF_SCHEMA_DIR"
|
||||
LIBQOF_LIBRARY_VERSION=1:1:0
|
||||
LIBQOF_BACKEND_QSF_LIBRARY_VERSION=0:0:0
|
||||
AC_SUBST(LIBQOF_LIBRARY_VERSION)
|
||||
@@ -441,7 +439,6 @@ AC_SUBST(QOF_LIBS)
|
||||
AS_SCRUB_INCLUDE(QOF_PREFIX)
|
||||
AC_SUBST(QOF_PREFIX)
|
||||
AC_SUBST(QOF_LIB_DIR)
|
||||
AC_SUBST(QOF_XML_DIR)
|
||||
|
||||
### --------------------------------------------------------------------------
|
||||
### for GOG/goffice...
|
||||
@@ -550,6 +547,7 @@ fi
|
||||
|
||||
GNC_ACCOUNTS_DIR='${GNC_SHAREDIR}/accounts'
|
||||
GNC_GLADE_DIR='${GNC_SHAREDIR}/glade'
|
||||
QSF_SCHEMA_DIR='${GNC_SHAREDIR}/xml/qsf'
|
||||
GNC_UI_DIR='${GNC_SHAREDIR}/ui'
|
||||
GNC_GWRAP_LIBDIR='${GNC_SHAREDIR}/guile-modules/g-wrapped'
|
||||
GNC_MODULE_DIR='${pkglibdir}'
|
||||
@@ -559,6 +557,7 @@ AC_SUBST(GNC_ACCOUNTS_DIR)
|
||||
AC_SUBST(GNC_CONFIGDIR)
|
||||
AC_SUBST(GNC_DOC_INSTALL_DIR)
|
||||
AC_SUBST(GNC_GLADE_DIR)
|
||||
AC_SUBST(QSF_SCHEMA_DIR)
|
||||
AC_SUBST(GNC_UI_DIR)
|
||||
AC_SUBST(GNC_GWRAP_LIBDIR)
|
||||
AC_SUBST(GNC_INCLUDE_DIR)
|
||||
@@ -1287,10 +1286,6 @@ AC_CONFIG_FILES(po/Makefile.in
|
||||
lib/goffice/pixmaps/Makefile
|
||||
lib/goffice/cut-n-paste/Makefile
|
||||
lib/goffice/cut-n-paste/pcre/Makefile
|
||||
lib/libqof/Makefile
|
||||
lib/libqof/qof/Makefile
|
||||
lib/libqof/backend/Makefile
|
||||
lib/libqof/backend/file/Makefile
|
||||
rpm/Makefile
|
||||
src/Makefile
|
||||
src/app-utils/Makefile
|
||||
@@ -1301,6 +1296,7 @@ AC_CONFIG_FILES(po/Makefile.in
|
||||
src/backend/file/test/Makefile
|
||||
src/backend/file/test/test-files/Makefile
|
||||
src/backend/file/test/test-files/xml2/Makefile
|
||||
src/backend/qsf/Makefile
|
||||
src/backend/postgres/Makefile
|
||||
src/backend/postgres/test/Makefile
|
||||
src/backend/rpc/Makefile
|
||||
|
@@ -1,15 +1,7 @@
|
||||
SUBDIRS = libc glib26 guile-www srfi
|
||||
|
||||
if USE_LIBGOFFICE
|
||||
SUBDIRS +=
|
||||
SUBDIRS = libc glib26 guile-www srfi
|
||||
else
|
||||
SUBDIRS += goffice
|
||||
endif
|
||||
|
||||
if USE_LIBQOF
|
||||
SUBDIRS += libqof
|
||||
else
|
||||
SUBDIRS +=
|
||||
SUBDIRS = libc glib26 guile-www srfi goffice
|
||||
endif
|
||||
|
||||
EXTRA_DIST = README guppi-legend.patch
|
||||
|
@@ -1,2 +0,0 @@
|
||||
SUBDIRS = . qof backend
|
||||
|
@@ -1,2 +0,0 @@
|
||||
SUBDIRS = file
|
||||
|
@@ -1,90 +0,0 @@
|
||||
lib_LTLIBRARIES = libqof.la
|
||||
|
||||
libqof_la_LDFLAGS= -version-info $(LIBQOF_LIBRARY_VERSION)
|
||||
|
||||
AM_CFLAGS = \
|
||||
-I. \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
libqof_la_SOURCES = \
|
||||
gnc-date.c \
|
||||
gnc-engine-util.c \
|
||||
gnc-numeric.c \
|
||||
gnc-event.c \
|
||||
gnc-trace.c \
|
||||
guid.c \
|
||||
kvp_frame.c \
|
||||
kvp-util.c \
|
||||
md5.c \
|
||||
qofbackend.c \
|
||||
qofclass.c \
|
||||
qofchoice.c \
|
||||
qofgobj.c \
|
||||
qofid.c \
|
||||
qofinstance.c \
|
||||
qofquery.c \
|
||||
qofbook.c \
|
||||
qofobject.c \
|
||||
qofquerycore.c \
|
||||
qofsession.c \
|
||||
qof_book_merge.c
|
||||
|
||||
qofincludedir = ${pkgincludedir}
|
||||
|
||||
qofinclude_HEADERS = \
|
||||
gnc-date.h \
|
||||
gnc-engine-util.h \
|
||||
gnc-numeric.h \
|
||||
gnc-event.h \
|
||||
gnc-trace.h \
|
||||
guid.h \
|
||||
kvp_frame.h \
|
||||
kvp-util.h \
|
||||
kvp-util-p.h \
|
||||
qof.h \
|
||||
qof-be-utils.h \
|
||||
qofbackend.h \
|
||||
qofbackend-p.h \
|
||||
qofclass.h \
|
||||
qofchoice.h \
|
||||
qofgobj.h \
|
||||
qofid.h \
|
||||
qofid-p.h \
|
||||
qofinstance-p.h \
|
||||
qofinstance.h \
|
||||
qofquery.h \
|
||||
qofbook.h \
|
||||
qofobject.h \
|
||||
qofquerycore.h \
|
||||
qofsession.h \
|
||||
qofla-dir.h \
|
||||
qof_book_merge.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
gnc-event-p.h \
|
||||
md5.h \
|
||||
qofclass-p.h \
|
||||
qofmath128.h \
|
||||
qofquery-p.h \
|
||||
qofquery-deserial.h \
|
||||
qofquery-serialize.h \
|
||||
qofbook-p.h \
|
||||
qofobject-p.h \
|
||||
qofquerycore-p.h \
|
||||
qofsession-p.h
|
||||
|
||||
QOFLIBdir = $(libdir)
|
||||
|
||||
EXTRA_DIST = \
|
||||
qofla-dir.h.in \
|
||||
qofmath128.c
|
||||
|
||||
qofla-dir.h: qofla-dir.h.in
|
||||
rm -f $@.tmp
|
||||
sed < $< > $@.tmp \
|
||||
-e 's:@-libdir-@:${QOFLIBdir}:g'
|
||||
mv $@.tmp $@
|
||||
|
||||
BUILT_SOURCES = qofla-dir.h
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,515 +0,0 @@
|
||||
/********************************************************************
|
||||
* gnc-numeric.h - A rational number library *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
*******************************************************************/
|
||||
|
||||
/** @addtogroup Numeric
|
||||
|
||||
The 'Numeric' functions provide a way of working with rational
|
||||
numbers while maintaining strict control over rounding errors
|
||||
when adding rationals with different denominators. The Numeric
|
||||
class is primarily used for working with monetary amounts,
|
||||
where the denominator typically represents the smallest fraction
|
||||
of the currency (e.g. pennies, centimes). The numeric class
|
||||
can handle any fraction (e.g. twelfth's) and is not limited
|
||||
to fractions that are powers of ten.
|
||||
|
||||
A 'Numeric' value represents a number in rational form, with a
|
||||
64-bit integer as numerator and denominator. Rationals are
|
||||
ideal for many uses, such as performing exact, roundoff-error-free
|
||||
addition and multiplication, but 64-bit rationals do not have
|
||||
the dynamic range of floating point numbers.
|
||||
|
||||
EXAMPLE\n
|
||||
-------\n
|
||||
The following program finds the best ::gnc_numeric approximation to
|
||||
the \a math.h constant \a M_PI given a maximum denominator. For
|
||||
large denominators, the ::gnc_numeric approximation is accurate to
|
||||
more decimal places than will generally be needed, but in some cases
|
||||
this may not be good enough. For example,
|
||||
|
||||
@verbatim
|
||||
M_PI = 3.14159265358979323846
|
||||
245850922 / 78256779 = 3.14159265358979311599 (16 sig figs)
|
||||
3126535 / 995207 = 3.14159265358865047446 (12 sig figs)
|
||||
355 / 113 = 3.14159292035398252096 (7 sig figs)
|
||||
@endverbatim
|
||||
|
||||
@verbatim
|
||||
#include <glib.h>
|
||||
#include "gnc-numeric.h"
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
gnc_numeric approx, best;
|
||||
double err, best_err=1.0;
|
||||
double m_pi = M_PI;
|
||||
gint64 denom;
|
||||
gint64 max;
|
||||
|
||||
sscanf(argv[1], "%Ld", &max);
|
||||
|
||||
for (denom = 1; denom < max; denom++)
|
||||
{
|
||||
approx = double_to_gnc_numeric (m_pi, denom, GNC_RND_ROUND);
|
||||
err = m_pi - gnc_numeric_to_double (approx);
|
||||
if (fabs (err) < fabs (best_err))
|
||||
{
|
||||
best = approx;
|
||||
best_err = err;
|
||||
printf ("%Ld / %Ld = %.30f\n", gnc_numeric_num (best),
|
||||
gnc_numeric_denom (best), gnc_numeric_to_double (best));
|
||||
}
|
||||
}
|
||||
}
|
||||
@endverbatim
|
||||
|
||||
@{ */
|
||||
/** @file gnc-numeric.h
|
||||
@brief An exact-rational-number library for gnucash.
|
||||
@author Copyright (C) 2000 Bill Gribble
|
||||
@author Copyright (C) 2004 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNC_NUMERIC_H
|
||||
#define GNC_NUMERIC_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct _gnc_numeric
|
||||
{
|
||||
gint64 num;
|
||||
gint64 denom;
|
||||
};
|
||||
|
||||
/** @brief An rational-number type
|
||||
*
|
||||
* This is a rational number, defined by numerator and denominator. */
|
||||
typedef struct _gnc_numeric gnc_numeric;
|
||||
|
||||
/** @name Arguments Standard Arguments to most functions
|
||||
|
||||
Most of the gnc_numeric arithmetic functions take two arguments
|
||||
in addition to their numeric args: 'denom', which is the denominator
|
||||
to use in the output gnc_numeric object, and 'how'. which
|
||||
describes how the arithmetic result is to be converted to that
|
||||
denominator. This combination of output denominator and rounding policy
|
||||
allows the results of financial and other rational computations to be
|
||||
properly rounded to the appropriate units.
|
||||
|
||||
Valid values for denom are:
|
||||
GNC_DENOM_AUTO -- compute denominator exactly
|
||||
integer n -- Force the denominator of teh result to be this integer
|
||||
GNC_DENOM_RECIPROCAL -- Use 1/n as the denominator (???huh???)
|
||||
|
||||
Valid values for 'how' are bitwise combinations of zero or one
|
||||
"rounding instructions" with zero or one "denominator types".
|
||||
Valid rounding instructions are:
|
||||
GNC_HOW_RND_FLOOR
|
||||
GNC_HOW_RND_CEIL
|
||||
GNC_HOW_RND_TRUNC
|
||||
GNC_HOW_RND_PROMOTE
|
||||
GNC_HOW_RND_ROUND_HALF_DOWN
|
||||
GNC_HOW_RND_ROUND_HALF_UP
|
||||
GNC_HOW_RND_ROUND
|
||||
GNC_HOW_RND_NEVER
|
||||
|
||||
The denominator type specifies how to compute a denominator if
|
||||
GNC_DENOM_AUTO is specified as the 'denom'. Valid
|
||||
denominator types are:
|
||||
GNC_HOW_DENOM_EXACT
|
||||
GNC_HOW_DENOM_REDUCE
|
||||
GNC_HOW_DENOM_LCD
|
||||
GNC_HOW_DENOM_FIXED
|
||||
GNC_HOW_DENOM_SIGFIGS(N)
|
||||
|
||||
To use traditional rational-number operational semantics (all results
|
||||
are exact and are reduced to relatively-prime fractions) pass the
|
||||
argument GNC_DENOM_AUTO as 'denom' and
|
||||
GNC_HOW_DENOM_REDUCE| GNC_HOW_RND_NEVER as 'how'.
|
||||
|
||||
To enforce strict financial semantics (such that all operands must have
|
||||
the same denominator as each other and as the result), use
|
||||
GNC_DENOM_AUTO as 'denom' and
|
||||
GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER as 'how'.
|
||||
@{
|
||||
*/
|
||||
|
||||
/** \brief bitmasks for HOW flags.
|
||||
|
||||
* bits 8-15 of 'how' are reserved for the number of significant
|
||||
* digits to use in the output with GNC_HOW_DENOM_SIGFIG
|
||||
*/
|
||||
#define GNC_NUMERIC_RND_MASK 0x0000000f
|
||||
#define GNC_NUMERIC_DENOM_MASK 0x000000f0
|
||||
#define GNC_NUMERIC_SIGFIGS_MASK 0x0000ff00
|
||||
|
||||
/** \brief Rounding/Truncation modes for operations.
|
||||
|
||||
* Rounding instructions control how fractional parts in the specified
|
||||
* denominator affect the result. For example, if a computed result is
|
||||
* "3/4" but the specified denominator for the return value is 2, should
|
||||
* the return value be "1/2" or "2/2"?
|
||||
*
|
||||
* Possible rounding instructions are:
|
||||
*/
|
||||
enum {
|
||||
/** Round toward -infinity */
|
||||
GNC_HOW_RND_FLOOR = 0x01,
|
||||
|
||||
/** Round toward +infinity */
|
||||
GNC_HOW_RND_CEIL = 0x02,
|
||||
|
||||
/** Truncate fractions (round toward zero) */
|
||||
GNC_HOW_RND_TRUNC = 0x03,
|
||||
|
||||
/** Promote fractions (round away from zero) */
|
||||
GNC_HOW_RND_PROMOTE = 0x04,
|
||||
|
||||
/** Round to the nearest integer, rounding toward zero
|
||||
* when there are two equidistant nearest integers.
|
||||
*/
|
||||
GNC_HOW_RND_ROUND_HALF_DOWN = 0x05,
|
||||
|
||||
/** Round to the nearest integer, rounding away from zero
|
||||
* when there are two equidistant nearest integers.
|
||||
*/
|
||||
GNC_HOW_RND_ROUND_HALF_UP = 0x06,
|
||||
|
||||
/** Use unbiased ("banker's") rounding. This rounds to the
|
||||
* nearest integer, and to the nearest even integer when there
|
||||
* are two equidistant nearest integers. This is generally the
|
||||
* one you should use for financial quantities.
|
||||
*/
|
||||
GNC_HOW_RND_ROUND = 0x07,
|
||||
|
||||
/** Never round at all, and signal an error if there is a
|
||||
* fractional result in a computation.
|
||||
*/
|
||||
GNC_HOW_RND_NEVER = 0x08
|
||||
};
|
||||
|
||||
/** How to compute a denominator, or'ed into the "how" field. */
|
||||
enum {
|
||||
/** Use any denominator which gives an exactly correct ratio of
|
||||
* numerator to denominator. Use EXACT when you do not wish to
|
||||
* lose any information in the result but also do not want to
|
||||
* spend any time finding the "best" denominator.
|
||||
*/
|
||||
GNC_HOW_DENOM_EXACT = 0x10,
|
||||
|
||||
/** Reduce the result value by common factor elimination,
|
||||
* using the smallest possible value for the denominator that
|
||||
* keeps the correct ratio. The numerator and denominator of
|
||||
* the result are relatively prime.
|
||||
*/
|
||||
GNC_HOW_DENOM_REDUCE = 0x20,
|
||||
|
||||
/** Find the least common multiple of the arguments' denominators
|
||||
* and use that as the denominator of the result.
|
||||
*/
|
||||
GNC_HOW_DENOM_LCD = 0x30,
|
||||
|
||||
/** All arguments are required to have the same denominator,
|
||||
* that denominator is to be used in the output, and an error
|
||||
* is to be signaled if any argument has a different denominator.
|
||||
*/
|
||||
GNC_HOW_DENOM_FIXED = 0x40,
|
||||
|
||||
/** Round to the number of significant figures given in the rounding
|
||||
* instructions by the GNC_HOW_DENOM_SIGFIGS () macro.
|
||||
*/
|
||||
GNC_HOW_DENOM_SIGFIG = 0x50
|
||||
};
|
||||
|
||||
/** Build a 'how' value that will generate a denominator that will
|
||||
* keep at least n significant figures in the result.
|
||||
*/
|
||||
#define GNC_HOW_DENOM_SIGFIGS( n ) ( ((( n ) & 0xff) << 8) | GNC_HOW_DENOM_SIGFIG)
|
||||
#define GNC_HOW_GET_SIGFIGS( a ) ( (( a ) & 0xff00 ) >> 8)
|
||||
|
||||
/** Error codes */
|
||||
typedef enum {
|
||||
GNC_ERROR_OK = 0, /**< No error */
|
||||
GNC_ERROR_ARG = -1, /**< Argument is not a valid number */
|
||||
GNC_ERROR_OVERFLOW = -2, /**< Intermediate result overflow */
|
||||
|
||||
/** GNC_HOW_DENOM_FIXED was specified, but argument denominators differed. */
|
||||
GNC_ERROR_DENOM_DIFF = -3,
|
||||
|
||||
/** GNC_HOW_RND_NEVER was specified, but the result could not be
|
||||
* converted to the desired denominator without a remainder. */
|
||||
GNC_ERROR_REMAINDER = -4
|
||||
} GNCNumericErrorCode;
|
||||
|
||||
|
||||
/** Values that can be passed as the 'denom' argument.
|
||||
* The include a positive number n to be used as the
|
||||
* denominator of teh output value. Other possibilities
|
||||
* include the list below:
|
||||
*/
|
||||
|
||||
/** Compute an appropriate denominator automatically. Flags in
|
||||
* the 'how' argument will specify how to compute the denominator.
|
||||
*/
|
||||
#define GNC_DENOM_AUTO 0
|
||||
|
||||
/** Use the value 1/n as the denominator of the output value. */
|
||||
#define GNC_DENOM_RECIPROCAL( a ) (- ( a ))
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name Constructors
|
||||
@{
|
||||
*/
|
||||
/** Make a gnc_numeric from numerator and denominator */
|
||||
static inline
|
||||
gnc_numeric gnc_numeric_create(gint64 num, gint64 denom) {
|
||||
gnc_numeric out;
|
||||
out.num = num;
|
||||
out.denom = denom;
|
||||
return out;
|
||||
}
|
||||
|
||||
/** create a zero-value gnc_numeric */
|
||||
static inline
|
||||
gnc_numeric gnc_numeric_zero(void) { return gnc_numeric_create(0, 1); }
|
||||
|
||||
/** Convert a floating-point number to a gnc_numeric.
|
||||
* Both 'denom' and 'how' are used as in arithmetic,
|
||||
* but GNC_DENOM_AUTO is not recognized; a denominator
|
||||
* must be specified either explicitctly or through sigfigs.
|
||||
*/
|
||||
gnc_numeric double_to_gnc_numeric(double in, gint64 denom,
|
||||
gint how);
|
||||
|
||||
/** Read a gnc_numeric from str, skipping any leading whitespace.
|
||||
* Return TRUE on success and store the resulting value in "n".
|
||||
* Return NULL on error. */
|
||||
gboolean string_to_gnc_numeric(const gchar* str, gnc_numeric *n);
|
||||
|
||||
/** Create a gnc_numeric object that signals the error condition
|
||||
* noted by error_code, rather than a number.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_error(GNCNumericErrorCode error_code);
|
||||
/** @} */
|
||||
|
||||
/** @name Value Accessors
|
||||
@{
|
||||
*/
|
||||
/** Return numerator */
|
||||
static inline
|
||||
gint64 gnc_numeric_num(gnc_numeric a) { return a.num; }
|
||||
/** Return denominator */
|
||||
static inline
|
||||
gint64 gnc_numeric_denom(gnc_numeric a) { return a.denom; }
|
||||
|
||||
/** Convert numeric to floating-point value. */
|
||||
double gnc_numeric_to_double(gnc_numeric in);
|
||||
|
||||
/** Convert to string. The returned buffer is to be g_free'd by the
|
||||
* caller (it was allocated through g_strdup) */
|
||||
gchar *gnc_numeric_to_string(gnc_numeric n);
|
||||
|
||||
/** Convert to string. Uses a static, non-thread-safe buffer.
|
||||
* For internal use only. */
|
||||
gchar * gnc_num_dbg_to_string(gnc_numeric n);
|
||||
/** @}*/
|
||||
|
||||
/** @name Comparisons and Predicates
|
||||
@{
|
||||
*/
|
||||
/** Check for error signal in value. Returns GNC_ERROR_OK (==0) if
|
||||
* the number appears to be valid, otherwise it returns the
|
||||
* type of error. Error values always have a denominator of zero.
|
||||
*/
|
||||
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a);
|
||||
|
||||
/** Returns 1 if a>b, -1 if b>a, 0 if a == b */
|
||||
int gnc_numeric_compare(gnc_numeric a, gnc_numeric b);
|
||||
|
||||
/** Returns 1 if the given gnc_numeric is 0 (zero), else returns 0. */
|
||||
gboolean gnc_numeric_zero_p(gnc_numeric a);
|
||||
|
||||
/** Returns 1 if a < 0, otherwise returns 0. */
|
||||
gboolean gnc_numeric_negative_p(gnc_numeric a);
|
||||
|
||||
/** Returns 1 if a > 0, otherwise returns 0. */
|
||||
gboolean gnc_numeric_positive_p(gnc_numeric a);
|
||||
|
||||
/** Equivalence predicate: Returns TRUE (1) if a and b are
|
||||
* exactly the same (have the same numerator and denominator)
|
||||
*/
|
||||
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b);
|
||||
|
||||
/** Equivalence predicate: Returns TRUE (1) if a and b represent
|
||||
* the same number. That is, return TRUE if the ratios, when
|
||||
* reduced by eliminating common factors, are identical.
|
||||
*/
|
||||
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b);
|
||||
|
||||
/** Equivalence predicate:
|
||||
* Convert both a and b to denom using the
|
||||
* specified DENOM and method HOW, and compare numerators
|
||||
* the results using gnc_numeric_equal.
|
||||
*
|
||||
For example, if a == 7/16 and b == 3/4,
|
||||
gnc_numeric_same(a, b, 2, GNC_HOW_RND_TRUNC) == 1
|
||||
because both 7/16 and 3/4 round to 1/2 under truncation. However,
|
||||
gnc_numeric_same(a, b, 2, GNC_HOW_RND_ROUND) == 0
|
||||
because 7/16 rounds to 1/2 under unbiased rounding but 3/4 rounds
|
||||
to 2/2.
|
||||
*/
|
||||
int gnc_numeric_same(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how);
|
||||
/** @} */
|
||||
|
||||
/** @name Arithmetic Operations
|
||||
@{
|
||||
*/
|
||||
/** Return a+b. */
|
||||
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how);
|
||||
|
||||
/** Return a-b. */
|
||||
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how);
|
||||
|
||||
/** Multiply a times b, returning the product. An overflow
|
||||
* may occur if the result of the multiplication can't
|
||||
* be represented as a ratio of 64-bit int's after removing
|
||||
* common factors.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how);
|
||||
|
||||
/** Division. Note that division can overflow, in the following
|
||||
* sense: if we write x=a/b and y=c/d then x/y = (a*d)/(b*c)
|
||||
* If, after eliminating all common factors between the numerator
|
||||
* (a*d) and the denominator (b*c), then if either the numerator
|
||||
* and/or the denominator are *still* greater than 2^63, then
|
||||
* the division has overflowed.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y,
|
||||
gint64 denom, gint how);
|
||||
/** Negate the argument */
|
||||
gnc_numeric gnc_numeric_neg(gnc_numeric a);
|
||||
|
||||
/** Return the absolute value of the argument */
|
||||
gnc_numeric gnc_numeric_abs(gnc_numeric a);
|
||||
|
||||
/**
|
||||
* Shortcut for common case: gnc_numeric_add(a, b, GNC_DENOM_AUTO,
|
||||
* GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
|
||||
*/
|
||||
static inline
|
||||
gnc_numeric gnc_numeric_add_fixed(gnc_numeric a, gnc_numeric b) {
|
||||
return gnc_numeric_add(a, b, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for most common case: gnc_numeric_sub(a, b, GNC_DENOM_AUTO,
|
||||
* GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
|
||||
*/
|
||||
static inline
|
||||
gnc_numeric gnc_numeric_sub_fixed(gnc_numeric a, gnc_numeric b) {
|
||||
return gnc_numeric_sub(a, b, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/** @name Arithmetic Functions with Exact Error Returns
|
||||
@{
|
||||
*/
|
||||
/** The same as gnc_numeric_add, but uses 'error' for accumulating
|
||||
* conversion roundoff error. */
|
||||
gnc_numeric gnc_numeric_add_with_error(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how,
|
||||
gnc_numeric * error);
|
||||
|
||||
/** The same as gnc_numeric_sub, but uses error for accumulating
|
||||
* conversion roundoff error. */
|
||||
gnc_numeric gnc_numeric_sub_with_error(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how,
|
||||
gnc_numeric * error);
|
||||
|
||||
/** The same as gnc_numeric_mul, but uses error for
|
||||
* accumulating conversion roundoff error.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_mul_with_error(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how,
|
||||
gnc_numeric * error);
|
||||
|
||||
/** The same as gnc_numeric_div, but uses error for
|
||||
* accumulating conversion roundoff error.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_div_with_error(gnc_numeric a, gnc_numeric b,
|
||||
gint64 denom, gint how,
|
||||
gnc_numeric * error);
|
||||
/** @} */
|
||||
|
||||
/** @name Change Denominator
|
||||
@{
|
||||
*/
|
||||
/** Change the denominator of a gnc_numeric value to the
|
||||
* specified denominator under standard arguments
|
||||
* 'denom' and 'how'.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_convert(gnc_numeric in, gint64 denom,
|
||||
gint how);
|
||||
|
||||
/** Same as gnc_numeric_convert, but return a remainder
|
||||
* value for accumulating conversion error.
|
||||
*/
|
||||
gnc_numeric gnc_numeric_convert_with_error(gnc_numeric in, gint64 denom,
|
||||
gint how,
|
||||
gnc_numeric * error);
|
||||
|
||||
/** Return input after reducing it by Greated Common Factor (GCF)
|
||||
* elimination */
|
||||
gnc_numeric gnc_numeric_reduce(gnc_numeric in);
|
||||
/** @} */
|
||||
|
||||
/** @name Deprecated, backwards-compatible definitions
|
||||
@{
|
||||
*/
|
||||
#define GNC_RND_FLOOR GNC_HOW_RND_FLOOR
|
||||
#define GNC_RND_CEIL GNC_HOW_RND_CEIL
|
||||
#define GNC_RND_TRUNC GNC_HOW_RND_TRUNC
|
||||
#define GNC_RND_PROMOTE GNC_HOW_RND_PROMOTE
|
||||
#define GNC_RND_ROUND_HALF_DOWN GNC_HOW_RND_ROUND_HALF_DOWN
|
||||
#define GNC_RND_ROUND_HALF_UP GNC_HOW_RND_ROUND_HALF_UP
|
||||
#define GNC_RND_ROUND GNC_HOW_RND_ROUND
|
||||
#define GNC_RND_NEVER GNC_HOW_RND_NEVER
|
||||
|
||||
#define GNC_DENOM_EXACT GNC_HOW_DENOM_EXACT
|
||||
#define GNC_DENOM_REDUCE GNC_HOW_DENOM_REDUCE
|
||||
#define GNC_DENOM_LCD GNC_HOW_DENOM_LCD
|
||||
#define GNC_DENOM_FIXED GNC_HOW_DENOM_FIXED
|
||||
#define GNC_DENOM_SIGFIG GNC_HOW_DENOM_SIGFIG
|
||||
|
||||
#define GNC_DENOM_SIGFIGS(X) GNC_HOW_DENOM_SIGFIGS(X)
|
||||
#define GNC_NUMERIC_GET_SIGFIGS(X) GNC_HOW_GET_SIGFIGS(X)
|
||||
/** @} */
|
||||
/** @} */
|
||||
#endif
|
@@ -1,95 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; gnc-numeric.scm : rational number representation for gnucash
|
||||
;; Copyright 2000 Bill Gribble <grib@gnumatic.com>
|
||||
;; Copyright 2001 Christian Stimming <stimming@tu-harburg.de>
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
;; Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; use 'logior' in guile to bit-combine RND and DENOM flags.
|
||||
|
||||
(define GNC-RND-FLOOR 1)
|
||||
(define GNC-RND-CEIL 2)
|
||||
(define GNC-RND-TRUNC 3)
|
||||
(define GNC-RND-PROMOTE 4)
|
||||
(define GNC-RND-ROUND-HALF-DOWN 5)
|
||||
(define GNC-RND-ROUND-HALF-UP 6)
|
||||
(define GNC-RND-ROUND 7)
|
||||
(define GNC-RND-NEVER 8)
|
||||
|
||||
(define GNC-DENOM-AUTO 0)
|
||||
(define GNC-DENOM-REDUCE 32)
|
||||
(define GNC-DENOM-FIXED 64)
|
||||
(define GNC-DENOM-LCD 48)
|
||||
(define GNC-DENOM-SIGFIG 80)
|
||||
|
||||
(define (GNC-DENOM-SIGFIGS n)
|
||||
(logior GNC-DENOM-SIGFIG (* n 256)))
|
||||
|
||||
(define GNC-ERROR-OK 0)
|
||||
(define GNC-ERROR-ARG -1)
|
||||
(define GNC-ERROR-OVERFLOW -2)
|
||||
(define GNC-ERROR-DENOM-DIFF -3)
|
||||
(define GNC-ERROR-REMAINDER -4)
|
||||
|
||||
(define <gnc-numeric>
|
||||
(make-record-type "<gnc-numeric>"
|
||||
'(num denom)))
|
||||
|
||||
(define gnc:make-gnc-numeric
|
||||
(record-constructor <gnc-numeric>))
|
||||
|
||||
(define gnc:gnc-numeric?
|
||||
(record-predicate <gnc-numeric>))
|
||||
|
||||
(define gnc:gnc-numeric-num
|
||||
(record-accessor <gnc-numeric> 'num))
|
||||
|
||||
(define gnc:gnc-numeric-denom
|
||||
(record-accessor <gnc-numeric> 'denom))
|
||||
|
||||
(define (gnc:gnc-numeric-denom-reciprocal arg)
|
||||
(- arg))
|
||||
|
||||
|
||||
|
||||
(define <gnc-monetary>
|
||||
(make-record-type "<gnc-monetary>"
|
||||
'(commodity amount)))
|
||||
|
||||
;; Constructor; takes one <gnc:commodity*> and one <gnc-numeric>
|
||||
(define (gnc:make-gnc-monetary c a)
|
||||
(if (and (gw:wcp-is-of-type? <gnc:commodity*> c) (gnc:gnc-numeric? a))
|
||||
((record-constructor <gnc-monetary>) c a)
|
||||
(warn "wrong arguments for gnc:make-gnc-monetary: " c a)))
|
||||
|
||||
(define gnc:gnc-monetary?
|
||||
(record-predicate <gnc-monetary>))
|
||||
|
||||
(define gnc:gnc-monetary-commodity
|
||||
(record-accessor <gnc-monetary> 'commodity))
|
||||
|
||||
(define gnc:gnc-monetary-amount
|
||||
(record-accessor <gnc-monetary> 'amount))
|
||||
|
||||
(define (gnc:monetary-neg a)
|
||||
(if (gnc:gnc-monetary? a)
|
||||
(gnc:make-gnc-monetary
|
||||
(gnc:gnc-monetary-commodity a)
|
||||
(gnc:numeric-neg (gnc:gnc-monetary-amount a)))
|
||||
(warn "wrong arguments for gnc:monetary-neg: " a)))
|
@@ -1,5 +1,10 @@
|
||||
|
||||
if USE_LIBQOF
|
||||
SUBDIRS = qsf file ${SQL_DIR} ${RPC_DIR}
|
||||
DIST_SUBDIRS = qsf file net postgres rpc
|
||||
else
|
||||
SUBDIRS = file ${SQL_DIR} ${RPC_DIR}
|
||||
DIST_SUBDIRS = file net postgres rpc
|
||||
DIST_SUBDIRS = qsf file net postgres rpc
|
||||
endif
|
||||
|
||||
noinst_HEADERS = gnc-backend-api.h
|
||||
|
@@ -4,8 +4,10 @@ lib_LTLIBRARIES = libqof-backend-qsf.la
|
||||
|
||||
AM_CFLAGS = \
|
||||
-I.. -I../.. \
|
||||
-I${top_srcdir}/src/backend \
|
||||
-I${top_srcdir}/src/engine \
|
||||
-DLOCALE_DIR=\""$(datadir)/locale"\" \
|
||||
${QOF_CFLAGS} \
|
||||
-I${top_srcdir}/src/gnc-module \
|
||||
${LIBXML2_CFLAGS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
@@ -15,9 +17,8 @@ libqof_backend_qsf_la_SOURCES = \
|
||||
qsf-xml.c
|
||||
|
||||
LIBADD = \
|
||||
${QOF_LIBS} \
|
||||
${GLIB_LIBS} \
|
||||
${LIBXML2_LIBS}
|
||||
${GLIB_LIBS} \
|
||||
${LIBXML2_LIBS}
|
||||
|
||||
qsfschemadir = $(QSF_SCHEMA_DIR)
|
||||
qsfschema_DATA = \
|
||||
@@ -40,4 +41,3 @@ qsf-dir.h: qsf-dir.h.in
|
||||
BUILT_SOURCES = qsf-dir.h
|
||||
|
||||
CONFIG_CLEAN_FILES = qsf-dir.h
|
||||
|
@@ -129,11 +129,11 @@ attributeFormDefault="unqualified" xml:lang="en-GB">
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="collection" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:complexType>
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:hexBinary">
|
||||
<xsd:attribute name="type" type="xsd:string" use="required"/>
|
||||
</xsd:extension>
|
||||
<xsd:complexType>
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:hexBinary">
|
||||
<xsd:attribute name="type" type="xsd:string" use="required"/>
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
@@ -117,21 +117,21 @@ gboolean is_qsf_object_with_map_be(char *map_file, qsf_param *params)
|
||||
map_path = g_strdup_printf("%s/%s", QSF_SCHEMA_DIR, map_file);
|
||||
if(path == NULL) {
|
||||
qof_backend_set_error(params->be, ERR_FILEIO_FILE_NOT_FOUND);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
doc = xmlParseFile(path);
|
||||
if(doc == NULL) {
|
||||
qof_backend_set_error(params->be, ERR_FILEIO_PARSE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_OBJECT_SCHEMA, doc)) {
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_OBJECT_SCHEMA, doc)) {
|
||||
qof_backend_set_error(params->be, ERR_QSF_INVALID_OBJ);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
object_root = xmlDocGetRootElement(doc);
|
||||
if(map_path == NULL) {
|
||||
qof_backend_set_error(params->be, ERR_FILEIO_FILE_NOT_FOUND);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
valid.validation_table = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
map_doc = xmlParseFile(map_path);
|
||||
@@ -139,9 +139,9 @@ gboolean is_qsf_object_with_map_be(char *map_file, qsf_param *params)
|
||||
qof_backend_set_error(params->be, ERR_FILEIO_PARSE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_MAP_SCHEMA, map_doc)) {
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_MAP_SCHEMA, map_doc)) {
|
||||
qof_backend_set_error(params->be, ERR_QSF_INVALID_MAP);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
map_root = xmlDocGetRootElement(map_doc);
|
||||
valid.map_calculated_count = 0;
|
||||
@@ -250,7 +250,7 @@ gboolean is_qsf_map_be(qsf_param *params)
|
||||
}
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_MAP_SCHEMA, doc)) {
|
||||
qof_backend_set_error(params->be, ERR_QSF_INVALID_MAP);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
map_root = xmlDocGetRootElement(doc);
|
||||
map_ns = map_root->ns;
|
||||
@@ -280,7 +280,7 @@ gboolean is_qsf_map(const char *path)
|
||||
doc = xmlParseFile(path);
|
||||
if(doc == NULL) { return FALSE; }
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_MAP_SCHEMA, doc)) {
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
map_root = xmlDocGetRootElement(doc);
|
||||
map_ns = map_root->ns;
|
||||
@@ -300,7 +300,7 @@ static void
|
||||
qsf_map_default_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params )
|
||||
{
|
||||
xmlChar *qsf_enum;
|
||||
|
||||
|
||||
g_return_if_fail(params->qsf_define_hash != NULL);
|
||||
if (qsf_is_element(child, ns, MAP_DEFINE_TAG)) {
|
||||
if(NULL == g_hash_table_lookup(params->qsf_define_hash,
|
||||
@@ -325,7 +325,7 @@ qsf_map_default_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params )
|
||||
if(NULL == g_hash_table_lookup(params->qsf_default_hash,
|
||||
xmlNodeGetContent(child)))
|
||||
{
|
||||
g_hash_table_insert(params->qsf_default_hash,
|
||||
g_hash_table_insert(params->qsf_default_hash,
|
||||
xmlNodeGetContent(child), child);
|
||||
}
|
||||
else
|
||||
@@ -393,7 +393,7 @@ qsf_else_set_value(xmlNodePtr parent, GHashTable *default_hash,
|
||||
}
|
||||
|
||||
/* Handles the set tag in the map.
|
||||
This function will be overhauled once inside QOF
|
||||
This function will be overhauled once inside QOF
|
||||
QOF hook required for "Lookup in the receiving application"
|
||||
*/
|
||||
static char*
|
||||
@@ -405,12 +405,12 @@ qsf_set_handler(xmlNodePtr parent, GHashTable *default_hash,
|
||||
content = NULL;
|
||||
for(cur_node = parent->children; cur_node != NULL; cur_node = cur_node->next)
|
||||
{
|
||||
if(qsf_is_element(cur_node, params->map_ns, QSF_CONDITIONAL_SET))
|
||||
if(qsf_is_element(cur_node, params->map_ns, QSF_CONDITIONAL_SET))
|
||||
{
|
||||
content = (char*)xmlGetProp(cur_node, BAD_CAST QSF_OPTION);
|
||||
if(qsf_strings_equal(xmlGetProp(cur_node, BAD_CAST QSF_OPTION), "qsf_lookup_string"))
|
||||
if(qsf_strings_equal(xmlGetProp(cur_node, BAD_CAST QSF_OPTION), "qsf_lookup_string"))
|
||||
{
|
||||
lookup_node = (xmlNodePtr) g_hash_table_lookup(default_hash,
|
||||
lookup_node = (xmlNodePtr) g_hash_table_lookup(default_hash,
|
||||
xmlNodeGetContent(cur_node));
|
||||
content = (char*)xmlGetProp(lookup_node, BAD_CAST MAP_VALUE_ATTR);
|
||||
/** \todo FIXME: do the lookup. type is defined by output object. */
|
||||
@@ -418,9 +418,9 @@ qsf_set_handler(xmlNodePtr parent, GHashTable *default_hash,
|
||||
g_message("Lookup %s in the receiving application\n", content );
|
||||
return content;
|
||||
}
|
||||
if(content)
|
||||
if(content)
|
||||
{
|
||||
lookup_node = (xmlNodePtr) g_hash_table_lookup(default_hash,
|
||||
lookup_node = (xmlNodePtr) g_hash_table_lookup(default_hash,
|
||||
xmlNodeGetContent(cur_node));
|
||||
content = (char*)xmlGetProp(lookup_node, BAD_CAST "value");
|
||||
return content;
|
||||
@@ -558,7 +558,7 @@ qsf_calculate_conditional(xmlNodePtr param_node, xmlNodePtr child, qsf_param *pa
|
||||
BAD_CAST QSF_BOOLEAN_DEFAULT) ), BAD_CAST MAP_VALUE_ATTR);
|
||||
}
|
||||
/* Is the default set to true? */
|
||||
if( 0 == qsf_compare_tag_strings(output_content, QSF_XML_BOOLEAN_TEST))
|
||||
if( 0 == qsf_compare_tag_strings(output_content, QSF_XML_BOOLEAN_TEST))
|
||||
{
|
||||
qsf_boolean_set_value(param_node, params, (char*)output_content, params->map_ns);
|
||||
export_node = xmlAddChild(params->lister, xmlNewNode(params->qsf_ns,
|
||||
@@ -608,7 +608,7 @@ qsf_map_object_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params)
|
||||
if(child == NULL) { return; }
|
||||
if(ns == NULL) { return; }
|
||||
params->boolean_calculation_done = 0;
|
||||
|
||||
|
||||
if(qsf_is_element(child, map_ns, MAP_CALCULATE_TAG)) {
|
||||
params->boolean_calculation_done = 0;
|
||||
for(param_node = child->children; param_node != NULL;
|
||||
@@ -668,7 +668,7 @@ qsf_map_object_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params)
|
||||
xmlGetProp(child_node, MAP_VALUE_ATTR), child_node->name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
is_qsf_object_with_map(path, map_path);
|
||||
*/
|
||||
}
|
@@ -169,7 +169,7 @@ gboolean is_our_qsf_object(const char *path)
|
||||
iter.ns = object_root->ns;
|
||||
qsf_valid_foreach(object_root, qsf_object_validation_handler, &iter, &valid);
|
||||
table_count = g_hash_table_size(valid.validation_table);
|
||||
g_hash_table_destroy(valid.validation_table);
|
||||
g_hash_table_destroy(valid.validation_table);
|
||||
if(table_count == valid.qof_registered_count) { return TRUE; }
|
||||
return FALSE;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ gboolean is_our_qsf_object_be(qsf_param *params)
|
||||
qof_backend_set_error(params->be, ERR_FILEIO_PARSE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_OBJECT_SCHEMA, doc))
|
||||
if(TRUE != qsf_is_valid(QSF_SCHEMA_DIR, QSF_OBJECT_SCHEMA, doc))
|
||||
{
|
||||
qof_backend_set_error(params->be, ERR_QSF_INVALID_OBJ);
|
||||
return FALSE;
|
@@ -12,6 +12,103 @@ AM_CFLAGS = \
|
||||
${QOF_CFLAGS} \
|
||||
${GNUCASH_ENGINE_CFLAGS}
|
||||
|
||||
qof_library = \
|
||||
gnc-date.c \
|
||||
gnc-engine-util.c \
|
||||
gnc-numeric.c \
|
||||
gnc-event.c \
|
||||
gnc-trace.c \
|
||||
guid.c \
|
||||
kvp_frame.c \
|
||||
kvp-util.c \
|
||||
md5.c \
|
||||
qofbackend.c \
|
||||
qofclass.c \
|
||||
qofchoice.c \
|
||||
qofid.c \
|
||||
qofinstance.c \
|
||||
qofquery.c \
|
||||
qofbook.c \
|
||||
qofobject.c \
|
||||
qofquerycore.c \
|
||||
qofsession.c \
|
||||
qof_book_merge.c
|
||||
|
||||
qof_headers = \
|
||||
gnc-date.h \
|
||||
gnc-engine-util.h \
|
||||
gnc-numeric.h \
|
||||
gnc-event.h \
|
||||
gnc-trace.h \
|
||||
guid.h \
|
||||
kvp_frame.h \
|
||||
kvp-util.h \
|
||||
kvp-util-p.h \
|
||||
qof.h \
|
||||
qof-be-utils.h \
|
||||
qofbackend.h \
|
||||
qofbackend-p.h \
|
||||
qofclass.h \
|
||||
qofchoice.h \
|
||||
qofid.h \
|
||||
qofid-p.h \
|
||||
qofinstance-p.h \
|
||||
qofinstance.h \
|
||||
qofquery.h \
|
||||
qofbook.h \
|
||||
qofobject.h \
|
||||
qofquerycore.h \
|
||||
qofsession.h \
|
||||
qof_book_merge.h
|
||||
|
||||
qof_noinst_headers = \
|
||||
gnc-event-p.h \
|
||||
md5.h \
|
||||
qofclass-p.h \
|
||||
qofmath128.h \
|
||||
qofquery-p.h \
|
||||
qofbook-p.h \
|
||||
qofobject-p.h \
|
||||
qofquerycore-p.h \
|
||||
qofsession-p.h \
|
||||
qofsql.h
|
||||
|
||||
if USE_LIBQOF
|
||||
|
||||
lib_LTLIBRARIES = libqof.la
|
||||
|
||||
libqof_la_LDFLAGS= -version-info $(LIBQOF_LIBRARY_VERSION)
|
||||
|
||||
libqof_la_SOURCES = ${qof_library}
|
||||
|
||||
qofincludedir = ${pkgincludedir}
|
||||
|
||||
qofinclude_HEADERS = ${qof_headers}
|
||||
|
||||
nodist_qofinclude_HEADERS = qofla-dir.h
|
||||
|
||||
QOFLIBdir = $(libdir)
|
||||
|
||||
qofla-dir.h: qofla-dir.h.in
|
||||
rm -f $@.tmp
|
||||
sed < $< > $@.tmp \
|
||||
-e 's:@-libdir-@:${QOFLIBdir}:g'
|
||||
mv $@.tmp $@
|
||||
|
||||
qof_builds = qofla-dir.h
|
||||
|
||||
else
|
||||
|
||||
libqof_la_SOURCES =
|
||||
|
||||
qofincludedir = ${pkgincludedir}
|
||||
|
||||
qofinclude_HEADERS =
|
||||
|
||||
qof_builds =
|
||||
|
||||
endif
|
||||
|
||||
libgncmod_engine_la_SOURCES = \
|
||||
Account.c \
|
||||
FreqSpec.c \
|
||||
@@ -99,7 +196,8 @@ noinst_HEADERS = \
|
||||
gnc-pricedb-p.h \
|
||||
gw-engine.h \
|
||||
gw-kvp.h \
|
||||
policy-p.h
|
||||
policy-p.h \
|
||||
${qof_noinst_headers}
|
||||
|
||||
noinst_SCRIPTS = iso-currencies-to-c
|
||||
|
||||
@@ -141,9 +239,12 @@ EXTRA_DIST = \
|
||||
extensions.txt \
|
||||
iso-4217-currencies.scm \
|
||||
iso-currencies-to-c \
|
||||
qofla-dir.h.in \
|
||||
gncla-dir.h.in \
|
||||
kvp_doc.txt \
|
||||
SX-book-p.h \
|
||||
${qof_library} \
|
||||
${qof_headers} \
|
||||
${gncmod_DATA} \
|
||||
${gncscm_DATA} \
|
||||
${gwmod_DATA}
|
||||
@@ -187,12 +288,13 @@ gw-kvp.scm gw-kvp.c gw-kvp.h: \
|
||||
(gw:generate-wrapset \"gw-kvp\")"
|
||||
|
||||
BUILT_SOURCES = \
|
||||
${qof_builds} \
|
||||
iso-4217-currencies.c \
|
||||
gw-engine.scm gw-engine.c gw-engine.h \
|
||||
gw-kvp.scm gw-kvp.c gw-kvp.h gncla-dir.h
|
||||
|
||||
DISTCLEANFILES = gnucash g-wrapped .scm-links ${SCM_FILE_LINKS} \
|
||||
gw-engine.html gw-kvp.html gncla-dir.h
|
||||
gw-engine.html gw-kvp.html qofla-dir.h gncla-dir.h
|
||||
|
||||
gncla-dir.h: gncla-dir.h.in
|
||||
rm -f $@.tmp
|
||||
|
@@ -238,7 +238,7 @@ timespec_abs(const Timespec *t)
|
||||
/** \brief Converts any time on a day to midday that day.
|
||||
|
||||
* given a timepair contains any time on a certain day (local time)
|
||||
* converts it to be midday that day.
|
||||
* converts it to be midday that day.
|
||||
*/
|
||||
|
||||
Timespec
|
||||
@@ -476,8 +476,8 @@ qof_print_date_dmy_buff (char * buff, size_t len, int day, int month, int year)
|
||||
t = mktime (&tm_str);
|
||||
localtime_r (&t, &tm_str);
|
||||
flen = strftime (buff, len, GNC_D_FMT, &tm_str);
|
||||
if (flen != 0)
|
||||
break;
|
||||
if (flen != 0)
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case QOF_DATE_FORMAT_ISO:
|
||||
@@ -674,20 +674,20 @@ qof_print_date_time_buff (char * buff, size_t len, time_t secs)
|
||||
size_t
|
||||
qof_print_time_buff (char * buff, size_t len, time_t secs)
|
||||
{
|
||||
int flen;
|
||||
int flen;
|
||||
struct tm ltm, gtm;
|
||||
|
||||
if (!buff) return 0;
|
||||
|
||||
if (!buff) return 0;
|
||||
if(dateFormat == QOF_DATE_FORMAT_UTC)
|
||||
{
|
||||
gtm = *gmtime (&secs);
|
||||
flen = strftime(buff, len, QOF_UTC_DATE_FORMAT, >m);
|
||||
return flen;
|
||||
}
|
||||
ltm = *localtime (&secs);
|
||||
flen = strftime (buff, len, GNC_T_FMT, <m);
|
||||
|
||||
return flen;
|
||||
ltm = *localtime (&secs);
|
||||
flen = strftime (buff, len, GNC_T_FMT, <m);
|
||||
|
||||
return flen;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
@@ -221,16 +221,43 @@ qof_util_bool_to_int (const char * val)
|
||||
|
||||
static GCache * gnc_string_cache = NULL;
|
||||
|
||||
/* maybe better to make this function static */
|
||||
#ifdef THESE_CAN_BE_USEFUL_FOR_DEGUGGING
|
||||
static guint g_str_hash_KEY(gconstpointer v) {
|
||||
return g_str_hash(v);
|
||||
}
|
||||
static guint g_str_hash_VAL(gconstpointer v) {
|
||||
return g_str_hash(v);
|
||||
}
|
||||
static gpointer g_strdup_VAL(gpointer v) {
|
||||
return g_strdup(v);
|
||||
}
|
||||
static gpointer g_strdup_KEY(gpointer v) {
|
||||
return g_strdup(v);
|
||||
}
|
||||
static void g_free_VAL(gpointer v) {
|
||||
return g_free(v);
|
||||
}
|
||||
static void g_free_KEY(gpointer v) {
|
||||
return g_free(v);
|
||||
}
|
||||
static gboolean gnc_str_equal(gconstpointer v, gconstpointer v2)
|
||||
{
|
||||
return (v && v2) ? g_str_equal(v, v2) : FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
GCache*
|
||||
gnc_engine_get_string_cache(void)
|
||||
{
|
||||
if(!gnc_string_cache)
|
||||
{
|
||||
if(!gnc_string_cache) {
|
||||
gnc_string_cache = g_cache_new(
|
||||
(GCacheNewFunc) g_strdup, g_free,
|
||||
(GCacheDupFunc) g_strdup, g_free, g_str_hash,
|
||||
g_str_hash, g_str_equal);
|
||||
(GCacheNewFunc) g_strdup, /* value_new_func */
|
||||
g_free, /* value_destroy_func */
|
||||
(GCacheDupFunc) g_strdup, /* key_dup_func */
|
||||
g_free, /* key_destroy_func */
|
||||
g_str_hash, /* hash_key_func */
|
||||
g_str_hash, /* hash_value_func */
|
||||
g_str_equal); /* key_equal_func */
|
||||
}
|
||||
return gnc_string_cache;
|
||||
}
|
||||
@@ -238,18 +265,22 @@ gnc_engine_get_string_cache(void)
|
||||
void
|
||||
gnc_engine_string_cache_destroy (void)
|
||||
{
|
||||
g_cache_destroy (gnc_string_cache);
|
||||
gnc_string_cache = NULL;
|
||||
if (gnc_string_cache)
|
||||
g_cache_destroy (gnc_string_cache);
|
||||
gnc_string_cache = NULL;
|
||||
}
|
||||
|
||||
void gnc_string_cache_remove(gpointer key)
|
||||
void
|
||||
gnc_string_cache_remove(gconstpointer key)
|
||||
{
|
||||
g_cache_remove(gnc_engine_get_string_cache(), key);
|
||||
g_cache_remove(gnc_engine_get_string_cache(), key);
|
||||
}
|
||||
|
||||
gpointer gnc_string_cache_insert(gpointer key)
|
||||
|
||||
gpointer
|
||||
gnc_string_cache_insert(gpointer key)
|
||||
{
|
||||
return g_cache_insert(gnc_engine_get_string_cache(), key);
|
||||
return g_cache_insert(gnc_engine_get_string_cache(), key);
|
||||
}
|
||||
|
||||
void
|
@@ -21,7 +21,7 @@
|
||||
|
||||
/** @addtogroup Utilities
|
||||
@{ */
|
||||
/** @file gnc-engine-util.h
|
||||
/** @file gnc-engine-util.h
|
||||
@brief QOF utility functions
|
||||
@author Copyright (C) 1997 Robin D. Clark <rclark@cs.hmc.edu>
|
||||
@author Copyright (C) 2000 Bill Gribble <grib@billgribble.com>
|
||||
@@ -85,7 +85,7 @@
|
||||
const char* name##asString(name n);
|
||||
|
||||
#define AS_STRING_FUNC(name, list) \
|
||||
const char* name##asString(name n) { \
|
||||
const char* name##asString(name n) { \
|
||||
switch (n) { \
|
||||
list(AS_STRING_CASE) \
|
||||
default: return ""; } }
|
||||
@@ -201,48 +201,64 @@ char * gnc_stpcpy (char *dest, const char *src);
|
||||
#define stpcpy gnc_stpcpy
|
||||
#endif
|
||||
|
||||
/** Return NULL if the field is whitespace (blank, tab, formfeed etc.)
|
||||
* Else return pointer to first non-whitespace character.
|
||||
/** Return NULL if the field is whitespace (blank, tab, formfeed etc.)
|
||||
* Else return pointer to first non-whitespace character.
|
||||
*/
|
||||
const char * qof_util_whitespace_filter (const char * val);
|
||||
|
||||
/** Return integer 1 if the string starts with 't' or 'T' or
|
||||
* contains the word 'true' or 'TRUE'; if string is a number,
|
||||
/** Return integer 1 if the string starts with 't' or 'T' or
|
||||
* contains the word 'true' or 'TRUE'; if string is a number,
|
||||
* return that number. (Leading whitespace is ignored). */
|
||||
int qof_util_bool_to_int (const char * val);
|
||||
|
||||
/** Many strings used throughout the engine are likely to be duplicated.
|
||||
|
||||
/** Gnucash's String Cache:
|
||||
*
|
||||
* Many strings used throughout the engine are likely to be duplicated.
|
||||
* So we provide a reference counted cache system for the strings, which
|
||||
* shares strings whenever possible.
|
||||
*
|
||||
* Use g_cache_insert to insert a string into the cache (it will return a
|
||||
* pointer to the cached string).
|
||||
* Basically you should use this instead of g_strdup.
|
||||
* Use gnc_string_cache_insert to insert a string into the cache (it
|
||||
* will return a pointer to the cached string). Basically you should
|
||||
* use this instead of g_strdup.
|
||||
*
|
||||
* Use g_cache_remove (giving it a pointer to a cached string) if the string
|
||||
* is unused. If this is the last reference to the string it will be
|
||||
* removed from the cache, otherwise it will just decrement the
|
||||
* reference count.
|
||||
* Basically you should use this instead of g_free.
|
||||
* Use gnc_string_cache_remove (giving it a pointer to a cached
|
||||
* string) if the string is unused. If this is the last reference to
|
||||
* the string it will be removed from the cache, otherwise it will
|
||||
* just decrement the reference count. Basically you should use this
|
||||
* instead of g_free.
|
||||
*
|
||||
* Just in case it's not clear: The remove function must NOT be called
|
||||
* for the string you passed INTO the insert function. It must be
|
||||
* called for the _cached_ string that is _returned_ by the insert
|
||||
* function.
|
||||
*
|
||||
* Note that all the work is done when inserting or removing. Once
|
||||
* cached the strings are just plain C strings.
|
||||
*/
|
||||
*
|
||||
* The string cache is demand-created on first use.
|
||||
*
|
||||
**/
|
||||
|
||||
/** Get the gnc_string_cache. Create it if it doesn't exist already
|
||||
/** \deprecated use qof_init instead.
|
||||
|
||||
\todo hide the gcache as a static */
|
||||
Get the gnc_string_cache. Create it if it doesn't exist already
|
||||
*/
|
||||
GCache* gnc_engine_get_string_cache(void);
|
||||
|
||||
/** Destroy the gnc_string_cache */
|
||||
void gnc_engine_string_cache_destroy (void);
|
||||
|
||||
/* You can use this function as a destroy notifier for a GHashTable
|
||||
that uses common strings as keys (or values, for that matter.) */
|
||||
void gnc_string_cache_remove(gpointer key);
|
||||
void gnc_string_cache_remove(gconstpointer key);
|
||||
|
||||
/* You can use this function with g_hash_table_insert(), or the key
|
||||
(or value), as long as you use the destroy notifier above. */
|
||||
(or value), as long as you use the destroy notifier above. */
|
||||
gpointer gnc_string_cache_insert(gpointer key);
|
||||
|
||||
#define CACHE_INSERT(str) gnc_string_cache_insert((gpointer)(str));
|
||||
#define CACHE_REMOVE(str) gnc_string_cache_remove((str));
|
||||
|
||||
#endif /* QOF_UTIL_H */
|
||||
/** @} */
|
@@ -31,7 +31,7 @@
|
||||
void gnc_engine_generate_event (const GUID *, QofIdType, GNCEngineEventType);
|
||||
|
||||
/* generates an event even when events are suspended! */
|
||||
void gnc_engine_force_event (QofEntity *entity,
|
||||
void gnc_engine_force_event (QofEntity *entity,
|
||||
GNCEngineEventType event_type);
|
||||
|
||||
#endif
|
@@ -154,76 +154,80 @@ gint qof_log_module_count(void);
|
||||
*/
|
||||
|
||||
/** Log an fatal error */
|
||||
#define FATAL(format, args...) { \
|
||||
#define FATAL(format, args...) do { \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \
|
||||
"Fatal Error: %s(): " format, FUNK , ## args); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** Log an serious error */
|
||||
#define PERR(format, args...) { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_ERROR)) { \
|
||||
#define PERR(format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_ERROR)) {\
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
|
||||
"Error: %s(): " format, FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** Log an warning */
|
||||
#define PWARN(format, args...) { \
|
||||
#define PWARN(format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_WARNING)) { \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \
|
||||
"Warning: %s(): " format, FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \
|
||||
"Warning: %s(): " format, FUNK , ## args); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/** Print an informational note */
|
||||
#define PINFO(format, args...) { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_INFO)) { \
|
||||
#define PINFO(format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_INFO)) { \
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \
|
||||
"Info: %s(): " format, \
|
||||
FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** Print an debugging message */
|
||||
#define DEBUG(format, args...) { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) { \
|
||||
#define DEBUG(format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) {\
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Debug: %s(): " format, \
|
||||
FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** Print an function entry debugging message */
|
||||
#define ENTER(format, args...) { \
|
||||
#define ENTER(format, args...) do { \
|
||||
extern gint gnc_trace_num_spaces; \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) {\
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Enter in %s: %s()" format, __FILE__, \
|
||||
FUNK , ## args); \
|
||||
gnc_trace_num_spaces += GNC_TRACE_INDENT_WIDTH;\
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** Print an function exit debugging message */
|
||||
#define LEAVE(format, args...) { \
|
||||
#define LEAVE(format, args...) do { \
|
||||
extern gint gnc_trace_num_spaces; \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) {\
|
||||
gnc_trace_num_spaces -= GNC_TRACE_INDENT_WIDTH;\
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Leave: %s()" format, \
|
||||
FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** Print an function trace debugging message */
|
||||
#define TRACE(format, args...) { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_TRACE)) { \
|
||||
#define TRACE(format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_TRACE)) {\
|
||||
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
|
||||
"Trace: %s(): " format, FUNK , ## args); \
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
#define DEBUGCMD(x) { if (gnc_should_log (log_module, GNC_LOG_DEBUG)) { (x); }}
|
||||
#define DEBUGCMD(x) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_DEBUG)) { \
|
||||
(x); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/** Infrastructure to make timing measurements for critical peices
|
||||
@@ -246,25 +250,25 @@ void gnc_report_clock_total (int clockno,
|
||||
const char *format, ...);
|
||||
|
||||
/** start a particular timer */
|
||||
#define START_CLOCK(clockno,format, args...) { \
|
||||
#define START_CLOCK(clockno,format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_INFO)) \
|
||||
gnc_start_clock (clockno, log_module, GNC_LOG_INFO, \
|
||||
__FUNCTION__, format , ## args); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** report elapsed time since last report on a particular timer */
|
||||
#define REPORT_CLOCK(clockno,format, args...) { \
|
||||
#define REPORT_CLOCK(clockno,format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_INFO)) \
|
||||
gnc_report_clock (clockno, log_module, GNC_LOG_INFO, \
|
||||
__FUNCTION__, format , ## args); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
/** report total elapsed time since timer started */
|
||||
#define REPORT_CLOCK_TOTAL(clockno,format, args...) { \
|
||||
#define REPORT_CLOCK_TOTAL(clockno,format, args...) do { \
|
||||
if (gnc_should_log (log_module, GNC_LOG_INFO)) \
|
||||
gnc_report_clock_total (clockno, log_module, GNC_LOG_INFO, \
|
||||
__FUNCTION__, format , ## args); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
#endif /* GNC_TRACE_H */
|
||||
/* @} */
|
@@ -108,6 +108,7 @@ guid_null(void)
|
||||
int i;
|
||||
char *tmp = "NULLGUID.EMPTY.";
|
||||
|
||||
/* 16th space for '\O' */
|
||||
for (i = 0; i < 16; i++)
|
||||
null_guid.data[i] = tmp[i];
|
||||
|
@@ -43,6 +43,8 @@
|
||||
* (gnc_string_cache), as it is very likely we will see the
|
||||
* same keys over and over again */
|
||||
|
||||
/* TODO: set the cache handling functions with hash_table_new_full */
|
||||
|
||||
struct _KvpFrame
|
||||
{
|
||||
GHashTable * hash;
|
||||
@@ -113,7 +115,7 @@ kvp_frame_new(void)
|
||||
static void
|
||||
kvp_frame_delete_worker(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_cache_remove(gnc_engine_get_string_cache(), key);
|
||||
gnc_string_cache_remove(key);
|
||||
kvp_value_delete((KvpValue *)value);
|
||||
}
|
||||
|
||||
@@ -148,7 +150,7 @@ kvp_frame_copy_worker(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
KvpFrame * dest = (KvpFrame *)user_data;
|
||||
g_hash_table_insert(dest->hash,
|
||||
(gpointer)g_cache_insert(gnc_engine_get_string_cache(), key),
|
||||
gnc_string_cache_insert(key),
|
||||
(gpointer)kvp_value_copy(value));
|
||||
}
|
||||
|
||||
@@ -189,7 +191,7 @@ kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot,
|
||||
if(key_exists)
|
||||
{
|
||||
g_hash_table_remove(frame->hash, slot);
|
||||
g_cache_remove(gnc_engine_get_string_cache(), orig_key);
|
||||
gnc_string_cache_remove(orig_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,8 +201,7 @@ kvp_frame_replace_slot_nc (KvpFrame * frame, const char * slot,
|
||||
if(new_value)
|
||||
{
|
||||
g_hash_table_insert(frame->hash,
|
||||
g_cache_insert(gnc_engine_get_string_cache(),
|
||||
(gpointer) slot),
|
||||
gnc_string_cache_insert((gpointer) slot),
|
||||
new_value);
|
||||
}
|
||||
|
||||
@@ -311,16 +312,16 @@ kvp_frame_get_frame_or_null_slash_trash (const KvpFrame *frame, char *key_path)
|
||||
*/
|
||||
|
||||
static inline KvpFrame *
|
||||
get_trailer_make (KvpFrame * frame, const char * key_path, char **end_key)
|
||||
get_trailer_make (KvpFrame * frame, const char * key_path, const char **end_key)
|
||||
{
|
||||
char *last_key;
|
||||
const char *last_key;
|
||||
|
||||
if (!frame || !key_path || (0 == key_path[0])) return NULL;
|
||||
|
||||
last_key = strrchr (key_path, '/');
|
||||
if (NULL == last_key)
|
||||
{
|
||||
last_key = (char *) key_path;
|
||||
last_key = key_path;
|
||||
}
|
||||
else if (last_key == key_path)
|
||||
{
|
||||
@@ -353,16 +354,16 @@ get_trailer_make (KvpFrame * frame, const char * key_path, char **end_key)
|
||||
*/
|
||||
|
||||
static inline const KvpFrame *
|
||||
get_trailer_or_null (const KvpFrame * frame, const char * key_path, char **end_key)
|
||||
get_trailer_or_null (const KvpFrame * frame, const char * key_path, const char **end_key)
|
||||
{
|
||||
char *last_key;
|
||||
const char *last_key;
|
||||
|
||||
if (!frame || !key_path || (0 == key_path[0])) return NULL;
|
||||
|
||||
last_key = strrchr (key_path, '/');
|
||||
if (NULL == last_key)
|
||||
{
|
||||
last_key = (char *) key_path;
|
||||
last_key = key_path;
|
||||
}
|
||||
else if (last_key == key_path)
|
||||
{
|
||||
@@ -468,7 +469,7 @@ KvpFrame *
|
||||
kvp_frame_set_value_nc (KvpFrame * frame, const char * key_path,
|
||||
KvpValue * value)
|
||||
{
|
||||
char *last_key;
|
||||
const char *last_key;
|
||||
|
||||
frame = get_trailer_make (frame, key_path, &last_key);
|
||||
if (!frame) return NULL;
|
||||
@@ -481,7 +482,7 @@ kvp_frame_set_value (KvpFrame * frame, const char * key_path,
|
||||
const KvpValue * value)
|
||||
{
|
||||
KvpValue *new_value = NULL;
|
||||
char *last_key;
|
||||
const char *last_key;
|
||||
|
||||
frame = get_trailer_make (frame, key_path, &last_key);
|
||||
if (!frame) return NULL;
|
||||
@@ -496,7 +497,7 @@ kvp_frame_replace_value_nc (KvpFrame * frame, const char * key_path,
|
||||
KvpValue * new_value)
|
||||
{
|
||||
KvpValue * old_value;
|
||||
char *last_key;
|
||||
const char *last_key;
|
||||
|
||||
last_key = NULL;
|
||||
if (new_value)
|
||||
@@ -518,7 +519,7 @@ kvp_frame_replace_value_nc (KvpFrame * frame, const char * key_path,
|
||||
KvpFrame *
|
||||
kvp_frame_add_value_nc(KvpFrame * frame, const char * path, KvpValue *value)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
KvpValue *oldvalue;
|
||||
|
||||
frame = (KvpFrame *) get_trailer_or_null (frame, path, &key);
|
||||
@@ -854,7 +855,7 @@ kvp_frame_add_url_encoding (KvpFrame *frame, const char *enc)
|
||||
gint64
|
||||
kvp_frame_get_gint64(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_gint64(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -862,7 +863,7 @@ kvp_frame_get_gint64(const KvpFrame *frame, const char *path)
|
||||
double
|
||||
kvp_frame_get_double(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_double(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -870,7 +871,7 @@ kvp_frame_get_double(const KvpFrame *frame, const char *path)
|
||||
gnc_numeric
|
||||
kvp_frame_get_numeric(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_numeric(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -878,7 +879,7 @@ kvp_frame_get_numeric(const KvpFrame *frame, const char *path)
|
||||
char *
|
||||
kvp_frame_get_string(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_string(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -886,7 +887,7 @@ kvp_frame_get_string(const KvpFrame *frame, const char *path)
|
||||
GUID *
|
||||
kvp_frame_get_guid(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_guid(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -895,7 +896,7 @@ void *
|
||||
kvp_frame_get_binary(const KvpFrame *frame, const char *path,
|
||||
guint64 * size_return)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_binary(kvp_frame_get_slot (frame, key), size_return);
|
||||
}
|
||||
@@ -903,7 +904,7 @@ kvp_frame_get_binary(const KvpFrame *frame, const char *path,
|
||||
Timespec
|
||||
kvp_frame_get_timespec(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_timespec(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -911,7 +912,7 @@ kvp_frame_get_timespec(const KvpFrame *frame, const char *path)
|
||||
KvpFrame *
|
||||
kvp_frame_get_frame(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_value_get_frame(kvp_frame_get_slot (frame, key));
|
||||
}
|
||||
@@ -919,7 +920,7 @@ kvp_frame_get_frame(const KvpFrame *frame, const char *path)
|
||||
KvpValue *
|
||||
kvp_frame_get_value(const KvpFrame *frame, const char *path)
|
||||
{
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
frame = get_trailer_or_null (frame, path, &key);
|
||||
return kvp_frame_get_slot (frame, key);
|
||||
}
|
||||
@@ -1745,6 +1746,7 @@ kvp_value_to_string(const KvpValue *val)
|
||||
break;
|
||||
|
||||
case KVP_TYPE_GUID:
|
||||
/* THREAD-UNSAFE */
|
||||
ctmp = guid_to_string(kvp_value_get_guid(val));
|
||||
tmp2 = g_strdup_printf("KVP_VALUE_GUID(%s)", ctmp ? ctmp : "");
|
||||
return tmp2;
|
@@ -75,7 +75,7 @@ typedef struct _KvpFrame KvpFrame;
|
||||
/** A KvpValue is a union with possible types enumerated in the
|
||||
* KvpValueType enum. */
|
||||
typedef struct _KvpValue KvpValue;
|
||||
|
||||
|
||||
/** \brief possible types in the union KvpValue
|
||||
* \todo : People have asked for boolean values,
|
||||
* e.g. in xaccAccountSetAutoInterestXfer
|
||||
@@ -99,9 +99,9 @@ typedef enum {
|
||||
KVP_TYPE_FRAME /**< no QOF equivalent. */
|
||||
} KvpValueType;
|
||||
|
||||
/** \deprecated Deprecated backwards compat tokens
|
||||
/** \deprecated Deprecated backwards compat tokens
|
||||
|
||||
do \b not use these in new code.
|
||||
do \b not use these in new code.
|
||||
*/
|
||||
#define kvp_frame KvpFrame
|
||||
#define kvp_value KvpValue
|
||||
@@ -241,7 +241,7 @@ KvpValue * kvp_frame_replace_value_nc (KvpFrame * frame, const char * slot,
|
||||
* 'November', respectively. This routine also handles % encoding.
|
||||
*
|
||||
* This routine treats all values as strings; it does *not* attempt
|
||||
* to perform any type-conversion.
|
||||
* to perform any type-conversion.
|
||||
* */
|
||||
void kvp_frame_add_url_encoding (KvpFrame *frame, const char *enc);
|
||||
/** @} */
|
@@ -22,7 +22,7 @@
|
||||
@{ */
|
||||
/** @addtogroup Backend
|
||||
@{ */
|
||||
/** @file qof-be-utils.h
|
||||
/** @file qof-be-utils.h
|
||||
@brief QOF Backend Utilities
|
||||
@author Derek Atkins <derek@ihtfp.com>
|
||||
@author Neil Williams <linux@codehelp.co.uk>
|
||||
@@ -85,14 +85,14 @@ gboolean qof_begin_edit(QofInstance *inst);
|
||||
/**
|
||||
* commit_edit helpers
|
||||
*
|
||||
* The caller should call PART1 as the first thing, then
|
||||
* The caller should call PART1 as the first thing, then
|
||||
* perform any local operations prior to calling the backend.
|
||||
* Then call PART2.
|
||||
* Then call PART2.
|
||||
*/
|
||||
|
||||
/**
|
||||
* part1 -- deal with the editlevel
|
||||
*
|
||||
*
|
||||
* @param inst: an instance of QofInstance
|
||||
*/
|
||||
|
||||
@@ -132,12 +132,12 @@ gboolean qof_commit_edit(QofInstance *inst);
|
||||
|
||||
/**
|
||||
* part2 -- deal with the backend
|
||||
*
|
||||
*
|
||||
* @param inst: an instance of QofInstance
|
||||
* @param on_error: a function called if there is a backend error.
|
||||
* void (*on_error)(inst, QofBackendError)
|
||||
* @param on_done: a function called after the commit is complete
|
||||
* but before the instect is freed. Perform any other
|
||||
* but before the instect is freed. Perform any other
|
||||
* operations after the commit.
|
||||
* void (*on_done)(inst)
|
||||
* @param on_free: a function called if inst->do_free is TRUE.
|
@@ -698,7 +698,7 @@ qof_book_mergeCommitRuleLoop(
|
||||
registered_type = TRUE;
|
||||
}
|
||||
if(safe_strcmp(rule->mergeType, QOF_TYPE_CHOICE) == 0) {
|
||||
referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
|
||||
reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
|
||||
if(reference_setter != NULL)
|
||||
{
|
@@ -313,7 +313,7 @@ struct QofBackend_s
|
||||
gboolean (*process_events) (QofBackend *);
|
||||
|
||||
QofBePercentageFunc percentage;
|
||||
|
||||
|
||||
QofBackendProvider *provider;
|
||||
|
||||
/** Document Me !!! what is this supposed to do ?? */
|
@@ -68,9 +68,10 @@ qof_book_init (QofBook *book)
|
||||
{
|
||||
if (!book) return;
|
||||
|
||||
book->hash_of_collections = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
gnc_string_cache_remove,
|
||||
coll_destroy);
|
||||
book->hash_of_collections = g_hash_table_new_full(
|
||||
g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)gnc_string_cache_remove, /* key_destroy_func */
|
||||
coll_destroy); /* value_destroy_func */
|
||||
|
||||
qof_instance_init (&book->inst, QOF_ID_BOOK, book);
|
||||
|
||||
@@ -116,7 +117,7 @@ qof_book_destroy (QofBook *book)
|
||||
book->shutting_down = TRUE;
|
||||
gnc_engine_force_event (&book->inst.entity, GNC_EVENT_DESTROY);
|
||||
|
||||
/* Call the list of finalizers, let them do thier thing.
|
||||
/* Call the list of finalizers, let them do their thing.
|
||||
* Do this before tearing into the rest of the book.
|
||||
*/
|
||||
g_hash_table_foreach (book->data_table_finalizers, book_final, book);
|
||||
@@ -124,7 +125,9 @@ qof_book_destroy (QofBook *book)
|
||||
qof_object_book_end (book);
|
||||
|
||||
g_hash_table_destroy (book->data_table_finalizers);
|
||||
book->data_table_finalizers = NULL;
|
||||
g_hash_table_destroy (book->data_tables);
|
||||
book->data_tables = NULL;
|
||||
|
||||
qof_instance_release (&book->inst);
|
||||
|
||||
@@ -239,13 +242,12 @@ qof_book_get_collection (QofBook *book, QofIdType entity_type)
|
||||
if (!book || !entity_type) return NULL;
|
||||
|
||||
col = g_hash_table_lookup (book->hash_of_collections, entity_type);
|
||||
if (col) return col;
|
||||
|
||||
col = qof_collection_new (entity_type);
|
||||
|
||||
g_hash_table_insert (book->hash_of_collections,
|
||||
gnc_string_cache_insert((gpointer) entity_type), col);
|
||||
|
||||
if (!col) {
|
||||
col = qof_collection_new (entity_type);
|
||||
g_hash_table_insert(
|
||||
book->hash_of_collections,
|
||||
gnc_string_cache_insert((gpointer) entity_type), col);
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
@@ -288,32 +290,32 @@ void qof_book_mark_closed (QofBook *book)
|
||||
|
||||
gchar qof_book_get_open_marker(QofBook *book)
|
||||
{
|
||||
if(!book) { return 'n'; }
|
||||
return book->book_open;
|
||||
if(!book) { return 'n'; }
|
||||
return book->book_open;
|
||||
}
|
||||
|
||||
gint32 qof_book_get_version (QofBook *book)
|
||||
{
|
||||
if(!book) { return -1; }
|
||||
return book->version;
|
||||
if(!book) { return -1; }
|
||||
return book->version;
|
||||
}
|
||||
|
||||
guint32 qof_book_get_idata (QofBook *book)
|
||||
{
|
||||
if(!book) { return 0; }
|
||||
return book->idata;
|
||||
if(!book) { return 0; }
|
||||
return book->idata;
|
||||
}
|
||||
|
||||
void qof_book_set_version (QofBook *book, gint32 version)
|
||||
{
|
||||
if(!book && version < 0) { return; }
|
||||
book->version = version;
|
||||
if(!book && version < 0) { return; }
|
||||
book->version = version;
|
||||
}
|
||||
|
||||
void qof_book_set_idata(QofBook *book, guint32 idata)
|
||||
{
|
||||
if(!book && idata < 0) { return; }
|
||||
book->idata = idata;
|
||||
if(!book && idata < 0) { return; }
|
||||
book->idata = idata;
|
||||
}
|
||||
|
||||
gint64
|
@@ -21,13 +21,13 @@
|
||||
/** @addtogroup Object
|
||||
@{ */
|
||||
/** @addtogroup Book
|
||||
A QOF Book is a dataset. It provides a single handle
|
||||
A QOF Book is a dataset. It provides a single handle
|
||||
through which all the various collections of entities
|
||||
can be found. In particular, given only the type of
|
||||
the entity, the collection can be found.
|
||||
|
||||
|
||||
Books also provide the 'natural' place to working with
|
||||
a storage backend, as a book can encapsulate everything
|
||||
a storage backend, as a book can encapsulate everything
|
||||
held in storage.
|
||||
@{ */
|
||||
/** @file qofbook.h
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
/** \brief QofBook reference */
|
||||
typedef struct _QofBook QofBook;
|
||||
|
||||
|
||||
/** GList of QofBook */
|
||||
typedef GList QofBookList;
|
||||
|
||||
@@ -70,12 +70,12 @@ typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
|
||||
|
||||
/** Register the book object with the QOF object system. */
|
||||
gboolean qof_book_register (void);
|
||||
|
||||
|
||||
/** Allocate, initialise and return a new QofBook. Books contain references
|
||||
* to all of the top-level object containers. */
|
||||
QofBook * qof_book_new (void);
|
||||
|
||||
/** End any editing sessions associated with book, and free all memory
|
||||
/** End any editing sessions associated with book, and free all memory
|
||||
associated with it. */
|
||||
void qof_book_destroy (QofBook *book);
|
||||
|
||||
@@ -86,17 +86,17 @@ and once marked closed, books cannnot be marked as open.
|
||||
*/
|
||||
void qof_book_mark_closed (QofBook *book);
|
||||
|
||||
/** \return The table of entities of the given type.
|
||||
/** \return The table of entities of the given type.
|
||||
*
|
||||
* When an object's constructor calls qof_instance_init(), a
|
||||
* reference to the object is stored in the book. The book stores
|
||||
* all the references to initialized instances, sorted by type. This
|
||||
* function returns a collection of the references for the specified
|
||||
* type.
|
||||
*
|
||||
*
|
||||
* If the collection doesn't yet exist for the indicated type,
|
||||
* it is created. Thus, this routine is gaurenteed to return
|
||||
* a non-NULL value. (Unless the system malloc failed (out of
|
||||
* a non-NULL value. (Unless the system malloc failed (out of
|
||||
* memory) in which case what happens??).
|
||||
*/
|
||||
QofCollection * qof_book_get_collection (QofBook *, QofIdType);
|
||||
@@ -114,23 +114,24 @@ void qof_book_foreach_collection (QofBook *, QofCollectionForeachCB, gpointer);
|
||||
*/
|
||||
#define qof_book_get_slots(book) qof_instance_get_slots(QOF_INSTANCE(book))
|
||||
|
||||
/** The qof_book_set_data() allows arbitrary pointers to structs
|
||||
* to be stored in QofBook. This is the "prefered" method for
|
||||
/** The qof_book_set_data() allows arbitrary pointers to structs
|
||||
* to be stored in QofBook. This is the "prefered" method for
|
||||
* extending QofBook to hold new data types. This is also
|
||||
* the ideal location to store other arbitrary runtime data
|
||||
* the ideal location to store other arbitrary runtime data
|
||||
* that the application may need.
|
||||
*
|
||||
* The book data differs from the book KVP in that the contents
|
||||
* of the book KVP are persistant (are saved and restored to file
|
||||
* of the book KVP are persistant (are saved and restored to file
|
||||
* or database), whereas the data pointers exist only at runtime.
|
||||
*/
|
||||
void qof_book_set_data (QofBook *book, const char *key, gpointer data);
|
||||
|
||||
/** Same as qof_book_set_data(), except that the callback will be called
|
||||
* when the book is destroyed. The argument to the callback will be
|
||||
* when the book is destroyed. The argument to the callback will be
|
||||
* the book followed by the data pointer.
|
||||
*/
|
||||
void qof_book_set_data_fin (QofBook *book, const char *key, gpointer data, QofBookFinalCB);
|
||||
void qof_book_set_data_fin (QofBook *book, const char *key, gpointer data,
|
||||
QofBookFinalCB);
|
||||
|
||||
/** Retrieves arbitrary pointers to structs stored by qof_book_set_data. */
|
||||
gpointer qof_book_get_data (QofBook *book, const char *key);
|
||||
@@ -138,12 +139,12 @@ gpointer qof_book_get_data (QofBook *book, const char *key);
|
||||
/** Is the book shutting down? */
|
||||
gboolean qof_book_shutting_down (QofBook *book);
|
||||
|
||||
/** qof_book_not_saved() will return TRUE if any
|
||||
/** qof_book_not_saved() will return TRUE if any
|
||||
* data in the book hasn't been saved to long-term storage.
|
||||
* (Actually, that's not quite true. The book doesn't know
|
||||
* (Actually, that's not quite true. The book doesn't know
|
||||
* anything about saving. Its just that whenever data is modified,
|
||||
* the 'dirty' flag is set. This routine returns the value of the
|
||||
* 'dirty' flag. Its up to the backend to periodically reset this
|
||||
* the 'dirty' flag is set. This routine returns the value of the
|
||||
* 'dirty' flag. Its up to the backend to periodically reset this
|
||||
* flag, when it actually does save the data.)
|
||||
*/
|
||||
gboolean qof_book_not_saved (QofBook *book);
|
||||
@@ -159,7 +160,7 @@ void qof_book_mark_saved(QofBook *book);
|
||||
* is marked 'dirty'. */
|
||||
void qof_book_kvp_changed (QofBook *book);
|
||||
|
||||
/** The qof_book_equal() method returns TRUE if books are equal.
|
||||
/** The qof_book_equal() method returns TRUE if books are equal.
|
||||
* XXX this routine is broken, and does not currently compare data.
|
||||
*/
|
||||
gboolean qof_book_equal (QofBook *book_1, QofBook *book_2);
|
@@ -46,7 +46,7 @@ static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
||||
/********************************************************************/
|
||||
/* PUBLISHED API FUNCTIONS */
|
||||
|
||||
void
|
||||
void
|
||||
qof_class_register (QofIdTypeConst obj_name,
|
||||
QofSortFunc default_sort_function,
|
||||
const QofParam *params)
|
||||
@@ -64,17 +64,17 @@ qof_class_register (QofIdTypeConst obj_name,
|
||||
ht = g_hash_table_lookup (classTable, obj_name);
|
||||
|
||||
/* If it doesn't already exist, create a new table for this object */
|
||||
if (!ht)
|
||||
if (!ht)
|
||||
{
|
||||
ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_hash_table_insert (classTable, (char *)obj_name, ht);
|
||||
}
|
||||
|
||||
/* At least right now, we allow dummy, paramterless objects,
|
||||
* for testing purposes. Although I suppose that should be
|
||||
/* At least right now, we allow dummy, parameterless objects,
|
||||
* for testing purposes. Although I suppose that should be
|
||||
* an error.. */
|
||||
/* Now insert all the parameters */
|
||||
if (params)
|
||||
if (params)
|
||||
{
|
||||
for (i = 0; params[i].param_name; i++)
|
||||
g_hash_table_insert (ht,
|
||||
@@ -83,7 +83,7 @@ qof_class_register (QofIdTypeConst obj_name,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
qof_class_init(void)
|
||||
{
|
||||
if (initialized) return;
|
||||
@@ -93,7 +93,7 @@ qof_class_init(void)
|
||||
sortTable = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
qof_class_shutdown (void)
|
||||
{
|
||||
if (!initialized) return;
|
||||
@@ -114,7 +114,7 @@ qof_class_is_registered (QofIdTypeConst obj_name)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const QofParam *
|
||||
const QofParam *
|
||||
qof_class_get_parameter (QofIdTypeConst obj_name,
|
||||
const char *parameter)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ qof_class_get_parameter (QofIdTypeConst obj_name,
|
||||
return (g_hash_table_lookup (ht, parameter));
|
||||
}
|
||||
|
||||
QofAccessFunc
|
||||
QofAccessFunc
|
||||
qof_class_get_parameter_getter (QofIdTypeConst obj_name,
|
||||
const char *parameter)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ qof_class_get_parameter_getter (QofIdTypeConst obj_name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QofSetterFunc
|
||||
QofSetterFunc
|
||||
qof_class_get_parameter_setter (QofIdTypeConst obj_name,
|
||||
const char *parameter)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ qof_class_get_parameter_setter (QofIdTypeConst obj_name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QofType
|
||||
QofType
|
||||
qof_class_get_parameter_type (QofIdTypeConst obj_name,
|
||||
const char *param_name)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ qof_class_get_parameter_type (QofIdTypeConst obj_name,
|
||||
return (prm->param_type);
|
||||
}
|
||||
|
||||
QofSortFunc
|
||||
QofSortFunc
|
||||
qof_class_get_default_sort (QofIdTypeConst obj_name)
|
||||
{
|
||||
if (!obj_name) return NULL;
|
||||
@@ -193,12 +193,12 @@ struct class_iterate {
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static void
|
||||
static void
|
||||
class_foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct class_iterate *iter = arg;
|
||||
QofIdTypeConst id = key;
|
||||
|
||||
|
||||
iter->fcn (id, iter->data);
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ struct parm_iterate {
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static void
|
||||
static void
|
||||
param_foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct parm_iterate *iter = arg;
|
||||
@@ -262,18 +262,18 @@ find_reference_param_cb(QofParam *param, gpointer user_data)
|
||||
|
||||
b = (struct param_ref_list*)user_data;
|
||||
if((param->param_getfcn == NULL)||(param->param_setfcn == NULL)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_STRING)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_NUMERIC)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_DATE)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_CHAR)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_DEBCRED)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_GUID)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_INT32)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_INT64)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_DOUBLE)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_KVP)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_BOOLEAN)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_ID_BOOK)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_STRING)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_NUMERIC)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_DATE)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_CHAR)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_DEBCRED)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_GUID)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_INT32)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_INT64)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_DOUBLE)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_KVP)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_TYPE_BOOLEAN)) { return; }
|
||||
if(0 == safe_strcmp(param->param_type, QOF_ID_BOOK)) { return; }
|
||||
b->list = g_list_append(b->list, param);
|
||||
}
|
||||
|
@@ -185,8 +185,8 @@ typedef int (*QofSortFunc)(gpointer, gpointer);
|
||||
* controlling the object. The getters are typically used by the
|
||||
* query subsystem to query type specific data. Note that there
|
||||
* is no particular requirement for there to be a setter for every
|
||||
* getter or even vice-versa, nor is there any requeirement for these
|
||||
* to map 'cleanly' or orthogonaly to the underlying object. The
|
||||
* getter or even vice-versa, nor is there any requirement for these
|
||||
* to map 'cleanly' or orthogonally to the underlying object. The
|
||||
* parameters are really just a set of value setting and getting
|
||||
* routines.
|
||||
*
|
@@ -164,7 +164,7 @@ qof_gobject_double_getter (gpointer data, QofParam *getter)
|
||||
{
|
||||
GObject *gob = data;
|
||||
double fval;
|
||||
|
||||
|
||||
GParamSpec *gps = getter->param_userdata;
|
||||
|
||||
/* Note that the return type must actually be of type
|
@@ -32,9 +32,6 @@
|
||||
#include "gnc-trace.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
|
||||
#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (gpointer)(str));
|
||||
|
||||
static QofLogModule log_module = QOF_MOD_ENGINE;
|
||||
|
||||
struct QofCollection_s
|
@@ -23,7 +23,7 @@
|
||||
/*
|
||||
* Object instance holds many common fields that most
|
||||
* gnucash objects use.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
@@ -51,7 +51,7 @@ qof_instance_create (QofIdType type, QofBook *book)
|
||||
return inst;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
|
||||
{
|
||||
QofCollection *col;
|
||||
@@ -68,7 +68,7 @@ qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
|
||||
qof_entity_init (&inst->entity, type, col);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
qof_instance_release (QofInstance *inst)
|
||||
{
|
||||
kvp_frame_delete (inst->kvp_data);
|
||||
@@ -85,14 +85,14 @@ qof_instance_get_guid (QofInstance *inst)
|
||||
return &inst->entity.guid;
|
||||
}
|
||||
|
||||
QofBook *
|
||||
QofBook *
|
||||
qof_instance_get_book (QofInstance *inst)
|
||||
{
|
||||
if (!inst) return NULL;
|
||||
return inst->book;
|
||||
}
|
||||
|
||||
KvpFrame*
|
||||
KvpFrame*
|
||||
qof_instance_get_slots (QofInstance *inst)
|
||||
{
|
||||
if (!inst) return NULL;
|
||||
@@ -102,15 +102,15 @@ qof_instance_get_slots (QofInstance *inst)
|
||||
Timespec
|
||||
qof_instance_get_last_update (QofInstance *inst)
|
||||
{
|
||||
if (!inst)
|
||||
if (!inst)
|
||||
{
|
||||
Timespec ts = {0,-1};
|
||||
Timespec ts = {0,-1};
|
||||
return ts;
|
||||
}
|
||||
return inst->last_update;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
qof_instance_version_cmp (QofInstance *left, QofInstance *right)
|
||||
{
|
||||
if (!left && !right) return 0;
|
||||
@@ -174,7 +174,7 @@ qof_instance_mark_clean (QofInstance *inst)
|
||||
inst->dirty = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
qof_instance_set_slots (QofInstance *inst, KvpFrame *frm)
|
||||
{
|
||||
if (!inst) return;
|
@@ -29,7 +29,7 @@
|
||||
a storage backend. Storage might be file or SQL storage.
|
||||
|
||||
QOF Objects are also used by the query system ....
|
||||
|
||||
|
||||
To work with your own QOF Objects, you can use the QOF
|
||||
Generator to create sample objects and a mini-application
|
||||
with the SQL-type query interface.
|
@@ -33,11 +33,6 @@
|
||||
#include "qofquerycore-p.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
#define CACHE_INSERT(str) \
|
||||
g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str))
|
||||
#define CACHE_REMOVE(str) \
|
||||
g_cache_remove(gnc_engine_get_string_cache(), (gpointer)(str))
|
||||
|
||||
/* =========================================================== */
|
||||
|
||||
#define GET_TEXT(node) ({ \
|
||||
@@ -376,7 +371,7 @@ qof_query_pred_numeric_from_xml (xmlNodePtr root)
|
||||
xmlNodePtr node;
|
||||
QofQueryCompare how;
|
||||
QofNumericMatch sm;
|
||||
gnc_numeric num;
|
||||
gnc_numeric num;
|
||||
xmlNodePtr xp;
|
||||
|
||||
xp = root->xmlChildrenNode;
|
||||
@@ -483,6 +478,7 @@ qof_query_param_path_from_xml (xmlNodePtr root)
|
||||
if (0 == strcmp (node->name, "qofquery:param"))
|
||||
{
|
||||
const char *str = GET_TEXT (node);
|
||||
/* BUG? I can't find the matching cache removal. */
|
||||
plist = g_slist_append (plist, CACHE_INSERT(str));
|
||||
}
|
||||
}
|
||||
@@ -635,15 +631,15 @@ qof_query_from_xml (xmlNodePtr root)
|
||||
xmlChar *version;
|
||||
xmlNodePtr qpart;
|
||||
xmlNodePtr node;
|
||||
|
||||
|
||||
if (!root) return NULL;
|
||||
|
||||
|
||||
version = xmlGetProp(root, "version");
|
||||
if (!root->name || strcmp ("qof:qofquery", root->name))
|
||||
{
|
||||
if (!root->name || strcmp ("qof:qofquery", root->name))
|
||||
{
|
||||
// XXX something is wrong. warn ...
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
q = qof_query_create ();
|
||||
|
@@ -221,7 +221,7 @@ qof_query_pred_data_to_xml (QofQueryPredData *pd)
|
||||
query_double_t pdata_db;
|
||||
query_boolean_t pdata_bool;
|
||||
query_char_t pdata_c;
|
||||
|
||||
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_GUID))
|
||||
{
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-guid");
|
||||
@@ -425,7 +425,7 @@ qof_query_terms_to_xml (QofQuery *q)
|
||||
xmlNodePtr terms;
|
||||
GList *n;
|
||||
xmlNodePtr andt;
|
||||
|
||||
|
||||
terms = NULL;
|
||||
n = qof_query_get_terms (q);
|
||||
if (!n) return NULL;
|
||||
@@ -543,7 +543,7 @@ int main (int argc, char * argv[])
|
||||
xmlChar *xbuf;
|
||||
int bufsz;
|
||||
xmlOutputBufferPtr xbuf;
|
||||
|
||||
|
||||
qof_query_init();
|
||||
qof_object_initialize ();
|
||||
|
@@ -1700,6 +1700,7 @@ qof_query_printValueForParam (QofQueryPredData *pd, GString * gs)
|
||||
qof_query_printGuidMatch (pdata->options));
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
/* THREAD-UNSAFE */
|
||||
g_string_sprintfa (gs, ", guids: %s",
|
||||
guid_to_string ((GUID *) node->data));
|
||||
}
|
@@ -155,10 +155,12 @@ void qof_query_destroy (QofQuery *q);
|
||||
*/
|
||||
void qof_query_search_for (QofQuery *query, QofIdTypeConst obj_type);
|
||||
|
||||
/** Set the book to be searched. Books contain/identify collections
|
||||
/** Set the book to be searched. Books contain/identify collections
|
||||
* of objects; the search will be performed over those books
|
||||
* specified with this function. If no books are set, no results
|
||||
* will be returned (since there is nothing to search over).
|
||||
* specified with this function. If no books are set, no results
|
||||
* will be returned (since there is nothing to search over). (CAS:
|
||||
* Apparently, if no books are set, you'll actually get a critical
|
||||
* assertion failure.)
|
||||
*
|
||||
* You can search multiple books. To specify multiple books, call
|
||||
* this function multiple times with different arguments.
|
@@ -39,7 +39,7 @@ typedef void (*QueryPredDataFree) (QofQueryPredData *pdata);
|
||||
/* A function to copy a query's predicate data */
|
||||
typedef QofQueryPredData *(*QueryPredicateCopyFunc) (QofQueryPredData *pdata);
|
||||
|
||||
/* A function to take the object, apply the getter->param_getfcn,
|
||||
/* A function to take the object, apply the getter->param_getfcn,
|
||||
* and return a printable string. Note that this QofParam->getfnc
|
||||
* function should be returning a type equal to this core object type.
|
||||
*
|
||||
@@ -48,7 +48,7 @@ typedef QofQueryPredData *(*QueryPredicateCopyFunc) (QofQueryPredData *pdata);
|
||||
typedef char * (*QueryToString) (gpointer object, QofParam *getter);
|
||||
|
||||
/* A function to test for equality of predicate data */
|
||||
typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
|
||||
typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
|
||||
QofQueryPredData *p2);
|
||||
|
||||
static QueryPredicateCopyFunc qof_query_copy_predicate (QofType type);
|
||||
@@ -129,8 +129,8 @@ static GHashTable *predEqualTable = NULL;
|
||||
|
||||
/* QOF_TYPE_STRING */
|
||||
|
||||
static int
|
||||
string_match_predicate (gpointer object,
|
||||
static int
|
||||
string_match_predicate (gpointer object,
|
||||
QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -169,7 +169,7 @@ string_match_predicate (gpointer object,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
string_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofParam *getter)
|
||||
{
|
||||
@@ -185,7 +185,7 @@ string_compare_func (gpointer a, gpointer b, gint options,
|
||||
return safe_strcmp (s1, s2);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
string_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_string_t pdata = (query_string_t) pd;
|
||||
@@ -207,12 +207,12 @@ string_copy_predicate (QofQueryPredData *pd)
|
||||
|
||||
VERIFY_PDATA_R (query_string_type);
|
||||
|
||||
return qof_query_string_predicate (pd->how, pdata->matchstring,
|
||||
return qof_query_string_predicate (pd->how, pdata->matchstring,
|
||||
pdata->options,
|
||||
pdata->is_regex);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
string_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_string_t pd1 = (query_string_t) p1;
|
||||
@@ -252,7 +252,7 @@ qof_query_string_predicate (QofQueryCompare how,
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
string_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
const char *res;
|
||||
@@ -264,7 +264,7 @@ string_to_string (gpointer object, QofParam *getter)
|
||||
|
||||
/* QOF_TYPE_DATE =================================================== */
|
||||
|
||||
static int
|
||||
static int
|
||||
date_compare (Timespec ta, Timespec tb, QofDateMatch options)
|
||||
{
|
||||
|
||||
@@ -286,7 +286,7 @@ date_compare (Timespec ta, Timespec tb, QofDateMatch options)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
date_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -318,7 +318,7 @@ date_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
date_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
{
|
||||
Timespec ta, tb;
|
||||
@@ -331,7 +331,7 @@ date_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
return date_compare (ta, tb, options);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
date_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_date_t pdata = (query_date_t)pd;
|
||||
@@ -351,7 +351,7 @@ date_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_date_predicate (pd->how, pdata->options, pdata->date);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
date_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_date_t pd1 = (query_date_t) p1;
|
||||
@@ -386,7 +386,7 @@ qof_query_date_predicate_get_date (QofQueryPredData *pd, Timespec *date)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
date_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
Timespec ts = ((query_date_getter)getter->param_getfcn)(object, getter);
|
||||
@@ -399,7 +399,7 @@ date_to_string (gpointer object, QofParam *getter)
|
||||
|
||||
/* QOF_TYPE_NUMERIC ================================================= */
|
||||
|
||||
static int
|
||||
static int
|
||||
numeric_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData* pd)
|
||||
{
|
||||
@@ -422,7 +422,7 @@ numeric_match_predicate (gpointer object, QofParam *getter,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Amounts are considered to be 'equal' if they match to
|
||||
/* Amounts are considered to be 'equal' if they match to
|
||||
* four decimal places. (epsilon=1/10000) */
|
||||
if (pd->how == QOF_COMPARE_EQUAL || pd->how == QOF_COMPARE_NEQ) {
|
||||
gnc_numeric cmp_val = gnc_numeric_create (1, 10000);
|
||||
@@ -454,7 +454,7 @@ numeric_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
numeric_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
{
|
||||
gnc_numeric va, vb;
|
||||
@@ -464,10 +464,10 @@ numeric_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
va = ((query_numeric_getter)getter->param_getfcn) (a, getter);
|
||||
vb = ((query_numeric_getter)getter->param_getfcn) (b, getter);
|
||||
|
||||
return gnc_numeric_compare (va, vb);
|
||||
return gnc_numeric_compare (va, vb);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
numeric_free_pdata (QofQueryPredData* pd)
|
||||
{
|
||||
query_numeric_t pdata = (query_numeric_t)pd;
|
||||
@@ -483,7 +483,7 @@ numeric_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_numeric_predicate (pd->how, pdata->options, pdata->amount);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
numeric_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_numeric_t pd1 = (query_numeric_t) p1;
|
||||
@@ -507,7 +507,7 @@ qof_query_numeric_predicate (QofQueryCompare how,
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
numeric_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
gnc_numeric num;
|
||||
@@ -516,7 +516,7 @@ numeric_to_string (gpointer object, QofParam *getter)
|
||||
return gnc_numeric_to_string (num);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
debcred_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
gnc_numeric num;
|
||||
@@ -527,7 +527,7 @@ debcred_to_string (gpointer object, QofParam *getter)
|
||||
|
||||
/* QOF_TYPE_GUID =================================================== */
|
||||
|
||||
static int
|
||||
static int
|
||||
guid_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -545,17 +545,17 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
* object list
|
||||
*/
|
||||
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
/* See if this GUID matches the object's guid */
|
||||
for (o_list = object; o_list; o_list = o_list->next)
|
||||
for (o_list = object; o_list; o_list = o_list->next)
|
||||
{
|
||||
guid = ((query_guid_getter)getter->param_getfcn) (o_list->data, getter);
|
||||
if (guid_equal (node->data, guid))
|
||||
if (guid_equal (node->data, guid))
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* If o_list is NULL, we've walked the whole list without finding
|
||||
* a match. Therefore break out now, the match has failed.
|
||||
*/
|
||||
@@ -563,7 +563,7 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* The match is complete. If node == NULL then we've succesfully
|
||||
* found a match for all the guids in the predicate. Return
|
||||
* appropriately below.
|
||||
@@ -580,12 +580,12 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
|
||||
o_list = ((query_glist_getter)getter->param_getfcn) (object, getter);
|
||||
|
||||
for (node = o_list; node; node = node->next)
|
||||
for (node = o_list; node; node = node->next)
|
||||
{
|
||||
GList *node2;
|
||||
|
||||
/* Search the predicate data for a match */
|
||||
for (node2 = pdata->guids; node2; node2 = node2->next)
|
||||
for (node2 = pdata->guids; node2; node2 = node2->next)
|
||||
{
|
||||
if (guid_equal (node->data, node2->data))
|
||||
break;
|
||||
@@ -605,13 +605,13 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
break;
|
||||
|
||||
default:
|
||||
/* object is a single object, getter returns a GUID*
|
||||
/* object is a single object, getter returns a GUID*
|
||||
*
|
||||
* See if the guid is in the list
|
||||
*/
|
||||
|
||||
guid = ((query_guid_getter)getter->param_getfcn) (object, getter);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
if (guid_equal (node->data, guid))
|
||||
break;
|
||||
@@ -636,7 +636,7 @@ guid_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
guid_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_guid_t pdata = (query_guid_t)pd;
|
||||
@@ -658,7 +658,7 @@ guid_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_guid_predicate (pdata->options, pdata->guids);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
guid_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_guid_t pd1 = (query_guid_t) p1;
|
||||
@@ -667,7 +667,7 @@ guid_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
|
||||
if (pd1->options != pd2->options) return FALSE;
|
||||
if (g_list_length (l1) != g_list_length (l2)) return FALSE;
|
||||
for ( ; l1 ; l1 = l1->next, l2 = l2->next)
|
||||
for ( ; l1 ; l1 = l1->next, l2 = l2->next)
|
||||
{
|
||||
if (!guid_equal (l1->data, l2->data))
|
||||
return FALSE;
|
||||
@@ -689,7 +689,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guid_list)
|
||||
pdata->options = options;
|
||||
|
||||
pdata->guids = g_list_copy (guid_list);
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
for (node = pdata->guids; node; node = node->next)
|
||||
{
|
||||
GUID *guid = guid_malloc ();
|
||||
*guid = *((GUID *)node->data);
|
||||
@@ -701,7 +701,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guid_list)
|
||||
/* ================================================================ */
|
||||
/* QOF_TYPE_INT32 */
|
||||
|
||||
static int
|
||||
static int
|
||||
int32_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -731,7 +731,7 @@ int32_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
int32_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofParam *getter)
|
||||
{
|
||||
@@ -746,7 +746,7 @@ int32_compare_func (gpointer a, gpointer b, gint options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
int32_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_int32_t pdata = (query_int32_t)pd;
|
||||
@@ -762,7 +762,7 @@ int32_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_int32_predicate (pd->how, pdata->val);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
int32_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_int32_t pd1 = (query_int32_t) p1;
|
||||
@@ -781,7 +781,7 @@ qof_query_int32_predicate (QofQueryCompare how, gint32 val)
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
int32_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
gint32 num = ((query_int32_getter)getter->param_getfcn)(object, getter);
|
||||
@@ -792,7 +792,7 @@ int32_to_string (gpointer object, QofParam *getter)
|
||||
/* ================================================================ */
|
||||
/* QOF_TYPE_INT64 */
|
||||
|
||||
static int
|
||||
static int
|
||||
int64_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -822,7 +822,7 @@ int64_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
int64_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofParam *getter)
|
||||
{
|
||||
@@ -837,7 +837,7 @@ int64_compare_func (gpointer a, gpointer b, gint options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
int64_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_int64_t pdata = (query_int64_t)pd;
|
||||
@@ -853,7 +853,7 @@ int64_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_int64_predicate (pd->how, pdata->val);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
int64_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_int64_t pd1 = (query_int64_t) p1;
|
||||
@@ -872,7 +872,7 @@ qof_query_int64_predicate (QofQueryCompare how, gint64 val)
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
int64_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
gint64 num = ((query_int64_getter)getter->param_getfcn)(object, getter);
|
||||
@@ -883,7 +883,7 @@ int64_to_string (gpointer object, QofParam *getter)
|
||||
/* ================================================================ */
|
||||
/* QOF_TYPE_DOUBLE */
|
||||
|
||||
static int
|
||||
static int
|
||||
double_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -913,7 +913,7 @@ double_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
double_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofParam *getter)
|
||||
{
|
||||
@@ -928,7 +928,7 @@ double_compare_func (gpointer a, gpointer b, gint options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
double_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_double_t pdata = (query_double_t)pd;
|
||||
@@ -944,7 +944,7 @@ double_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_double_predicate (pd->how, pdata->val);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
double_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_double_t pd1 = (query_double_t) p1;
|
||||
@@ -963,7 +963,7 @@ qof_query_double_predicate (QofQueryCompare how, double val)
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
double_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
double num = ((query_double_getter)getter->param_getfcn)(object, getter);
|
||||
@@ -973,7 +973,7 @@ double_to_string (gpointer object, QofParam *getter)
|
||||
|
||||
/* QOF_TYPE_BOOLEAN =================================================== */
|
||||
|
||||
static int
|
||||
static int
|
||||
boolean_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -995,7 +995,7 @@ boolean_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
boolean_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofParam *getter)
|
||||
{
|
||||
@@ -1008,7 +1008,7 @@ boolean_compare_func (gpointer a, gpointer b, gint options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
boolean_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_boolean_t pdata = (query_boolean_t)pd;
|
||||
@@ -1024,7 +1024,7 @@ boolean_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_boolean_predicate (pd->how, pdata->val);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
boolean_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_boolean_t pd1 = (query_boolean_t) p1;
|
||||
@@ -1046,7 +1046,7 @@ qof_query_boolean_predicate (QofQueryCompare how, gboolean val)
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
boolean_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
gboolean num = ((query_boolean_getter)getter->param_getfcn)(object, getter);
|
||||
@@ -1056,7 +1056,7 @@ boolean_to_string (gpointer object, QofParam *getter)
|
||||
|
||||
/* QOF_TYPE_CHAR =================================================== */
|
||||
|
||||
static int
|
||||
static int
|
||||
char_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -1080,7 +1080,7 @@ char_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
char_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
{
|
||||
char va, vb;
|
||||
@@ -1090,13 +1090,13 @@ char_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||
return (va-vb);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
char_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_char_t pdata = (query_char_t)pd;
|
||||
VERIFY_PDATA (query_char_type);
|
||||
g_free (pdata->char_list);
|
||||
g_free (pdata);
|
||||
g_free (pdata);
|
||||
}
|
||||
|
||||
static QofQueryPredData *
|
||||
@@ -1107,7 +1107,7 @@ char_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_char_predicate (pdata->options, pdata->char_list);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
char_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_char_t pd1 = (query_char_t) p1;
|
||||
@@ -1130,7 +1130,7 @@ qof_query_char_predicate (QofCharMatch options, const char *chars)
|
||||
return ((QofQueryPredData*)pdata);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
char_to_string (gpointer object, QofParam *getter)
|
||||
{
|
||||
char num = ((query_char_getter)getter->param_getfcn)(object, getter);
|
||||
@@ -1140,7 +1140,7 @@ char_to_string (gpointer object, QofParam *getter)
|
||||
|
||||
/* QOF_TYPE_KVP ================================================ */
|
||||
|
||||
static int
|
||||
static int
|
||||
kvp_match_predicate (gpointer object, QofParam *getter,
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
@@ -1184,7 +1184,7 @@ kvp_match_predicate (gpointer object, QofParam *getter,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
kvp_free_pdata (QofQueryPredData *pd)
|
||||
{
|
||||
query_kvp_t pdata = (query_kvp_t)pd;
|
||||
@@ -1192,13 +1192,13 @@ kvp_free_pdata (QofQueryPredData *pd)
|
||||
|
||||
VERIFY_PDATA (query_kvp_type);
|
||||
kvp_value_delete (pdata->value);
|
||||
for (node = pdata->path; node; node = node->next)
|
||||
for (node = pdata->path; node; node = node->next)
|
||||
{
|
||||
g_free (node->data);
|
||||
node->data = NULL;
|
||||
}
|
||||
g_slist_free (pdata->path);
|
||||
g_free (pdata);
|
||||
g_free (pdata);
|
||||
}
|
||||
|
||||
static QofQueryPredData *
|
||||
@@ -1209,7 +1209,7 @@ kvp_copy_predicate (QofQueryPredData *pd)
|
||||
return qof_query_kvp_predicate (pd->how, pdata->path, pdata->value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
kvp_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
query_kvp_t pd1 = (query_kvp_t) p1;
|
||||
@@ -1616,7 +1616,7 @@ qof_query_choice_predicate (QofGuidMatch options, GList *guid_list)
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
static void
|
||||
qof_query_register_core_object (QofType core_name,
|
||||
QofQueryPredicateFunc pred,
|
||||
QofCompareFunc comp,
|
||||
@@ -1650,7 +1650,7 @@ qof_query_register_core_object (QofType core_name,
|
||||
static void init_tables (void)
|
||||
{
|
||||
unsigned int i;
|
||||
struct
|
||||
struct
|
||||
{
|
||||
QofType name;
|
||||
QofQueryPredicateFunc pred;
|
||||
@@ -1659,10 +1659,10 @@ static void init_tables (void)
|
||||
QueryPredDataFree pd_free;
|
||||
QueryToString toString;
|
||||
QueryPredicateEqual pred_equal;
|
||||
} knownTypes[] =
|
||||
} knownTypes[] =
|
||||
{
|
||||
{ QOF_TYPE_STRING, string_match_predicate, string_compare_func,
|
||||
string_copy_predicate, string_free_pdata, string_to_string,
|
||||
string_copy_predicate, string_free_pdata, string_to_string,
|
||||
string_predicate_equal },
|
||||
{ QOF_TYPE_DATE, date_match_predicate, date_compare_func,
|
||||
date_copy_predicate, date_free_pdata, date_to_string,
|
||||
@@ -1701,7 +1701,7 @@ static void init_tables (void)
|
||||
};
|
||||
|
||||
/* Register the known data types */
|
||||
for (i = 0; i < (sizeof(knownTypes)/sizeof(*knownTypes)); i++)
|
||||
for (i = 0; i < (sizeof(knownTypes)/sizeof(*knownTypes)); i++)
|
||||
{
|
||||
qof_query_register_core_object (knownTypes[i].name,
|
||||
knownTypes[i].pred,
|
||||
@@ -1713,7 +1713,7 @@ static void init_tables (void)
|
||||
}
|
||||
}
|
||||
|
||||
static QueryPredicateCopyFunc
|
||||
static QueryPredicateCopyFunc
|
||||
qof_query_copy_predicate (QofType type)
|
||||
{
|
||||
QueryPredicateCopyFunc rc;
|
||||
@@ -1722,7 +1722,7 @@ qof_query_copy_predicate (QofType type)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static QueryPredDataFree
|
||||
static QueryPredDataFree
|
||||
qof_query_predicate_free (QofType type)
|
||||
{
|
||||
g_return_val_if_fail (type, NULL);
|
||||
@@ -1776,7 +1776,7 @@ qof_query_core_get_compare (QofType type)
|
||||
return g_hash_table_lookup (cmpTable, type);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
qof_query_core_predicate_free (QofQueryPredData *pdata)
|
||||
{
|
||||
QueryPredDataFree free_fcn;
|
||||
@@ -1800,7 +1800,7 @@ qof_query_core_predicate_copy (QofQueryPredData *pdata)
|
||||
return (copy (pdata));
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
qof_query_core_to_string (QofType type, gpointer object,
|
||||
QofParam *getter)
|
||||
{
|
||||
@@ -1816,7 +1816,7 @@ qof_query_core_to_string (QofType type, gpointer object,
|
||||
return toString (object, getter);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gboolean
|
||||
qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
{
|
||||
QueryPredicateEqual pred_equal;
|
@@ -23,7 +23,7 @@
|
||||
|
||||
/** @addtogroup Query
|
||||
@{ */
|
||||
|
||||
|
||||
/** @file qofquerycore.h
|
||||
@brief API for providing core Query data types
|
||||
@author Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
|
||||
@@ -42,7 +42,7 @@
|
||||
/**
|
||||
* PREDICATE DATA TYPES: All the predicate data types are rolled up into
|
||||
* the union type PredicateData. The "type" field specifies which type
|
||||
* the union is.
|
||||
* the union is.
|
||||
*/
|
||||
typedef struct _QofQueryPredData QofQueryPredData;
|
||||
|
||||
@@ -58,7 +58,7 @@ typedef enum {
|
||||
QOF_COMPARE_NEQ
|
||||
} QofQueryCompare;
|
||||
|
||||
/** List of known core query data-types...
|
||||
/** List of known core query data-types...
|
||||
* Each core query type defines it's set of optional "comparitor qualifiers".
|
||||
*/
|
||||
/* Comparisons for QOF_TYPE_STRING */
|
||||
@@ -67,7 +67,7 @@ typedef enum {
|
||||
QOF_STRING_MATCH_CASEINSENSITIVE
|
||||
} QofStringMatch;
|
||||
|
||||
/** Comparisons for QOF_TYPE_DATE
|
||||
/** Comparisons for QOF_TYPE_DATE
|
||||
* The QOF_DATE_MATCH_DAY comparison rounds the two time
|
||||
* values to mid-day and then compares these rounded values.
|
||||
* The QOF_DATE_MATCH_NORMAL comparison matches the time values,
|
||||
@@ -84,10 +84,10 @@ typedef enum {
|
||||
/** Comparisons for QOF_TYPE_NUMERIC, QOF_TYPE_DEBCRED
|
||||
*
|
||||
* XXX Should be deprecated, or at least wrapped up as a convnience
|
||||
* function, this is based on the old bill gribble code, which assumed
|
||||
* the amount was always positive, and then specified a funds-flow
|
||||
* function, this is based on the old bill gribble code, which assumed
|
||||
* the amount was always positive, and then specified a funds-flow
|
||||
* direction (credit, debit, or either).
|
||||
*
|
||||
*
|
||||
* The point being that 'match credit' is equivalent to the compound
|
||||
* predicate (amount >= 0) && (amount 'op' value) while the 'match
|
||||
* debit' predicate is equivalent to (amount <= 0) && (abs(amount) 'op' value)
|
||||
@@ -101,7 +101,7 @@ typedef enum {
|
||||
|
||||
/* Comparisons for QOF_TYPE_GUID */
|
||||
typedef enum {
|
||||
/** These expect a single object and expect the
|
||||
/** These expect a single object and expect the
|
||||
* QofAccessFunc returns GUID* */
|
||||
QOF_GUID_MATCH_ANY = 1,
|
||||
QOF_GUID_MATCH_NONE,
|
||||
@@ -114,12 +114,12 @@ typedef enum {
|
||||
QOF_GUID_MATCH_LIST_ANY,
|
||||
} QofGuidMatch;
|
||||
|
||||
/** A CHAR type is for a RECNCell, Comparisons for QOF_TYPE_CHAR
|
||||
/** A CHAR type is for a RECNCell, Comparisons for QOF_TYPE_CHAR
|
||||
* 'ANY' will match any charagter in the string.
|
||||
*
|
||||
* Match 'ANY' is a convenience/performance-enhanced predicate
|
||||
* Match 'ANY' is a convenience/performance-enhanced predicate
|
||||
* for the compound statement (value==char1) || (value==char2) || etc.
|
||||
* Match 'NONE' is equivalent to
|
||||
* Match 'NONE' is equivalent to
|
||||
* (value != char1) && (value != char2) && etc.
|
||||
*/
|
||||
typedef enum {
|
||||
@@ -138,15 +138,15 @@ struct _QofQueryPredData {
|
||||
};
|
||||
|
||||
|
||||
/** @name Core Data Type Predicates
|
||||
/** @name Core Data Type Predicates
|
||||
@{ */
|
||||
QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
|
||||
QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
|
||||
const char *str,
|
||||
QofStringMatch options,
|
||||
gboolean is_regex);
|
||||
|
||||
QofQueryPredData *qof_query_date_predicate (QofQueryCompare how,
|
||||
QofDateMatch options,
|
||||
QofDateMatch options,
|
||||
Timespec date);
|
||||
|
||||
QofQueryPredData *qof_query_numeric_predicate (QofQueryCompare how,
|
||||
@@ -169,13 +169,13 @@ QofQueryPredData *qof_query_choice_predicate (QofGuidMatch options, GList *guid
|
||||
* sense, the 'path' is handled as if it were a paramter.
|
||||
*/
|
||||
QofQueryPredData *qof_query_kvp_predicate (QofQueryCompare how,
|
||||
GSList *path,
|
||||
GSList *path,
|
||||
const KvpValue *value);
|
||||
|
||||
/** Same predicate as above, except that 'path' is assumed to be
|
||||
/** Same predicate as above, except that 'path' is assumed to be
|
||||
* a string containing slash-separated pathname. */
|
||||
QofQueryPredData *qof_query_kvp_predicate_path (QofQueryCompare how,
|
||||
const char *path,
|
||||
const char *path,
|
||||
const KvpValue *value);
|
||||
|
||||
/** Copy a predicate. */
|
@@ -29,7 +29,7 @@
|
||||
@author Copyright (c) 1998-2004 Linas Vepstas <linas@linas.org>
|
||||
@author Copyright (c) 2000 Dave Peticolas
|
||||
@author Copyright (c) 2005 Neil Williams <linux@codehelp.co.uk>
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -77,7 +77,7 @@ qof_session_add_close_hook (GFunc fn, gpointer data)
|
||||
GHook *hook;
|
||||
|
||||
if (session_closed_hooks == NULL) {
|
||||
session_closed_hooks = malloc(sizeof(GHookList));
|
||||
session_closed_hooks = malloc(sizeof(GHookList)); /* LEAKED */
|
||||
g_hook_list_init (session_closed_hooks, sizeof(GHook));
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ qof_book_set_partial(QofBook *book)
|
||||
gboolean partial;
|
||||
|
||||
partial =
|
||||
(gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
|
||||
(gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
|
||||
if(!partial) {
|
||||
qof_book_set_data(book, PARTIAL_QOFBOOK, (gboolean*)TRUE);
|
||||
}
|
||||
@@ -412,7 +412,7 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
|
||||
void (*i64_setter) (QofEntity*, gint64);
|
||||
void (*char_setter) (QofEntity*, char*);
|
||||
void (*kvp_frame_setter) (QofEntity*, KvpFrame*);
|
||||
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
context = (QofEntityCopyData*) user_data;
|
||||
cm_date.tv_nsec = 0;
|
||||
@@ -507,7 +507,7 @@ qof_entity_guid_match(QofSession *new_session, QofEntity *original)
|
||||
QofIdTypeConst type;
|
||||
QofBook *targetBook;
|
||||
QofCollection *coll;
|
||||
|
||||
|
||||
copy = NULL;
|
||||
g_return_val_if_fail(original != NULL, FALSE);
|
||||
targetBook = qof_session_get_book(new_session);
|
||||
@@ -528,7 +528,7 @@ qof_entity_list_foreach(gpointer data, gpointer user_data)
|
||||
QofInstance *inst;
|
||||
QofBook *book;
|
||||
const GUID *g;
|
||||
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
original = (QofEntity*)data;
|
||||
g_return_if_fail(user_data != NULL);
|
||||
@@ -558,7 +558,7 @@ qof_entity_coll_foreach(QofEntity *original, gpointer user_data)
|
||||
QofBook *targetBook;
|
||||
QofCollection *coll;
|
||||
QofEntity *copy;
|
||||
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
copy = NULL;
|
||||
qecd = (QofEntityCopyData*)user_data;
|
||||
@@ -576,7 +576,7 @@ qof_entity_coll_copy(QofEntity *original, gpointer user_data)
|
||||
QofBook *book;
|
||||
QofInstance *inst;
|
||||
const GUID *g;
|
||||
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
qecd = (QofEntityCopyData*)user_data;
|
||||
book = qof_session_get_book(qecd->new_session);
|
||||
@@ -669,7 +669,7 @@ recurse_collection_cb (QofEntity *ent, gpointer user_data)
|
||||
if(!ent || !store) { return; }
|
||||
store->success = qof_entity_copy_to_session(store->session, ent);
|
||||
if(store->success) {
|
||||
store->ent_list = g_list_append(store->ent_list, ent);
|
||||
store->ent_list = g_list_append(store->ent_list, ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ qof_session_load_backend(QofSession * session, char * access_method)
|
||||
continue;
|
||||
}
|
||||
/* Use the providers creation callback */
|
||||
session->backend = (*(prov->backend_new))();
|
||||
session->backend = (*(prov->backend_new))();
|
||||
session->backend->provider = prov;
|
||||
/* Tell the books about the backend that they'll be using. */
|
||||
for (node=session->books; node; node=node->next)
|
||||
@@ -1083,6 +1083,7 @@ qof_session_load (QofSession *session,
|
||||
qof_book_set_backend (ob, NULL);
|
||||
qof_book_destroy (ob);
|
||||
}
|
||||
/* Um, I think we're leaking the oldbooks list. */
|
||||
|
||||
LEAVE ("sess = %p, book_id=%s", session, session->book_id
|
||||
? session->book_id : "(null)");
|
||||
@@ -1259,48 +1260,6 @@ qof_session_save (QofSession *session,
|
||||
LEAVE("error -- No backend!");
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
/* XXX This exports the list of accounts to a file. It does not export
|
||||
* any transactions. Its a place-holder until full book-closing is implemented.
|
||||
*/
|
||||
|
||||
#ifdef GNUCASH_MAJOR_VERSION
|
||||
|
||||
gboolean
|
||||
qof_session_export (QofSession *tmp_session,
|
||||
QofSession *real_session,
|
||||
QofPercentageFunc percentage_func)
|
||||
{
|
||||
QofBook *book;
|
||||
QofBackend *be;
|
||||
|
||||
if ((!tmp_session) || (!real_session)) return FALSE;
|
||||
|
||||
book = qof_session_get_book (real_session);
|
||||
ENTER ("tmp_session=%p real_session=%p book=%p book_id=%s",
|
||||
tmp_session, real_session, book,
|
||||
tmp_session -> book_id
|
||||
? tmp_session->book_id : "(null)");
|
||||
|
||||
/* There must be a backend or else. (It should always be the file
|
||||
* backend too.)
|
||||
*/
|
||||
be = tmp_session->backend;
|
||||
if (!be)
|
||||
return FALSE;
|
||||
|
||||
be->percentage = percentage_func;
|
||||
if (be->export)
|
||||
{
|
||||
|
||||
(be->export)(be, book);
|
||||
if (save_error_handler(be, tmp_session)) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* GNUCASH_MAJOR_VERSION */
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
void
|
||||
@@ -1340,7 +1299,7 @@ qof_session_destroy (QofSession *session)
|
||||
/* destroy the backend */
|
||||
qof_session_destroy_backend(session);
|
||||
|
||||
for (node=session->books; node; node=node->next)
|
||||
for (node = session->books; node; node = node->next)
|
||||
{
|
||||
QofBook *book = node->data;
|
||||
qof_book_set_backend (book, NULL);
|
||||
@@ -1411,48 +1370,4 @@ qof_session_process_events (QofSession *session)
|
||||
return session->backend->process_events (session->backend);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
#ifdef GNUCASH_MAJOR_VERSION
|
||||
|
||||
/* this should go in a separate binary to create a rpc server */
|
||||
|
||||
void
|
||||
gnc_run_rpc_server (void)
|
||||
{
|
||||
const char * dll_err;
|
||||
void * dll_handle;
|
||||
int (*rpc_run)(short);
|
||||
int ret;
|
||||
|
||||
/* open and resolve all symbols now (we don't want mystery
|
||||
* failure later) */
|
||||
#ifndef RTLD_NOW
|
||||
# ifdef RTLD_LAZY
|
||||
# define RTLD_NOW RTLD_LAZY
|
||||
# endif
|
||||
#endif
|
||||
dll_handle = dlopen ("libgnc_rpc.so", RTLD_NOW);
|
||||
if (! dll_handle)
|
||||
{
|
||||
dll_err = dlerror();
|
||||
PWARN (" can't load library: %s\n", dll_err ? dll_err : "");
|
||||
return;
|
||||
}
|
||||
|
||||
rpc_run = dlsym (dll_handle, "rpc_server_run");
|
||||
dll_err = dlerror();
|
||||
if (dll_err)
|
||||
{
|
||||
dll_err = dlerror();
|
||||
PWARN (" can't find symbol: %s\n", dll_err ? dll_err : "");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = (*rpc_run)(0);
|
||||
|
||||
/* XXX How do we force an exit? */
|
||||
}
|
||||
#endif /* GNUCASH_MAJOR_VERSION */
|
||||
|
||||
/* =================== END OF FILE ====================================== */
|
@@ -425,8 +425,8 @@ repeated references for a single entity.
|
||||
*/
|
||||
typedef struct qof_entity_reference {
|
||||
QofIdType choice_type;/**< When the reference is a different type.*/
|
||||
QofIdType type; /**< The type of entity */
|
||||
GUID *ref_guid; /**< The GUID of the REFERENCE entity */
|
||||
QofIdType type; /**< The type of entity */
|
||||
GUID *ref_guid; /**< The GUID of the REFERENCE entity */
|
||||
const QofParam *param; /**< The parameter name and type. */
|
||||
const GUID *ent_guid; /**< The GUID of the original entity. */
|
||||
}QofEntityReference;
|
@@ -72,7 +72,7 @@ QofSqlQuery *
|
||||
qof_sql_query_new(void)
|
||||
{
|
||||
QofSqlQuery * sqn = (QofSqlQuery *) g_new0 (QofSqlQuery, 1);
|
||||
|
||||
|
||||
sqn->qof_query = NULL;
|
||||
sqn->parse_result = NULL;
|
||||
sqn->book = NULL;
|
||||
@@ -171,7 +171,7 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
Timespec ts;
|
||||
QofType param_type;
|
||||
QofGuidMatch gm;
|
||||
|
||||
|
||||
pred_data = NULL;
|
||||
if (NULL == cond)
|
||||
{
|
||||
@@ -484,7 +484,7 @@ handle_where (QofSqlQuery *query, sql_where *swear)
|
||||
{
|
||||
QofQueryOp qop;
|
||||
QofQuery * qq;
|
||||
|
||||
|
||||
switch (swear->type)
|
||||
{
|
||||
case SQL_pair:
|
||||
@@ -536,7 +536,7 @@ handle_sort_order (QofSqlQuery *query, GList *sorder_list)
|
||||
int i;
|
||||
sql_order_field *sorder;
|
||||
char * qparam_name;
|
||||
|
||||
|
||||
if (!sorder_list) return;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
@@ -581,7 +581,7 @@ static void
|
||||
qof_queryForeachParam( QofParam* param, gpointer user_data)
|
||||
{
|
||||
QofSqlQuery *q;
|
||||
|
||||
|
||||
g_return_if_fail(user_data != NULL);
|
||||
q = (QofSqlQuery*)user_data;
|
||||
g_return_if_fail(param != NULL);
|
||||
@@ -754,7 +754,7 @@ qof_sql_insertCB( gpointer value, gpointer data)
|
||||
boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
|
||||
if(boolean_setter != NULL) { boolean_setter(ent, cm_boolean); }
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_KVP) == 0) {
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_KVP) == 0) {
|
||||
|
||||
}
|
||||
if(safe_strcmp(cm_param->param_type, QOF_TYPE_CHAR) == 0) {
|
||||
@@ -817,7 +817,7 @@ qof_sql_query_parse (QofSqlQuery *query, const char *str)
|
||||
char *buf;
|
||||
sql_select_statement *sss;
|
||||
sql_where *swear;
|
||||
|
||||
|
||||
if (!query) return;
|
||||
|
||||
/* Delete old query, if any */
|
Reference in New Issue
Block a user