summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-04 05:27:36 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:37 -0400
commit6c7e35dc17504c41bb177b3d1327c6b6cee4017d (patch)
treea86913687b2881a5c3dedbcf53adf9591791adcc
parent90975c27d0a701a66ee4d24ea8f08a12eda6cfce (diff)
downloadfork-ledger-6c7e35dc17504c41bb177b3d1327c6b6cee4017d.tar.gz
fork-ledger-6c7e35dc17504c41bb177b3d1327c6b6cee4017d.tar.bz2
fork-ledger-6c7e35dc17504c41bb177b3d1327c6b6cee4017d.zip
*** no comment ***
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rwxr-xr-xacprep10
-rw-r--r--src/commodity.cc5
-rw-r--r--src/commodity.h130
-rw-r--r--src/utils.h6
6 files changed, 83 insertions, 72 deletions
diff --git a/Makefile.am b/Makefile.am
index af6a0cb0..cddd1257 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,7 +70,7 @@ libledger_la_CPPFLAGS += -DHAVE_LIBOFX=1
libledger_la_SOURCES += src/ofx.cc
endif
if DEBUG
-libledger_la_CPPFLAGS += -DFULL_DEBUG
+libledger_la_CPPFLAGS += -DDEBUG_MODE
endif
if HAVE_BOOST_PYTHON
libledger_la_CPPFLAGS += -DUSE_BOOST_PYTHON=1
diff --git a/Makefile.in b/Makefile.in
index 7f3e2cb0..c937d66f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -42,7 +42,7 @@ host_triplet = @host@
@HAVE_XMLPARSE_TRUE@am__append_5 = src/gnucash.cc
@HAVE_LIBOFX_TRUE@am__append_6 = -DHAVE_LIBOFX=1
@HAVE_LIBOFX_TRUE@am__append_7 = src/ofx.cc
-@DEBUG_TRUE@am__append_8 = -DFULL_DEBUG
+@DEBUG_TRUE@am__append_8 = -DDEBUG_MODE
@HAVE_BOOST_PYTHON_TRUE@am__append_9 = -DUSE_BOOST_PYTHON=1
@HAVE_BOOST_PYTHON_TRUE@am__append_10 = src/pyinterp.cc
@USE_PCH_TRUE@am__append_11 = system.hh.gch
diff --git a/acprep b/acprep
index 45ce5348..c0708f91 100755
--- a/acprep
+++ b/acprep
@@ -49,12 +49,18 @@ fi
# since there are no clients except a GUI tool which might use it (and
# that is built again anyway by Xcode).
SWITCHES="--disable-shared --enable-pch"
+CPPFLAGS="$INCDIRS"
+LDFLAGS="$LIBDIRS"
while [ -n "$1" ]; do
case "$1" in
--debug)
SWITCHES="$SWITCHES --enable-debug"
+ if [ -f /usr/local/lib/libstlportstlg.a ]; then
+ CPPFLAGS="-I/usr/local/include/stlport -D_STLP_DEBUG $CPPFLAGS"
+ #LDFLAGS="-lstlportstlg $LDFLAGS"
+ fi
CXXFLAGS="$CXXFLAGS -g" ;;
--prof | --perf)
@@ -96,5 +102,5 @@ if [ -d "$HOME/Products" ]; then
fi
"$HERE/configure" --srcdir="$HERE" \
- CPPFLAGS="$INCDIRS" CXXFLAGS="$CXXFLAGS $local_cxxflags" \
- LDFLAGS="$LIBDIRS" $SWITCHES "$@"
+ CPPFLAGS="$CPPFLAGS" CXXFLAGS="$CXXFLAGS $local_cxxflags" \
+ LDFLAGS="$LDFLAGS" $SWITCHES "$@"
diff --git a/src/commodity.cc b/src/commodity.cc
index 1fac4a4e..ababfd67 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -279,8 +279,9 @@ commodity_pool_t::commodity_pool_t() : default_commodity(NULL)
commodity_t * commodity_pool_t::create(const string& symbol)
{
- shared_ptr<commodity_base_t> base_commodity(new commodity_base_t(symbol));
- std::auto_ptr<commodity_t> commodity(new commodity_t(this, base_commodity));
+ shared_ptr<commodity_t::base_t>
+ base_commodity(new commodity_t::base_t(symbol));
+ std::auto_ptr<commodity_t> commodity(new commodity_t(this, base_commodity));
DEBUG("amounts.commodities", "Creating base commodity " << symbol);
diff --git a/src/commodity.h b/src/commodity.h
index 29534729..7b9a7be4 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -45,73 +45,70 @@
namespace ledger {
-#define COMMODITY_STYLE_DEFAULTS 0x0000
-#define COMMODITY_STYLE_SUFFIXED 0x0001
-#define COMMODITY_STYLE_SEPARATED 0x0002
-#define COMMODITY_STYLE_EUROPEAN 0x0004
-#define COMMODITY_STYLE_THOUSANDS 0x0008
-#define COMMODITY_STYLE_NOMARKET 0x0010
-#define COMMODITY_STYLE_BUILTIN 0x0020
-
-class commodity_base_t : public noncopyable
+class commodity_t
+ : public equality_comparable1<commodity_t, noncopyable>
{
-private:
- friend class commodity_pool_t;
- friend class commodity_t;
- friend class annotated_commodity_t;
-
- typedef std::map<const moment_t, amount_t> history_map;
- typedef std::pair<const moment_t, amount_t> history_pair;
-
- struct history_t {
- history_map prices;
- ptime last_lookup;
- };
-
- typedef uint_least8_t flags_t;
-
- flags_t flags;
- string symbol;
- amount_t::precision_t precision;
- optional<string> name;
- optional<string> note;
- optional<history_t> history;
- optional<amount_t> smaller;
- optional<amount_t> larger;
-
-public:
- explicit commodity_base_t()
- : flags(COMMODITY_STYLE_DEFAULTS), precision(0) {
- TRACE_CTOR(commodity_base_t, "");
- }
- explicit commodity_base_t
+ class base_t : public noncopyable
+ {
+ private:
+ friend class commodity_pool_t;
+ friend class commodity_t;
+
+ typedef std::map<const moment_t, amount_t> history_map;
+ typedef std::pair<const moment_t, amount_t> history_pair;
+
+ struct history_t {
+ history_map prices;
+ ptime last_lookup;
+ };
+
+ typedef uint_least8_t flags_t;
+
+#define COMMODITY_STYLE_DEFAULTS 0x00
+#define COMMODITY_STYLE_SUFFIXED 0x01
+#define COMMODITY_STYLE_SEPARATED 0x02
+#define COMMODITY_STYLE_EUROPEAN 0x04
+#define COMMODITY_STYLE_THOUSANDS 0x08
+#define COMMODITY_STYLE_NOMARKET 0x10
+#define COMMODITY_STYLE_BUILTIN 0x20
+
+ flags_t flags;
+ string symbol;
+ amount_t::precision_t precision;
+ optional<string> name;
+ optional<string> note;
+ optional<history_t> history;
+ optional<amount_t> smaller;
+ optional<amount_t> larger;
+
+ public:
+ explicit base_t()
+ : flags(COMMODITY_STYLE_DEFAULTS), precision(0) {
+ TRACE_CTOR(base_t, "");
+ }
+ explicit base_t
(const string& _symbol,
amount_t::precision_t _precision = 0,
unsigned int _flags = COMMODITY_STYLE_DEFAULTS)
- : flags(_flags), symbol(_symbol), precision(_precision) {
- TRACE_CTOR(commodity_base_t,
- "const string&, amount_t::precision_t, unsigned int");
- }
- ~commodity_base_t() {
- TRACE_DTOR(commodity_base_t);
- }
-};
-
-class annotated_commodity_t;
+ : flags(_flags), symbol(_symbol), precision(_precision) {
+ TRACE_CTOR(base_t,
+ "const string&, amount_t::precision_t, unsigned int");
+ }
+ ~base_t() {
+ TRACE_DTOR(base_t);
+ }
+ };
-class commodity_t
- : public equality_comparable1<commodity_t, noncopyable>
-{
public:
static bool symbol_needs_quotes(const string& symbol);
- typedef commodity_base_t::flags_t flags_t;
- typedef commodity_base_t::history_t history_t;
- typedef commodity_base_t::history_map history_map;
- typedef commodity_base_t::history_pair history_pair;
+ typedef base_t::flags_t flags_t;
+ 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;
- shared_ptr<commodity_base_t> base;
+ shared_ptr<base_t> base;
commodity_pool_t * parent_;
ident_t ident;
@@ -121,7 +118,7 @@ public:
public:
explicit commodity_t(commodity_pool_t * _parent,
- const shared_ptr<commodity_base_t>& _base)
+ const shared_ptr<base_t>& _base)
: base(_base), parent_(_parent), annotated(false) {
TRACE_CTOR(commodity_t, "");
}
@@ -234,9 +231,10 @@ struct annotation_t : public equality_comparable<annotation_t>
optional<moment_t> date;
optional<string> tag;
- explicit annotation_t(const optional<amount_t>& _price = optional<amount_t>(),
- const optional<moment_t>& _date = optional<moment_t>(),
- const optional<string>& _tag = optional<string>())
+ explicit annotation_t
+ (const optional<amount_t>& _price = optional<amount_t>(),
+ const optional<moment_t>& _date = optional<moment_t>(),
+ const optional<string>& _tag = optional<string>())
: price(_price), date(_date), tag(_tag) {}
operator bool() const {
@@ -267,7 +265,9 @@ inline std::ostream& operator<<(std::ostream& out, const annotation_t& details)
class annotated_commodity_t
: public commodity_t,
- equality_comparable1<annotated_commodity_t, noncopyable>
+ equality_comparable<annotated_commodity_t,
+ equality_comparable2<annotated_commodity_t, commodity_t,
+ noncopyable> >
{
public:
commodity_t * ptr;
@@ -284,6 +284,9 @@ public:
}
virtual bool operator==(const commodity_t& comm) const;
+ virtual bool operator==(const annotated_commodity_t& comm) const {
+ return *this == static_cast<commodity_t&>(comm);
+ }
commodity_t& referent() {
return *ptr;
@@ -306,7 +309,6 @@ struct compare_amount_commodities {
class commodity_pool_t : public noncopyable
{
-public:
/**
* The commodities collection in commodity_pool_t maintains pointers
* to all the commodities which have ever been created by the user,
@@ -332,6 +334,8 @@ public:
> commodities_t;
commodities_t commodities;
+
+public:
commodity_t * null_commodity;
commodity_t * default_commodity;
diff --git a/src/utils.h b/src/utils.h
index 4a7213b7..bde23b2b 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,7 +1,7 @@
#ifndef _UTILS_H
#define _UTILS_H
-#if defined(FULL_DEBUG)
+#if defined(DEBUG_MODE)
#define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE 1
#define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING 1
#endif
@@ -13,13 +13,13 @@
* Default values
*/
-#if defined(FULL_DEBUG)
+#if defined(DEBUG_MODE)
#define VERIFY_ON 1
#define TRACING_ON 1
#define DEBUG_ON 1
#define TIMERS_ON 1
#define FREE_MEMORY 1
-#elif defined(NO_DEBUG)
+#elif defined(NDEBUG)
#define NO_ASSERTS 1
#define NO_LOGGING 1
#else