summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am26
-rw-r--r--Makefile.in143
-rwxr-xr-xconfigure97
-rw-r--r--configure.in40
-rw-r--r--src/amount.cc42
-rw-r--r--src/amount.h34
-rw-r--r--src/balance.cc58
-rw-r--r--src/balance.h92
-rw-r--r--src/binary.cc2
-rw-r--r--src/binary.h2
-rw-r--r--src/commodity.cc4
-rw-r--r--src/commodity.h23
-rw-r--r--src/format.cc2
-rw-r--r--src/gnucash.cc10
-rw-r--r--src/gnucash.h5
-rw-r--r--src/journal.cc39
-rw-r--r--src/journal.h60
-rw-r--r--src/ofx.cc7
-rw-r--r--src/py_amount.cc49
-rw-r--r--src/py_option.cc3
-rw-r--r--src/py_value.cc8
-rw-r--r--src/pyinterp.cc12
-rw-r--r--src/register.cc9
-rw-r--r--src/report.cc12
-rw-r--r--src/report.h14
-rw-r--r--src/session.h2
-rw-r--r--src/system.hh4
-rw-r--r--src/textual.cc9
-rw-r--r--src/times.cc4
-rw-r--r--src/transform.cc4
-rw-r--r--src/utils.cc19
-rw-r--r--src/utils.h7
-rw-r--r--src/value.cc2065
-rw-r--r--src/value.h421
-rw-r--r--src/xml.cc11
-rw-r--r--src/xml.h36
-rw-r--r--src/xmlparse.cc6
-rw-r--r--src/xpath.cc138
-rw-r--r--src/xpath.h48
-rw-r--r--tests/numerics/BasicAmount.cc3
-rw-r--r--tests/numerics/CommodityAmount.cc3
-rw-r--r--tests/python/numerics/BasicAmount.py3
-rw-r--r--tests/python/numerics/CommodityAmount.py3
43 files changed, 1360 insertions, 2219 deletions
diff --git a/Makefile.am b/Makefile.am
index 3e22e2a8..a35635b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
-SUBDIRS = gdtoa
+SUBDIRS = gdtoa
BUILT_SOURCES =
-CLEANFILES =
+CLEANFILES =
ESC_srcdir=`echo "$(srcdir)" | sed 's/\//\\\\\//g'`
@@ -22,14 +22,14 @@ endif
AM_YFLAGS = -d
AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c
-#WARNFLAGS = -H -Wall -Wextra -Wfloat-equal -Wno-endif-labels
-#WARNFLAGS += -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion
-#WARNFLAGS += -Wconversion -Wshorten-64-to-32 -Wsign-compare
-#WARNFLAGS += -Wmissing-field-initializers -pedantic-errors
+WARNFLAGS = -Wall -Wextra -Wfloat-equal -Wno-endif-labels
+WARNFLAGS += -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion
+WARNFLAGS += -Wconversion -Wshorten-64-to-32 -Wsign-compare
+WARNFLAGS += -Wmissing-field-initializers -pedantic-errors
libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \
- -I$(srcdir)/src
-libledger_la_LDFLAGS = -release 3.0
+ -I$(srcdir)/src #$(WARNFLAGS)
+libledger_la_LDFLAGS = -release $(PACKAGE_VERSION)
libledger_la_SOURCES = \
src/utils.cc \
@@ -79,7 +79,6 @@ libledger_la_SOURCES += src/pyinterp.cc
endif
if USE_PCH
-libledger_la_CXXFLAGS = $(WARNFLAGS)
nodist_libledger_la_SOURCES = system.hh.gch
BUILT_SOURCES += system.hh.gch
@@ -93,7 +92,7 @@ endif
libpyledger_la_CPPFLAGS = $(libledger_la_CPPFLAGS)
-libpyledger_la_LDFLAGS = -release 3.0
+libpyledger_la_LDFLAGS = -release $(PACKAGE_VERSION)
libpyledger_la_SOURCES = \
src/py_utils.cc \
@@ -142,11 +141,10 @@ pkginclude_HEADERS = \
bin_PROGRAMS = ledger
ledger_CPPFLAGS = $(libledger_la_CPPFLAGS)
-ledger_CXXFLAGS = $(WARNFLAGS)
-ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la $(LEXLIB)
-ledger_LDFLAGS = -static # for the sake of command-line speed
+ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la $(LEXLIB)
+ledger_LDFLAGS = -static # for the sake of command-line speed
-ledger_SOURCES = \
+ledger_SOURCES = \
src/option.cc \
src/main.cc
diff --git a/Makefile.in b/Makefile.in
index a8a30214..feaa7e80 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -114,7 +114,7 @@ nodist_libledger_la_OBJECTS =
libledger_la_OBJECTS = $(am_libledger_la_OBJECTS) \
$(nodist_libledger_la_OBJECTS)
libledger_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libledger_la_CXXFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(libledger_la_LDFLAGS) $(LDFLAGS) -o $@
libpyledger_la_LIBADD =
am_libpyledger_la_OBJECTS = libpyledger_la-py_utils.lo \
@@ -145,7 +145,7 @@ ledger_OBJECTS = $(am_ledger_OBJECTS)
ledger_DEPENDENCIES = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la \
$(am__append_13)
ledger_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=link $(CXXLD) $(ledger_CXXFLAGS) $(CXXFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(ledger_LDFLAGS) $(LDFLAGS) -o $@
am__ledger_so_SOURCES_DIST = src/pyledger.cc src/py_utils.cc \
src/py_times.cc src/py_amount.cc
@@ -354,15 +354,14 @@ EXTRA_DIST = docs tests ledger.pdf ledger.info
lib_LTLIBRARIES = libledger.la $(am__append_1)
AM_YFLAGS = -d
AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c
-
-#WARNFLAGS = -H -Wall -Wextra -Wfloat-equal -Wno-endif-labels
-#WARNFLAGS += -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion
-#WARNFLAGS += -Wconversion -Wshorten-64-to-32 -Wsign-compare
-#WARNFLAGS += -Wmissing-field-initializers -pedantic-errors
+WARNFLAGS = -Wall -Wextra -Wfloat-equal -Wno-endif-labels -Wcast-qual \
+ -Wcast-align -Wwrite-strings -Wconversion -Wconversion \
+ -Wshorten-64-to-32 -Wsign-compare -Wmissing-field-initializers \
+ -pedantic-errors
libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \
-I$(srcdir)/src $(am__append_2) $(am__append_4) \
$(am__append_6) $(am__append_8) $(am__append_9)
-libledger_la_LDFLAGS = -release 3.0
+libledger_la_LDFLAGS = -release $(PACKAGE_VERSION)
libledger_la_SOURCES = src/utils.cc src/times.cc src/mask.cc \
src/commodity.cc src/amount.cc src/balance.cc src/value.cc \
src/session.cc src/journal.cc src/binary.cc src/qif.cc \
@@ -371,10 +370,9 @@ libledger_la_SOURCES = src/utils.cc src/times.cc src/mask.cc \
src/report.cc src/transform.cc src/xml.cc src/xmlparse.cc \
src/xpath.cc $(am__append_3) $(am__append_5) $(am__append_7) \
$(am__append_10)
-@USE_PCH_TRUE@libledger_la_CXXFLAGS = $(WARNFLAGS)
@USE_PCH_TRUE@nodist_libledger_la_SOURCES = system.hh.gch
libpyledger_la_CPPFLAGS = $(libledger_la_CPPFLAGS)
-libpyledger_la_LDFLAGS = -release 3.0
+libpyledger_la_LDFLAGS = -release $(PACKAGE_VERSION)
libpyledger_la_SOURCES = \
src/py_utils.cc \
src/py_times.cc \
@@ -417,7 +415,6 @@ pkginclude_HEADERS = \
src/xpath.h
ledger_CPPFLAGS = $(libledger_la_CPPFLAGS)
-ledger_CXXFLAGS = $(WARNFLAGS)
ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la $(LEXLIB) \
$(am__append_13)
ledger_LDFLAGS = -static # for the sake of command-line speed
@@ -663,193 +660,193 @@ distclean-compile:
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
libledger_la-utils.lo: src/utils.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-utils.lo -MD -MP -MF $(DEPDIR)/libledger_la-utils.Tpo -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-utils.lo -MD -MP -MF $(DEPDIR)/libledger_la-utils.Tpo -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-utils.Tpo $(DEPDIR)/libledger_la-utils.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/utils.cc' object='libledger_la-utils.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc
libledger_la-times.lo: src/times.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-times.lo -MD -MP -MF $(DEPDIR)/libledger_la-times.Tpo -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-times.lo -MD -MP -MF $(DEPDIR)/libledger_la-times.Tpo -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-times.Tpo $(DEPDIR)/libledger_la-times.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/times.cc' object='libledger_la-times.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc
libledger_la-mask.lo: src/mask.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-mask.lo -MD -MP -MF $(DEPDIR)/libledger_la-mask.Tpo -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-mask.lo -MD -MP -MF $(DEPDIR)/libledger_la-mask.Tpo -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-mask.Tpo $(DEPDIR)/libledger_la-mask.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/mask.cc' object='libledger_la-mask.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc
libledger_la-commodity.lo: src/commodity.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-commodity.lo -MD -MP -MF $(DEPDIR)/libledger_la-commodity.Tpo -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-commodity.lo -MD -MP -MF $(DEPDIR)/libledger_la-commodity.Tpo -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-commodity.Tpo $(DEPDIR)/libledger_la-commodity.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/commodity.cc' object='libledger_la-commodity.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc
libledger_la-amount.lo: src/amount.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-amount.lo -MD -MP -MF $(DEPDIR)/libledger_la-amount.Tpo -c -o libledger_la-amount.lo `test -f 'src/amount.cc' || echo '$(srcdir)/'`src/amount.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-amount.lo -MD -MP -MF $(DEPDIR)/libledger_la-amount.Tpo -c -o libledger_la-amount.lo `test -f 'src/amount.cc' || echo '$(srcdir)/'`src/amount.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-amount.Tpo $(DEPDIR)/libledger_la-amount.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/amount.cc' object='libledger_la-amount.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-amount.lo `test -f 'src/amount.cc' || echo '$(srcdir)/'`src/amount.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-amount.lo `test -f 'src/amount.cc' || echo '$(srcdir)/'`src/amount.cc
libledger_la-balance.lo: src/balance.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-balance.lo -MD -MP -MF $(DEPDIR)/libledger_la-balance.Tpo -c -o libledger_la-balance.lo `test -f 'src/balance.cc' || echo '$(srcdir)/'`src/balance.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-balance.lo -MD -MP -MF $(DEPDIR)/libledger_la-balance.Tpo -c -o libledger_la-balance.lo `test -f 'src/balance.cc' || echo '$(srcdir)/'`src/balance.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-balance.Tpo $(DEPDIR)/libledger_la-balance.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/balance.cc' object='libledger_la-balance.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-balance.lo `test -f 'src/balance.cc' || echo '$(srcdir)/'`src/balance.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-balance.lo `test -f 'src/balance.cc' || echo '$(srcdir)/'`src/balance.cc
libledger_la-value.lo: src/value.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-value.lo -MD -MP -MF $(DEPDIR)/libledger_la-value.Tpo -c -o libledger_la-value.lo `test -f 'src/value.cc' || echo '$(srcdir)/'`src/value.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-value.lo -MD -MP -MF $(DEPDIR)/libledger_la-value.Tpo -c -o libledger_la-value.lo `test -f 'src/value.cc' || echo '$(srcdir)/'`src/value.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-value.Tpo $(DEPDIR)/libledger_la-value.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/value.cc' object='libledger_la-value.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-value.lo `test -f 'src/value.cc' || echo '$(srcdir)/'`src/value.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-value.lo `test -f 'src/value.cc' || echo '$(srcdir)/'`src/value.cc
libledger_la-session.lo: src/session.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-session.lo -MD -MP -MF $(DEPDIR)/libledger_la-session.Tpo -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-session.lo -MD -MP -MF $(DEPDIR)/libledger_la-session.Tpo -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-session.Tpo $(DEPDIR)/libledger_la-session.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/session.cc' object='libledger_la-session.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc
libledger_la-journal.lo: src/journal.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-journal.lo -MD -MP -MF $(DEPDIR)/libledger_la-journal.Tpo -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-journal.lo -MD -MP -MF $(DEPDIR)/libledger_la-journal.Tpo -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-journal.Tpo $(DEPDIR)/libledger_la-journal.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/journal.cc' object='libledger_la-journal.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc
libledger_la-binary.lo: src/binary.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-binary.lo -MD -MP -MF $(DEPDIR)/libledger_la-binary.Tpo -c -o libledger_la-binary.lo `test -f 'src/binary.cc' || echo '$(srcdir)/'`src/binary.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-binary.lo -MD -MP -MF $(DEPDIR)/libledger_la-binary.Tpo -c -o libledger_la-binary.lo `test -f 'src/binary.cc' || echo '$(srcdir)/'`src/binary.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-binary.Tpo $(DEPDIR)/libledger_la-binary.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/binary.cc' object='libledger_la-binary.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-binary.lo `test -f 'src/binary.cc' || echo '$(srcdir)/'`src/binary.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-binary.lo `test -f 'src/binary.cc' || echo '$(srcdir)/'`src/binary.cc
libledger_la-qif.lo: src/qif.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-qif.lo -MD -MP -MF $(DEPDIR)/libledger_la-qif.Tpo -c -o libledger_la-qif.lo `test -f 'src/qif.cc' || echo '$(srcdir)/'`src/qif.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-qif.lo -MD -MP -MF $(DEPDIR)/libledger_la-qif.Tpo -c -o libledger_la-qif.lo `test -f 'src/qif.cc' || echo '$(srcdir)/'`src/qif.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-qif.Tpo $(DEPDIR)/libledger_la-qif.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/qif.cc' object='libledger_la-qif.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-qif.lo `test -f 'src/qif.cc' || echo '$(srcdir)/'`src/qif.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-qif.lo `test -f 'src/qif.cc' || echo '$(srcdir)/'`src/qif.cc
libledger_la-textual.lo: src/textual.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-textual.lo -MD -MP -MF $(DEPDIR)/libledger_la-textual.Tpo -c -o libledger_la-textual.lo `test -f 'src/textual.cc' || echo '$(srcdir)/'`src/textual.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-textual.lo -MD -MP -MF $(DEPDIR)/libledger_la-textual.Tpo -c -o libledger_la-textual.lo `test -f 'src/textual.cc' || echo '$(srcdir)/'`src/textual.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-textual.Tpo $(DEPDIR)/libledger_la-textual.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/textual.cc' object='libledger_la-textual.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-textual.lo `test -f 'src/textual.cc' || echo '$(srcdir)/'`src/textual.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-textual.lo `test -f 'src/textual.cc' || echo '$(srcdir)/'`src/textual.cc
libledger_la-quotes.lo: src/quotes.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-quotes.lo -MD -MP -MF $(DEPDIR)/libledger_la-quotes.Tpo -c -o libledger_la-quotes.lo `test -f 'src/quotes.cc' || echo '$(srcdir)/'`src/quotes.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-quotes.lo -MD -MP -MF $(DEPDIR)/libledger_la-quotes.Tpo -c -o libledger_la-quotes.lo `test -f 'src/quotes.cc' || echo '$(srcdir)/'`src/quotes.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-quotes.Tpo $(DEPDIR)/libledger_la-quotes.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/quotes.cc' object='libledger_la-quotes.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-quotes.lo `test -f 'src/quotes.cc' || echo '$(srcdir)/'`src/quotes.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-quotes.lo `test -f 'src/quotes.cc' || echo '$(srcdir)/'`src/quotes.cc
libledger_la-csv.lo: src/csv.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-csv.lo -MD -MP -MF $(DEPDIR)/libledger_la-csv.Tpo -c -o libledger_la-csv.lo `test -f 'src/csv.cc' || echo '$(srcdir)/'`src/csv.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-csv.lo -MD -MP -MF $(DEPDIR)/libledger_la-csv.Tpo -c -o libledger_la-csv.lo `test -f 'src/csv.cc' || echo '$(srcdir)/'`src/csv.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-csv.Tpo $(DEPDIR)/libledger_la-csv.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/csv.cc' object='libledger_la-csv.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-csv.lo `test -f 'src/csv.cc' || echo '$(srcdir)/'`src/csv.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-csv.lo `test -f 'src/csv.cc' || echo '$(srcdir)/'`src/csv.cc
libledger_la-derive.lo: src/derive.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-derive.lo -MD -MP -MF $(DEPDIR)/libledger_la-derive.Tpo -c -o libledger_la-derive.lo `test -f 'src/derive.cc' || echo '$(srcdir)/'`src/derive.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-derive.lo -MD -MP -MF $(DEPDIR)/libledger_la-derive.Tpo -c -o libledger_la-derive.lo `test -f 'src/derive.cc' || echo '$(srcdir)/'`src/derive.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-derive.Tpo $(DEPDIR)/libledger_la-derive.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/derive.cc' object='libledger_la-derive.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-derive.lo `test -f 'src/derive.cc' || echo '$(srcdir)/'`src/derive.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-derive.lo `test -f 'src/derive.cc' || echo '$(srcdir)/'`src/derive.cc
libledger_la-emacs.lo: src/emacs.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-emacs.lo -MD -MP -MF $(DEPDIR)/libledger_la-emacs.Tpo -c -o libledger_la-emacs.lo `test -f 'src/emacs.cc' || echo '$(srcdir)/'`src/emacs.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-emacs.lo -MD -MP -MF $(DEPDIR)/libledger_la-emacs.Tpo -c -o libledger_la-emacs.lo `test -f 'src/emacs.cc' || echo '$(srcdir)/'`src/emacs.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-emacs.Tpo $(DEPDIR)/libledger_la-emacs.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/emacs.cc' object='libledger_la-emacs.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-emacs.lo `test -f 'src/emacs.cc' || echo '$(srcdir)/'`src/emacs.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-emacs.lo `test -f 'src/emacs.cc' || echo '$(srcdir)/'`src/emacs.cc
libledger_la-format.lo: src/format.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-format.lo -MD -MP -MF $(DEPDIR)/libledger_la-format.Tpo -c -o libledger_la-format.lo `test -f 'src/format.cc' || echo '$(srcdir)/'`src/format.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-format.lo -MD -MP -MF $(DEPDIR)/libledger_la-format.Tpo -c -o libledger_la-format.lo `test -f 'src/format.cc' || echo '$(srcdir)/'`src/format.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-format.Tpo $(DEPDIR)/libledger_la-format.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/format.cc' object='libledger_la-format.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-format.lo `test -f 'src/format.cc' || echo '$(srcdir)/'`src/format.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-format.lo `test -f 'src/format.cc' || echo '$(srcdir)/'`src/format.cc
libledger_la-reconcile.lo: src/reconcile.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-reconcile.lo -MD -MP -MF $(DEPDIR)/libledger_la-reconcile.Tpo -c -o libledger_la-reconcile.lo `test -f 'src/reconcile.cc' || echo '$(srcdir)/'`src/reconcile.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-reconcile.lo -MD -MP -MF $(DEPDIR)/libledger_la-reconcile.Tpo -c -o libledger_la-reconcile.lo `test -f 'src/reconcile.cc' || echo '$(srcdir)/'`src/reconcile.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-reconcile.Tpo $(DEPDIR)/libledger_la-reconcile.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/reconcile.cc' object='libledger_la-reconcile.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-reconcile.lo `test -f 'src/reconcile.cc' || echo '$(srcdir)/'`src/reconcile.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-reconcile.lo `test -f 'src/reconcile.cc' || echo '$(srcdir)/'`src/reconcile.cc
libledger_la-register.lo: src/register.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-register.lo -MD -MP -MF $(DEPDIR)/libledger_la-register.Tpo -c -o libledger_la-register.lo `test -f 'src/register.cc' || echo '$(srcdir)/'`src/register.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-register.lo -MD -MP -MF $(DEPDIR)/libledger_la-register.Tpo -c -o libledger_la-register.lo `test -f 'src/register.cc' || echo '$(srcdir)/'`src/register.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-register.Tpo $(DEPDIR)/libledger_la-register.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/register.cc' object='libledger_la-register.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-register.lo `test -f 'src/register.cc' || echo '$(srcdir)/'`src/register.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-register.lo `test -f 'src/register.cc' || echo '$(srcdir)/'`src/register.cc
libledger_la-report.lo: src/report.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-report.lo -MD -MP -MF $(DEPDIR)/libledger_la-report.Tpo -c -o libledger_la-report.lo `test -f 'src/report.cc' || echo '$(srcdir)/'`src/report.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-report.lo -MD -MP -MF $(DEPDIR)/libledger_la-report.Tpo -c -o libledger_la-report.lo `test -f 'src/report.cc' || echo '$(srcdir)/'`src/report.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-report.Tpo $(DEPDIR)/libledger_la-report.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/report.cc' object='libledger_la-report.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-report.lo `test -f 'src/report.cc' || echo '$(srcdir)/'`src/report.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-report.lo `test -f 'src/report.cc' || echo '$(srcdir)/'`src/report.cc
libledger_la-transform.lo: src/transform.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-transform.lo -MD -MP -MF $(DEPDIR)/libledger_la-transform.Tpo -c -o libledger_la-transform.lo `test -f 'src/transform.cc' || echo '$(srcdir)/'`src/transform.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-transform.lo -MD -MP -MF $(DEPDIR)/libledger_la-transform.Tpo -c -o libledger_la-transform.lo `test -f 'src/transform.cc' || echo '$(srcdir)/'`src/transform.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-transform.Tpo $(DEPDIR)/libledger_la-transform.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/transform.cc' object='libledger_la-transform.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-transform.lo `test -f 'src/transform.cc' || echo '$(srcdir)/'`src/transform.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-transform.lo `test -f 'src/transform.cc' || echo '$(srcdir)/'`src/transform.cc
libledger_la-xml.lo: src/xml.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xml.lo -MD -MP -MF $(DEPDIR)/libledger_la-xml.Tpo -c -o libledger_la-xml.lo `test -f 'src/xml.cc' || echo '$(srcdir)/'`src/xml.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xml.lo -MD -MP -MF $(DEPDIR)/libledger_la-xml.Tpo -c -o libledger_la-xml.lo `test -f 'src/xml.cc' || echo '$(srcdir)/'`src/xml.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-xml.Tpo $(DEPDIR)/libledger_la-xml.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/xml.cc' object='libledger_la-xml.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-xml.lo `test -f 'src/xml.cc' || echo '$(srcdir)/'`src/xml.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-xml.lo `test -f 'src/xml.cc' || echo '$(srcdir)/'`src/xml.cc
libledger_la-xmlparse.lo: src/xmlparse.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xmlparse.lo -MD -MP -MF $(DEPDIR)/libledger_la-xmlparse.Tpo -c -o libledger_la-xmlparse.lo `test -f 'src/xmlparse.cc' || echo '$(srcdir)/'`src/xmlparse.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xmlparse.lo -MD -MP -MF $(DEPDIR)/libledger_la-xmlparse.Tpo -c -o libledger_la-xmlparse.lo `test -f 'src/xmlparse.cc' || echo '$(srcdir)/'`src/xmlparse.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-xmlparse.Tpo $(DEPDIR)/libledger_la-xmlparse.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/xmlparse.cc' object='libledger_la-xmlparse.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-xmlparse.lo `test -f 'src/xmlparse.cc' || echo '$(srcdir)/'`src/xmlparse.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-xmlparse.lo `test -f 'src/xmlparse.cc' || echo '$(srcdir)/'`src/xmlparse.cc
libledger_la-xpath.lo: src/xpath.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xpath.lo -MD -MP -MF $(DEPDIR)/libledger_la-xpath.Tpo -c -o libledger_la-xpath.lo `test -f 'src/xpath.cc' || echo '$(srcdir)/'`src/xpath.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xpath.lo -MD -MP -MF $(DEPDIR)/libledger_la-xpath.Tpo -c -o libledger_la-xpath.lo `test -f 'src/xpath.cc' || echo '$(srcdir)/'`src/xpath.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-xpath.Tpo $(DEPDIR)/libledger_la-xpath.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/xpath.cc' object='libledger_la-xpath.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-xpath.lo `test -f 'src/xpath.cc' || echo '$(srcdir)/'`src/xpath.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-xpath.lo `test -f 'src/xpath.cc' || echo '$(srcdir)/'`src/xpath.cc
libledger_la-gnucash.lo: src/gnucash.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-gnucash.lo -MD -MP -MF $(DEPDIR)/libledger_la-gnucash.Tpo -c -o libledger_la-gnucash.lo `test -f 'src/gnucash.cc' || echo '$(srcdir)/'`src/gnucash.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-gnucash.lo -MD -MP -MF $(DEPDIR)/libledger_la-gnucash.Tpo -c -o libledger_la-gnucash.lo `test -f 'src/gnucash.cc' || echo '$(srcdir)/'`src/gnucash.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-gnucash.Tpo $(DEPDIR)/libledger_la-gnucash.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/gnucash.cc' object='libledger_la-gnucash.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-gnucash.lo `test -f 'src/gnucash.cc' || echo '$(srcdir)/'`src/gnucash.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-gnucash.lo `test -f 'src/gnucash.cc' || echo '$(srcdir)/'`src/gnucash.cc
libledger_la-ofx.lo: src/ofx.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-ofx.lo -MD -MP -MF $(DEPDIR)/libledger_la-ofx.Tpo -c -o libledger_la-ofx.lo `test -f 'src/ofx.cc' || echo '$(srcdir)/'`src/ofx.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-ofx.lo -MD -MP -MF $(DEPDIR)/libledger_la-ofx.Tpo -c -o libledger_la-ofx.lo `test -f 'src/ofx.cc' || echo '$(srcdir)/'`src/ofx.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-ofx.Tpo $(DEPDIR)/libledger_la-ofx.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/ofx.cc' object='libledger_la-ofx.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-ofx.lo `test -f 'src/ofx.cc' || echo '$(srcdir)/'`src/ofx.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-ofx.lo `test -f 'src/ofx.cc' || echo '$(srcdir)/'`src/ofx.cc
libledger_la-pyinterp.lo: src/pyinterp.cc
-@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-pyinterp.lo -MD -MP -MF $(DEPDIR)/libledger_la-pyinterp.Tpo -c -o libledger_la-pyinterp.lo `test -f 'src/pyinterp.cc' || echo '$(srcdir)/'`src/pyinterp.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-pyinterp.lo -MD -MP -MF $(DEPDIR)/libledger_la-pyinterp.Tpo -c -o libledger_la-pyinterp.lo `test -f 'src/pyinterp.cc' || echo '$(srcdir)/'`src/pyinterp.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-pyinterp.Tpo $(DEPDIR)/libledger_la-pyinterp.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/pyinterp.cc' object='libledger_la-pyinterp.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-pyinterp.lo `test -f 'src/pyinterp.cc' || echo '$(srcdir)/'`src/pyinterp.cc
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-pyinterp.lo `test -f 'src/pyinterp.cc' || echo '$(srcdir)/'`src/pyinterp.cc
libpyledger_la-py_utils.lo: src/py_utils.cc
@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpyledger_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libpyledger_la-py_utils.lo -MD -MP -MF $(DEPDIR)/libpyledger_la-py_utils.Tpo -c -o libpyledger_la-py_utils.lo `test -f 'src/py_utils.cc' || echo '$(srcdir)/'`src/py_utils.cc
@@ -943,32 +940,32 @@ UnitTests-Commodity.obj: tests/numerics/Commodity.cc
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(UnitTests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o UnitTests-Commodity.obj `if test -f 'tests/numerics/Commodity.cc'; then $(CYGPATH_W) 'tests/numerics/Commodity.cc'; else $(CYGPATH_W) '$(srcdir)/tests/numerics/Commodity.cc'; fi`
ledger-option.o: src/option.cc
-@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -MT ledger-option.o -MD -MP -MF $(DEPDIR)/ledger-option.Tpo -c -o ledger-option.o `test -f 'src/option.cc' || echo '$(srcdir)/'`src/option.cc
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ledger-option.o -MD -MP -MF $(DEPDIR)/ledger-option.Tpo -c -o ledger-option.o `test -f 'src/option.cc' || echo '$(srcdir)/'`src/option.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/ledger-option.Tpo $(DEPDIR)/ledger-option.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/option.cc' object='ledger-option.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -c -o ledger-option.o `test -f 'src/option.cc' || echo '$(srcdir)/'`src/option.cc
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ledger-option.o `test -f 'src/option.cc' || echo '$(srcdir)/'`src/option.cc
ledger-option.obj: src/option.cc
-@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -MT ledger-option.obj -MD -MP -MF $(DEPDIR)/ledger-option.Tpo -c -o ledger-option.obj `if test -f 'src/option.cc'; then $(CYGPATH_W) 'src/option.cc'; else $(CYGPATH_W) '$(srcdir)/src/option.cc'; fi`
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ledger-option.obj -MD -MP -MF $(DEPDIR)/ledger-option.Tpo -c -o ledger-option.obj `if test -f 'src/option.cc'; then $(CYGPATH_W) 'src/option.cc'; else $(CYGPATH_W) '$(srcdir)/src/option.cc'; fi`
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/ledger-option.Tpo $(DEPDIR)/ledger-option.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/option.cc' object='ledger-option.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -c -o ledger-option.obj `if test -f 'src/option.cc'; then $(CYGPATH_W) 'src/option.cc'; else $(CYGPATH_W) '$(srcdir)/src/option.cc'; fi`
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ledger-option.obj `if test -f 'src/option.cc'; then $(CYGPATH_W) 'src/option.cc'; else $(CYGPATH_W) '$(srcdir)/src/option.cc'; fi`
ledger-main.o: src/main.cc
-@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -MT ledger-main.o -MD -MP -MF $(DEPDIR)/ledger-main.Tpo -c -o ledger-main.o `test -f 'src/main.cc' || echo '$(srcdir)/'`src/main.cc
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ledger-main.o -MD -MP -MF $(DEPDIR)/ledger-main.Tpo -c -o ledger-main.o `test -f 'src/main.cc' || echo '$(srcdir)/'`src/main.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/ledger-main.Tpo $(DEPDIR)/ledger-main.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/main.cc' object='ledger-main.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -c -o ledger-main.o `test -f 'src/main.cc' || echo '$(srcdir)/'`src/main.cc
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ledger-main.o `test -f 'src/main.cc' || echo '$(srcdir)/'`src/main.cc
ledger-main.obj: src/main.cc
-@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -MT ledger-main.obj -MD -MP -MF $(DEPDIR)/ledger-main.Tpo -c -o ledger-main.obj `if test -f 'src/main.cc'; then $(CYGPATH_W) 'src/main.cc'; else $(CYGPATH_W) '$(srcdir)/src/main.cc'; fi`
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ledger-main.obj -MD -MP -MF $(DEPDIR)/ledger-main.Tpo -c -o ledger-main.obj `if test -f 'src/main.cc'; then $(CYGPATH_W) 'src/main.cc'; else $(CYGPATH_W) '$(srcdir)/src/main.cc'; fi`
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/ledger-main.Tpo $(DEPDIR)/ledger-main.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/main.cc' object='ledger-main.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -c -o ledger-main.obj `if test -f 'src/main.cc'; then $(CYGPATH_W) 'src/main.cc'; else $(CYGPATH_W) '$(srcdir)/src/main.cc'; fi`
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ledger_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ledger-main.obj `if test -f 'src/main.cc'; then $(CYGPATH_W) 'src/main.cc'; else $(CYGPATH_W) '$(srcdir)/src/main.cc'; fi`
pyledger.o: src/pyledger.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT pyledger.o -MD -MP -MF $(DEPDIR)/pyledger.Tpo -c -o pyledger.o `test -f 'src/pyledger.cc' || echo '$(srcdir)/'`src/pyledger.cc
diff --git a/configure b/configure
index b4f15a79..4b3eaa30 100755
--- a/configure
+++ b/configure
@@ -19693,83 +19693,26 @@ See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
-# check for boost_signals
-{ echo "$as_me:$LINENO: checking if boost_signals is available" >&5
-echo $ECHO_N "checking if boost_signals is available... $ECHO_C" >&6; }
-if test "${boost_signals_cpplib_avail+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- boost_signals_save_libs=$LIBS
- LIBS="-lboost_signals $LIBS"
- ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <boost/signal.hpp>
-int
-main ()
-{
-boost::signal<void (void)> this_signal;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_cxx_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- boost_signals_cpplib_avail=true
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- boost_signals_cpplib_avail=false
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
- LIBS=$boost_signals_save_libs
-fi
-{ echo "$as_me:$LINENO: result: $boost_signals_cpplib_avail" >&5
-echo "${ECHO_T}$boost_signals_cpplib_avail" >&6; }
-
-if test x$boost_signals_cpplib_avail = xtrue ; then
- LIBS="-lboost_signals $LIBS"
-else
- { { echo "$as_me:$LINENO: error: \"Could not find boost_signals library (set CPPFLAGS and LDFLAGS?)\"
-See \`config.log' for more details." >&5
-echo "$as_me: error: \"Could not find boost_signals library (set CPPFLAGS and LDFLAGS?)\"
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
+## check for boost_signals
+#AC_CACHE_CHECK(
+# [if boost_signals is available],
+# [boost_signals_cpplib_avail],
+# [boost_signals_save_libs=$LIBS
+# LIBS="-lboost_signals $LIBS"
+# AC_LANG_PUSH(C++)
+# AC_TRY_LINK(
+# [#include <boost/signal.hpp>],
+# [boost::signal<void (void)> this_signal;],
+# [boost_signals_cpplib_avail=true],
+# [boost_signals_cpplib_avail=false])
+# AC_LANG_POP
+# LIBS=$boost_signals_save_libs])
+#
+#if [test x$boost_signals_cpplib_avail = xtrue ]; then
+# LIBS="-lboost_signals $LIBS"
+#else
+# AC_MSG_FAILURE("Could not find boost_signals library (set CPPFLAGS and LDFLAGS?)")
+#fi
# check for gmp
{ echo "$as_me:$LINENO: checking if libgmp is available" >&5
diff --git a/configure.in b/configure.in
index 20798aaa..af5da038 100644
--- a/configure.in
+++ b/configure.in
@@ -148,26 +148,26 @@ else
AC_MSG_FAILURE("Could not find boost_filesystem library (set CPPFLAGS and LDFLAGS?)")
fi
-# check for boost_signals
-AC_CACHE_CHECK(
- [if boost_signals is available],
- [boost_signals_cpplib_avail],
- [boost_signals_save_libs=$LIBS
- LIBS="-lboost_signals $LIBS"
- AC_LANG_PUSH(C++)
- AC_TRY_LINK(
- [#include <boost/signal.hpp>],
- [boost::signal<void (void)> this_signal;],
- [boost_signals_cpplib_avail=true],
- [boost_signals_cpplib_avail=false])
- AC_LANG_POP
- LIBS=$boost_signals_save_libs])
-
-if [test x$boost_signals_cpplib_avail = xtrue ]; then
- LIBS="-lboost_signals $LIBS"
-else
- AC_MSG_FAILURE("Could not find boost_signals library (set CPPFLAGS and LDFLAGS?)")
-fi
+## check for boost_signals
+#AC_CACHE_CHECK(
+# [if boost_signals is available],
+# [boost_signals_cpplib_avail],
+# [boost_signals_save_libs=$LIBS
+# LIBS="-lboost_signals $LIBS"
+# AC_LANG_PUSH(C++)
+# AC_TRY_LINK(
+# [#include <boost/signal.hpp>],
+# [boost::signal<void (void)> this_signal;],
+# [boost_signals_cpplib_avail=true],
+# [boost_signals_cpplib_avail=false])
+# AC_LANG_POP
+# LIBS=$boost_signals_save_libs])
+#
+#if [test x$boost_signals_cpplib_avail = xtrue ]; then
+# LIBS="-lboost_signals $LIBS"
+#else
+# AC_MSG_FAILURE("Could not find boost_signals library (set CPPFLAGS and LDFLAGS?)")
+#fi
# check for gmp
AC_CACHE_CHECK(
diff --git a/src/amount.cc b/src/amount.cc
index 9281d981..85ba07f5 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -688,7 +688,7 @@ bool amount_t::is_zero() const
}
-double amount_t::to_double() const
+double amount_t::to_double(bool no_check) const
{
if (! quantity)
return 0.0;
@@ -711,10 +711,15 @@ double amount_t::to_double() const
mpz_clear(remainder);
- return lexical_cast<double>(num.str());
+ double value = lexical_cast<double>(num.str());
+
+ if (! no_check && *this != value)
+ throw_(amount_error, "Conversion of amount to_double loses precision");
+
+ return value;
}
-long amount_t::to_long() const
+long amount_t::to_long(bool no_check) const
{
if (! quantity)
return 0;
@@ -723,7 +728,24 @@ long amount_t::to_long() const
mpz_ui_pow_ui(divisor, 10, quantity->prec);
mpz_tdiv_q(temp, temp, divisor);
- return mpz_get_si(temp);
+ long value = mpz_get_si(temp);
+
+ if (! no_check && *this != value)
+ throw_(amount_error, "Conversion of amount to_long loses precision");
+
+ return value;
+}
+
+bool amount_t::fits_in_double() const
+{
+ double value = to_double(true);
+ return *this == amount_t(value);
+}
+
+bool amount_t::fits_in_long() const
+{
+ long value = to_long(true);
+ return *this == amount_t(value);
}
@@ -943,7 +965,7 @@ namespace {
}
}
-void amount_t::parse(std::istream& in, flags_t tflags)
+void amount_t::parse(std::istream& in, flags_t flags)
{
// The possible syntax for an amount is:
//
@@ -1048,7 +1070,7 @@ void amount_t::parse(std::istream& in, flags_t tflags)
// Set the commodity's flags and precision accordingly
if (commodity_ &&
- (newly_created || ! (tflags & AMOUNT_PARSE_NO_MIGRATE))) {
+ (newly_created || ! (flags & AMOUNT_PARSE_NO_MIGRATE))) {
commodity().add_flags(comm_flags);
if (quantity->prec > commodity().precision())
commodity().set_precision(quantity->prec);
@@ -1056,9 +1078,7 @@ void amount_t::parse(std::istream& in, flags_t tflags)
// Setup the amount's own flags
- set_flags(tflags);
-
- if (has_flags(AMOUNT_PARSE_NO_MIGRATE))
+ if (flags & AMOUNT_PARSE_NO_MIGRATE)
quantity->add_flags(BIGINT_KEEP_PREC);
// Now we have the final number. Remove commas and periods, if
@@ -1086,7 +1106,7 @@ void amount_t::parse(std::istream& in, flags_t tflags)
if (negative)
in_place_negate();
- if (! has_flags(AMOUNT_PARSE_NO_REDUCE))
+ if (! (flags & AMOUNT_PARSE_NO_REDUCE))
in_place_reduce();
}
@@ -1407,7 +1427,7 @@ void amount_t::read_quantity(std::istream& in)
quantity->set_flags(tflags);
}
else {
- assert(0);
+ assert(false);
}
}
diff --git a/src/amount.h b/src/amount.h
index de1c2283..5f8fa2ec 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -71,8 +71,7 @@ DECLARE_EXCEPTION(amount_error);
* degree.
*/
class amount_t
- : public supports_flags<>,
- ordered_field_operators<amount_t,
+ : public ordered_field_operators<amount_t,
ordered_field_operators<amount_t, long,
ordered_field_operators<amount_t, unsigned long,
ordered_field_operators<amount_t, double> > > >
@@ -417,11 +416,19 @@ public:
* are in Python), rather the following conversion methods must be
* called explicitly:
*
- * to_double() returns an amount as a double. Note: precision is
- * very likely to be lost in this conversion!
+ * to_double([bool]) returns an amount as a double. If the optional
+ * boolean argument is true (the default), an exception is thrown if
+ * the conversion would lose information.
*
- * to_long() returns an amount as a long integer. This is only
- * useful if the amount is know to be of a small, integral value.
+ * to_long([bool]) returns an amount as a long integer. If the
+ * optional boolean argument is true (the default), an exception is
+ * thrown if the conversion would lose information.
+ *
+ * fits_in_double() returns true if to_double() would not lose
+ * precision.
+ *
+ * fits_in_long() returns true if to_long() would not lose
+ * precision.
*
* to_string() returns an amount'ss "display value" as a string --
* after rounding the value according to the commodity's default
@@ -436,12 +443,15 @@ public:
* been stripped and the full, internal precision of the amount
* would be displayed.
*/
- double to_double() const;
- long to_long() const;
+ double to_double(bool no_check = false) const;
+ long to_long(bool no_check = false) const;
string to_string() const;
string to_fullstring() const;
string quantity_string() const;
+ bool fits_in_double() const;
+ bool fits_in_long() const;
+
/**
* Commodity-related methods. The following methods relate to an
* amount's commodity:
@@ -556,10 +566,12 @@ public:
#define AMOUNT_PARSE_NO_MIGRATE 0x01
#define AMOUNT_PARSE_NO_REDUCE 0x02
- void parse(std::istream& in, flags_t bits = 0);
- void parse(const string& str, flags_t bits = 0) {
+ typedef uint_least8_t flags_t;
+
+ void parse(std::istream& in, flags_t flags = 0);
+ void parse(const string& str, flags_t flags = 0) {
std::istringstream stream(str);
- parse(stream, bits);
+ parse(stream, flags);
}
static void parse_conversion(const string& larger_str,
diff --git a/src/balance.cc b/src/balance.cc
index 9d5e57f4..6952b123 100644
--- a/src/balance.cc
+++ b/src/balance.cc
@@ -33,39 +33,6 @@
namespace ledger {
-balance_t& balance_t::operator*=(const balance_t& bal)
-{
- if (is_realzero()) {
- return *this;
- }
- else if (bal.is_realzero()) {
- return *this = bal;
- }
- else if (bal.amounts.size() == 1) {
- return *this *= (*bal.amounts.begin()).second;
- }
- else if (amounts.size() == 1) {
- return *this = bal * *this;
- }
- else {
- // Since we would fail with an error at this point otherwise, try
- // stripping annotations to see if we can come up with a
- // reasonable result. The user will not notice any annotations
- // missing (since they are viewing a stripped report anyway), only
- // that some of their value expression may not see any pricing or
- // date data because of this operation.
-
- balance_t temp(bal.strip_annotations());
- if (temp.amounts.size() == 1)
- return *this *= temp;
- temp = strip_annotations();
- if (temp.amounts.size() == 1)
- return *this = bal * temp;
-
- throw_(amount_error, "Cannot multiply two balances: " << temp << " * " << bal);
- }
-}
-
balance_t& balance_t::operator*=(const amount_t& amt)
{
if (is_realzero()) {
@@ -107,31 +74,6 @@ balance_t& balance_t::operator*=(const amount_t& amt)
return *this;
}
-balance_t& balance_t::operator/=(const balance_t& bal)
-{
- if (bal.is_realzero()) {
- throw_(amount_error, "Divide by zero: " << *this << " / " << bal);
- }
- else if (is_realzero()) {
- return *this;
- }
- else if (bal.amounts.size() == 1) {
- return *this /= (*bal.amounts.begin()).second;
- }
- else if (*this == bal) {
- return *this = amount_t(1L);
- }
- else {
- // Try stripping annotations before giving an error.
- balance_t temp(bal.strip_annotations());
- if (temp.amounts.size() == 1)
- return *this /= temp;
-
- throw_(amount_error,
- "Cannot divide two balances: " << temp << " / " << bal);
- }
-}
-
balance_t& balance_t::operator/=(const amount_t& amt)
{
if (amt.is_realzero()) {
diff --git a/src/balance.h b/src/balance.h
index d4736366..a7c95870 100644
--- a/src/balance.h
+++ b/src/balance.h
@@ -36,16 +36,15 @@
namespace ledger {
-// jww (2007-05-01): What really should be the operational semantics
-// of a balance?
-
class balance_t
- : public ordered_field_operators<balance_t,
- ordered_field_operators<balance_t, amount_t> >
+ : public equality_comparable<balance_t,
+ equality_comparable<balance_t, amount_t,
+ additive<balance_t,
+ additive<balance_t, amount_t,
+ multiplicative<balance_t, amount_t> > > > >
{
public:
- typedef std::map<const commodity_t *, amount_t> amounts_map;
- typedef std::pair<const commodity_t *, amount_t> amounts_pair;
+ typedef std::map<const commodity_t *, amount_t> amounts_map;
protected:
amounts_map amounts;
@@ -67,7 +66,7 @@ public:
}
balance_t(const amount_t& amt) {
TRACE_CTOR(balance_t, "const amount_t&");
- amounts.insert(amounts_pair(&amt.commodity(), amt));
+ amounts.insert(amounts_map::value_type(&amt.commodity(), amt));
}
~balance_t() {
TRACE_DTOR(balance_t);
@@ -98,6 +97,9 @@ public:
}
return i == amounts.end() && j == bal.amounts.end();
}
+ bool operator==(const amount_t& amt) const {
+ return amounts.size() == 1 && amounts.begin()->second == amt;
+ }
// in-place arithmetic
balance_t& operator+=(const balance_t& bal) {
@@ -114,34 +116,9 @@ public:
*this -= (*i).second;
return *this;
}
- balance_t& operator*=(const balance_t& bal);
- balance_t& operator*=(const amount_t& amt); // special
- balance_t& operator/=(const balance_t& bal);
- balance_t& operator/=(const amount_t& amt); // special
- // comparison
- bool operator<(const balance_t& bal) const {
- for (amounts_map::const_iterator i = bal.amounts.begin();
- i != bal.amounts.end();
- i++) {
- optional<amount_t> amt = amount(*(*i).first);
- if (amt && ! (*amt < (*i).second))
- return false;
- }
-
- for (amounts_map::const_iterator i = amounts.begin();
- i != amounts.end();
- i++) {
- optional<amount_t> amt = bal.amount(*(*i).first);
- if (amt && ! ((*i).second < *amt))
- return false;
- }
-
- if (bal.amounts.size() == 0 && amounts.size() == 0)
- return false;
-
- return true;
- }
+ balance_t& operator*=(const amount_t& amt);
+ balance_t& operator/=(const amount_t& amt);
// unary negation
void in_place_negate() {
@@ -252,9 +229,13 @@ inline std::ostream& operator<<(std::ostream& out, const balance_t& bal) {
}
class balance_pair_t
- : public ordered_field_operators<balance_pair_t,
- ordered_field_operators<balance_pair_t, balance_t,
- ordered_field_operators<balance_pair_t, amount_t> > >
+ : public equality_comparable<balance_pair_t,
+ equality_comparable<balance_pair_t, balance_t,
+ equality_comparable<balance_pair_t, amount_t,
+ additive<balance_pair_t,
+ additive<balance_pair_t, balance_t,
+ additive<balance_pair_t, amount_t,
+ multiplicative<balance_pair_t, amount_t> > > > > > >
{
balance_t quantity;
optional<balance_t> cost;
@@ -309,29 +290,26 @@ public:
*cost -= bal_pair.cost ? *bal_pair.cost : bal_pair.quantity;
return *this;
}
- balance_pair_t& operator*=(const balance_pair_t& bal_pair) {
- if (bal_pair.cost && ! cost)
- cost = quantity;
- quantity *= bal_pair.quantity;
- if (cost)
- *cost *= bal_pair.cost ? *bal_pair.cost : bal_pair.quantity;
- return *this;
- }
- balance_pair_t& operator/=(const balance_pair_t& bal_pair) {
- if (bal_pair.cost && ! cost)
- cost = quantity;
- quantity /= bal_pair.quantity;
- if (cost)
- *cost /= bal_pair.cost ? *bal_pair.cost : bal_pair.quantity;
- return *this;
- }
// comparison
bool operator==(const balance_pair_t& bal_pair) const {
return quantity == bal_pair.quantity;
}
- bool operator<(const balance_pair_t& bal_pair) const {
- return quantity < bal_pair.quantity;
+ bool operator==(const balance_t& bal) const {
+ return quantity == bal;
+ }
+
+ balance_pair_t& operator*=(const amount_t& amt) {
+ quantity *= amt;
+ if (cost)
+ *cost *= amt;
+ return *this;
+ }
+ balance_pair_t& operator/=(const amount_t& amt) {
+ quantity /= amt;
+ if (cost)
+ *cost /= amt;
+ return *this;
}
// unary negation
@@ -422,7 +400,7 @@ public:
return temp;
}
- balance_pair_t unround() {
+ balance_pair_t unround() const {
balance_pair_t temp(quantity.unround());
if (cost)
temp.cost = cost->unround();
diff --git a/src/binary.cc b/src/binary.cc
index 94c4ba8c..0d4bfb80 100644
--- a/src/binary.cc
+++ b/src/binary.cc
@@ -171,7 +171,7 @@ inline void read_binary_value(char *& data, value_t& val)
case value_t::BALANCE:
case value_t::BALANCE_PAIR:
- assert(0);
+ assert(false);
break;
}
}
diff --git a/src/binary.h b/src/binary.h
index bd68f51b..194c675e 100644
--- a/src/binary.h
+++ b/src/binary.h
@@ -77,7 +77,7 @@ inline T read_binary_number_nocheck(char *& data) {
#if DEBUG_LEVEL >= ALPHA
#define read_binary_guard(in, id) \
if (read_binary_number_nocheck<unsigned short>(in) != id) \
- assert(0);
+ assert(false);
#else
#define read_binary_guard(in, id)
#endif
diff --git a/src/commodity.cc b/src/commodity.cc
index de801898..b94aedc7 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -54,7 +54,7 @@ void commodity_t::add_price(const moment_t& date,
(*i).second = price;
} else {
std::pair<history_map::iterator, bool> result
- = base->history->prices.insert(history_pair(date, price));
+ = base->history->prices.insert(history_map::value_type(date, price));
assert(result.second);
}
}
@@ -107,7 +107,7 @@ optional<amount_t> commodity_t::value(const optional<moment_t>& moment)
}
}
- if (! (flags() & COMMODITY_STYLE_NOMARKET)) {
+ if (! has_flags(COMMODITY_STYLE_NOMARKET) && parent().get_quote) {
if (optional<amount_t> quote = parent().get_quote
(*this, age, moment,
(base->history && base->history->prices.size() > 0 ?
diff --git a/src/commodity.h b/src/commodity.h
index 4c13f864..f6e888f3 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -56,8 +56,7 @@ class commodity_t
class base_t : public noncopyable, public supports_flags<>
{
public:
- typedef std::map<const moment_t, amount_t> history_map;
- typedef std::pair<const moment_t, amount_t> history_pair;
+ typedef std::map<const moment_t, amount_t> history_map;
struct history_t {
history_map prices;
@@ -94,10 +93,9 @@ class commodity_t
public:
static bool symbol_needs_quotes(const string& symbol);
- typedef base_t::history_t history_t;
- typedef base_t::history_map history_map;
- typedef base_t::history_pair history_pair;
- typedef uint_least32_t ident_t;
+ typedef base_t::history_t history_t;
+ typedef base_t::history_map history_map;
+ typedef uint_least32_t ident_t;
shared_ptr<base_t> base;
@@ -234,6 +232,7 @@ struct annotation_t : public equality_comparable<annotation_t>
bool valid() const {
assert(*this);
+ return true;
}
};
@@ -335,12 +334,12 @@ private:
};
public:
- boost::signal<optional<amount_t>
- (commodity_t& commodity,
- const optional<moment_t>& date,
- const optional<moment_t>& moment,
- const optional<moment_t>& last),
- first_initialized<optional<amount_t> > > get_quote;
+ boost::function<optional<amount_t>
+ (commodity_t& commodity,
+ const optional<moment_t>& date,
+ const optional<moment_t>& moment,
+ const optional<moment_t>& last),
+ first_initialized<optional<amount_t> > > get_quote;
explicit commodity_pool_t();
diff --git a/src/format.cc b/src/format.cc
index 999e4bbc..8c5f6c55 100644
--- a/src/format.cc
+++ b/src/format.cc
@@ -227,7 +227,7 @@ int format_t::element_formatter_t::operator()
else if (elem->kind == element_t::TEXT)
out << *elem->chars;
else
- assert(0);
+ assert(false);
string temp = out.str();
for (string::const_iterator i = temp.begin();
diff --git a/src/gnucash.cc b/src/gnucash.cc
index a09d06fa..8fa5a524 100644
--- a/src/gnucash.cc
+++ b/src/gnucash.cc
@@ -93,8 +93,8 @@ void endElement(void *userData, const char *name)
assert(parser->curr_account);
if (parser->curr_account->parent == parser->master_account)
parser->curr_journal->add_account(parser->curr_account);
- parser->accounts_by_id.insert(accounts_pair(parser->curr_account_id,
- parser->curr_account));
+ parser->accounts_by_id.insert
+ (accounts_map::value_type(parser->curr_account_id, parser->curr_account));
parser->curr_account = NULL;
}
else if (std::strcmp(name, "gnc:commodity") == 0) {
@@ -230,8 +230,8 @@ void dataHandler(void *userData, const char *s, int len)
if (parser->curr_account)
parser->account_comms.insert
- (gnucash_parser_t::account_comm_pair(parser->curr_account,
- parser->curr_comm));
+ (gnucash_parser_t::account_comm_map::value_type
+ (parser->curr_account, parser->curr_comm));
else if (parser->curr_entry)
parser->entry_comm = parser->curr_comm;
break;
@@ -307,7 +307,7 @@ void dataHandler(void *userData, const char *s, int len)
break;
default:
- assert(0);
+ assert(false);
break;
}
}
diff --git a/src/gnucash.h b/src/gnucash.h
index 9968707d..087f18a3 100644
--- a/src/gnucash.h
+++ b/src/gnucash.h
@@ -40,10 +40,7 @@ namespace ledger {
struct gnucash_parser_t : public parser_t
{
typedef std::map<const string, account_t *> accounts_map;
- typedef std::pair<const string, account_t *> accounts_pair;
-
- typedef std::map<account_t *, commodity_t *> account_comm_map;
- typedef std::pair<account_t *, commodity_t *> account_comm_pair;
+ typedef std::map<account_t *, commodity_t *> account_comm_map;
journal_t * curr_journal;
account_t * master_account;
diff --git a/src/journal.cc b/src/journal.cc
index 26ea3fd9..dcf9dd9d 100644
--- a/src/journal.cc
+++ b/src/journal.cc
@@ -98,11 +98,6 @@ bool transaction_t::valid() const
return false;
}
- if (flags & ~0x003f) {
- DEBUG("ledger.validate", "transaction_t: flags are bad");
- return false;
- }
-
return true;
}
@@ -130,8 +125,8 @@ bool entry_base_t::finalize()
for (transactions_list::const_iterator x = transactions.begin();
x != transactions.end();
x++)
- if (! ((*x)->flags & TRANSACTION_VIRTUAL) ||
- ((*x)->flags & TRANSACTION_BALANCE)) {
+ if (! (*x)->has_flags(TRANSACTION_VIRTUAL) ||
+ (*x)->has_flags(TRANSACTION_BALANCE)) {
optional<amount_t>& p((*x)->cost ? (*x)->cost : (*x)->amount);
if (p) {
if (no_amounts) {
@@ -168,7 +163,7 @@ bool entry_base_t::finalize()
// The amount doesn't need to be set because the code below will
// balance this transaction against the other.
add_transaction(nxact);
- nxact->flags |= TRANSACTION_CALCULATED;
+ nxact->add_flags(TRANSACTION_CALCULATED);
}
// If the first transaction of a two-transaction entry is of a
@@ -177,15 +172,15 @@ bool entry_base_t::finalize()
// the balance. This is done for the last eligible commodity.
if (! saw_null && balance && balance.type == value_t::BALANCE &&
- balance.to_balance().amounts.size() == 2) {
+ balance.as_balance().amounts.size() == 2) {
transactions_list::const_iterator x = transactions.begin();
assert((*x)->amount);
commodity_t& this_comm = (*x)->amount->commodity();
balance_t::amounts_map::const_iterator this_bal =
- balance.to_balance().amounts.find(&this_comm);
+ balance.as_balance().amounts.find(&this_comm);
balance_t::amounts_map::const_iterator other_bal =
- balance.to_balance().amounts.begin();
+ balance.as_balance().amounts.begin();
if (this_bal == other_bal)
other_bal++;
@@ -193,7 +188,7 @@ bool entry_base_t::finalize()
amount_t((*other_bal).second / (*this_bal).second.number()).unround();
for (; x != transactions.end(); x++) {
- if ((*x)->cost || ((*x)->flags & TRANSACTION_VIRTUAL) ||
+ if ((*x)->cost || (*x)->has_flags(TRANSACTION_VIRTUAL) ||
! (*x)->amount || (*x)->amount->commodity() != this_comm)
continue;
@@ -223,8 +218,8 @@ bool entry_base_t::finalize()
x != transactions.end();
x++) {
if ((*x)->amount ||
- (((*x)->flags & TRANSACTION_VIRTUAL) &&
- ! ((*x)->flags & TRANSACTION_BALANCE)))
+ ((*x)->has_flags(TRANSACTION_VIRTUAL) &&
+ ! (*x)->has_flags(TRANSACTION_BALANCE)))
continue;
if (! empty_allowed)
@@ -240,12 +235,12 @@ bool entry_base_t::finalize()
balance_t * bal = NULL;
switch (balance.type) {
case value_t::BALANCE_PAIR:
- bal = &balance.to_balance_pair().quantity;
+ bal = &balance.as_balance_pair().quantity;
// fall through...
case value_t::BALANCE:
if (! bal)
- bal = &balance.to_balance();
+ bal = &balance.as_balance();
if (bal->amounts.size() < 2) {
balance.cast(value_t::AMOUNT);
@@ -263,7 +258,7 @@ bool entry_base_t::finalize()
} else {
transaction_t * nxact = new transaction_t((*x)->account);
add_transaction(nxact);
- nxact->flags |= TRANSACTION_CALCULATED;
+ nxact->add_flags(TRANSACTION_CALCULATED);
nxact->amount = amt;
}
@@ -274,8 +269,8 @@ bool entry_base_t::finalize()
// fall through...
case value_t::AMOUNT:
- (*x)->amount = balance.to_amount().negate();
- (*x)->flags |= TRANSACTION_CALCULATED;
+ (*x)->amount = balance.as_amount().negate();
+ (*x)->add_flags(TRANSACTION_CALCULATED);
balance += *(*x)->amount;
break;
@@ -405,7 +400,7 @@ void auto_entry_t::extend_entry(entry_base_t& entry, bool post)
account = (*i)->account;
transaction_t * xact
- = new transaction_t(account, amt, (*t)->flags | TRANSACTION_AUTO);
+ = new transaction_t(account, amt, (*t)->flags() | TRANSACTION_AUTO);
entry.add_transaction(xact);
}
}
@@ -457,7 +452,7 @@ account_t * account_t::find_account(const string& name,
account->journal = journal;
std::pair<accounts_map::iterator, bool> result
- = accounts.insert(accounts_pair(first, account));
+ = accounts.insert(accounts_map::value_type(first, account));
assert(result.second);
} else {
account = (*i).second;
@@ -666,7 +661,7 @@ void print_entry(std::ostream& out, const entry_base_t& entry_base,
print_format = prefix + " %-34A %12o\n";
}
else {
- assert(0);
+ assert(false);
}
#if 0
diff --git a/src/journal.h b/src/journal.h
index 3a1b044b..04bb1d5d 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -44,7 +44,7 @@ namespace xml {
class entry_node_t;
class account_node_t;
class journal_node_t;
-};
+}
// These flags persist with the object
#define TRANSACTION_NORMAL 0x0000
@@ -57,13 +57,12 @@ namespace xml {
class entry_t;
class account_t;
-class transaction_t
+class transaction_t : public supports_flags<>
{
public:
enum state_t { UNCLEARED, CLEARED, PENDING };
entry_t * entry;
- unsigned short flags;
state_t state;
account_t * account;
optional<moment_t> _date;
@@ -84,26 +83,52 @@ class transaction_t
static bool use_effective_date;
explicit transaction_t(account_t * _account = NULL)
- : entry(NULL), account(_account), state(UNCLEARED),
- flags(TRANSACTION_NORMAL), beg_pos(0), beg_line(0),
- end_pos(0), end_line(0), data(NULL) {
+ : supports_flags<>(TRANSACTION_NORMAL),
+ entry(NULL),
+ state(UNCLEARED),
+ account(_account),
+ beg_pos(0),
+ beg_line(0),
+ end_pos(0),
+ end_line(0),
+ data(NULL) {
TRACE_CTOR(transaction_t, "account_t *");
}
- explicit transaction_t(account_t * _account,
+ explicit transaction_t(account_t * _account,
const amount_t& _amount,
unsigned int _flags = TRANSACTION_NORMAL,
const optional<string> _note = optional<string>())
- : entry(NULL), account(_account), amount(_amount),
- state(UNCLEARED), flags(_flags), note(_note),
- beg_pos(0), beg_line(0), end_pos(0), end_line(0), data(NULL) {
+ : supports_flags<>(_flags),
+ entry(NULL),
+ state(UNCLEARED),
+ account(_account),
+ amount(_amount),
+ note(_note),
+ beg_pos(0),
+ beg_line(0),
+ end_pos(0),
+ end_line(0),
+ data(NULL) {
TRACE_CTOR(transaction_t,
"account_t *, const amount_t&, unsigned int, const string&");
}
explicit transaction_t(const transaction_t& xact)
- : entry(xact.entry), account(xact.account), amount(xact.amount),
- cost(xact.cost), state(xact.state), flags(xact.flags), note(xact.note),
- beg_pos(xact.beg_pos), beg_line(xact.beg_line),
- end_pos(xact.end_pos), end_line(xact.end_line), data(NULL) {
+ : supports_flags<>(xact),
+ entry(xact.entry),
+ state(xact.state),
+ account(xact.account),
+ _date(xact._date),
+ _date_eff(xact._date_eff),
+ amount(xact.amount),
+ amount_expr(xact.amount_expr),
+ cost(xact.cost),
+ cost_expr(xact.cost_expr),
+ note(xact.note),
+ beg_pos(xact.beg_pos),
+ beg_line(xact.beg_line),
+ end_pos(xact.end_pos),
+ end_line(xact.end_line),
+ data(xact.data) {
TRACE_CTOR(transaction_t, "copy");
}
~transaction_t();
@@ -164,7 +189,7 @@ class entry_base_t
for (transactions_list::iterator i = transactions.begin();
i != transactions.end();
i++)
- if (! ((*i)->flags & TRANSACTION_BULK_ALLOC))
+ if (! (*i)->has_flags(TRANSACTION_BULK_ALLOC))
checked_delete(*i);
else
(*i)->~transaction_t();
@@ -299,7 +324,6 @@ class period_entry_t : public entry_base_t
typedef std::map<const string, account_t *> accounts_map;
-typedef std::pair<const string, account_t *> accounts_pair;
class account_t
{
@@ -334,7 +358,7 @@ class account_t
string fullname() const;
void add_account(account_t * acct) {
- accounts.insert(accounts_pair(acct->name, acct));
+ accounts.insert(accounts_map::value_type(acct->name, acct));
acct->journal = journal;
}
bool remove_account(account_t * acct) {
@@ -448,7 +472,7 @@ class journal_t
return (*c).second;
account_t * account = master->find_account(name, auto_create);
- accounts_cache.insert(accounts_pair(name, account));
+ accounts_cache.insert(accounts_map::value_type(name, account));
account->journal = this;
return account;
}
diff --git a/src/ofx.cc b/src/ofx.cc
index d99be262..24be9409 100644
--- a/src/ofx.cc
+++ b/src/ofx.cc
@@ -33,11 +33,8 @@
namespace ledger {
-typedef std::map<const string, account_t *> accounts_map;
-typedef std::pair<const string, account_t *> accounts_pair;
-
-typedef std::map<const string, commodity_t *> commodities_map;
-typedef std::pair<const string, commodity_t *> commodities_pair;
+typedef std::map<const string, account_t *> accounts_map;
+typedef std::map<const string, commodity_t *> commodities_map;
journal_t * curr_journal;
accounts_map ofx_accounts;
diff --git a/src/py_amount.cc b/src/py_amount.cc
index c9b4e8d3..7fc667e7 100644
--- a/src/py_amount.cc
+++ b/src/py_amount.cc
@@ -40,27 +40,41 @@ namespace ledger {
using namespace boost::python;
-void py_parse_1(amount_t& amount, const string& str, unsigned char flags) {
- amount.parse(str, flags);
+double py_to_double_0(amount_t& amount) {
+ return amount.to_double();
+}
+double py_to_double_1(amount_t& amount, bool no_check) {
+ return amount.to_double(no_check);
+}
+
+long py_to_long_0(amount_t& amount) {
+ return amount.to_long();
+}
+long py_to_long_1(amount_t& amount, bool no_check) {
+ return amount.to_long(no_check);
}
-void py_parse_2(amount_t& amount, const string& str) {
+
+void py_parse_1(amount_t& amount, const string& str) {
amount.parse(str);
}
+void py_parse_2(amount_t& amount, const string& str, unsigned char flags) {
+ amount.parse(str, flags);
+}
+amount_t py_round_0(const amount_t& amount) {
+ return amount.round();
+}
amount_t py_round_1(const amount_t& amount, amount_t::precision_t prec) {
return amount.round(prec);
}
-amount_t py_round_2(const amount_t& amount) {
- return amount.round();
-}
+boost::optional<amount_t> py_value_0(const amount_t& amount) {
+ return amount.value();
+}
boost::optional<amount_t> py_value_1(const amount_t& amount,
const boost::optional<moment_t>& moment) {
return amount.value(moment);
}
-boost::optional<amount_t> py_value_2(const amount_t& amount) {
- return amount.value();
-}
#define EXC_TRANSLATOR(type) \
void exc_translate_ ## type(const type& err) { \
@@ -193,8 +207,8 @@ void export_amount()
.def("abs", &amount_t::abs)
.def("__abs__", &amount_t::abs)
+ .def("round", py_round_0)
.def("round", py_round_1)
- .def("round", py_round_2)
.def("unround", &amount_t::unround)
.def("reduce", &amount_t::reduce)
@@ -205,8 +219,8 @@ void export_amount()
.def("in_place_unreduce", &amount_t::in_place_unreduce,
return_value_policy<reference_existing_object>())
+ .def("value", py_value_0)
.def("value", py_value_1)
- .def("value", py_value_2)
.def("sign", &amount_t::sign)
.def("__nonzero__", &amount_t::is_nonzero)
@@ -215,15 +229,20 @@ void export_amount()
.def("is_realzero", &amount_t::is_realzero)
.def("is_null", &amount_t::is_null)
- .def("to_double", &amount_t::to_double)
- .def("__float__", &amount_t::to_double)
- .def("to_long", &amount_t::to_long)
- .def("__int__", &amount_t::to_long)
+ .def("to_double", py_to_double_0)
+ .def("to_double", py_to_double_1)
+ .def("__float__", py_to_double_0)
+ .def("to_long", py_to_long_0)
+ .def("to_long", py_to_long_1)
+ .def("__int__", py_to_long_0)
.def("to_string", &amount_t::to_string)
.def("__str__", &amount_t::to_string)
.def("to_fullstring", &amount_t::to_fullstring)
.def("__repr__", &amount_t::to_fullstring)
+ .def("fits_in_double", &amount_t::fits_in_double)
+ .def("fits_in_long", &amount_t::fits_in_long)
+
.def("quantity_string", &amount_t::quantity_string)
.add_property("commodity",
diff --git a/src/py_option.cc b/src/py_option.cc
index 354c2766..2e298272 100644
--- a/src/py_option.cc
+++ b/src/py_option.cc
@@ -58,8 +58,7 @@ struct py_option_t : public option_t
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(option_select_overloads,
py_option_t::select, 1, 2)
-typedef std::map<const string, object> options_map;
-typedef std::pair<const string, object> options_pair;
+typedef std::map<const string, object> options_map;
options_map options;
diff --git a/src/py_value.cc b/src/py_value.cc
index 05e8263a..f85eef1e 100644
--- a/src/py_value.cc
+++ b/src/py_value.cc
@@ -61,10 +61,10 @@ long value_len(value_t& val)
return (*(value_t::sequence_t **) val.data)->size();
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return 0;
}
@@ -109,10 +109,10 @@ amount_t value_getitem(value_t& val, int i)
return (*(value_t::sequence_t **) val.data)[i];
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return 0L;
}
diff --git a/src/pyinterp.cc b/src/pyinterp.cc
index ec36188f..dc070fd1 100644
--- a/src/pyinterp.cc
+++ b/src/pyinterp.cc
@@ -148,11 +148,11 @@ void python_interpreter_t::functor_t::operator()(value_t& result,
result = static_cast<const value_t&>(extract<value_t>(func.ptr()));
} else {
assert(locals->args.type == value_t::SEQUENCE);
- if (locals->args.to_sequence()->size() > 0) {
+ if (locals->args.as_sequence().size() > 0) {
list arglist;
for (value_t::sequence_t::iterator
- i = locals->args.to_sequence()->begin();
- i != locals->args.to_sequence()->end();
+ i = locals->args.as_sequence().begin();
+ i != locals->args.as_sequence().end();
i++)
arglist.append(*i);
@@ -167,7 +167,7 @@ void python_interpreter_t::functor_t::operator()(value_t& result,
throw_(xml::xpath_t::calc_error,
"While calling Python function '" << name() << "'");
} else {
- assert(0);
+ assert(false);
}
} else {
result = call<value_t>(func.ptr());
@@ -186,10 +186,10 @@ void python_interpreter_t::lambda_t::operator()(value_t& result,
{
try {
assert(locals->args.type == value_t::SEQUENCE);
- assert(locals->args.to_sequence()->size() == 1);
+ assert(locals->args.as_sequence().size() == 1);
value_t item = locals->args[0];
assert(item.type == value_t::POINTER);
- result = call<value_t>(func.ptr(), item.to_xml_node());
+ result = call<value_t>(func.ptr(), item.as_xml_node());
}
catch (const error_already_set&) {
PyErr_Print();
diff --git a/src/register.cc b/src/register.cc
index 16fa40eb..d3843887 100644
--- a/src/register.cc
+++ b/src/register.cc
@@ -125,11 +125,10 @@ string abbreviate(const string& str,
static void scan_for_transactions(std::ostream& out, const xml::node_t * node)
{
- if (! (node->flags & XML_NODE_IS_PARENT))
+ if (! node->has_flags(XML_NODE_IS_PARENT))
return;
- const xml::parent_node_t * parent =
- static_cast<const xml::parent_node_t *>(node);
+ const xml::parent_node_t * parent = node->as_parent_node();
for (const xml::node_t * child = parent->children();
child;
@@ -167,13 +166,13 @@ void register_command::print_document(std::ostream& out,
value_t nodelist;
xml::xpath_t::eval(nodelist, "//transaction", doc);
- const value_t::sequence_t * xact_list = nodelist.to_sequence();
+ value_t::sequence_t& xact_list(nodelist.as_sequence());
assert(xact_list);
for (value_t::sequence_t::const_iterator i = xact_list->begin();
i != xact_list->end();
i++) {
- const xml::node_t * node = (*i).to_xml_node();
+ const xml::node_t * node = (*i).as_xml_node();
assert(node);
const xml::transaction_node_t * xact_node =
diff --git a/src/report.cc b/src/report.cc
index 95db80b4..4e90f680 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -51,16 +51,16 @@ void report_t::abbrev(value_t& result, xml::xpath_t::scope_t * locals)
if (locals->args.size() < 2)
throw_(std::logic_error, "usage: abbrev(STRING, WIDTH [, STYLE, ABBREV_LEN])");
- string str = locals->args[0].to_string();
+ string str = locals->args[0].as_string();
long wid = locals->args[1];
elision_style_t style = session->elision_style;
if (locals->args.size() == 3)
- style = (elision_style_t)locals->args[2].to_long();
+ style = (elision_style_t)locals->args[2].as_long();
long abbrev_len = session->abbrev_length;
if (locals->args.size() == 4)
- abbrev_len = locals->args[3].to_long();
+ abbrev_len = locals->args[3].as_long();
result.set_string(abbreviate(str, wid, style, true, (int)abbrev_len));
}
@@ -70,17 +70,17 @@ void report_t::ftime(value_t&, xml::xpath_t::scope_t * locals)
if (locals->args.size() < 1)
throw_(std::logic_error, "usage: ftime(DATE [, DATE_FORMAT])");
- moment_t date = locals->args[0].to_datetime();
+ moment_t date = locals->args[0].as_datetime();
string date_format;
if (locals->args.size() == 2)
- date_format = locals->args[1].to_string();
+ date_format = locals->args[1].as_string();
#if 0
// jww (2007-04-18): Need to setup an output facet here
else
date_format = moment_t::output_format;
- result.set_string(date.to_string(date_format));
+ result.set_string(date.as_string(date_format));
#endif
}
diff --git a/src/report.h b/src/report.h
index aaf5a47c..d6cfef3c 100644
--- a/src/report.h
+++ b/src/report.h
@@ -91,18 +91,18 @@ class report_t : public xml::xpath_t::scope_t
xml::xpath_t(expr).compile((xml::document_t *)NULL, this);
}
void option_eval(value_t&, xml::xpath_t::scope_t * locals) {
- eval(locals->args[0].to_string());
+ eval(locals->args[0].as_string());
}
void option_amount(value_t&, xml::xpath_t::scope_t * locals) {
- eval(string("t=") + locals->args[0].to_string());
+ eval(string("t=") + locals->args[0].as_string());
}
void option_total(value_t&, xml::xpath_t::scope_t * locals) {
- eval(string("T()=") + locals->args[0].to_string());
+ eval(string("T()=") + locals->args[0].as_string());
}
void option_format(value_t&, xml::xpath_t::scope_t * locals) {
- format_string = locals->args[0].to_string();
+ format_string = locals->args[0].as_string();
}
void option_raw(value_t&) {
@@ -122,16 +122,16 @@ class report_t : public xml::xpath_t::scope_t
#if 0
void option_select(value_t&, xml::xpath_t::scope_t * locals) {
- transforms.push_back(new select_transform(locals->args[0].to_string()));
+ transforms.push_back(new select_transform(locals->args[0].as_string()));
}
void option_limit(value_t&, xml::xpath_t::scope_t * locals) {
string expr = (string("//xact[") +
- locals->args[0].to_string() + "]");
+ locals->args[0].as_string() + "]");
transforms.push_back(new select_transform(expr));
}
void option_remove(value_t&, xml::xpath_t::scope_t * locals) {
- transforms.push_back(new remove_transform(locals->args[0].to_string()));
+ transforms.push_back(new remove_transform(locals->args[0].as_string()));
}
void option_accounts(value_t&) {
diff --git a/src/session.h b/src/session.h
index a9947cf6..4693cacf 100644
--- a/src/session.h
+++ b/src/session.h
@@ -203,7 +203,7 @@ class session_t : public xml::xpath_t::scope_t
//
void option_file(value_t&, xml::xpath_t::scope_t * locals) {
- data_file = locals->args.to_string();
+ data_file = locals->args.as_string();
}
#if 0
diff --git a/src/system.hh b/src/system.hh
index 9028d0dd..61dd9530 100644
--- a/src/system.hh
+++ b/src/system.hh
@@ -128,6 +128,7 @@ extern "C" {
#include <libofx.h>
#endif
+#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/cast.hpp>
#include <boost/current_function.hpp>
@@ -138,6 +139,8 @@ extern "C" {
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/function.hpp>
+#include <boost/lambda/bind.hpp>
+#include <boost/lambda/lambda.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
@@ -148,6 +151,5 @@ extern "C" {
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/regex.hpp>
-#include <boost/signal.hpp>
#endif // _SYSTEM_HH
diff --git a/src/textual.cc b/src/textual.cc
index 39b970f9..f7e8e0b2 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -42,6 +42,7 @@ static unsigned int src_idx;
static accounts_map account_aliases;
typedef std::list<std::pair<path, int> > include_stack_t;
+
static include_stack_t include_stack;
#define TIMELOG_SUPPORT 1
@@ -98,7 +99,7 @@ parse_amount_expr(std::istream& in, journal_t *,
}
#endif
- amount = xpath.calc(xact.data).to_amount();
+ amount = xpath.calc(xact.data).as_amount();
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"The transaction amount is " << amount);
@@ -174,11 +175,11 @@ transaction_t * parse_transaction(char * line,
char * e = &account_path[std::strlen(account_path) - 1];
if ((*b == '[' && *e == ']') ||
(*b == '(' && *e == ')')) {
- xact->flags |= TRANSACTION_VIRTUAL;
+ xact->add_flags(TRANSACTION_VIRTUAL);
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed a virtual account name");
if (*b == '[') {
- xact->flags |= TRANSACTION_BALANCE;
+ xact->add_flags(TRANSACTION_BALANCE);
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed a balanced virtual account name");
}
@@ -907,7 +908,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
// parser to resolve alias references.
if (account_t * acct = account_stack.front()->find_account(e)) {
std::pair<accounts_map::iterator, bool> result
- = account_aliases.insert(accounts_pair(b, acct));
+ = account_aliases.insert(accounts_map::value_type(b, acct));
assert(result.second);
} else {
; // jww (2007-04-30): throw an error here
diff --git a/src/times.cc b/src/times.cc
index 1a02b316..fc6f2f1b 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -77,8 +77,4 @@ moment_t parse_datetime(const char * str)
#endif
}
-moment_t datetime_range_from_stream(std::istream& in)
-{
-}
-
} // namespace ledger
diff --git a/src/transform.cc b/src/transform.cc
index 4955e299..d13d9f7e 100644
--- a/src/transform.cc
+++ b/src/transform.cc
@@ -202,7 +202,7 @@ void split_transform::execute(xml::document_t * document)
switch (i->kind) {
case repitem_t::TRANSACTION:
- assert(0);
+ assert(false);
j = new xact_repitem_t(static_cast<xact_repitem_t *>(i)->xact);
break;
case repitem_t::ENTRY:
@@ -244,7 +244,7 @@ void merge_transform::execute(xml::document_t * document)
bool merge = false;
switch (i->kind) {
case repitem_t::TRANSACTION:
- assert(0);
+ assert(false);
break;
case repitem_t::ENTRY:
if (static_cast<entry_repitem_t *>(i)->entry ==
diff --git a/src/utils.cc b/src/utils.cc
index 930a74ba..e4e0f2bc 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -49,7 +49,7 @@ void debug_assert(const string& reason,
{
std::ostringstream buf;
buf << "Assertion failed in \"" << file << "\", line " << line
- << ": " << reason;
+ << ": " << func << ": " << reason;
throw assertion_failed(buf.str());
}
@@ -70,12 +70,10 @@ bool verify_enabled = false;
typedef std::pair<std::string, std::size_t> allocation_pair;
typedef std::map<void *, allocation_pair> live_memory_map;
-typedef std::pair<void *, allocation_pair> live_memory_pair;
typedef std::multimap<void *, allocation_pair> live_objects_map;
-typedef std::pair<void *, allocation_pair> live_objects_pair;
+
typedef std::pair<unsigned int, std::size_t> count_size_pair;
typedef std::map<std::string, count_size_pair> object_count_map;
-typedef std::pair<std::string, count_size_pair> object_count_pair;
static live_memory_map * live_memory = NULL;
static object_count_map * live_memory_count = NULL;
@@ -137,7 +135,7 @@ inline void add_to_count_map(object_count_map& the_map,
(*k).second.second += size;
} else {
std::pair<object_count_map::iterator, bool> result =
- the_map.insert(object_count_pair(name, count_size_pair(1, size)));
+ the_map.insert(object_count_map::value_type(name, count_size_pair(1, size)));
VERIFY(result.second);
}
}
@@ -160,7 +158,8 @@ static void trace_new_func(void * ptr, const char * which, std::size_t size)
if (! live_memory) return;
- live_memory->insert(live_memory_pair(ptr, allocation_pair(which, size)));
+ live_memory->insert
+ (live_memory_map::value_type(ptr, allocation_pair(which, size)));
add_to_count_map(*live_memory_count, which, size);
add_to_count_map(*total_memory_count, which, size);
@@ -287,7 +286,8 @@ void trace_ctor_func(void * ptr, const char * cls_name, const char * args,
DEBUG("verify.memory", "TRACE_CTOR " << ptr << " " << name);
- live_objects->insert(live_objects_pair(ptr, allocation_pair(cls_name, cls_size)));
+ live_objects->insert
+ (live_objects_map::value_type(ptr, allocation_pair(cls_name, cls_size)));
add_to_count_map(*live_object_count, cls_name, cls_size);
add_to_count_map(*total_object_count, cls_name, cls_size);
@@ -554,8 +554,7 @@ struct timer_t {
description(_description), active(true) {}
};
-typedef std::map<std::string, timer_t> timer_map;
-typedef std::pair<std::string, timer_t> timer_pair;
+typedef std::map<std::string, timer_t> timer_map;
static timer_map timers;
@@ -567,7 +566,7 @@ void start_timer(const char * name, log_level_t lvl)
timer_map::iterator i = timers.find(name);
if (i == timers.end()) {
- timers.insert(timer_pair(name, timer_t(lvl, _log_buffer.str())));
+ timers.insert(timer_map::value_type(name, timer_t(lvl, _log_buffer.str())));
} else {
assert((*i).second.description == _log_buffer.str());
(*i).second.begin = CURRENT_TIME();
diff --git a/src/utils.h b/src/utils.h
index f95e5dc0..8ff142ca 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -473,8 +473,8 @@ inline void throw_func(const std::string& message) {
#define throw_(cls, msg) \
((_exc_buffer << msg), throw_func<cls>(_exc_buffer.str()))
-inline void throw_unexpected_error(char c, char wanted) {
#if 0
+inline void throw_unexpected_error(char c, char wanted) {
if (c == -1) {
if (wanted)
throw new error(string("Missing '") + wanted + "'");
@@ -487,8 +487,11 @@ inline void throw_unexpected_error(char c, char wanted) {
else
throw new error(string("Invalid char '") + c + "'");
}
-#endif
}
+#else
+inline void throw_unexpected_error(char, char) {
+}
+#endif
} // namespace ledger
diff --git a/src/value.cc b/src/value.cc
index e155d0d7..c4d22f60 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -34,115 +34,94 @@
namespace ledger {
-bool& value_t::to_boolean()
+bool value_t::to_boolean() const
{
if (type == BOOLEAN) {
- return *(bool *) data;
+ return as_boolean();
} else {
- throw_(value_error, "Value is not a boolean");
value_t temp(*this);
temp.in_place_cast(BOOLEAN);
- return *(bool *) temp.data;
+ return temp.as_boolean();
}
}
-long& value_t::to_long()
+long value_t::to_long() const
{
if (type == INTEGER) {
- return *(long *) data;
+ return as_long();
} else {
- throw_(value_error, "Value is not an integer");
value_t temp(*this);
temp.in_place_cast(INTEGER);
- return *(long *) temp.data;
+ return temp.as_long();
}
}
-moment_t& value_t::to_datetime()
+moment_t value_t::to_datetime() const
{
if (type == DATETIME) {
- return *(moment_t *) data;
+ return as_datetime();
} else {
- throw_(value_error, "Value is not a date/time");
value_t temp(*this);
temp.in_place_cast(DATETIME);
- return *(moment_t *) temp.data;
+ return temp.as_datetime();
}
}
-amount_t& value_t::to_amount()
+amount_t value_t::to_amount() const
{
if (type == AMOUNT) {
- return *(amount_t *) data;
+ return as_amount();
} else {
- throw_(value_error, "Value is not an amount");
value_t temp(*this);
temp.in_place_cast(AMOUNT);
- return *(amount_t *) temp.data;
+ return temp.as_amount();
}
}
-balance_t& value_t::to_balance()
+balance_t value_t::to_balance() const
{
if (type == BALANCE) {
- return *(balance_t *) data;
+ return as_balance();
} else {
- throw_(value_error, "Value is not a balance");
value_t temp(*this);
temp.in_place_cast(BALANCE);
- return *(balance_t *) temp.data;
+ return temp.as_balance();
}
}
-balance_pair_t& value_t::to_balance_pair()
+balance_pair_t value_t::to_balance_pair() const
{
if (type == BALANCE_PAIR) {
- return *(balance_pair_t *) data;
+ return as_balance_pair();
} else {
- throw_(value_error, "Value is not a balance pair");
value_t temp(*this);
temp.in_place_cast(BALANCE_PAIR);
- return *(balance_pair_t *) temp.data;
+ return temp.as_balance_pair();
}
}
-string& value_t::to_string()
+string value_t::to_string() const
{
if (type == STRING) {
- return **(string **) data;
+ return as_string();
} else {
- throw_(value_error, "Value is not a string");
-#if 0
- std::ostringstream out;
- out << *this;
- return out.str();
-#endif
+ value_t temp(*this);
+ temp.in_place_cast(STRING);
+ return temp.as_string();
}
}
-xml::node_t *& value_t::to_xml_node()
+value_t::sequence_t value_t::to_sequence() const
{
- if (type == XML_NODE)
- return *(xml::node_t **) data;
- else
- throw_(value_error, "Value is not an XML node");
-}
-
-void *& value_t::to_pointer()
-{
- if (type == POINTER)
- return *(void **) data;
- else
- throw_(value_error, "Value is not a pointer");
+ if (type == SEQUENCE) {
+ return as_sequence();
+ } else {
+ value_t temp(*this);
+ temp.in_place_cast(SEQUENCE);
+ return temp.as_sequence();
+ }
}
-value_t::sequence_t *& value_t::to_sequence()
-{
- if (type == SEQUENCE)
- return *(sequence_t **) data;
- else
- throw_(value_error, "Value is not a sequence");
-}
void value_t::destroy()
{
@@ -157,40 +136,43 @@ void value_t::destroy()
((balance_pair_t *)data)->~balance_pair_t();
break;
case STRING:
- checked_delete(*(string **) data);
+ ((string *)data)->~string();
break;
case SEQUENCE:
- checked_delete(*(sequence_t **) data);
+ ((sequence_t *)data)->~sequence_t();
break;
+
default:
break;
}
}
-void value_t::simplify()
+void value_t::in_place_simplify()
{
+ LOGGER("amounts.values.simplify");
+
if (is_realzero()) {
- DEBUG("amounts.values.simplify", "Zeroing type " << type);
- *this = 0L;
+ DEBUG_("Zeroing type " << type);
+ destroy();
+ type = INTEGER;
+ as_long() = 0L;
return;
}
if (type == BALANCE_PAIR &&
- (! ((balance_pair_t *) data)->cost ||
- ((balance_pair_t *) data)->cost->is_realzero())) {
- DEBUG("amounts.values.simplify", "Reducing balance pair to balance");
+ (! as_balance_pair().cost || as_balance_pair().cost->is_realzero())) {
+ DEBUG_("Reducing balance pair to balance");
in_place_cast(BALANCE);
}
- if (type == BALANCE &&
- ((balance_t *) data)->amounts.size() == 1) {
- DEBUG("amounts.values.simplify", "Reducing balance to amount");
+ if (type == BALANCE && as_balance().amounts.size() == 1) {
+ DEBUG_("Reducing balance to amount");
in_place_cast(AMOUNT);
}
- if (type == AMOUNT &&
- ! ((amount_t *) data)->commodity()) {
- DEBUG("amounts.values.simplify", "Reducing amount to integer");
+ if (type == AMOUNT && ! as_amount().has_commodity() &&
+ as_amount().fits_in_long()) {
+ DEBUG_("Reducing amount to integer");
in_place_cast(INTEGER);
}
}
@@ -200,504 +182,415 @@ value_t& value_t::operator=(const value_t& val)
if (this == &val)
return *this;
- if (type == BOOLEAN && val.type == BOOLEAN) {
- *((bool *) data) = *((bool *) val.data);
- return *this;
- }
- else if (type == INTEGER && val.type == INTEGER) {
- *((long *) data) = *((long *) val.data);
- return *this;
- }
- else if (type == DATETIME && val.type == DATETIME) {
- *((moment_t *) data) = *((moment_t *) val.data);
- return *this;
- }
- else if (type == AMOUNT && val.type == AMOUNT) {
- *(amount_t *) data = *(amount_t *) val.data;
- return *this;
- }
- else if (type == BALANCE && val.type == BALANCE) {
- *(balance_t *) data = *(balance_t *) val.data;
- return *this;
- }
- else if (type == BALANCE_PAIR && val.type == BALANCE_PAIR) {
- *(balance_pair_t *) data = *(balance_pair_t *) val.data;
- return *this;
- }
- else if (type == STRING && val.type == STRING) {
- **(string **) data = **(string **) val.data;
- return *this;
- }
- else if (type == SEQUENCE && val.type == SEQUENCE) {
- **(sequence_t **) data = **(sequence_t **) val.data;
- return *this;
- }
+ if (type == val.type)
+ switch (type) {
+ case BOOLEAN:
+ as_boolean() = val.as_boolean();
+ return *this;
+ case INTEGER:
+ as_long() = val.as_long();
+ return *this;
+ case DATETIME:
+ as_datetime() = val.as_datetime();
+ return *this;
+ case AMOUNT:
+ as_amount() = val.as_amount();
+ return *this;
+ case BALANCE:
+ as_balance() = val.as_balance();
+ return *this;
+ case BALANCE_PAIR:
+ as_balance_pair() = val.as_balance_pair();
+ return *this;
+ case STRING:
+ as_string() = val.as_string();
+ return *this;
+ case SEQUENCE:
+ as_sequence() = val.as_sequence();
+ return *this;
+ }
destroy();
+ type = val.type;
+
switch (val.type) {
+ case VOID:
+ break;
+
case BOOLEAN:
- *((bool *) data) = *((bool *) val.data);
+ as_boolean() = val.as_boolean();
break;
case INTEGER:
- *((long *) data) = *((long *) val.data);
+ as_long() = val.as_long();
break;
case DATETIME:
- *((moment_t *) data) = *((moment_t *) val.data);
+ new((moment_t *) data) moment_t(val.as_datetime());
break;
case AMOUNT:
- new((amount_t *)data) amount_t(*((amount_t *) val.data));
+ new((amount_t *)data) amount_t(val.as_amount());
break;
case BALANCE:
- new((balance_t *)data) balance_t(*((balance_t *) val.data));
+ new((balance_t *)data) balance_t(val.as_balance());
break;
case BALANCE_PAIR:
- new((balance_pair_t *)data) balance_pair_t(*((balance_pair_t *) val.data));
+ new((balance_pair_t *)data) balance_pair_t(val.as_balance_pair());
break;
case STRING:
- *(string **) data = new string(**(string **) val.data);
+ new((string *)data) string(val.as_string());
break;
- case XML_NODE:
- *(xml::node_t **) data = *(xml::node_t **) val.data;
+ case SEQUENCE:
+ new((sequence_t *)data) sequence_t(val.as_sequence());
break;
- case POINTER:
- *(void **) data = *(void **) val.data;
+ case XML_NODE:
+ as_xml_node() = val.as_xml_node();
break;
- case SEQUENCE:
- *(sequence_t **) data = new sequence_t(**(sequence_t **) val.data);
+ case POINTER:
+ as_pointer() = val.as_pointer();
break;
default:
- assert(0);
+ assert(false);
break;
}
- type = val.type;
-
return *this;
}
value_t& value_t::operator+=(const value_t& val)
{
- if (val.type == BOOLEAN)
- throw_(value_error, "Cannot add a boolean to a value");
- else if (val.type == DATETIME)
- throw_(value_error, "Cannot add a date/time to a value");
- else if (val.type == POINTER)
- throw_(value_error, "Cannot add a pointer to a value");
- else if (val.type == SEQUENCE)
- throw_(value_error, "Cannot add a sequence to a value");
- else if (val.type == XML_NODE) // recurse
- return *this += (*(xml::node_t **) val.data)->to_value();
+ if (type == STRING) {
+ if (val.type == STRING)
+ as_string() += val.as_string();
+ else
+ as_string() += val.to_string();
+ return *this;
+ }
+ else if (type == SEQUENCE) {
+ if (val.type == SEQUENCE)
+ as_sequence().insert(as_sequence().end(),
+ val.as_sequence().begin(),
+ val.as_sequence().end());
+ else
+ as_sequence().push_back(val);
+ return *this;
+ }
- switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot add a value to a boolean");
+ if (val.type == XML_NODE) // recurse
+ return *this += val.as_xml_node()->to_value();
- case INTEGER:
+ switch (type) {
+ case DATETIME:
switch (val.type) {
case INTEGER:
- *((long *) data) += *((long *) val.data);
- break;
+ as_datetime() += date_duration(val.as_long());
+ return *this;
case AMOUNT:
- in_place_cast(AMOUNT);
- *((amount_t *) data) += *((amount_t *) val.data);
- break;
- case BALANCE:
- in_place_cast(BALANCE);
- *((balance_t *) data) += *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) += *((balance_pair_t *) val.data);
- break;
- case STRING:
- throw_(value_error, "Cannot add a string to an integer");
- default:
- assert(0);
- break;
+ as_datetime() += date_duration(val.as_amount().to_long());
+ return *this;
}
break;
- case DATETIME:
+ case INTEGER:
switch (val.type) {
case INTEGER:
- *((moment_t *) data) += date_duration(*((long *) val.data));
- break;
+ as_long() += val.as_long();
+ return *this;
case AMOUNT:
- *((moment_t *) data) += date_duration(long(*((amount_t *) val.data)));
- break;
+ in_place_cast(AMOUNT);
+ as_amount() += val.as_amount();
+ return *this;
case BALANCE:
- *((moment_t *) data) += date_duration(long(*((balance_t *) val.data)));
- break;
+ in_place_cast(BALANCE);
+ as_balance() += val.as_balance();
+ return *this;
case BALANCE_PAIR:
- *((moment_t *) data) += date_duration(long(*((balance_pair_t *) val.data)));
- break;
- case STRING:
- throw_(value_error, "Cannot add a string to an date/time");
- default:
- assert(0);
- break;
+ in_place_cast(BALANCE_PAIR);
+ as_balance_pair() += val.as_balance_pair();
+ return *this;
}
break;
case AMOUNT:
switch (val.type) {
case INTEGER:
- if (*((long *) val.data) &&
- ((amount_t *) data)->commodity()) {
+ if (as_amount().has_commodity()) {
in_place_cast(BALANCE);
return *this += val;
+ } else {
+ as_amount() += val.as_long();
+ return *this;
}
- *((amount_t *) data) += *((long *) val.data);
break;
case AMOUNT:
- if (((amount_t *) data)->commodity() !=
- ((amount_t *) val.data)->commodity()) {
+ if (as_amount().commodity() != val.as_amount().commodity()) {
in_place_cast(BALANCE);
return *this += val;
+ } else {
+ as_amount() += val.as_amount();
+ return *this;
}
- *((amount_t *) data) += *((amount_t *) val.data);
break;
case BALANCE:
in_place_cast(BALANCE);
- *((balance_t *) data) += *((balance_t *) val.data);
- break;
+ as_balance() += val.as_balance();
+ return *this;
case BALANCE_PAIR:
in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) += *((balance_pair_t *) val.data);
- break;
-
- case STRING:
- throw_(value_error, "Cannot add a string to an amount");
-
- default:
- assert(0);
- break;
+ as_balance_pair() += val.as_balance_pair();
+ return *this;
}
break;
case BALANCE:
switch (val.type) {
case INTEGER:
- *((balance_t *) data) += amount_t(*((long *) val.data));
- break;
+ as_balance() += val.to_amount();
+ return *this;
case AMOUNT:
- *((balance_t *) data) += *((amount_t *) val.data);
- break;
+ as_balance() += val.as_amount();
+ return *this;
case BALANCE:
- *((balance_t *) data) += *((balance_t *) val.data);
- break;
+ as_balance() += val.as_balance();
+ return *this;
case BALANCE_PAIR:
in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) += *((balance_pair_t *) val.data);
- break;
- case STRING:
- throw_(value_error, "Cannot add a string to an balance");
- default:
- assert(0);
- break;
+ as_balance_pair() += val.as_balance_pair();
+ return *this;
}
break;
case BALANCE_PAIR:
switch (val.type) {
case INTEGER:
- *((balance_pair_t *) data) += amount_t(*((long *) val.data));
- break;
- case AMOUNT:
- *((balance_pair_t *) data) += *((amount_t *) val.data);
- break;
- case BALANCE:
- *((balance_pair_t *) data) += *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- *((balance_pair_t *) data) += *((balance_pair_t *) val.data);
- break;
- case STRING:
- throw_(value_error, "Cannot add a string to an balance pair");
- default:
- assert(0);
- break;
- }
- break;
-
- case STRING:
- switch (val.type) {
- case INTEGER:
- throw_(value_error, "Cannot add an integer to a string");
+ as_balance_pair() += val.to_amount();
+ return *this;
case AMOUNT:
- throw_(value_error, "Cannot add an amount to a string");
+ as_balance_pair() += val.as_amount();
+ return *this;
case BALANCE:
- throw_(value_error, "Cannot add a balance to a string");
+ as_balance_pair() += val.as_balance();
+ return *this;
case BALANCE_PAIR:
- throw_(value_error, "Cannot add a balance pair to a string");
- case STRING:
- **(string **) data += **(string **) val.data;
- break;
- default:
- assert(0);
- break;
+ as_balance_pair() += val.as_balance_pair();
+ return *this;
}
break;
-
- case XML_NODE:
- throw_(value_error, "Cannot add a value to an XML node");
-
- case POINTER:
- throw_(value_error, "Cannot add a value to a pointer");
-
- case SEQUENCE:
- throw_(value_error, "Cannot add a value to a sequence");
-
- default:
- assert(0);
- break;
}
- return *this;
+
+ throw_(value_error,
+ "Cannot add " << label() << " to " << val.label());
}
value_t& value_t::operator-=(const value_t& val)
{
- if (val.type == BOOLEAN)
- throw_(value_error, "Cannot subtract a boolean from a value");
- else if (val.type == DATETIME && type != DATETIME)
- throw_(value_error, "Cannot subtract a date/time from a value");
- else if (val.type == STRING)
- throw_(value_error, "Cannot subtract a string from a value");
- else if (val.type == POINTER)
- throw_(value_error, "Cannot subtract a pointer from a value");
- else if (val.type == SEQUENCE)
- throw_(value_error, "Cannot subtract a sequence from a value");
- else if (val.type == XML_NODE) // recurse
- return *this -= (*(xml::node_t **) val.data)->to_value();
+ if (type == SEQUENCE) {
+ if (val.type == SEQUENCE) {
+ for (sequence_t::const_iterator i = val.as_sequence().begin();
+ i != val.as_sequence().end();
+ i++) {
+ sequence_t::iterator j =
+ std::find(as_sequence().begin(), as_sequence().end(), *i);
+ if (j != as_sequence().end())
+ as_sequence().erase(j);
+ }
+ } else {
+ sequence_t::iterator i =
+ std::find(as_sequence().begin(), as_sequence().end(), val);
+ if (i != as_sequence().end())
+ as_sequence().erase(i);
+ }
+ return *this;
+ }
- switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot subtract a value from a boolean");
+ if (val.type == XML_NODE) // recurse
+ return *this -= val.as_xml_node()->to_value();
- case INTEGER:
+ switch (type) {
+ case DATETIME:
switch (val.type) {
case INTEGER:
- *((long *) data) -= *((long *) val.data);
- break;
+ as_datetime() -= date_duration(val.as_long());
+ return *this;
case AMOUNT:
- in_place_cast(AMOUNT);
- *((amount_t *) data) -= *((amount_t *) val.data);
- break;
- case BALANCE:
- in_place_cast(BALANCE);
- *((balance_t *) data) -= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) -= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
- break;
+ as_datetime() -= date_duration(val.as_amount().to_long());
+ return *this;
}
break;
- case DATETIME:
+ case INTEGER:
switch (val.type) {
case INTEGER:
- *((moment_t *) data) -= date_duration(*((long *) val.data));
- break;
- case DATETIME: {
- duration_t tval = ((moment_t *) data)->operator-(*((moment_t *) val.data));
- in_place_cast(INTEGER);
- *((long *) data) = tval.total_seconds() / 86400L;
- break;
- }
+ as_long() -= val.as_long();
+ return *this;
case AMOUNT:
- *((moment_t *) data) -= date_duration(long(*((amount_t *) val.data)));
- break;
+ in_place_cast(AMOUNT);
+ as_amount() -= val.as_amount();
+ in_place_simplify();
+ return *this;
case BALANCE:
- *((moment_t *) data) -= date_duration(long(*((balance_t *) val.data)));
- break;
+ in_place_cast(BALANCE);
+ as_balance() -= val.as_balance();
+ in_place_simplify();
+ return *this;
case BALANCE_PAIR:
- *((moment_t *) data) -= date_duration(long(*((balance_pair_t *) val.data)));
- break;
- default:
- assert(0);
- break;
+ in_place_cast(BALANCE_PAIR);
+ as_balance_pair() -= val.as_balance_pair();
+ in_place_simplify();
+ return *this;
}
break;
case AMOUNT:
switch (val.type) {
case INTEGER:
- if (*((long *) val.data) &&
- ((amount_t *) data)->commodity()) {
+ if (as_amount().has_commodity()) {
in_place_cast(BALANCE);
- return *this -= val;
+ *this -= val;
+ in_place_simplify();
+ return *this;
+ } else {
+ as_amount() -= val.as_long();
+ in_place_simplify();
+ return *this;
}
- *((amount_t *) data) -= *((long *) val.data);
break;
case AMOUNT:
- if (((amount_t *) data)->commodity() !=
- ((amount_t *) val.data)->commodity()) {
+ if (as_amount().commodity() != val.as_amount().commodity()) {
in_place_cast(BALANCE);
- return *this -= val;
+ *this -= val;
+ in_place_simplify();
+ return *this;
+ } else {
+ as_amount() -= val.as_amount();
+ in_place_simplify();
+ return *this;
}
- *((amount_t *) data) -= *((amount_t *) val.data);
break;
case BALANCE:
in_place_cast(BALANCE);
- *((balance_t *) data) -= *((balance_t *) val.data);
- break;
+ as_balance() -= val.as_balance();
+ in_place_simplify();
+ return *this;
case BALANCE_PAIR:
in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) -= *((balance_pair_t *) val.data);
- break;
-
- default:
- assert(0);
- break;
+ as_balance_pair() -= val.as_balance_pair();
+ in_place_simplify();
+ return *this;
}
break;
case BALANCE:
switch (val.type) {
case INTEGER:
- *((balance_t *) data) -= amount_t(*((long *) val.data));
- break;
+ as_balance() -= val.to_amount();
+ in_place_simplify();
+ return *this;
case AMOUNT:
- *((balance_t *) data) -= *((amount_t *) val.data);
- break;
+ as_balance() -= val.as_amount();
+ in_place_simplify();
+ return *this;
case BALANCE:
- *((balance_t *) data) -= *((balance_t *) val.data);
- break;
+ as_balance() -= val.as_balance();
+ in_place_simplify();
+ return *this;
case BALANCE_PAIR:
in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) -= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
- break;
+ as_balance_pair() -= val.as_balance_pair();
+ in_place_simplify();
+ return *this;
}
break;
case BALANCE_PAIR:
switch (val.type) {
case INTEGER:
- *((balance_pair_t *) data) -= amount_t(*((long *) val.data));
- break;
+ as_balance_pair() -= val.to_amount();
+ in_place_simplify();
+ return *this;
case AMOUNT:
- *((balance_pair_t *) data) -= *((amount_t *) val.data);
- break;
+ as_balance_pair() -= val.as_amount();
+ in_place_simplify();
+ return *this;
case BALANCE:
- *((balance_pair_t *) data) -= *((balance_t *) val.data);
- break;
+ as_balance_pair() -= val.as_balance();
+ in_place_simplify();
+ return *this;
case BALANCE_PAIR:
- *((balance_pair_t *) data) -= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
- break;
+ as_balance_pair() -= val.as_balance_pair();
+ in_place_simplify();
+ return *this;
}
break;
-
- case STRING:
- throw_(value_error, "Cannot subtract a value from a string");
- case XML_NODE:
- throw_(value_error, "Cannot subtract a value from an XML node");
- case POINTER:
- throw_(value_error, "Cannot subtract a value from a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot subtract a value from a sequence");
-
- default:
- assert(0);
- break;
}
- simplify();
-
- return *this;
+ throw_(value_error,
+ "Cannot subtract " << label() << " from " << val.label());
}
value_t& value_t::operator*=(const value_t& val)
{
- if (val.type == BOOLEAN)
- throw_(value_error, "Cannot multiply a value by a boolean");
- else if (val.type == DATETIME)
- throw_(value_error, "Cannot multiply a value by a date/time");
- else if (val.type == STRING)
- throw_(value_error, "Cannot multiply a value by a string");
- else if (val.type == POINTER)
- throw_(value_error, "Cannot multiply a value by a pointer");
- else if (val.type == SEQUENCE)
- throw_(value_error, "Cannot multiply a value by a sequence");
- else if (val.type == XML_NODE) // recurse
- return *this *= (*(xml::node_t **) val.data)->to_value();
-
- if (val.is_realzero() && type != STRING) {
- *this = 0L;
+ if (type == STRING) {
+ string temp;
+ long count = val.to_long();
+ for (long i = 0; i < count; i++)
+ temp += as_string();
+ as_string() = temp;
return *this;
}
+ else if (type == SEQUENCE) {
+ value_t temp;
+ long count = val.to_long();
+ for (long i = 0; i < count; i++)
+ temp += as_sequence();
+ return *this = temp;
+ }
- switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot multiply a value by a boolean");
+ if (val.type == XML_NODE) // recurse
+ return *this *= val.as_xml_node()->to_value();
+ switch (type) {
case INTEGER:
switch (val.type) {
case INTEGER:
- *((long *) data) *= *((long *) val.data);
- break;
- case AMOUNT:
+ as_long() *= val.as_long();
+ return *this;
+ case AMOUNT: {
+ long temp = as_long();
in_place_cast(AMOUNT);
- *((amount_t *) data) *= *((amount_t *) val.data);
- break;
- case BALANCE:
- in_place_cast(BALANCE);
- *((balance_t *) data) *= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) *= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
- break;
+ as_amount() = val.as_amount() * temp;
+ return *this;
+ }
}
break;
case AMOUNT:
switch (val.type) {
case INTEGER:
- *((amount_t *) data) *= *((long *) val.data);
- break;
+ as_amount() *= val.as_long();
+ return *this;
+
case AMOUNT:
- *((amount_t *) data) *= *((amount_t *) val.data);
- break;
- case BALANCE:
- in_place_cast(BALANCE);
- *((balance_t *) data) *= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) *= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
+ if (as_amount().commodity() == val.as_amount().commodity() ||
+ ! val.as_amount().has_commodity()) {
+ as_amount() *= val.as_amount();
+ return *this;
+ }
break;
}
break;
@@ -705,20 +598,13 @@ value_t& value_t::operator*=(const value_t& val)
case BALANCE:
switch (val.type) {
case INTEGER:
- *((balance_t *) data) *= *((long *) val.data);
- break;
+ as_balance() *= val.to_amount();
+ return *this;
case AMOUNT:
- *((balance_t *) data) *= *((amount_t *) val.data);
- break;
- case BALANCE:
- *((balance_t *) data) *= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) *= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
+ if (! val.as_amount().has_commodity()) {
+ as_balance() *= val.as_amount();
+ return *this;
+ }
break;
}
break;
@@ -726,125 +612,54 @@ value_t& value_t::operator*=(const value_t& val)
case BALANCE_PAIR:
switch (val.type) {
case INTEGER:
- *((balance_pair_t *) data) *= amount_t(*((long *) val.data));
- break;
+ as_balance_pair() *= val.to_amount();
+ return *this;
case AMOUNT:
- *((balance_pair_t *) data) *= *((amount_t *) val.data);
- break;
- case BALANCE:
- *((balance_pair_t *) data) *= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- *((balance_pair_t *) data) *= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
- break;
- }
- break;
-
- case STRING:
- switch (val.type) {
- case INTEGER: {
- string temp;
- for (long i = 0; i < *(long *) val.data; i++)
- temp += **(string **) data;
- **(string **) data = temp;
- break;
- }
- case AMOUNT: {
- string temp;
- value_t num(val);
- num.in_place_cast(INTEGER);
- for (long i = 0; i < *(long *) num.data; i++)
- temp += **(string **) data;
- **(string **) data = temp;
- break;
- }
- case BALANCE:
- throw_(value_error, "Cannot multiply a string by a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot multiply a string by a balance pair");
- default:
- assert(0);
+ if (! val.as_amount().has_commodity()) {
+ as_balance_pair() *= val.as_amount();
+ return *this;
+ }
break;
}
break;
-
- case XML_NODE:
- throw_(value_error, "Cannot multiply an XML node by a value");
- case POINTER:
- throw_(value_error, "Cannot multiply a pointer by a value");
- case SEQUENCE:
- throw_(value_error, "Cannot multiply a sequence by a value");
-
- default:
- assert(0);
- break;
}
- return *this;
+
+ throw_(value_error,
+ "Cannot multiply " << label() << " with " << val.label());
}
value_t& value_t::operator/=(const value_t& val)
{
- if (val.type == BOOLEAN)
- throw_(value_error, "Cannot divide a boolean by a value");
- else if (val.type == DATETIME)
- throw_(value_error, "Cannot divide a date/time by a value");
- else if (val.type == STRING)
- throw_(value_error, "Cannot divide a string by a value");
- else if (val.type == POINTER)
- throw_(value_error, "Cannot divide a pointer by a value");
- else if (val.type == SEQUENCE)
- throw_(value_error, "Cannot divide a value by a sequence");
- else if (val.type == XML_NODE) // recurse
- return *this /= (*(xml::node_t **) val.data)->to_value();
+ if (val.type == XML_NODE) // recurse
+ return *this /= val.as_xml_node()->to_value();
switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot divide a value by a boolean");
-
case INTEGER:
switch (val.type) {
case INTEGER:
- *((long *) data) /= *((long *) val.data);
- break;
- case AMOUNT:
+ as_long() /= val.as_long();
+ return *this;
+ case AMOUNT: {
+ long temp = as_long();
in_place_cast(AMOUNT);
- *((amount_t *) data) /= *((amount_t *) val.data);
- break;
- case BALANCE:
- in_place_cast(BALANCE);
- *((balance_t *) data) /= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) /= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
- break;
+ as_amount() = val.as_amount() / temp;
+ return *this;
+ }
}
break;
case AMOUNT:
switch (val.type) {
case INTEGER:
- *((amount_t *) data) /= *((long *) val.data);
- break;
+ as_amount() /= val.as_long();
+ return *this;
+
case AMOUNT:
- *((amount_t *) data) /= *((amount_t *) val.data);
- break;
- case BALANCE:
- in_place_cast(BALANCE);
- *((balance_t *) data) /= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) /= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
+ if (as_amount().commodity() == val.as_amount().commodity() ||
+ ! val.as_amount().has_commodity()) {
+ as_amount() /= val.as_amount();
+ return *this;
+ }
break;
}
break;
@@ -852,20 +667,13 @@ value_t& value_t::operator/=(const value_t& val)
case BALANCE:
switch (val.type) {
case INTEGER:
- *((balance_t *) data) /= *((long *) val.data);
- break;
+ as_balance() /= val.to_amount();
+ return *this;
case AMOUNT:
- *((balance_t *) data) /= *((amount_t *) val.data);
- break;
- case BALANCE:
- *((balance_t *) data) /= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- in_place_cast(BALANCE_PAIR);
- *((balance_pair_t *) data) /= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
+ if (! val.as_amount().has_commodity()) {
+ as_balance() /= val.as_amount();
+ return *this;
+ }
break;
}
break;
@@ -873,1102 +681,594 @@ value_t& value_t::operator/=(const value_t& val)
case BALANCE_PAIR:
switch (val.type) {
case INTEGER:
- *((balance_pair_t *) data) /= amount_t(*((long *) val.data));
- break;
+ as_balance_pair() /= val.to_amount();
+ return *this;
case AMOUNT:
- *((balance_pair_t *) data) /= *((amount_t *) val.data);
- break;
- case BALANCE:
- *((balance_pair_t *) data) /= *((balance_t *) val.data);
- break;
- case BALANCE_PAIR:
- *((balance_pair_t *) data) /= *((balance_pair_t *) val.data);
- break;
- default:
- assert(0);
+ if (! val.as_amount().has_commodity()) {
+ as_balance_pair() /= val.as_amount();
+ return *this;
+ }
break;
}
break;
-
- case STRING:
- throw_(value_error, "Cannot divide a value from a string");
- case XML_NODE:
- throw_(value_error, "Cannot divide a value from an XML node");
- case POINTER:
- throw_(value_error, "Cannot divide a value from a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot divide a value from a sequence");
-
- default:
- assert(0);
- break;
}
- return *this;
-}
-
-value_t::operator bool() const
-{
- switch (type) {
- case BOOLEAN:
- return *(bool *) data;
- case INTEGER:
- return *(long *) data;
- case DATETIME:
- return is_valid_moment(*((moment_t *) data));
- case AMOUNT:
- return *(amount_t *) data;
- case BALANCE:
- return *(balance_t *) data;
- case BALANCE_PAIR:
- return *(balance_pair_t *) data;
- case STRING:
- return ! (**((string **) data)).empty();
- case XML_NODE:
- return (*(xml::node_t **) data)->to_value().to_boolean();
- case POINTER:
- return *(void **) data != NULL;
- case SEQUENCE:
- return (*(sequence_t **) data != NULL &&
- ! (*(sequence_t **) data)->empty());
- default:
- assert(0);
- break;
- }
- assert(0);
- return 0;
+ throw_(value_error,
+ "Cannot divide " << label() << " by " << val.label());
}
-#if 0
-template <>
-value_t::operator long() const
-{
- switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot convert a boolean to an integer");
- case INTEGER:
- return *((long *) data);
- case DATETIME:
- throw_(value_error, "Cannot convert a date/time to an integer");
- case AMOUNT:
- return *((amount_t *) data);
- case BALANCE:
- throw_(value_error, "Cannot convert a balance to an integer");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a balance pair to an integer");
- case STRING:
- throw_(value_error, "Cannot convert a string to an integer");
- case XML_NODE:
- return (*(xml::node_t **) data)->to_value().to_integer();
- case POINTER:
- throw_(value_error, "Cannot convert a pointer to an integer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a sequence to an integer");
-
- default:
- assert(0);
- break;
- }
- assert(0);
- return 0;
-}
-template <>
-value_t::operator moment_t() const
+bool value_t::operator==(const value_t& val) const
{
- switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot convert a boolean to a date/time");
- case INTEGER:
- throw_(value_error, "Cannot convert an integer to a date/time");
- case DATETIME:
- return *((moment_t *) data);
- case AMOUNT:
- throw_(value_error, "Cannot convert an amount to a date/time");
- case BALANCE:
- throw_(value_error, "Cannot convert a balance to a date/time");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a balance pair to a date/time");
- case STRING:
- throw_(value_error, "Cannot convert a string to a date/time");
- case XML_NODE:
- return (*(xml::node_t **) data)->to_value().to_datetime();
- case POINTER:
- throw_(value_error, "Cannot convert a pointer to a date/time");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a sequence to a date/time");
-
- default:
- assert(0);
- break;
- }
- assert(0);
- return moment_t();
-}
+ if (type == XML_NODE && val.type == XML_NODE)
+ return as_xml_node() == val.as_xml_node();
+ else if (type == XML_NODE)
+ return as_xml_node()->to_value() == val;
+ else if (val.type == XML_NODE)
+ return *this == val.as_xml_node()->to_value();
-template <>
-value_t::operator double() const
-{
switch (type) {
case BOOLEAN:
- throw_(value_error, "Cannot convert a boolean to a double");
- case INTEGER:
- return *((long *) data);
- case DATETIME:
- throw_(value_error, "Cannot convert a date/time to a double");
- case AMOUNT:
- return *((amount_t *) data);
- case BALANCE:
- throw_(value_error, "Cannot convert a balance to a double");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a balance pair to a double");
- case STRING:
- throw_(value_error, "Cannot convert a string to a double");
- case XML_NODE:
- return (*(xml::node_t **) data)->to_value().to_amount().number();
- case POINTER:
- throw_(value_error, "Cannot convert a pointer to a double");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a sequence to a double");
-
- default:
- assert(0);
+ if (val.type == BOOLEAN)
+ return as_boolean() == val.as_boolean();
break;
- }
- assert(0);
- return 0;
-}
-template <>
-value_t::operator string() const
-{
- switch (type) {
- case BOOLEAN:
- case INTEGER:
case DATETIME:
- case AMOUNT:
- case BALANCE:
- case BALANCE_PAIR: {
- value_t temp(*this);
- temp.in_place_cast(STRING);
- return temp;
- }
- case STRING:
- return **(string **) data;
- case XML_NODE:
- return (*(xml::node_t **) data)->to_value().to_string();
-
- case POINTER:
- throw_(value_error, "Cannot convert a pointer to a string");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a sequence to a string");
-
- default:
- assert(0);
+ if (val.type == DATETIME)
+ return as_datetime() == val.as_datetime();
break;
- }
- assert(0);
- return 0;
-}
-#endif
-template <typename T>
-inline int compare_bool(const T& left, const T& right) {
- return (! left && right ? -1 : (left && ! right ? 1 : 0));
-}
-
-// jww (2007-05-01): This is going to be slow as hell for two
-// balance_t objects
-template <typename T>
-inline int compare_equality(const T& left, const T& right) {
- return (left < right ? -1 : (left > right ? 1 : 0));
-}
-
-int value_t::compare(const value_t& val) const
-{
- if (val.type == XML_NODE)
- return compare((*(xml::node_t **) data)->to_value());
-
- switch (type) {
- case BOOLEAN:
+ case INTEGER:
switch (val.type) {
- case BOOLEAN:
- return compare_bool(*((bool *) data), *((bool *) val.data));
-
case INTEGER:
- return compare_bool(*((bool *) data), bool(*((long *) val.data)));
-
- case DATETIME:
- throw_(value_error, "Cannot compare a boolean to a date/time");
-
+ return as_long() == val.as_long();
case AMOUNT:
- return compare_bool(*((bool *) data), bool(*((amount_t *) val.data)));
-
+ return val.as_amount() == as_amount();
case BALANCE:
- return compare_bool(*((bool *) data), bool(*((balance_t *) val.data)));
-
+ return val.as_balance() == to_amount();
case BALANCE_PAIR:
- return compare_bool(*((bool *) data), bool(*((balance_pair_t *) val.data)));
-
- case STRING:
- throw_(value_error, "Cannot compare a boolean to a string");
- case POINTER:
- throw_(value_error, "Cannot compare a boolean to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare a boolean to a sequence");
-
+ return val.as_balance_pair() == to_balance();
default:
- assert(0);
break;
}
break;
- case INTEGER:
+ case AMOUNT:
switch (val.type) {
- case BOOLEAN:
- return *((long *) data) - ((long) *((bool *) val.data));
-
case INTEGER:
- return *((long *) data) - *((long *) val.data);
-
- case DATETIME:
- throw_(value_error, "Cannot compare an integer to a date/time");
-
+ return as_amount() == val.as_long();
case AMOUNT:
- return amount_t(*((long *) data)).compare(*((amount_t *) val.data));
-
+ return as_amount() == val.as_amount();
case BALANCE:
- return compare_equality(balance_t(*((long *) data)),
- *((balance_t *) val.data));
-
+ return val.as_balance() == as_amount();
case BALANCE_PAIR:
- return compare_equality(balance_pair_t(*((long *) data)),
- *((balance_pair_t *) val.data));
-
- case STRING:
- throw_(value_error, "Cannot compare an integer to a string");
- case POINTER:
- throw_(value_error, "Cannot compare an integer to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare an integer to a sequence");
-
+ return val.as_balance_pair() == to_balance();
default:
- assert(0);
break;
}
break;
- case DATETIME:
+ case BALANCE:
switch (val.type) {
- case BOOLEAN:
- throw_(value_error, "Cannot compare a date/time to a boolean");
case INTEGER:
- throw_(value_error, "Cannot compare a date/time to an integer");
-
- case DATETIME:
- return compare_equality(*((moment_t *) data), *((moment_t *) val.data));
-
+ return as_balance() == val.to_amount();
case AMOUNT:
- throw_(value_error, "Cannot compare a date/time to an amount");
+ return as_balance() == val.as_amount();
case BALANCE:
- throw_(value_error, "Cannot compare a date/time to a balance");
+ return as_balance() == val.as_balance();
case BALANCE_PAIR:
- throw_(value_error, "Cannot compare a date/time to a balance pair");
- case STRING:
- throw_(value_error, "Cannot compare a date/time to a string");
- case POINTER:
- throw_(value_error, "Cannot compare a date/time to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare a date/time to a sequence");
-
+ return val.as_balance_pair() == as_balance();
default:
- assert(0);
break;
}
break;
- case AMOUNT:
+ case BALANCE_PAIR:
switch (val.type) {
- case BOOLEAN:
- throw_(value_error, "Cannot compare an amount to a boolean");
-
case INTEGER:
- return ((amount_t *) data)->compare(*((long *) val.data));
-
- case DATETIME:
- throw_(value_error, "Cannot compare an amount to a date/time");
-
+ return as_balance_pair() == val.to_balance();
case AMOUNT:
- return ((amount_t *) data)->compare(*((amount_t *) val.data));
-
+ return as_balance_pair() == val.to_balance();
case BALANCE:
- return compare_equality(balance_t(*((amount_t *) data)),
- *((balance_t *) val.data));
-
+ return as_balance_pair() == val.as_balance();
case BALANCE_PAIR:
- return compare_equality(balance_pair_t(*((amount_t *) data)),
- *((balance_pair_t *) val.data));
-
- case STRING:
- throw_(value_error, "Cannot compare an amount to a string");
- case POINTER:
- throw_(value_error, "Cannot compare an amount to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare an amount to a sequence");
-
+ return as_balance_pair() == val.as_balance_pair();
default:
- assert(0);
break;
}
break;
- case BALANCE:
- switch (val.type) {
- case BOOLEAN:
- throw_(value_error, "Cannot compare a balance to a boolean");
+ case STRING:
+ if (val.type == STRING)
+ return as_string() == val.as_string();
+ break;
- case INTEGER:
- return compare_equality(*(balance_t *) data,
- balance_t(*((long *) val.data)));
+ case SEQUENCE:
+ if (val.type == SEQUENCE)
+ return as_sequence() == val.as_sequence();
+ break;
- case DATETIME:
- throw_(value_error, "Cannot compare a balance to a date/time");
+ case POINTER:
+ if (val.type == POINTER)
+ return as_pointer() == val.as_pointer();
+ break;
- case AMOUNT:
- return compare_equality(*(balance_t *) data,
- balance_t(*((amount_t *) val.data)));
+ default:
+ break;
+ }
- case BALANCE:
- return compare_equality(*(balance_t *) data, *((balance_t *) val.data));
+ throw_(value_error,
+ "Cannot compare " << label() << " to " << val.label());
- case BALANCE_PAIR:
- return compare_equality(balance_pair_t(*((balance_t *) data)),
- *(balance_pair_t *) val.data);
+ return *this;
+}
- case STRING:
- throw_(value_error, "Cannot compare a balance to a string");
- case POINTER:
- throw_(value_error, "Cannot compare a balance to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare a balance to a sequence");
+bool value_t::operator<(const value_t& val) const
+{
+ if (type == XML_NODE && val.type == XML_NODE)
+ return as_xml_node() < val.as_xml_node();
+ else if (type == XML_NODE)
+ return as_xml_node()->to_value() < val;
+ else if (val.type == XML_NODE)
+ return *this < val.as_xml_node()->to_value();
+ switch (type) {
+ case DATETIME:
+ if (val.type == DATETIME)
+ return as_datetime() < val.as_datetime();
+ break;
+
+ case INTEGER:
+ switch (val.type) {
+ case INTEGER:
+ return as_long() < val.as_long();
+ case AMOUNT:
+ return val.as_amount() < as_long();
default:
- assert(0);
break;
}
break;
- case BALANCE_PAIR:
+ case AMOUNT:
switch (val.type) {
- case BOOLEAN:
- throw_(value_error, "Cannot compare a balance pair to a boolean");
-
case INTEGER:
- return compare_equality(*(balance_pair_t *) data,
- balance_pair_t(amount_t(*((long *) val.data))));
-
- case DATETIME:
- throw_(value_error, "Cannot compare a balance pair to a date/time");
-
+ return as_amount() < val.as_long();
case AMOUNT:
- return compare_equality(*(balance_pair_t *) data,
- balance_pair_t(*((amount_t *) val.data)));
-
- case BALANCE:
- return compare_equality(*(balance_pair_t *) data,
- balance_pair_t(*((balance_t *) val.data)));
-
- case BALANCE_PAIR:
- return compare_equality(*(balance_pair_t *) data,
- *((balance_pair_t *) val.data));
-
- case STRING:
- throw_(value_error, "Cannot compare a balance pair to a string");
- case POINTER:
- throw_(value_error, "Cannot compare a balance pair to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare a balance pair to a sequence");
-
+ return as_amount() < val.as_amount();
default:
- assert(0);
break;
}
break;
case STRING:
- switch (val.type) {
- case BOOLEAN:
- throw_(value_error, "Cannot compare a string to a boolean");
- case INTEGER:
- throw_(value_error, "Cannot compare a string to an integer");
- case DATETIME:
- throw_(value_error, "Cannot compare a string to a date/time");
- case AMOUNT:
- throw_(value_error, "Cannot compare a string to an amount");
- case BALANCE:
- throw_(value_error, "Cannot compare a string to a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot compare a string to a balance pair");
+ if (val.type == STRING)
+ return as_string() < val.as_string();
+ break;
- case STRING:
- return (**((string **) data)).compare(**((string **) val.data));
+ case POINTER:
+ if (val.type == POINTER)
+ return as_pointer() < val.as_pointer();
+ break;
- case POINTER:
- throw_(value_error, "Cannot compare a string to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare a string to a sequence");
+ default:
+ break;
+ }
- default:
- assert(0);
- break;
- }
+ throw_(value_error,
+ "Cannot compare " << label() << " to " << val.label());
+
+ return *this;
+}
+
+#if 0
+bool value_t::operator>(const value_t& val) const
+{
+ if (type == XML_NODE && val.type == XML_NODE)
+ return as_xml_node() > val.as_xml_node();
+ else if (type == XML_NODE)
+ return as_xml_node()->to_value() > val;
+ else if (val.type == XML_NODE)
+ return *this > val.as_xml_node()->to_value();
+
+ switch (type) {
+ case DATETIME:
+ if (val.type == DATETIME)
+ return as_datetime() > val.as_datetime();
break;
- case XML_NODE:
+ case INTEGER:
switch (val.type) {
- case BOOLEAN:
- return (*(xml::node_t **) data)->to_value().compare(*this);
case INTEGER:
- return (*(xml::node_t **) data)->to_value().compare(*this);
- case DATETIME:
- return (*(xml::node_t **) data)->to_value().compare(*this);
+ return as_long() > val.as_long();
case AMOUNT:
- return (*(xml::node_t **) data)->to_value().compare(*this);
- case BALANCE:
- return (*(xml::node_t **) data)->to_value().compare(*this);
- case BALANCE_PAIR:
- return (*(xml::node_t **) data)->to_value().compare(*this);
- case STRING:
- return (*(xml::node_t **) data)->to_value().compare(*this);
-
- case POINTER:
- throw_(value_error, "Cannot compare an XML node to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot compare an XML node to a sequence");
-
+ return val.as_amount() > as_long();
default:
- assert(0);
break;
}
break;
- case POINTER:
+ case AMOUNT:
switch (val.type) {
- case BOOLEAN:
- throw_(value_error, "Cannot compare a pointer to a boolean");
case INTEGER:
- throw_(value_error, "Cannot compare a pointer to an integer");
- case DATETIME:
- throw_(value_error, "Cannot compare a pointer to a date/time");
+ return as_amount() > val.as_long();
case AMOUNT:
- throw_(value_error, "Cannot compare a pointer to an amount");
- case BALANCE:
- throw_(value_error, "Cannot compare a pointer to a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot compare a pointer to a balance pair");
- case STRING:
- throw_(value_error, "Cannot compare a pointer to a string node");
- case POINTER:
- throw_(value_error, "Cannot compare two pointers");
- case SEQUENCE:
- throw_(value_error, "Cannot compare a pointer to a sequence");
-
+ return as_amount() > val.as_amount();
default:
- assert(0);
break;
}
break;
- case SEQUENCE:
- throw_(value_error, "Cannot compare a value to a sequence");
+ case STRING:
+ if (val.type == STRING)
+ return as_string() > val.as_string();
+ break;
+
+ case POINTER:
+ if (val.type == POINTER)
+ return as_pointer() > val.as_pointer();
+ break;
default:
- assert(0);
break;
}
+
+ throw_(value_error,
+ "Cannot compare " << label() << " to " << val.label());
+
return *this;
}
-
-#if 0
-DEF_VALUE_CMP_OP(==)
-DEF_VALUE_CMP_OP(<)
-DEF_VALUE_CMP_OP(<=)
-DEF_VALUE_CMP_OP(>)
-DEF_VALUE_CMP_OP(>=)
#endif
-void value_t::in_place_cast(type_t cast_type)
+value_t::operator bool() const
{
switch (type) {
case BOOLEAN:
- switch (cast_type) {
- case BOOLEAN:
- break;
- case INTEGER:
- throw_(value_error, "Cannot convert a boolean to an integer");
- case DATETIME:
- throw_(value_error, "Cannot convert a boolean to a date/time");
- case AMOUNT:
- throw_(value_error, "Cannot convert a boolean to an amount");
- case BALANCE:
- throw_(value_error, "Cannot convert a boolean to a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a boolean to a balance pair");
- case STRING:
- *(string **) data = new string(*((bool *) data) ? "true" : "false");
- break;
- case XML_NODE:
- throw_(value_error, "Cannot convert a boolean to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert a boolean to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a boolean to a sequence");
-
- default:
- assert(0);
- break;
- }
+ return as_boolean();
+ case INTEGER:
+ return as_long();
+ case DATETIME:
+ return is_valid_moment(as_datetime());
+ case AMOUNT:
+ return as_amount();
+ case BALANCE:
+ return as_balance();
+ case BALANCE_PAIR:
+ return as_balance_pair();
+ case STRING:
+ return ! as_string().empty();
+ case SEQUENCE:
+ return ! as_sequence().empty();
+ case XML_NODE:
+ return as_xml_node()->to_value();
+ case POINTER:
+ return as_pointer() != NULL;
+ default:
+ assert(false);
break;
+ }
+ assert(false);
+ return 0;
+}
- case INTEGER:
- switch (cast_type) {
- case BOOLEAN:
- *((bool *) data) = *((long *) data);
- break;
- case INTEGER:
- break;
- case DATETIME:
- throw_(value_error, "Cannot convert an integer to a date/time");
+void value_t::in_place_cast(type_t cast_type)
+{
+ if (type == cast_type)
+ return;
- case AMOUNT:
- new((amount_t *)data) amount_t(*((long *) data));
- break;
- case BALANCE:
- new((balance_t *)data) balance_t(*((long *) data));
- break;
- case BALANCE_PAIR:
- new((balance_pair_t *)data) balance_pair_t(*((long *) data));
- break;
- case STRING: {
- char buf[32];
- std::sprintf(buf, "%ld", *(long *) data);
- *(string **) data = new string(buf);
- break;
- }
- case XML_NODE:
- throw_(value_error, "Cannot convert an integer to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert an integer to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert an integer to a sequence");
+ if (cast_type == BOOLEAN) {
+ bool truth(*this);
+ destroy();
+ type = BOOLEAN;
+ as_boolean() = truth;
+ return;
+ }
+ else if (cast_type == SEQUENCE) {
+ value_t temp(*this);
+ destroy();
+ type = SEQUENCE;
+ new((sequence_t *)data) sequence_t;
+ as_sequence().push_back(temp);
+ return;
+ }
- default:
- assert(0);
- break;
+ // This must came after the if's above, otherwise it would be
+ // impossible to turn an XML node into a sequence containing that
+ // same XML node.
+ if (type == XML_NODE) {
+ *this = as_xml_node()->to_value().cast(cast_type);
+ return;
+ }
+
+ switch (type) {
+ case BOOLEAN:
+ switch (cast_type) {
+ case STRING:
+ new((string *)data) string(as_boolean() ? "true" : "false");
+ type = cast_type;
+ return;
}
break;
- case DATETIME:
+ case INTEGER:
switch (cast_type) {
- case BOOLEAN:
- *((bool *) data) = is_valid_moment(*((moment_t *) data));
- break;
- case INTEGER:
- throw_(value_error, "Cannot convert a date/time to an integer");
- case DATETIME:
- break;
case AMOUNT:
- throw_(value_error, "Cannot convert a date/time to an amount");
+ new((amount_t *)data) amount_t(as_long());
+ type = cast_type;
+ return;
case BALANCE:
- throw_(value_error, "Cannot convert a date/time to a balance");
+ new((balance_t *)data) balance_t(as_long());
+ type = cast_type;
+ return;
case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a date/time to a balance pair");
+ new((balance_pair_t *)data) balance_pair_t(as_long());
+ type = cast_type;
+ return;
case STRING:
- throw_(value_error, "Cannot convert a date/time to a string");
- case XML_NODE:
- throw_(value_error, "Cannot convert a date/time to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert a date/time to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a date/time to a sequence");
-
- default:
- assert(0);
- break;
+ new((string *)data) string(lexical_cast<string>(as_long()));
+ type = cast_type;
+ return;
}
break;
case AMOUNT:
switch (cast_type) {
- case BOOLEAN: {
- bool temp = *((amount_t *) data);
- destroy();
- *((bool *)data) = temp;
- break;
- }
case INTEGER: {
- long temp = *((amount_t *) data);
+ long temp = as_amount().to_long();
destroy();
- *((long *)data) = temp;
- break;
+ type = cast_type;
+ as_long() = temp;
+ return;
}
- case DATETIME:
- throw_(value_error, "Cannot convert an amount to a date/time");
- case AMOUNT:
- break;
case BALANCE: {
- amount_t temp = *((amount_t *) data);
+ amount_t temp = as_amount();
destroy();
+ type = cast_type;
new((balance_t *)data) balance_t(temp);
- break;
+ return;
}
case BALANCE_PAIR: {
- amount_t temp = *((amount_t *) data);
+ amount_t temp = as_amount();
destroy();
+ type = cast_type;
new((balance_pair_t *)data) balance_pair_t(temp);
- break;
+ return;
}
case STRING: {
- std::ostringstream out;
- out << *(amount_t *) data;
+ amount_t temp = as_amount();
destroy();
- *(string **) data = new string(out.str());
- break;
+ type = cast_type;
+ new((string *)data) string(temp.to_string());
+ return;
}
- case XML_NODE:
- throw_(value_error, "Cannot convert an amount to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert an amount to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert an amount to a sequence");
-
- default:
- assert(0);
- break;
}
break;
case BALANCE:
switch (cast_type) {
- case BOOLEAN: {
- bool temp = *((balance_t *) data);
- destroy();
- *((bool *)data) = temp;
- break;
- }
- case INTEGER:
- throw_(value_error, "Cannot convert a balance to an integer");
- case DATETIME:
- throw_(value_error, "Cannot convert a balance to a date/time");
-
case AMOUNT: {
- balance_t * temp = (balance_t *) data;
- if (temp->amounts.size() == 1) {
- amount_t amt = (*temp->amounts.begin()).second;
+ balance_t& temp(as_balance());
+ if (temp.amounts.size() == 1) {
+ amount_t amt = (*temp.amounts.begin()).second;
destroy();
+ type = cast_type;
new((amount_t *)data) amount_t(amt);
+ return;
}
- else if (temp->amounts.size() == 0) {
- new((amount_t *)data) amount_t();
+ else if (temp.amounts.size() == 0) {
+ destroy();
+ type = cast_type;
+ new((amount_t *)data) amount_t(0L);
+ return;
}
else {
- throw_(value_error, "Cannot convert a balance with "
- "multiple commodities to an amount");
+ throw_(value_error,
+ "Cannot convert " << label() <<
+ " with multiple commodities to " << label(cast_type));
}
break;
}
- case BALANCE:
- break;
case BALANCE_PAIR: {
- balance_t temp = *((balance_t *) data);
+ balance_t temp = as_balance();
destroy();
+ type = cast_type;
new((balance_pair_t *)data) balance_pair_t(temp);
- break;
+ return;
}
- case STRING:
- throw_(value_error, "Cannot convert a balance to a string");
- case XML_NODE:
- throw_(value_error, "Cannot convert a balance to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert a balance to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a balance to a sequence");
-
- default:
- assert(0);
- break;
}
break;
case BALANCE_PAIR:
switch (cast_type) {
- case BOOLEAN: {
- bool temp = *((balance_pair_t *) data);
- destroy();
- *((bool *)data) = temp;
- break;
- }
- case INTEGER:
- throw_(value_error, "Cannot convert a balance pair to an integer");
- case DATETIME:
- throw_(value_error, "Cannot convert a balance pair to a date/time");
-
case AMOUNT: {
- balance_t * temp = &((balance_pair_t *) data)->quantity;
- if (temp->amounts.size() == 1) {
- amount_t amt = (*temp->amounts.begin()).second;
+ balance_t& temp(as_balance_pair().quantity);
+ if (temp.amounts.size() == 1) {
+ amount_t amt = (*temp.amounts.begin()).second;
destroy();
+ type = cast_type;
new((amount_t *)data) amount_t(amt);
+ return;
}
- else if (temp->amounts.size() == 0) {
- new((amount_t *)data) amount_t();
+ else if (temp.amounts.size() == 0) {
+ type = cast_type;
+ new((amount_t *)data) amount_t(0L);
+ return;
}
else {
- throw_(value_error, "Cannot convert a balance pair with "
- "multiple commodities to an amount");
+ throw_(value_error,
+ "Cannot convert " << label() <<
+ " with multiple commodities to " << label(cast_type));
}
break;
}
case BALANCE: {
- balance_t temp = ((balance_pair_t *) data)->quantity;
+ balance_t temp = as_balance_pair().quantity;
destroy();
+ type = cast_type;
new((balance_t *)data) balance_t(temp);
- break;
+ return;
}
- case BALANCE_PAIR:
- break;
- case STRING:
- throw_(value_error, "Cannot convert a balance pair to a string");
- case XML_NODE:
- throw_(value_error, "Cannot convert a balance pair to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert a balance pair to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a balance pair to a sequence");
-
- default:
- assert(0);
- break;
}
break;
case STRING:
switch (cast_type) {
- case BOOLEAN: {
- if (**(string **) data == "true") {
- destroy();
- *(bool *) data = true;
- }
- else if (**(string **) data == "false") {
- destroy();
- *(bool *) data = false;
- }
- else {
- throw_(value_error, "Cannot convert string to an boolean");
- }
- break;
- }
case INTEGER: {
- int l = (*(string **) data)->length();
- const char * p = (*(string **) data)->c_str();
- bool alldigits = true;
- for (int i = 0; i < l; i++)
- if (! std::isdigit(p[i])) {
- alldigits = false;
- break;
- }
- if (alldigits) {
- long temp = lexical_cast<long>((*(string **) data)->c_str());
+ if (all(as_string(), is_digit())) {
+ long temp = lexical_cast<long>(as_string());
destroy();
- *(long *) data = temp;
+ type = cast_type;
+ as_long() = temp;
+ return;
} else {
- throw_(value_error, "Cannot convert string to an integer");
+ throw_(value_error,
+ "Cannot convert string '" << *this << "' to an integer");
}
break;
}
- case DATETIME:
- throw_(value_error, "Cannot convert a string to a date/time");
-
case AMOUNT: {
- amount_t temp = **(string **) data;
+ amount_t temp(as_string());
destroy();
+ type = cast_type;
new((amount_t *)data) amount_t(temp);
- break;
+ return;
}
- case BALANCE:
- throw_(value_error, "Cannot convert a string to a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a string to a balance pair");
- case STRING:
- break;
- case XML_NODE:
- throw_(value_error, "Cannot convert a string to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert a string to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert a string to a sequence");
-
- default:
- assert(0);
- break;
}
break;
-
- case XML_NODE:
- switch (cast_type) {
- case BOOLEAN:
- case INTEGER:
- case DATETIME:
- case AMOUNT:
- case BALANCE:
- case BALANCE_PAIR:
- case STRING:
- *this = (*(xml::node_t **) data)->to_value();
- break;
- case XML_NODE:
- break;
- case POINTER:
- throw_(value_error, "Cannot convert an XML node to a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot convert an XML node to a sequence");
-
- default:
- assert(0);
- break;
- }
- break;
-
- case POINTER:
- switch (cast_type) {
- case BOOLEAN:
- throw_(value_error, "Cannot convert a pointer to a boolean");
- case INTEGER:
- throw_(value_error, "Cannot convert a pointer to an integer");
- case DATETIME:
- throw_(value_error, "Cannot convert a pointer to a date/time");
- case AMOUNT:
- throw_(value_error, "Cannot convert a pointer to an amount");
- case BALANCE:
- throw_(value_error, "Cannot convert a pointer to a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a pointer to a balance pair");
- case STRING:
- throw_(value_error, "Cannot convert a pointer to a string");
- case XML_NODE:
- throw_(value_error, "Cannot convert a pointer to an XML node");
- case POINTER:
- break;
- case SEQUENCE:
- throw_(value_error, "Cannot convert a pointer to a sequence");
-
- default:
- assert(0);
- break;
- }
- break;
-
- case SEQUENCE:
- switch (cast_type) {
- case BOOLEAN:
- throw_(value_error, "Cannot convert a sequence to a boolean");
- case INTEGER:
- throw_(value_error, "Cannot convert a sequence to an integer");
- case DATETIME:
- throw_(value_error, "Cannot convert a sequence to a date/time");
- case AMOUNT:
- throw_(value_error, "Cannot convert a sequence to an amount");
- case BALANCE:
- throw_(value_error, "Cannot convert a sequence to a balance");
- case BALANCE_PAIR:
- throw_(value_error, "Cannot convert a sequence to a balance pair");
- case STRING:
- throw_(value_error, "Cannot convert a sequence to a string");
- case XML_NODE:
- throw_(value_error, "Cannot compare a sequence to an XML node");
- case POINTER:
- throw_(value_error, "Cannot convert a sequence to a pointer");
- case SEQUENCE:
- break;
-
- default:
- assert(0);
- break;
- }
- break;
-
- default:
- assert(0);
- break;
}
- type = cast_type;
+
+ throw_(value_error,
+ "Cannot convert " << label() << " to " << label(cast_type));
}
void value_t::in_place_negate()
{
switch (type) {
case BOOLEAN:
- *((bool *) data) = ! *((bool *) data);
- break;
+ as_boolean() = ! as_boolean();
+ return;
case INTEGER:
- *((long *) data) = - *((long *) data);
- break;
- case DATETIME:
- throw_(value_error, "Cannot negate a date/time");
+ as_long() = - as_long();
+ return;
case AMOUNT:
- ((amount_t *) data)->in_place_negate();
- break;
+ as_amount().in_place_negate();
+ return;
case BALANCE:
- ((balance_t *) data)->in_place_negate();
- break;
+ as_balance().in_place_negate();
+ return;
case BALANCE_PAIR:
- ((balance_pair_t *) data)->in_place_negate();
- break;
- case STRING:
- throw_(value_error, "Cannot negate a string");
+ as_balance_pair().in_place_negate();
+ return;
case XML_NODE:
- *this = (*(xml::node_t **) data)->to_value();
+ *this = as_xml_node()->to_value();
in_place_negate();
- break;
- case POINTER:
- throw_(value_error, "Cannot negate a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot negate a sequence");
-
- default:
- assert(0);
- break;
+ return;
}
+
+ throw_(value_error, "Cannot negate " << label());
}
bool value_t::is_realzero() const
{
switch (type) {
case BOOLEAN:
- return ! *((bool *) data);
+ return ! as_boolean();
case INTEGER:
- return *((long *) data) == 0;
+ return as_long() == 0;
case DATETIME:
- return ! is_valid_moment(*((moment_t *) data));
+ return ! is_valid_moment(as_datetime());
case AMOUNT:
- return ((amount_t *) data)->is_realzero();
+ return as_amount().is_realzero();
case BALANCE:
- return ((balance_t *) data)->is_realzero();
+ return as_balance().is_realzero();
case BALANCE_PAIR:
- return ((balance_pair_t *) data)->is_realzero();
+ return as_balance_pair().is_realzero();
case STRING:
- return ((string *) data)->empty();
+ return as_string().empty();
+ case SEQUENCE:
+ return as_sequence().empty();
+
case XML_NODE:
+ return as_xml_node() == NULL;
case POINTER:
- case SEQUENCE:
- return *(void **) data == NULL;
+ return as_pointer() == NULL;
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
- return 0;
+ assert(false);
+ return true;
}
value_t value_t::value(const optional<moment_t>& moment) const
{
switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot find the value of a boolean");
- case DATETIME:
- throw_(value_error, "Cannot find the value of a date/time");
case INTEGER:
return *this;
case AMOUNT: {
- if (optional<amount_t> val = ((amount_t *) data)->value(moment))
+ if (optional<amount_t> val = as_amount().value(moment))
return *val;
return false;
}
case BALANCE: {
- if (optional<balance_t> bal = ((balance_t *) data)->value(moment))
+ if (optional<balance_t> bal = as_balance().value(moment))
return *bal;
return false;
}
case BALANCE_PAIR: {
- if (optional<balance_t> bal =
- ((balance_pair_t *) data)->quantity.value(moment))
- return *bal;
+ if (optional<balance_t> bal_pair =
+ as_balance_pair().quantity.value(moment))
+ return *bal_pair;
return false;
}
-
- case STRING:
- throw_(value_error, "Cannot find the value of a string");
-
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().value(moment);
-
- case POINTER:
- throw_(value_error, "Cannot find the value of a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot find the value of a sequence");
- default:
- assert(0);
- return value_t();
+ return as_xml_node()->to_value().value(moment);
}
+
+ throw_(value_error, "Cannot find the value of " << label());
}
void value_t::in_place_reduce()
{
switch (type) {
- case BOOLEAN:
- case DATETIME:
case INTEGER:
break;
case AMOUNT:
- ((amount_t *) data)->in_place_reduce();
+ as_amount().in_place_reduce();
break;
case BALANCE:
- ((balance_t *) data)->in_place_reduce();
+ as_balance().in_place_reduce();
break;
case BALANCE_PAIR:
- ((balance_pair_t *) data)->in_place_reduce();
+ as_balance_pair().in_place_reduce();
break;
- case STRING:
- throw_(value_error, "Cannot reduce a string");
case XML_NODE:
- *this = (*(xml::node_t **) data)->to_value();
+ *this = as_xml_node()->to_value();
in_place_reduce(); // recurse
break;
- case POINTER:
- throw_(value_error, "Cannot reduce a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot reduce a sequence");
}
+
+ throw_(value_error, "Cannot reduce " << label());
}
value_t value_t::round() const
{
switch (type) {
- case BOOLEAN:
- throw_(value_error, "Cannot round a boolean");
- case DATETIME:
- throw_(value_error, "Cannot round a date/time");
case INTEGER:
return *this;
case AMOUNT:
- return ((amount_t *) data)->round();
+ return as_amount().round();
case BALANCE:
- return ((balance_t *) data)->round();
+ return as_balance().round();
case BALANCE_PAIR:
- return ((balance_pair_t *) data)->round();
- case STRING:
- throw_(value_error, "Cannot round a string");
+ return as_balance_pair().round();
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().round();
- case POINTER:
- throw_(value_error, "Cannot round a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot round a sequence");
+ return as_xml_node()->to_value().round();
}
- assert(0);
- return value_t();
+
+ throw_(value_error, "Cannot round " << label());
}
value_t value_t::unround() const
@@ -1981,21 +1281,21 @@ value_t value_t::unround() const
case INTEGER:
return *this;
case AMOUNT:
- return ((amount_t *) data)->unround();
+ return as_amount().unround();
case BALANCE:
- return ((balance_t *) data)->unround();
+ return as_balance().unround();
case BALANCE_PAIR:
- return ((balance_pair_t *) data)->unround();
+ return as_balance_pair().unround();
case STRING:
throw_(value_error, "Cannot un-round a string");
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().unround();
+ return as_xml_node()->to_value().unround();
case POINTER:
throw_(value_error, "Cannot un-round a pointer");
case SEQUENCE:
throw_(value_error, "Cannot un-round a sequence");
}
- assert(0);
+ assert(false);
return value_t();
}
@@ -2010,7 +1310,7 @@ value_t value_t::annotated_price() const
throw_(value_error, "Cannot find the annotated price of a date/time");
case AMOUNT: {
- optional<amount_t> temp = ((amount_t *) data)->annotation_details().price;
+ optional<amount_t> temp = as_amount().annotation_details().price;
if (! temp)
return false;
return *temp;
@@ -2024,7 +1324,7 @@ value_t value_t::annotated_price() const
throw_(value_error, "Cannot find the annotated price of a string");
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().annotated_price();
+ return as_xml_node()->to_value().annotated_price();
case POINTER:
throw_(value_error, "Cannot find the annotated price of a pointer");
@@ -2032,10 +1332,10 @@ value_t value_t::annotated_price() const
throw_(value_error, "Cannot find the annotated price of a sequence");
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return value_t();
}
@@ -2051,7 +1351,7 @@ value_t value_t::annotated_date() const
return *this;
case AMOUNT: {
- optional<moment_t> temp = ((amount_t *) data)->annotation_details().date;
+ optional<moment_t> temp = as_amount().annotation_details().date;
if (! temp)
return false;
return *temp;
@@ -2065,7 +1365,7 @@ value_t value_t::annotated_date() const
throw_(value_error, "Cannot find the annotated date of a string");
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().annotated_date();
+ return as_xml_node()->to_value().annotated_date();
case POINTER:
throw_(value_error, "Cannot find the annotated date of a pointer");
@@ -2073,10 +1373,10 @@ value_t value_t::annotated_date() const
throw_(value_error, "Cannot find the annotated date of a sequence");
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return value_t();
}
@@ -2092,7 +1392,7 @@ value_t value_t::annotated_tag() const
return *this;
case AMOUNT: {
- optional<string> temp = ((amount_t *) data)->annotation_details().tag;
+ optional<string> temp = as_amount().annotation_details().tag;
if (! temp)
return false;
return *temp;
@@ -2106,7 +1406,7 @@ value_t value_t::annotated_tag() const
throw_(value_error, "Cannot find the annotated tag of a string");
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().annotated_tag();
+ return as_xml_node()->to_value().annotated_tag();
case POINTER:
throw_(value_error, "Cannot find the annotated tag of a pointer");
@@ -2114,10 +1414,10 @@ value_t value_t::annotated_tag() const
throw_(value_error, "Cannot find the annotated tag of a sequence");
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return value_t();
}
@@ -2135,24 +1435,24 @@ value_t value_t::strip_annotations(const bool keep_price,
return *this;
case SEQUENCE:
- assert(0); // jww (2006-09-28): strip them all!
+ assert(false); // jww (2006-09-28): strip them all!
break;
case AMOUNT:
- return ((amount_t *) data)->strip_annotations
+ return as_amount().strip_annotations
(keep_price, keep_date, keep_tag);
case BALANCE:
- return ((balance_t *) data)->strip_annotations
+ return as_balance().strip_annotations
(keep_price, keep_date, keep_tag);
case BALANCE_PAIR:
- return ((balance_pair_t *) data)->quantity.strip_annotations
+ return as_balance_pair().quantity.strip_annotations
(keep_price, keep_date, keep_tag);
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return value_t();
}
@@ -2169,26 +1469,26 @@ value_t value_t::cost() const
throw_(value_error, "Cannot find the cost of a date/time");
case BALANCE_PAIR:
- assert(((balance_pair_t *) data)->cost);
- if (((balance_pair_t *) data)->cost)
- return *(((balance_pair_t *) data)->cost);
+ assert(as_balance_pair().cost);
+ if (as_balance_pair().cost)
+ return *(as_balance_pair().cost);
else
- return ((balance_pair_t *) data)->quantity;
+ return as_balance_pair().quantity;
case STRING:
throw_(value_error, "Cannot find the cost of a string");
case XML_NODE:
- return (*(xml::node_t **) data)->to_value().cost();
+ return as_xml_node()->to_value().cost();
case POINTER:
throw_(value_error, "Cannot find the cost of a pointer");
case SEQUENCE:
throw_(value_error, "Cannot find the cost of a sequence");
default:
- assert(0);
+ assert(false);
break;
}
- assert(0);
+ assert(false);
return value_t();
}
@@ -2206,7 +1506,7 @@ value_t& value_t::add(const amount_t& amount, const optional<amount_t>& tcost)
return add(amount, tcost);
}
else if ((type == AMOUNT &&
- ((amount_t *) data)->commodity() != amount.commodity()) ||
+ as_amount().commodity() != amount.commodity()) ||
(type != AMOUNT && amount.commodity())) {
in_place_cast(BALANCE);
return add(amount, tcost);
@@ -2214,7 +1514,7 @@ value_t& value_t::add(const amount_t& amount, const optional<amount_t>& tcost)
else if (type != AMOUNT) {
in_place_cast(AMOUNT);
}
- *((amount_t *) data) += amount;
+ as_amount() += amount;
break;
case BALANCE:
@@ -2222,11 +1522,11 @@ value_t& value_t::add(const amount_t& amount, const optional<amount_t>& tcost)
in_place_cast(BALANCE_PAIR);
return add(amount, tcost);
}
- *((balance_t *) data) += amount;
+ as_balance() += amount;
break;
case BALANCE_PAIR:
- ((balance_pair_t *) data)->add(amount, tcost);
+ as_balance_pair().add(amount, tcost);
break;
case STRING:
@@ -2239,7 +1539,7 @@ value_t& value_t::add(const amount_t& amount, const optional<amount_t>& tcost)
throw_(value_error, "Cannot add an amount to a sequence");
default:
- assert(0);
+ assert(false);
break;
}
@@ -2260,18 +1560,18 @@ void value_t::print(std::ostream& out, const int first_width,
break;
case XML_NODE:
- (*(xml::node_t **) data)->print(out);
+ as_xml_node()->print(out);
break;
case SEQUENCE:
- assert(0); // jww (2006-09-28): write them all out!
+ assert(false); // jww (2006-09-28): write them all out!
throw_(value_error, "Cannot write out a sequence");
case BALANCE:
- ((balance_t *) data)->print(out, first_width, latter_width);
+ as_balance().print(out, first_width, latter_width);
break;
case BALANCE_PAIR:
- ((balance_pair_t *) data)->print(out, first_width, latter_width);
+ as_balance_pair().print(out, first_width, latter_width);
break;
}
}
@@ -2280,31 +1580,31 @@ std::ostream& operator<<(std::ostream& out, const value_t& val)
{
switch (val.type) {
case value_t::BOOLEAN:
- out << (*((bool *) val.data) ? "true" : "false");
+ out << (val.as_boolean() ? "true" : "false");
break;
case value_t::INTEGER:
- out << *(long *) val.data;
+ out << val.as_long();
break;
case value_t::DATETIME:
- out << *(moment_t *) val.data;
+ out << val.as_datetime();
break;
case value_t::AMOUNT:
- out << *(amount_t *) val.data;
+ out << val.as_amount();
break;
case value_t::BALANCE:
- out << *(balance_t *) val.data;
+ out << val.as_balance();
break;
case value_t::BALANCE_PAIR:
- out << *(balance_pair_t *) val.data;
+ out << val.as_balance_pair();
break;
case value_t::STRING:
- out << **(string **) val.data;
+ out << val.as_string();
break;
case value_t::XML_NODE:
- if ((*(xml::node_t **) val.data)->flags & XML_NODE_IS_PARENT)
- out << '<' << (*(xml::node_t **) val.data)->name() << '>';
+ if (val.as_xml_node()->has_flags(XML_NODE_IS_PARENT))
+ out << '<' << val.as_xml_node()->name() << '>';
else
- out << (*(xml::node_t **) val.data)->text();
+ out << val.as_xml_node()->text();
break;
case value_t::POINTER:
@@ -2313,9 +1613,8 @@ std::ostream& operator<<(std::ostream& out, const value_t& val)
case value_t::SEQUENCE: {
out << '(';
bool first = true;
- for (value_t::sequence_t::iterator
- i = (*(value_t::sequence_t **) val.data)->begin();
- i != (*(value_t::sequence_t **) val.data)->end();
+ for (value_t::sequence_t::const_iterator i = val.as_sequence().begin();
+ i != val.as_sequence().end();
i++) {
if (first)
first = false;
@@ -2328,7 +1627,7 @@ std::ostream& operator<<(std::ostream& out, const value_t& val)
}
default:
- assert(0);
+ assert(false);
break;
}
return out;
@@ -2378,7 +1677,7 @@ void value_context::describe(std::ostream& out) const throw()
ptr->print(out, 20);
break;
default:
- assert(0);
+ assert(false);
break;
}
out << std::endl;
diff --git a/src/value.h b/src/value.h
index b1e0459d..a6bb091f 100644
--- a/src/value.h
+++ b/src/value.h
@@ -65,92 +65,101 @@ class value_t
typedef std::vector<value_t> sequence_t;
enum type_t {
+ VOID,
BOOLEAN,
- INTEGER,
DATETIME,
+ INTEGER,
AMOUNT,
BALANCE,
BALANCE_PAIR,
STRING,
+ SEQUENCE,
XML_NODE,
- POINTER,
- SEQUENCE
+ POINTER
} type;
- value_t() {
+ value_t() : type(VOID) {
TRACE_CTOR(value_t, "");
- *((long *) data) = 0;
- type = INTEGER;
}
- value_t(const value_t& val) : type(INTEGER) {
+ value_t(const value_t& val) : type(VOID) {
TRACE_CTOR(value_t, "copy");
*this = val;
}
value_t(const bool val) {
TRACE_CTOR(value_t, "const bool");
- *((bool *) data) = val;
type = BOOLEAN;
+ as_boolean() = val;
}
value_t(const long val) {
TRACE_CTOR(value_t, "const long");
- *((long *) data) = val;
type = INTEGER;
+ as_long() = val;
}
value_t(const moment_t val) {
TRACE_CTOR(value_t, "const moment_t");
- *((moment_t *) data) = val;
type = DATETIME;
- }
- value_t(const unsigned long val) {
- TRACE_CTOR(value_t, "const unsigned long");
- new((amount_t *) data) amount_t(val);
- type = AMOUNT;
+ new((moment_t *) data) moment_t(val);
}
value_t(const double val) {
TRACE_CTOR(value_t, "const double");
+ type = AMOUNT;
new((amount_t *) data) amount_t(val);
+ }
+ value_t(const unsigned long val) {
+ TRACE_CTOR(value_t, "const unsigned long");
type = AMOUNT;
+ new((amount_t *) data) amount_t(val);
}
value_t(const string& val, bool literal = false) {
TRACE_CTOR(value_t, "const string&, bool");
if (literal) {
- type = INTEGER;
- set_string(val);
+ type = STRING;
+ new((string *) data) string(val);
} else {
- new((amount_t *) data) amount_t(val);
type = AMOUNT;
+ new((amount_t *) data) amount_t(val);
}
}
- value_t(const char * val) {
+ value_t(const char * val, bool literal = false) {
TRACE_CTOR(value_t, "const char *");
- new((amount_t *) data) amount_t(val);
- type = AMOUNT;
+ if (literal) {
+ type = STRING;
+ new((string *) data) string(val);
+ } else {
+ type = AMOUNT;
+ new((amount_t *) data) amount_t(val);
+ }
}
value_t(const amount_t& val) {
TRACE_CTOR(value_t, "const amount_t&");
- new((amount_t *)data) amount_t(val);
type = AMOUNT;
+ new((amount_t *)data) amount_t(val);
}
- value_t(const balance_t& val) : type(INTEGER) {
+ value_t(const balance_t& val) : type(VOID) {
TRACE_CTOR(value_t, "const balance_t&");
- *this = val;
+ type = BALANCE;
+ new((balance_t *)data) balance_t(val);
}
- value_t(const balance_pair_t& val) : type(INTEGER) {
+ value_t(const balance_pair_t& val) : type(VOID) {
TRACE_CTOR(value_t, "const balance_pair_t&");
- *this = val;
+ type = BALANCE_PAIR;
+ new((balance_pair_t *)data) balance_pair_t(val);
+ }
+ value_t(const sequence_t& val) {
+ TRACE_CTOR(value_t, "const sequence_t&");
+ type = SEQUENCE;
+ new((sequence_t *)data) sequence_t(val);
}
- value_t(xml::node_t * xml_node) : type(INTEGER) { // gets set in =
+ value_t(xml::node_t * xml_node) {
TRACE_CTOR(value_t, "xml::node_t *");
- *this = xml_node;
+ type = XML_NODE;
+ as_xml_node() = xml_node;
}
- value_t(void * item) : type(INTEGER) { // gets set in =
+ value_t(void * item) {
TRACE_CTOR(value_t, "void *");
- *this = item;
- }
- value_t(sequence_t * seq) : type(INTEGER) { // gets set in =
- TRACE_CTOR(value_t, "sequence_t *");
- *this = seq;
+ type = POINTER;
+ as_pointer() = item;
}
~value_t() {
@@ -159,184 +168,125 @@ class value_t
}
void destroy();
- void simplify();
+ value_t simplify() const {
+ value_t temp = *this;
+ temp.in_place_simplify();
+ return temp;
+ }
+ void in_place_simplify();
value_t& operator=(const value_t& val);
-#if 0
- value_t& operator=(const bool val) {
- if ((bool *) data != &val) {
+
+ value_t& set_string(const string& str = "") {
+ if (type != STRING) {
destroy();
- *((bool *) data) = val;
- type = BOOLEAN;
+ type = STRING;
}
+ as_string() = str;
return *this;
}
- value_t& operator=(const long val) {
- if ((long *) data != &val) {
- destroy();
- *((long *) data) = val;
- type = INTEGER;
- }
- return *this;
+
+ bool& as_boolean() {
+ assert(type == BOOLEAN);
+ return *(bool *) data;
}
- value_t& operator=(const moment_t val) {
- if ((moment_t *) data != &val) {
- destroy();
- *((moment_t *) data) = val;
- type = DATETIME;
- }
- return *this;
+ const bool& as_boolean() const {
+ assert(type == BOOLEAN);
+ return *(bool *) data;
}
- value_t& operator=(const unsigned long val) {
- return *this = amount_t(val);
+ long& as_long() {
+ assert(type == INTEGER);
+ return *(long *) data;
}
- value_t& operator=(const double val) {
- return *this = amount_t(val);
+ const long& as_long() const {
+ assert(type == INTEGER);
+ return *(long *) data;
}
- value_t& operator=(const string& val) {
- return *this = amount_t(val);
+ moment_t& as_datetime() {
+ assert(type == DATETIME);
+ return *(moment_t *) data;
}
- value_t& operator=(const char * val) {
- return *this = amount_t(val);
+ const moment_t& as_datetime() const {
+ assert(type == DATETIME);
+ return *(moment_t *) data;
}
- value_t& operator=(const amount_t& val) {
- if (type == AMOUNT &&
- (amount_t *) data == &val)
- return *this;
-
- if (val.realzero()) {
- return *this = 0L;
- } else {
- destroy();
- new((amount_t *)data) amount_t(val);
- type = AMOUNT;
- }
- return *this;
+ amount_t& as_amount() {
+ assert(type == AMOUNT);
+ return *(amount_t *) data;
}
- value_t& operator=(const balance_t& val) {
- if (type == BALANCE &&
- (balance_t *) data == &val)
- return *this;
-
- if (val.realzero()) {
- return *this = 0L;
- }
- else if (val.amounts.size() == 1) {
- return *this = (*val.amounts.begin()).second;
- }
- else {
- destroy();
- new((balance_t *)data) balance_t(val);
- type = BALANCE;
- return *this;
- }
+ const amount_t& as_amount() const {
+ assert(type == AMOUNT);
+ return *(amount_t *) data;
}
- value_t& operator=(const balance_pair_t& val) {
- if (type == BALANCE_PAIR &&
- (balance_pair_t *) data == &val)
- return *this;
-
- if (val.realzero()) {
- return *this = 0L;
- }
- else if (! val.cost) {
- return *this = val.quantity;
- }
- else {
- destroy();
- new((balance_pair_t *)data) balance_pair_t(val);
- type = BALANCE_PAIR;
- return *this;
- }
+ balance_t& as_balance() {
+ assert(type == BALANCE);
+ return *(balance_t *) data;
}
- value_t& operator=(xml::node_t * xml_node) {
- assert(xml_node);
- if (type == XML_NODE && *(xml::node_t **) data == xml_node)
- return *this;
-
- if (! xml_node) {
- type = XML_NODE;
- return *this = 0L;
- }
- else {
- destroy();
- *(xml::node_t **)data = xml_node;
- type = XML_NODE;
- return *this;
- }
+ const balance_t& as_balance() const {
+ assert(type == BALANCE);
+ return *(balance_t *) data;
}
- value_t& operator=(void * item) {
- assert(item);
- if (type == POINTER && *(void **) data == item)
- return *this;
-
- if (! item) {
- type = POINTER;
- return *this = 0L;
- }
- else {
- destroy();
- *(void **)data = item;
- type = POINTER;
- return *this;
- }
+ balance_pair_t& as_balance_pair() {
+ assert(type == BALANCE_PAIR);
+ return *(balance_pair_t *) data;
}
- value_t& operator=(sequence_t * seq) {
- assert(seq);
- if (type == SEQUENCE && *(sequence_t **) data == seq)
- return *this;
-
- if (! seq) {
- type = SEQUENCE;
- return *this = 0L;
- }
- else {
- destroy();
- *(sequence_t **)data = seq;
- type = SEQUENCE;
- return *this;
- }
+ const balance_pair_t& as_balance_pair() const {
+ assert(type == BALANCE_PAIR);
+ return *(balance_pair_t *) data;
+ }
+ string& as_string() {
+ assert(type == STRING);
+ return *(string *) data;
+ }
+ const string& as_string() const {
+ assert(type == STRING);
+ return *(string *) data;
+ }
+ sequence_t& as_sequence() {
+ assert(type == SEQUENCE);
+ return *(sequence_t *) data;
+ }
+ const sequence_t& as_sequence() const {
+ assert(type == SEQUENCE);
+ return *(sequence_t *) data;
}
-#endif
- value_t& set_string(const string& str = "") {
- if (type != STRING) {
- destroy();
- *(string **) data = new string(str);
- type = STRING;
- } else {
- **(string **) data = str;
- }
- return *this;
+ xml::node_t *& as_xml_node() {
+ assert(type == XML_NODE);
+ return *(xml::node_t **) data;
+ }
+ xml::node_t * as_xml_node() const {
+ assert(type == XML_NODE);
+ return *(xml::node_t **) data;
+ }
+ void *& as_pointer() {
+ assert(type == POINTER);
+ return *(void **) data;
+ }
+ void * as_pointer() const {
+ assert(type == POINTER);
+ return *(void **) data;
}
- bool& to_boolean();
- long& to_long();
- moment_t& to_datetime();
- amount_t& to_amount();
- balance_t& to_balance();
- balance_pair_t& to_balance_pair();
- string& to_string();
- xml::node_t *& to_xml_node();
- void *& to_pointer();
- sequence_t *& to_sequence();
+ bool to_boolean() const;
+ long to_long() const;
+ moment_t to_datetime() const;
+ amount_t to_amount() const;
+ balance_t to_balance() const;
+ balance_pair_t to_balance_pair() const;
+ string to_string() const;
+ sequence_t to_sequence() const;
value_t& operator[](const int index) {
- sequence_t * seq = to_sequence();
- assert(seq);
- return (*seq)[index];
+ return as_sequence()[index];
}
void push_back(const value_t& val) {
- sequence_t * seq = to_sequence();
- assert(seq);
- return seq->push_back(val);
+ return as_sequence().push_back(val);
}
std::size_t size() const {
- sequence_t * seq = const_cast<value_t&>(*this).to_sequence();
- assert(seq);
- return seq->size();
+ return as_sequence().size();
}
value_t& operator+=(const value_t& val);
@@ -344,42 +294,42 @@ class value_t
value_t& operator*=(const value_t& val);
value_t& operator/=(const value_t& val);
- int compare(const value_t& val) const;
-
- bool operator==(const value_t& val) const {
- return compare(val) == 0;
- }
-#if 0
- template <typename T>
- bool operator==(const T& val) const {
- return *this == value_t(val);
- }
-#endif
-
- bool operator<(const value_t& val) const {
- return compare(val) < 0;
- }
-#if 0
- template <typename T>
- bool operator<(const T& val) const {
- return *this < value_t(val);
+ bool operator==(const value_t& val) const;
+ bool operator<(const value_t& val) const;
+ //bool operator>(const value_t& val) const;
+
+ string label(optional<type_t> the_type = optional<type_t>()) const {
+ switch (the_type ? *the_type : type) {
+ case VOID:
+ return "an uninitialized value";
+ case BOOLEAN:
+ return "a boolean";
+ case INTEGER:
+ return "an integer";
+ case DATETIME:
+ return "a date/time";
+ case AMOUNT:
+ return "an amount";
+ case BALANCE:
+ return "a balance";
+ case BALANCE_PAIR:
+ return "a balance pair";
+ case STRING:
+ return "a string";
+ case SEQUENCE:
+ return "a sequence";
+ case XML_NODE:
+ return "an xml node";
+ case POINTER:
+ return "a pointer";
+ default:
+ assert(false);
+ break;
+ }
}
-#endif
-
+
operator bool() const;
-#if 0
- operator long() const;
- operator unsigned long() const;
- operator double() const;
- operator moment_t() const;
- operator string() const;
- operator char *() const;
- operator amount_t() const;
- operator balance_t() const;
- operator balance_pair_t() const;
-#endif
-
value_t operator-() const {
return negate();
}
@@ -429,45 +379,6 @@ class value_t
friend std::ostream& operator<<(std::ostream& out, const value_t& val);
};
-#if 0
-template <typename T>
-value_t::operator T() const
-{
- switch (type) {
- case BOOLEAN:
- return *(bool *) data;
- case INTEGER:
- return *(long *) data;
- case DATETIME:
- return *(moment_t *) data;
- case AMOUNT:
- return *(amount_t *) data;
- case BALANCE:
- return *(balance_t *) data;
- case STRING:
- return **(string **) data;
- case XML_NODE:
- return *(xml::node_t **) data;
- case POINTER:
- return *(void **) data;
- case SEQUENCE:
- return *(sequence_t **) data;
-
- default:
- assert(0);
- break;
- }
- assert(0);
- return 0;
-}
-
-template <> value_t::operator bool() const;
-template <> value_t::operator long() const;
-template <> value_t::operator moment_t() const;
-template <> value_t::operator double() const;
-template <> value_t::operator string() const;
-#endif
-
std::ostream& operator<<(std::ostream& out, const value_t& val);
#if 0
diff --git a/src/xml.cc b/src/xml.cc
index 90ddb1f7..219a0162 100644
--- a/src/xml.cc
+++ b/src/xml.cc
@@ -82,7 +82,7 @@ int document_t::register_name(const string& name)
DEBUG("xml.lookup", this << " Inserting name: " << names.back());
std::pair<names_map::iterator, bool> result =
- names_index.insert(names_pair(names.back(), index));
+ names_index.insert(names_map::value_type(names.back(), index));
assert(result.second);
return index + 1000;
@@ -160,9 +160,9 @@ document_t * node_t::document;
#endif
node_t::node_t(document_t * _document, parent_node_t * _parent,
- unsigned int _flags)
- : name_id(0), parent(_parent), next(NULL), prev(NULL),
- flags(_flags), attrs(NULL)
+ flags_t _flags)
+ : supports_flags<>(_flags),
+ name_id(0), parent(_parent), next(NULL), prev(NULL), attrs(NULL)
{
TRACE_CTOR(node_t, "document_t *, node_t *");
document = _document;
@@ -316,7 +316,8 @@ static void startElement(void *userData, const char *name, const char **attrs)
parser->pending_attrs = new node_t::attrs_map;
std::pair<node_t::attrs_map::iterator, bool> result
- = parser->pending_attrs->insert(node_t::attrs_pair(*p, *(p + 1)));
+ = parser->pending_attrs->insert
+ (node_t::attrs_map::value_type(*p, *(p + 1)));
assert(result.second);
}
}
diff --git a/src/xml.h b/src/xml.h
index 5e2cb642..96964975 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -52,27 +52,25 @@ DECLARE_EXCEPTION(conversion_error);
class parent_node_t;
class document_t;
-class node_t
+class node_t : public supports_flags<>
{
public:
- unsigned int name_id;
+ unsigned int name_id;
#ifdef THREADSAFE
- document_t * document;
+ document_t * document;
#else
static document_t * document;
#endif
- parent_node_t * parent;
- node_t * next;
- node_t * prev;
- unsigned int flags;
+ parent_node_t * parent;
+ node_t * next;
+ node_t * prev;
- typedef std::map<string, string> attrs_map;
- typedef std::pair<string, string> attrs_pair;
+ typedef std::map<string, string> attrs_map;
attrs_map * attrs;
node_t(document_t * _document, parent_node_t * _parent = NULL,
- unsigned int _flags = 0);
+ flags_t _flags = 0);
virtual ~node_t() {
TRACE_DTOR(node_t);
@@ -80,10 +78,21 @@ public:
if (attrs) checked_delete(attrs);
}
+ parent_node_t * as_parent_node() {
+ if (! has_flags(XML_NODE_IS_PARENT))
+ throw_(std::logic_error, "Request to cast leaf node to a parent node");
+ return polymorphic_downcast<parent_node_t *>(this);
+ }
+ const parent_node_t * as_parent_node() const {
+ if (! has_flags(XML_NODE_IS_PARENT))
+ throw_(std::logic_error, "Request to cast leaf node to a parent node");
+ return polymorphic_downcast<const parent_node_t *>(this);
+ }
+
void extract(); // extract this node from its parent's child list
virtual const char * text() const {
- assert(0);
+ assert(false);
return NULL;
}
@@ -98,7 +107,7 @@ public:
if (! attrs)
attrs = new attrs_map;
std::pair<attrs_map::iterator, bool> result =
- attrs->insert(attrs_pair(n, v));
+ attrs->insert(attrs_map::value_type(n, v));
assert(result.second);
}
const char * get_attr(const char * n) {
@@ -223,8 +232,7 @@ private:
names_array names;
- typedef std::map<string, int> names_map;
- typedef std::pair<string, int> names_pair;
+ typedef std::map<string, int> names_map;
names_map names_index;
diff --git a/src/xmlparse.cc b/src/xmlparse.cc
index fdd1fca7..34a16124 100644
--- a/src/xmlparse.cc
+++ b/src/xmlparse.cc
@@ -128,10 +128,10 @@ static void endElement(void *userData, const char *name)
curr_entry->transactions.back()->state = transaction_t::PENDING;
}
else if (std::strcmp(name, "tr:virtual") == 0) {
- curr_entry->transactions.back()->flags |= TRANSACTION_VIRTUAL;
+ curr_entry->transactions.back()->add_flags(TRANSACTION_VIRTUAL);
}
else if (std::strcmp(name, "tr:generated") == 0) {
- curr_entry->transactions.back()->flags |= TRANSACTION_AUTO;
+ curr_entry->transactions.back()->add_flags(TRANSACTION_AUTO);
}
else if (std::strcmp(name, "symbol") == 0) {
assert(! curr_comm);
@@ -367,7 +367,7 @@ void xml_write_value(std::ostream& out, const value_t& value,
break;
default:
- assert(0);
+ assert(false);
break;
}
diff --git a/src/xpath.cc b/src/xpath.cc
index 6b421c8c..d4a2fafd 100644
--- a/src/xpath.cc
+++ b/src/xpath.cc
@@ -478,12 +478,12 @@ xpath_t::op_t * xpath_t::wrap_value(const value_t& val)
return temp;
}
-xpath_t::op_t * xpath_t::wrap_sequence(value_t::sequence_t * val)
+xpath_t::op_t * xpath_t::wrap_sequence(const value_t::sequence_t& val)
{
- if (val->size() == 0)
+ if (val.size() == 0)
return wrap_value(false);
- else if (val->size() == 1)
- return wrap_value(val->front());
+ else if (val.size() == 1)
+ return wrap_value(val.front());
else
return wrap_value(val);
}
@@ -509,7 +509,7 @@ void xpath_t::scope_t::define(const string& name, op_t * def)
DEBUG("ledger.xpath.syms", "Defining '" << name << "' = " << def);
std::pair<symbol_map::iterator, bool> result
- = symbols.insert(symbol_pair(name, def));
+ = symbols.insert(symbol_map::value_type(name, def));
if (! result.second) {
symbol_map::iterator i = symbols.find(name);
assert(i != symbols.end());
@@ -517,7 +517,7 @@ void xpath_t::scope_t::define(const string& name, op_t * def)
symbols.erase(i);
std::pair<symbol_map::iterator, bool> result2
- = symbols.insert(symbol_pair(name, def));
+ = symbols.insert(symbol_map::value_type(name, def));
if (! result2.second)
throw_(compile_error,
"Redefinition of '" << name << "' in same scope");
@@ -541,16 +541,13 @@ void xpath_t::scope_t::define(const string& name, functor_t * def) {
}
bool xpath_t::function_scope_t::resolve(const string& name,
- value_t& result,
- scope_t * locals)
+ value_t& result,
+ scope_t * locals)
{
switch (name[0]) {
case 'l':
if (name == "last") {
- if (sequence)
- result = (long)sequence->size();
- else
- result = 1L;
+ result = (long)sequence.size();
return true;
}
break;
@@ -565,7 +562,7 @@ bool xpath_t::function_scope_t::resolve(const string& name,
case 't':
if (name == "text") {
if (value->type == value_t::XML_NODE)
- result.set_string(value->to_xml_node()->text());
+ result.set_string(value->as_xml_node()->text());
else
throw_(calc_error, "Attempt to call text() on a non-node value");
return true;
@@ -656,7 +653,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const
case token_t::IDENT: {
#if 0
#ifdef USE_BOOST_PYTHON
- if (tok.value->to_string() == "lambda") // special
+ if (tok.value->as_string() == "lambda") // special
try {
char c, buf[4096];
@@ -681,7 +678,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const
#endif /* USE_BOOST_PYTHON */
#endif
- string ident = tok.value.to_string();
+ string ident = tok.value.as_string();
int id = -1;
if (std::isdigit(ident[0])) {
node.reset(new op_t(op_t::ARG_INDEX));
@@ -723,7 +720,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const
throw_(parse_error, "@ symbol must be followed by attribute name");
node.reset(new op_t(op_t::ATTR_NAME));
- node->name = new string(tok.value.to_string());
+ node->name = new string(tok.value.as_string());
break;
#if 0
@@ -733,7 +730,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const
throw parse_error("$ symbol must be followed by variable name");
node.reset(new op_t(op_t::VAR_NAME));
- node->name = new string(tok.value.to_string());
+ node->name = new string(tok.value.as_string());
break;
#endif
@@ -767,7 +764,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const
#if 0
case token_t::REGEXP:
- node.reset(wrap_mask(tok.value.to_string()));
+ node.reset(wrap_mask(tok.value.as_string()));
break;
#endif
@@ -1215,8 +1212,8 @@ void xpath_t::op_t::find_values(value_t * context, scope_t * scope,
if (recursive) {
if (context->type == value_t::XML_NODE) {
- node_t * ptr = context->to_xml_node();
- if (ptr->flags & XML_NODE_IS_PARENT) {
+ node_t * ptr = context->as_xml_node();
+ if (ptr->has_flags(XML_NODE_IS_PARENT)) {
parent_node_t * parent = static_cast<parent_node_t *>(ptr);
for (node_t * node = parent->children();
node;
@@ -1245,7 +1242,7 @@ bool xpath_t::op_t::test_value(value_t * context, scope_t * scope,
return *expr->valuep == value_t((long)index + 1);
default:
- return expr->valuep->to_boolean();
+ return expr->valuep->as_boolean();
}
}
@@ -1277,7 +1274,7 @@ xpath_t::op_t * xpath_t::op_t::defer_sequence(value_t::sequence_t& result_seq)
if ((*i).type != value_t::POINTER)
*opp = wrap_value(*i)->acquire();
else
- *opp = static_cast<op_t *>((*i).to_pointer());
+ *opp = static_cast<op_t *>((*i).as_pointer());
}
return lit_seq.release();
@@ -1286,15 +1283,11 @@ xpath_t::op_t * xpath_t::op_t::defer_sequence(value_t::sequence_t& result_seq)
void xpath_t::op_t::append_value(value_t& val,
value_t::sequence_t& result_seq)
{
- if (val.type == value_t::SEQUENCE) {
- value_t::sequence_t * subseq = val.to_sequence();
- for (value_t::sequence_t::iterator i = subseq->begin();
- i != subseq->end();
- i++)
- result_seq.push_back(*i);
- } else {
+ if (val.type == value_t::SEQUENCE)
+ std::for_each(val.as_sequence().begin(), val.as_sequence().end(),
+ bind(&value_t::sequence_t::push_back, ref(result_seq), _1));
+ else
result_seq.push_back(val);
- }
}
xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
@@ -1315,8 +1308,8 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case document_t::PARENT:
if (context->type != value_t::XML_NODE)
throw_(compile_error, "Referencing parent node from a non-node value");
- else if (context->to_xml_node()->parent)
- return wrap_value(context->to_xml_node()->parent)->acquire();
+ else if (context->as_xml_node()->parent)
+ return wrap_value(context->as_xml_node()->parent)->acquire();
else
throw_(compile_error, "Referencing parent node from the root node");
@@ -1324,21 +1317,16 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
if (context->type != value_t::XML_NODE)
throw_(compile_error, "Referencing root node from a non-node value");
else
- return wrap_value(context->to_xml_node()->document->top)->acquire();
+ return wrap_value(context->as_xml_node()->document->top)->acquire();
case document_t::ALL: {
if (context->type != value_t::XML_NODE)
throw_(compile_error, "Referencing child nodes from a non-node value");
- node_t * ptr = context->to_xml_node();
- if (! (ptr->flags & XML_NODE_IS_PARENT))
- throw_(compile_error, "Request for child nodes of a leaf node");
-
- parent_node_t * parent = static_cast<parent_node_t *>(ptr);
-
- value_t::sequence_t * nodes = new value_t::sequence_t;
+ parent_node_t * parent = context->as_xml_node()->as_parent_node();
+ value_t::sequence_t nodes;
for (node_t * node = parent->children(); node; node = node->next)
- nodes->push_back(node);
+ nodes.push_back(node);
return wrap_value(nodes)->acquire();
}
@@ -1350,14 +1338,14 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case NODE_NAME:
if (context->type == value_t::XML_NODE) {
- node_t * ptr = context->to_xml_node();
+ node_t * ptr = context->as_xml_node();
if (resolve) {
// First, look up the symbol as a node name within the current
// context. If any exist, then return the set of names.
std::auto_ptr<value_t::sequence_t> nodes(new value_t::sequence_t);
- if (ptr->flags & XML_NODE_IS_PARENT) {
+ if (ptr->has_flags(XML_NODE_IS_PARENT)) {
parent_node_t * parent = static_cast<parent_node_t *>(ptr);
for (node_t * node = parent->children();
node;
@@ -1383,7 +1371,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case ATTR_NAME: {
// jww (2006-09-29): Attrs should map strings to values, not strings
- const char * value = context->to_xml_node()->get_attr(name->c_str());
+ const char * value = context->as_xml_node()->get_attr(name->c_str());
return wrap_value(value)->acquire();
}
@@ -1403,8 +1391,8 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case ARG_INDEX:
if (scope && scope->kind == scope_t::ARGUMENT) {
assert(scope->args.type == value_t::SEQUENCE);
- if (arg_index < scope->args.to_sequence()->size())
- return wrap_value((*scope->args.to_sequence())[arg_index])->acquire();
+ if (arg_index < scope->args.as_sequence().size())
+ return wrap_value(scope->args.as_sequence()[arg_index])->acquire();
else
throw_(compile_error, "Reference to non-existing argument");
} else {
@@ -1481,15 +1469,15 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
return copy(lexpr, rexpr)->acquire();
}
- std::auto_ptr<value_t::sequence_t> result_seq(new value_t::sequence_t);
+ value_t::sequence_t result_seq;
- append_value(*lexpr->valuep, *result_seq);
- append_value(*rexpr->valuep, *result_seq);
+ append_value(*lexpr->valuep, result_seq);
+ append_value(*rexpr->valuep, result_seq);
- if (result_seq->size() == 1)
- return wrap_value(result_seq->front())->acquire();
+ if (result_seq.size() == 1)
+ return wrap_value(result_seq.front())->acquire();
else
- return wrap_sequence(result_seq.release())->acquire();
+ return wrap_sequence(result_seq)->acquire();
break;
}
@@ -1515,7 +1503,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case O_SUB: temp -= *rexpr->valuep; break;
case O_MUL: temp *= *rexpr->valuep; break;
case O_DIV: temp /= *rexpr->valuep; break;
- default: assert(0); break;
+ default: assert(false); break;
}
return wrap_value(temp)->acquire();
} else {
@@ -1524,7 +1512,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case O_SUB: *lexpr->valuep -= *rexpr->valuep; break;
case O_MUL: *lexpr->valuep *= *rexpr->valuep; break;
case O_DIV: *lexpr->valuep /= *rexpr->valuep; break;
- default: assert(0); break;
+ default: assert(false); break;
}
return lexpr->acquire();
}
@@ -1567,7 +1555,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case O_GTE:
return wrap_value(*lexpr->valuep >= *rexpr->valuep)->acquire();
break;
- default: assert(0); break;
+ default: assert(false); break;
}
} else {
switch (kind) {
@@ -1577,7 +1565,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case O_LTE: *lexpr->valuep = *lexpr->valuep <= *rexpr->valuep; break;
case O_GT: *lexpr->valuep = *lexpr->valuep > *rexpr->valuep; break;
case O_GTE: *lexpr->valuep = *lexpr->valuep >= *rexpr->valuep; break;
- default: assert(0); break;
+ default: assert(false); break;
}
return lexpr->acquire();
}
@@ -1694,7 +1682,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
assert(rexpr->mask);
- bool result = rexpr->mask->match(lexpr->valuep->to_string());
+ bool result = rexpr->mask->match(lexpr->valuep->as_string());
if (kind == O_NMATCH)
result = ! result;
@@ -1808,7 +1796,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
return wrap_value(temp)->acquire();
}
else {
- assert(0);
+ assert(false);
}
break;
}
@@ -1829,28 +1817,28 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
return copy(lexpr, rexpr)->acquire();
}
- std::auto_ptr<value_t::sequence_t> result_seq(new value_t::sequence_t);
+ value_t::sequence_t result_seq;
// jww (2006-09-24): What about when nothing is found?
switch (lexpr->valuep->type) {
case value_t::XML_NODE: {
- function_scope_t xpath_fscope(NULL, lexpr->valuep, 0, scope);
+ function_scope_t xpath_fscope(lexpr->valuep, 0, scope);
if (kind == O_PRED) {
if (rexpr->test_value(lexpr->valuep, &xpath_fscope))
- result_seq->push_back(*lexpr->valuep);
+ result_seq.push_back(*lexpr->valuep);
} else {
- rexpr->find_values(lexpr->valuep, &xpath_fscope, *result_seq.get(),
+ rexpr->find_values(lexpr->valuep, &xpath_fscope, result_seq,
kind == O_RFIND);
}
break;
}
case value_t::SEQUENCE: {
- value_t::sequence_t * seq = lexpr->valuep->to_sequence();
+ value_t::sequence_t& seq(lexpr->valuep->as_sequence());
int index = 0;
- for (value_t::sequence_t::iterator i = seq->begin();
- i != seq->end();
+ for (value_t::sequence_t::iterator i = seq.begin();
+ i != seq.end();
i++, index++) {
assert((*i).type != value_t::SEQUENCE);
if ((*i).type != value_t::XML_NODE)
@@ -1860,9 +1848,9 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
function_scope_t xpath_fscope(seq, &(*i), index, scope);
if (kind == O_PRED) {
if (rexpr->test_value(&(*i), &xpath_fscope, index))
- result_seq->push_back(*i);
+ result_seq.push_back(*i);
} else {
- rexpr->find_values(&(*i), &xpath_fscope, *result_seq.get(),
+ rexpr->find_values(&(*i), &xpath_fscope, result_seq,
kind == O_RFIND);
}
}
@@ -1874,10 +1862,10 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
"to non-node(s)");
}
- if (result_seq->size() == 1)
- return wrap_value(result_seq->front())->acquire();
+ if (result_seq.size() == 1)
+ return wrap_value(result_seq.front())->acquire();
else
- return wrap_sequence(result_seq.release())->acquire();
+ return wrap_sequence(result_seq)->acquire();
}
#if 0
@@ -1899,7 +1887,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
case LAST:
default:
- assert(0);
+ assert(false);
break;
}
#if 0
@@ -1915,7 +1903,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope,
}
#endif
- assert(0);
+ assert(false);
return NULL;
}
@@ -2035,7 +2023,7 @@ bool xpath_t::op_t::print(std::ostream& out,
break;
case value_t::BALANCE:
case value_t::BALANCE_PAIR:
- assert(0);
+ assert(false);
break;
case value_t::DATETIME:
out << '[' << *valuep << ']';
@@ -2312,7 +2300,7 @@ bool xpath_t::op_t::print(std::ostream& out,
case LAST:
default:
- assert(0);
+ assert(false);
break;
}
@@ -2422,7 +2410,7 @@ void xpath_t::op_t::dump(std::ostream& out, const int depth) const
case LAST:
default:
- assert(0);
+ assert(false);
break;
}
diff --git a/src/xpath.h b/src/xpath.h
index 7da422ad..a7e2dea0 100644
--- a/src/xpath.h
+++ b/src/xpath.h
@@ -150,7 +150,7 @@ public:
};
static op_t * wrap_value(const value_t& val);
- static op_t * wrap_sequence(value_t::sequence_t * val);
+ static op_t * wrap_sequence(const value_t::sequence_t& val);
static op_t * wrap_functor(functor_t * fobj);
#if 0
static op_t * wrap_mask(const string& pattern);
@@ -182,8 +182,7 @@ public:
public:
class scope_t
{
- typedef std::map<const string, op_t *> symbol_map;
- typedef std::pair<const string, op_t *> symbol_pair;
+ typedef std::map<const string, op_t *> symbol_map;
symbol_map symbols;
@@ -226,15 +225,17 @@ public:
class function_scope_t : public scope_t
{
- value_t::sequence_t * sequence;
- value_t * value;
- int index;
+ value_t::sequence_t sequence;
+ value_t * value;
+ int index;
public:
- function_scope_t(value_t::sequence_t * _sequence, value_t * _value,
- int _index, scope_t * _parent = NULL)
+ function_scope_t(const value_t::sequence_t& _sequence,
+ value_t * _value, int _index, scope_t * _parent = NULL)
: scope_t(_parent, STATIC),
sequence(_sequence), value(_value), index(_index) {}
+ function_scope_t(value_t * _value, int _index, scope_t * _parent = NULL)
+ : scope_t(_parent, STATIC), value(_value), index(_index) {}
virtual bool resolve(const string& name, value_t& result,
scope_t * locals = NULL);
@@ -309,7 +310,7 @@ private:
}
token_t(const token_t& other) {
- assert(0);
+ assert(false);
TRACE_CTOR(xpath_t::token_t, "copy");
*this = other;
}
@@ -321,7 +322,7 @@ private:
token_t& operator=(const token_t& other) {
if (&other == this)
return *this;
- assert(0);
+ assert(false);
return *this;
}
@@ -416,17 +417,26 @@ public:
mutable short refc;
op_t * left;
+#if 0
+ optional<variant<value_t,
+ string,
+ unsigned int,
+ functor_t,
+ mask_t,
+ op_t> > data;
+#else
union {
- value_t * valuep; // used by constant VALUE
- string * name; // used by constant SYMBOL
- unsigned int arg_index; // used by ARG_INDEX and O_ARG
- functor_t * functor; // used by terminal FUNCTOR
- unsigned int name_id; // used by NODE_NAME and ATTR_NAME
+ value_t * valuep; // used by constant VALUE
+ string * name; // used by constant SYMBOL
+ unsigned int arg_index; // used by ARG_INDEX and O_ARG
+ functor_t * functor; // used by terminal FUNCTOR
+ unsigned int name_id; // used by NODE_NAME and ATTR_NAME
#if 0
- mask_t * mask; // used by terminal MASK
+ mask_t * mask; // used by terminal MASK
#endif
- op_t * right; // used by all operators
+ op_t * right; // used by all operators
};
+#endif
op_t(const kind_t _kind)
: kind(_kind), refc(0), left(NULL), right(NULL) {
@@ -784,14 +794,14 @@ public:
inline std::ostream& operator<<(std::ostream& out, const xpath_t::op_t& op) {
op.print(out);
return out;
-};
+}
} // namespace xml
template <typename T>
inline T * get_ptr(xml::xpath_t::scope_t * locals, unsigned int idx) {
assert(locals->args.size() > idx);
- T * ptr = static_cast<T *>(locals->args[idx].to_pointer());
+ T * ptr = static_cast<T *>(locals->args[idx].as_pointer());
assert(ptr);
return ptr;
}
diff --git a/tests/numerics/BasicAmount.cc b/tests/numerics/BasicAmount.cc
index f386d8f4..a6772b13 100644
--- a/tests/numerics/BasicAmount.cc
+++ b/tests/numerics/BasicAmount.cc
@@ -612,7 +612,8 @@ void BasicAmountTestCase::testFractionalConversion()
amount_t x1(1234.56);
assertEqual(true, bool(x1));
- assertEqual(1234L, x1.to_long());
+ assertThrow(x1.to_long(), amount_error); // loses precision
+ assertEqual(1234L, x1.to_long(true));
assertEqual(1234.56, x1.to_double());
assertEqual(string("1234.56"), x1.to_string());
assertEqual(string("1234.56"), x1.quantity_string());
diff --git a/tests/numerics/CommodityAmount.cc b/tests/numerics/CommodityAmount.cc
index 611d2650..cc26bc80 100644
--- a/tests/numerics/CommodityAmount.cc
+++ b/tests/numerics/CommodityAmount.cc
@@ -466,7 +466,8 @@ void CommodityAmountTestCase::testConversion()
amount_t x1("$1234.56");
assertEqual(true, bool(x1));
- assertEqual(1234L, x1.to_long());
+ assertThrow(x1.to_long(), amount_error); // loses precision
+ assertEqual(1234L, x1.to_long(true));
assertEqual(1234.56, x1.to_double());
assertEqual(string("$1234.56"), x1.to_string());
assertEqual(string("1234.56"), x1.quantity_string());
diff --git a/tests/python/numerics/BasicAmount.py b/tests/python/numerics/BasicAmount.py
index 9e2c1b3e..9654f6a7 100644
--- a/tests/python/numerics/BasicAmount.py
+++ b/tests/python/numerics/BasicAmount.py
@@ -372,7 +372,8 @@ class BasicAmountTestCase(unittest.TestCase):
x1 = amount(1234.56)
self.assertTrue(x1)
- self.assertEqual(1234, int(x1))
+ self.assertRaises(exceptions.ArithmeticError, amount.to_long, x1)
+ self.assertEqual(1234, x1.to_long(True))
self.assertEqual(1234.56, float(x1))
self.assertEqual("1234.56", x1.to_string())
self.assertEqual("1234.56", x1.quantity_string())
diff --git a/tests/python/numerics/CommodityAmount.py b/tests/python/numerics/CommodityAmount.py
index 0edd9fad..3b7c98a9 100644
--- a/tests/python/numerics/CommodityAmount.py
+++ b/tests/python/numerics/CommodityAmount.py
@@ -449,7 +449,8 @@ class CommodityAmountTestCase(unittest.TestCase):
x1 = amount("$1234.56")
self.assertEqual(True, bool(x1))
- self.assertEqual(1234, int(x1))
+ self.assertRaises(exceptions.ArithmeticError, amount.to_long, x1)
+ self.assertEqual(1234, x1.to_long(True))
self.assertEqual(1234.56, float(x1))
self.assertEqual("$1234.56", x1.to_string())
self.assertEqual("1234.56", x1.quantity_string())