Changed some of the logging macro names.

This commit is contained in:
John Wiegley 2007-04-30 08:24:37 +00:00
parent 83fc097062
commit 3ba6c2572d
19 changed files with 202 additions and 181 deletions

View file

@ -340,8 +340,8 @@ amount_t::amount_t(const double val)
void amount_t::_release() void amount_t::_release()
{ {
DEBUG_("amounts.refs", DEBUG("amounts.refs", quantity << " ref--, now " << (quantity->ref - 1));
quantity << " ref--, now " << (quantity->ref - 1));
if (--quantity->ref == 0) { if (--quantity->ref == 0) {
if (! (quantity->flags & BIGINT_BULK_ALLOC)) if (! (quantity->flags & BIGINT_BULK_ALLOC))
delete quantity; delete quantity;
@ -382,7 +382,7 @@ void amount_t::_copy(const amount_t& amt)
quantity = new bigint_t(*amt.quantity); quantity = new bigint_t(*amt.quantity);
} else { } else {
quantity = amt.quantity; quantity = amt.quantity;
DEBUG_("amounts.refs", DEBUG("amounts.refs",
quantity << " ref++, now " << (quantity->ref + 1)); quantity << " ref++, now " << (quantity->ref + 1));
quantity->ref++; quantity->ref++;
} }
@ -1214,7 +1214,7 @@ bool parse_annotations(std::istream& in, amount_t& price,
} }
} while (true); } while (true);
DEBUG_("amounts.commodities", DEBUG("amounts.commodities",
"Parsed commodity annotations: " "Parsed commodity annotations: "
<< " price " << price << " " << " price " << price << " "
<< " date " << date << " " << " date " << date << " "
@ -1473,7 +1473,7 @@ void amount_t::read_quantity(char *& data)
data += sizeof(unsigned int); data += sizeof(unsigned int);
quantity = (bigint_t *) (bigints + (index - 1) * sizeof(bigint_t)); quantity = (bigint_t *) (bigints + (index - 1) * sizeof(bigint_t));
DEBUG_("amounts.refs", DEBUG("amounts.refs",
quantity << " ref++, now " << (quantity->ref + 1)); quantity << " ref++, now " << (quantity->ref + 1));
quantity->ref++; quantity->ref++;
} }
@ -1562,12 +1562,12 @@ bool amount_t::valid() const
{ {
if (quantity) { if (quantity) {
if (quantity->ref == 0) { if (quantity->ref == 0) {
DEBUG_("ledger.validate", "amount_t: quantity->ref == 0"); DEBUG("ledger.validate", "amount_t: quantity->ref == 0");
return false; return false;
} }
} }
else if (commodity_) { else if (commodity_) {
DEBUG_("ledger.validate", "amount_t: commodity_ != NULL"); DEBUG("ledger.validate", "amount_t: commodity_ != NULL");
return false; return false;
} }
return true; return true;
@ -1588,7 +1588,7 @@ void amount_t::annotate_commodity(const amount_t& tprice,
} }
assert(this_base); assert(this_base);
DEBUG_("amounts.commodities", "Annotating commodity for amount " DEBUG("amounts.commodities", "Annotating commodity for amount "
<< *this << std::endl << *this << std::endl
<< " price " << tprice << " " << " price " << tprice << " "
<< " date " << tdate << " " << " date " << tdate << " "
@ -1602,7 +1602,7 @@ void amount_t::annotate_commodity(const amount_t& tprice,
if (ann_comm) if (ann_comm)
set_commodity(*ann_comm); set_commodity(*ann_comm);
DEBUG_("amounts.commodities", " Annotated amount is " << *this); DEBUG("amounts.commodities", " Annotated amount is " << *this);
} }
amount_t amount_t::strip_annotations(const bool _keep_price, amount_t amount_t::strip_annotations(const bool _keep_price,
@ -1613,7 +1613,7 @@ amount_t amount_t::strip_annotations(const bool _keep_price,
(_keep_price && _keep_date && _keep_tag)) (_keep_price && _keep_date && _keep_tag))
return *this; return *this;
DEBUG_("amounts.commodities", "Reducing commodity for amount " DEBUG("amounts.commodities", "Reducing commodity for amount "
<< *this << std::endl << *this << std::endl
<< " keep price " << _keep_price << " " << " keep price " << _keep_price << " "
<< " keep date " << _keep_date << " " << " keep date " << _keep_date << " "
@ -1640,7 +1640,7 @@ amount_t amount_t::strip_annotations(const bool _keep_price,
amount_t t(*this); amount_t t(*this);
t.set_commodity(*new_comm); t.set_commodity(*new_comm);
DEBUG_("amounts.commodities", " Reduced amount is " << t); DEBUG("amounts.commodities", " Reduced amount is " << t);
return t; return t;
} }
@ -1650,7 +1650,7 @@ amount_t amount_t::price() const
if (commodity_ && commodity_->annotated) { if (commodity_ && commodity_->annotated) {
amount_t t(((annotated_commodity_t *)commodity_)->price); amount_t t(((annotated_commodity_t *)commodity_)->price);
t *= number(); t *= number();
DEBUG_("amounts.commodities", DEBUG("amounts.commodities",
"Returning price of " << *this << " = " << t); "Returning price of " << *this << " = " << t);
return t; return t;
} }
@ -1660,7 +1660,7 @@ amount_t amount_t::price() const
moment_t amount_t::date() const moment_t amount_t::date() const
{ {
if (commodity_ && commodity_->annotated) { if (commodity_ && commodity_->annotated) {
DEBUG_("amounts.commodities", DEBUG("amounts.commodities",
"Returning date of " << *this << " = " "Returning date of " << *this << " = "
<< ((annotated_commodity_t *)commodity_)->date); << ((annotated_commodity_t *)commodity_)->date);
return ((annotated_commodity_t *)commodity_)->date; return ((annotated_commodity_t *)commodity_)->date;
@ -1702,7 +1702,7 @@ commodity_base_t * commodity_base_t::create(const string& symbol)
{ {
commodity_base_t * commodity = new commodity_base_t(symbol); commodity_base_t * commodity = new commodity_base_t(symbol);
DEBUG_("amounts.commodities", "Creating base commodity " << symbol); DEBUG("amounts.commodities", "Creating base commodity " << symbol);
std::pair<base_commodities_map::iterator, bool> result std::pair<base_commodities_map::iterator, bool> result
= commodities.insert(base_commodities_pair(symbol, commodity)); = commodities.insert(base_commodities_pair(symbol, commodity));
@ -1723,18 +1723,18 @@ bool commodity_t::needs_quotes(const string& symbol)
bool commodity_t::valid() const bool commodity_t::valid() const
{ {
if (symbol().empty() && this != null_commodity) { if (symbol().empty() && this != null_commodity) {
DEBUG_("ledger.validate", DEBUG("ledger.validate",
"commodity_t: symbol().empty() && this != null_commodity"); "commodity_t: symbol().empty() && this != null_commodity");
return false; return false;
} }
if (annotated && ! base) { if (annotated && ! base) {
DEBUG_("ledger.validate", "commodity_t: annotated && ! base"); DEBUG("ledger.validate", "commodity_t: annotated && ! base");
return false; return false;
} }
if (precision() > 16) { if (precision() > 16) {
DEBUG_("ledger.validate", "commodity_t: precision() > 16"); DEBUG("ledger.validate", "commodity_t: precision() > 16");
return false; return false;
} }
@ -1755,7 +1755,7 @@ commodity_t * commodity_t::create(const string& symbol)
commodity->qualified_symbol = symbol; commodity->qualified_symbol = symbol;
} }
DEBUG_("amounts.commodities", DEBUG("amounts.commodities",
"Creating commodity " << commodity->qualified_symbol); "Creating commodity " << commodity->qualified_symbol);
std::pair<commodities_map::iterator, bool> result std::pair<commodities_map::iterator, bool> result
@ -1777,7 +1777,7 @@ commodity_t * commodity_t::create(const string& symbol)
commodity_t * commodity_t::find_or_create(const string& symbol) commodity_t * commodity_t::find_or_create(const string& symbol)
{ {
DEBUG_("amounts.commodities", "Find-or-create commodity " << symbol); DEBUG("amounts.commodities", "Find-or-create commodity " << symbol);
commodity_t * commodity = find(symbol); commodity_t * commodity = find(symbol);
if (commodity) if (commodity)
@ -1787,7 +1787,7 @@ commodity_t * commodity_t::find_or_create(const string& symbol)
commodity_t * commodity_t::find(const string& symbol) commodity_t * commodity_t::find(const string& symbol)
{ {
DEBUG_("amounts.commodities", "Find commodity " << symbol); DEBUG("amounts.commodities", "Find commodity " << symbol);
commodities_map::const_iterator i = commodities.find(symbol); commodities_map::const_iterator i = commodities.find(symbol);
if (i != commodities.end()) if (i != commodities.end())
@ -1899,7 +1899,7 @@ annotated_commodity_t::create(const commodity_t& comm,
commodity->qualified_symbol = comm.symbol(); commodity->qualified_symbol = comm.symbol();
DEBUG_("amounts.commodities", "Creating annotated commodity " DEBUG("amounts.commodities", "Creating annotated commodity "
<< "symbol " << commodity->symbol() << "symbol " << commodity->symbol()
<< " key " << mapping_key << std::endl << " key " << mapping_key << std::endl
<< " price " << price << " " << " price " << price << " "
@ -1934,13 +1934,13 @@ namespace {
comm.write(name); comm.write(name);
annotated_commodity_t::write_annotations(name, price, date, tag); annotated_commodity_t::write_annotations(name, price, date, tag);
DEBUG_("amounts.commodities", "make_qualified_name for " DEBUG("amounts.commodities", "make_qualified_name for "
<< comm.qualified_symbol << std::endl << comm.qualified_symbol << std::endl
<< " price " << price << " " << " price " << price << " "
<< " date " << date << " " << " date " << date << " "
<< " tag " << tag); << " tag " << tag);
DEBUG_("amounts.commodities", "qualified_name is " << name.str()); DEBUG("amounts.commodities", "qualified_name is " << name.str());
return name.str(); return name.str();
} }

View file

@ -7,20 +7,30 @@ class context
{ {
public: public:
string context; // ex: 'While parsing file "%R" at line %L' string context; // ex: 'While parsing file "%R" at line %L'
};
string resource; // ex: ledger.dat class file_context : public context
long linenum_beg; // ex: 1010 {
long linenum_end; // ex: 1010 public:
long colnum_beg; // ex: 8 path pathname; // ex: ledger.dat
long colnum_end; // ex: 8
long position_beg;
long position_end;
optional<long> linenum_beg; // ex: 1010
optional<long> linenum_end; // ex: 1010
optional<long> colnum_beg; // ex: 8
optional<long> colnum_end; // ex: 8
optional<long> position_beg;
optional<long> position_end;
};
class string_context : public context
{
public:
string text; // ex: (The multi-line text of an entry) string text; // ex: (The multi-line text of an entry)
long linenum_beg_off; // ex: 2 / -1 means start at beginning
long linenum_end_off; // ex: 2 / -1 means start at beginning optional<long> linenum_beg_off; // ex: 2 / none means start at beginning
long colnum_beg_off; // ex: 8 / -1 means start optional<long> linenum_end_off; // ex: 2 / none means start at beginning
long colnum_end_off; // ex: 8 / -1 means start optional<long> colnum_beg_off; // ex: 8 / none means start
optional<long> colnum_end_off; // ex: 8 / none means start
}; };
} // namespace ledger } // namespace ledger

View file

@ -35,12 +35,12 @@ moment_t transaction_t::effective_date() const
bool transaction_t::valid() const bool transaction_t::valid() const
{ {
if (! entry) { if (! entry) {
DEBUG_("ledger.validate", "transaction_t: ! entry"); DEBUG("ledger.validate", "transaction_t: ! entry");
return false; return false;
} }
if (state != UNCLEARED && state != CLEARED && state != PENDING) { if (state != UNCLEARED && state != CLEARED && state != PENDING) {
DEBUG_("ledger.validate", "transaction_t: state is bad"); DEBUG("ledger.validate", "transaction_t: state is bad");
return false; return false;
} }
@ -53,27 +53,27 @@ bool transaction_t::valid() const
break; break;
} }
if (! found) { if (! found) {
DEBUG_("ledger.validate", "transaction_t: ! found"); DEBUG("ledger.validate", "transaction_t: ! found");
return false; return false;
} }
if (! account) { if (! account) {
DEBUG_("ledger.validate", "transaction_t: ! account"); DEBUG("ledger.validate", "transaction_t: ! account");
return false; return false;
} }
if (! amount.valid()) { if (! amount.valid()) {
DEBUG_("ledger.validate", "transaction_t: ! amount.valid()"); DEBUG("ledger.validate", "transaction_t: ! amount.valid()");
return false; return false;
} }
if (cost && ! cost->valid()) { if (cost && ! cost->valid()) {
DEBUG_("ledger.validate", "transaction_t: cost && ! cost->valid()"); DEBUG("ledger.validate", "transaction_t: cost && ! cost->valid()");
return false; return false;
} }
if (flags & ~0x003f) { if (flags & ~0x003f) {
DEBUG_("ledger.validate", "transaction_t: flags are bad"); DEBUG("ledger.validate", "transaction_t: flags are bad");
return false; return false;
} }
@ -311,7 +311,7 @@ void entry_t::add_transaction(transaction_t * xact)
bool entry_t::valid() const bool entry_t::valid() const
{ {
if (! is_valid_moment(_date) || ! journal) { if (! is_valid_moment(_date) || ! journal) {
DEBUG_("ledger.validate", "entry_t: ! _date || ! journal"); DEBUG("ledger.validate", "entry_t: ! _date || ! journal");
return false; return false;
} }
@ -319,7 +319,7 @@ bool entry_t::valid() const
i != transactions.end(); i != transactions.end();
i++) i++)
if ((*i)->entry != this || ! (*i)->valid()) { if ((*i)->entry != this || ! (*i)->valid()) {
DEBUG_("ledger.validate", "entry_t: transaction not valid"); DEBUG("ledger.validate", "entry_t: transaction not valid");
return false; return false;
} }
@ -470,7 +470,7 @@ std::ostream& operator<<(std::ostream& out, const account_t& account)
bool account_t::valid() const bool account_t::valid() const
{ {
if (depth > 256 || ! journal) { if (depth > 256 || ! journal) {
DEBUG_("ledger.validate", "account_t: depth > 256 || ! journal"); DEBUG("ledger.validate", "account_t: depth > 256 || ! journal");
return false; return false;
} }
@ -478,12 +478,12 @@ bool account_t::valid() const
i != accounts.end(); i != accounts.end();
i++) { i++) {
if (this == (*i).second) { if (this == (*i).second) {
DEBUG_("ledger.validate", "account_t: parent refers to itself!"); DEBUG("ledger.validate", "account_t: parent refers to itself!");
return false; return false;
} }
if (! (*i).second->valid()) { if (! (*i).second->valid()) {
DEBUG_("ledger.validate", "account_t: child not valid"); DEBUG("ledger.validate", "account_t: child not valid");
return false; return false;
} }
} }
@ -579,7 +579,7 @@ bool journal_t::remove_entry(entry_t * entry)
bool journal_t::valid() const bool journal_t::valid() const
{ {
if (! master->valid()) { if (! master->valid()) {
DEBUG_("ledger.validate", "journal_t: master not valid"); DEBUG("ledger.validate", "journal_t: master not valid");
return false; return false;
} }
@ -587,7 +587,7 @@ bool journal_t::valid() const
i != entries.end(); i != entries.end();
i++) i++)
if (! (*i)->valid()) { if (! (*i)->valid()) {
DEBUG_("ledger.validate", "journal_t: entry not valid"); DEBUG("ledger.validate", "journal_t: entry not valid");
return false; return false;
} }
@ -595,7 +595,7 @@ bool journal_t::valid() const
i != commodity_t::commodities.end(); i != commodity_t::commodities.end();
i++) i++)
if (! (*i).second->valid()) { if (! (*i).second->valid()) {
DEBUG_("ledger.validate", "journal_t: commodity not valid"); DEBUG("ledger.validate", "journal_t: commodity not valid");
return false; return false;
} }

View file

@ -46,7 +46,7 @@ static int read_and_report(report_t * report, int argc, char * argv[],
else else
session.use_cache = session.data_file.empty() && session.price_db.empty(); session.use_cache = session.data_file.empty() && session.price_db.empty();
DEBUG_("ledger.session.cache", "1. use_cache = " << session.use_cache); DEBUG("ledger.session.cache", "1. use_cache = " << session.use_cache);
// Process the environment settings // Process the environment settings
@ -68,7 +68,7 @@ static int read_and_report(report_t * report, int argc, char * argv[],
if (session.data_file == session.cache_file) if (session.data_file == session.cache_file)
session.use_cache = false; session.use_cache = false;
DEBUG_("ledger.session.cache", "2. use_cache = " << session.use_cache); DEBUG("ledger.session.cache", "2. use_cache = " << session.use_cache);
INFO("Initialization file is " << session.init_file); INFO("Initialization file is " << session.init_file);
INFO("Price database is " << session.price_db); INFO("Price database is " << session.price_db);

View file

@ -3,8 +3,6 @@
#include "utils.h" #include "utils.h"
#include <boost/regex.hpp>
namespace ledger { namespace ledger {
class mask_t class mask_t

View file

@ -23,7 +23,7 @@ int ofx_proc_account_cb(struct OfxAccountData data, void * account_data)
if (! data.account_id_valid) if (! data.account_id_valid)
return -1; return -1;
DEBUG_("ledger.ofx.parse", "account " << data.account_name); DEBUG("ledger.ofx.parse", "account " << data.account_name);
account_t * account = new account_t(master_account, data.account_name); account_t * account = new account_t(master_account, data.account_name);
curr_journal->add_account(account); curr_journal->add_account(account);
ofx_accounts.insert(accounts_pair(data.account_id, account)); ofx_accounts.insert(accounts_pair(data.account_id, account));
@ -80,7 +80,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data,
xact->cost = new amount_t(stream.str()); xact->cost = new amount_t(stream.str());
} }
DEBUG_("ofx.parse", "xact " << xact->amount << " from " << *xact->account); DEBUG("ofx.parse", "xact " << xact->amount << " from " << *xact->account);
if (data.date_initiated_valid) if (data.date_initiated_valid)
entry->_date = data.date_initiated; entry->_date = data.date_initiated;
@ -141,13 +141,13 @@ int ofx_proc_security_cb(struct OfxSecurityData data, void * security_data)
commodities_map::iterator i = ofx_securities.find(data.unique_id); commodities_map::iterator i = ofx_securities.find(data.unique_id);
if (i == ofx_securities.end()) { if (i == ofx_securities.end()) {
DEBUG_("ledger.ofx.parse", "security " << symbol); DEBUG("ledger.ofx.parse", "security " << symbol);
ofx_securities.insert(commodities_pair(data.unique_id, commodity)); ofx_securities.insert(commodities_pair(data.unique_id, commodity));
} }
// jww (2005-02-09): What is the commodity for data.unitprice? // jww (2005-02-09): What is the commodity for data.unitprice?
if (data.date_unitprice_valid && data.unitprice_valid) { if (data.date_unitprice_valid && data.unitprice_valid) {
DEBUG_("ledger.ofx.parse", " price " << data.unitprice); DEBUG("ledger.ofx.parse", " price " << data.unitprice);
commodity->add_price(data.date_unitprice, amount_t(data.unitprice)); commodity->add_price(data.date_unitprice, amount_t(data.unitprice));
} }

View file

@ -1,10 +1,14 @@
#include "pyinterp.h" #include "pyinterp.h"
#include <boost/python/module_init.hpp>
#include <boost/python/exception_translator.hpp>
namespace ledger { namespace ledger {
struct python_run struct python_run
{ {
object result; object result;
python_run(python_interpreter_t * intepreter, python_run(python_interpreter_t * intepreter,
const string& str, int input_mode) const string& str, int input_mode)
: result(handle<>(borrowed(PyRun_String(str.c_str(), input_mode, : result(handle<>(borrowed(PyRun_String(str.c_str(), input_mode,
@ -23,7 +27,7 @@ python_interpreter_t::python_interpreter_t(xml::xpath_t::scope_t * parent)
nspace(handle<>(borrowed(PyModule_GetDict(mmodule.get())))) nspace(handle<>(borrowed(PyModule_GetDict(mmodule.get()))))
{ {
Py_Initialize(); Py_Initialize();
detail::init_module("ledger", &initialize_for_python); boost::python::detail::init_module("ledger", &initialize_for_python);
} }
object python_interpreter_t::import(const string& str) object python_interpreter_t::import(const string& str)
@ -121,7 +125,8 @@ void python_interpreter_t::functor_t::operator()(value_t& result,
arglist.append(*i); arglist.append(*i);
if (PyObject * val = if (PyObject * val =
PyObject_CallObject(func.ptr(), tuple(arglist).ptr())) { PyObject_CallObject(func.ptr(),
boost::python::tuple(arglist).ptr())) {
result = extract<value_t>(val)(); result = extract<value_t>(val)();
Py_DECREF(val); Py_DECREF(val);
} }

View file

@ -6,18 +6,14 @@
#if defined(USE_BOOST_PYTHON) #if defined(USE_BOOST_PYTHON)
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/exception_translator.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <Python.h> #include <Python.h>
#include "pyfstream.h" #include "pyfstream.h"
using namespace boost::python;
namespace ledger { namespace ledger {
using namespace boost::python;
class python_interpreter_t : public xml::xpath_t::scope_t class python_interpreter_t : public xml::xpath_t::scope_t
{ {
handle<> mmodule; handle<> mmodule;

View file

@ -6,7 +6,7 @@ namespace ledger {
#define MAX_LINE 1024 #define MAX_LINE 1024
static char line[MAX_LINE + 1]; static char line[MAX_LINE + 1];
static string path; static string pathname;
static unsigned int src_idx; static unsigned int src_idx;
static unsigned int linenum; static unsigned int linenum;
@ -52,7 +52,7 @@ unsigned int qif_parser_t::parse(std::istream& in,
xact = new transaction_t(master); xact = new transaction_t(master);
entry->add_transaction(xact); entry->add_transaction(xact);
path = journal->sources.back(); pathname = journal->sources.back();
src_idx = journal->sources.size() - 1; src_idx = journal->sources.size() - 1;
linenum = 1; linenum = 1;

View file

@ -10,15 +10,15 @@ void quotes_by_script::operator()(commodity_base_t& commodity,
{ {
LOGGER("quotes.download"); LOGGER("quotes.download");
DEBUG("commodity: " << commodity.symbol); DEBUG_("commodity: " << commodity.symbol);
DEBUG(" now: " << now); DEBUG_(" now: " << now);
DEBUG(" moment: " << moment); DEBUG_(" moment: " << moment);
DEBUG(" date: " << date); DEBUG_(" date: " << date);
DEBUG(" last: " << last); DEBUG_(" last: " << last);
if (SHOW_DEBUG() && commodity.history) if (SHOW_DEBUG_() && commodity.history)
DEBUG("last_lookup: " << commodity.history->last_lookup); DEBUG_("last_lookup: " << commodity.history->last_lookup);
DEBUG("pricing_leeway is " << pricing_leeway); DEBUG_("pricing_leeway is " << pricing_leeway);
if ((commodity.history && if ((commodity.history &&
(time_now - commodity.history->last_lookup) < pricing_leeway) || (time_now - commodity.history->last_lookup) < pricing_leeway) ||
@ -26,7 +26,7 @@ void quotes_by_script::operator()(commodity_base_t& commodity,
(price && moment > date && (moment - date) <= pricing_leeway)) (price && moment > date && (moment - date) <= pricing_leeway))
return; return;
DEBUG("downloading quote for symbol " << commodity.symbol); DEBUG_("downloading quote for symbol " << commodity.symbol);
char buf[256]; char buf[256];
buf[0] = '\0'; buf[0] = '\0';
@ -47,7 +47,7 @@ void quotes_by_script::operator()(commodity_base_t& commodity,
char * p = strchr(buf, '\n'); char * p = strchr(buf, '\n');
if (p) *p = '\0'; if (p) *p = '\0';
DEBUG("downloaded quote: " << buf); DEBUG_("downloaded quote: " << buf);
price.parse(buf); price.parse(buf);
commodity.add_price(now, price); commodity.add_price(now, price);

View file

@ -59,11 +59,11 @@ journal_t * session_t::read_data(const string& master_account)
unsigned int entry_count = 0; unsigned int entry_count = 0;
DEBUG_("ledger.cache", "3. use_cache = " << use_cache); DEBUG("ledger.cache", "3. use_cache = " << use_cache);
if (use_cache && ! cache_file.empty() && if (use_cache && ! cache_file.empty() &&
! data_file.empty()) { ! data_file.empty()) {
DEBUG_("ledger.cache", "using_cache " << cache_file); DEBUG("ledger.cache", "using_cache " << cache_file);
cache_dirty = true; cache_dirty = true;
if (access(cache_file.c_str(), R_OK) != -1) { if (access(cache_file.c_str(), R_OK) != -1) {
std::ifstream stream(cache_file.c_str()); std::ifstream stream(cache_file.c_str());
@ -90,12 +90,12 @@ journal_t * session_t::read_data(const string& master_account)
if (read_journal(journal->price_db, journal)) { if (read_journal(journal->price_db, journal)) {
throw_(exception, "Entries not allowed in price history file"); throw_(exception, "Entries not allowed in price history file");
} else { } else {
DEBUG_("ledger.cache", "read price database " << journal->price_db); DEBUG("ledger.cache", "read price database " << journal->price_db);
journal->sources.pop_back(); journal->sources.pop_back();
} }
} }
DEBUG_("ledger.cache", "rejected cache, parsing " << data_file); DEBUG("ledger.cache", "rejected cache, parsing " << data_file);
if (data_file == "-") { if (data_file == "-") {
use_cache = false; use_cache = false;
journal->sources.push_back("<stdin>"); journal->sources.push_back("<stdin>");

View file

@ -7,7 +7,7 @@ namespace ledger {
#define MAX_LINE 1024 #define MAX_LINE 1024
static string path; static string pathname;
static unsigned int linenum; static unsigned int linenum;
static unsigned int src_idx; static unsigned int src_idx;
static accounts_map account_aliases; static accounts_map account_aliases;
@ -52,11 +52,11 @@ parse_amount_expr(std::istream& in, journal_t *,
{ {
xml::xpath_t xpath(in, flags | XPATH_PARSE_RELAXED | XPATH_PARSE_PARTIAL); xml::xpath_t xpath(in, flags | XPATH_PARSE_RELAXED | XPATH_PARSE_PARTIAL);
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed an amount expression"); "Parsed an amount expression");
#if 0 #if 0
IF_DEBUG_("ledger.textual.parse") { IF_DEBUG("ledger.textual.parse") {
if (_debug_stream) { if (_debug_stream) {
xpath.dump(*_debug_stream); xpath.dump(*_debug_stream);
*_debug_stream << std::endl; *_debug_stream << std::endl;
@ -66,7 +66,7 @@ parse_amount_expr(std::istream& in, journal_t *,
amount = xpath.calc(static_cast<xml::transaction_node_t *>(xact.data)).to_amount(); amount = xpath.calc(static_cast<xml::transaction_node_t *>(xact.data)).to_amount();
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"The transaction amount is " << amount); "The transaction amount is " << amount);
} }
@ -124,12 +124,12 @@ transaction_t * parse_transaction(char * line,
switch (*state) { switch (*state) {
case '*': case '*':
xact->state = transaction_t::CLEARED; xact->state = transaction_t::CLEARED;
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed the CLEARED flag"); "Parsed the CLEARED flag");
break; break;
case '!': case '!':
xact->state = transaction_t::PENDING; xact->state = transaction_t::PENDING;
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed the PENDING flag"); "Parsed the PENDING flag");
break; break;
} }
@ -141,18 +141,18 @@ transaction_t * parse_transaction(char * line,
if ((*b == '[' && *e == ']') || if ((*b == '[' && *e == ']') ||
(*b == '(' && *e == ')')) { (*b == '(' && *e == ')')) {
xact->flags |= TRANSACTION_VIRTUAL; xact->flags |= TRANSACTION_VIRTUAL;
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed a virtual account name"); "Parsed a virtual account name");
if (*b == '[') { if (*b == '[') {
xact->flags |= TRANSACTION_BALANCE; xact->flags |= TRANSACTION_BALANCE;
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed a balanced virtual account name"); "Parsed a balanced virtual account name");
} }
*account_path++ = '\0'; *account_path++ = '\0';
*e = '\0'; *e = '\0';
} }
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed account name " << account_path); "Parsed account name " << account_path);
if (account_aliases.size() > 0) { if (account_aliases.size() > 0) {
accounts_map::const_iterator i = account_aliases.find(account_path); accounts_map::const_iterator i = account_aliases.find(account_path);
@ -214,14 +214,14 @@ transaction_t * parse_transaction(char * line,
if (in.good() && ! in.eof()) { if (in.good() && ! in.eof()) {
char c = peek_next_nonws(in); char c = peek_next_nonws(in);
if (c == '@') { if (c == '@') {
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Found a price indicator"); "Found a price indicator");
bool per_unit = true; bool per_unit = true;
in.get(c); in.get(c);
if (in.peek() == '@') { if (in.peek() == '@') {
in.get(c); in.get(c);
per_unit = false; per_unit = false;
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"And it's for a total price"); "And it's for a total price");
} }
@ -262,13 +262,13 @@ transaction_t * parse_transaction(char * line,
xact->entry->actual_date(), xact->entry->actual_date(),
xact->entry->code); xact->entry->code);
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Total cost is " << *xact->cost); "Total cost is " << *xact->cost);
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Per-unit cost is " << per_unit_cost); "Per-unit cost is " << per_unit_cost);
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Annotated amount is " << xact->amount); "Annotated amount is " << xact->amount);
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Bare amount is " << xact->amount.number()); "Bare amount is " << xact->amount.number());
} }
} }
@ -276,7 +276,7 @@ transaction_t * parse_transaction(char * line,
xact->amount.in_place_reduce(); xact->amount.in_place_reduce();
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Reduced amount is " << xact->amount); "Reduced amount is " << xact->amount);
} }
@ -284,7 +284,7 @@ transaction_t * parse_transaction(char * line,
if (note) { if (note) {
xact->note = note; xact->note = note;
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed a note '" << xact->note << "'"); "Parsed a note '" << xact->note << "'");
if (char * b = std::strchr(xact->note.c_str(), '[')) if (char * b = std::strchr(xact->note.c_str(), '['))
@ -293,7 +293,7 @@ transaction_t * parse_transaction(char * line,
std::strncpy(buf, b + 1, e - b - 1); std::strncpy(buf, b + 1, e - b - 1);
buf[e - b - 1] = '\0'; buf[e - b - 1] = '\0';
DEBUG_("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Parsed a transaction date " << buf); "Parsed a transaction date " << buf);
if (char * p = std::strchr(buf, '=')) { if (char * p = std::strchr(buf, '=')) {
@ -635,11 +635,11 @@ unsigned int textual_parser_t::parse(std::istream& in,
account_stack.push_front(master); account_stack.push_front(master);
path = journal ? journal->sources.back() : *original_file; pathname = journal ? journal->sources.back() : *original_file;
src_idx = journal ? journal->sources.size() - 1 : 0; src_idx = journal ? journal->sources.size() - 1 : 0;
linenum = 1; linenum = 1;
INFO("Parsing file '" << path << "'"); INFO("Parsing file '" << pathname << "'");
unsigned long beg_pos = in.tellg(); unsigned long beg_pos = in.tellg();
unsigned long end_pos; unsigned long end_pos;
@ -829,28 +829,29 @@ unsigned int textual_parser_t::parse(std::istream& in,
char * p = next_element(line); char * p = next_element(line);
string word(line + 1); string word(line + 1);
if (word == "include") { if (word == "include") {
push_var<string> save_path(path); push_var<string> save_path(pathname);
push_var<unsigned int> save_src_idx(src_idx); push_var<unsigned int> save_src_idx(src_idx);
push_var<unsigned long> save_beg_pos(beg_pos); push_var<unsigned long> save_beg_pos(beg_pos);
push_var<unsigned long> save_end_pos(end_pos); push_var<unsigned long> save_end_pos(end_pos);
push_var<unsigned int> save_linenum(linenum); push_var<unsigned int> save_linenum(linenum);
path = p; pathname = p;
if (path[0] != '/' && path[0] != '\\' && path[0] != '~') { if (pathname[0] != '/' && pathname[0] != '\\' &&
pathname[0] != '~') {
string::size_type pos = save_path.prev.rfind('/'); string::size_type pos = save_path.prev.rfind('/');
if (pos == string::npos) if (pos == string::npos)
pos = save_path.prev.rfind('\\'); pos = save_path.prev.rfind('\\');
if (pos != string::npos) if (pos != string::npos)
path = string(save_path.prev, 0, pos + 1) + path; pathname = string(save_path.prev, 0, pos + 1) + pathname;
} }
path = resolve_path(path); pathname = resolve_path(pathname);
DEBUG_("ledger.textual.include", "line " << linenum << ": " << DEBUG("ledger.textual.include", "line " << linenum << ": " <<
"Including path '" << path << "'"); "Including path '" << pathname << "'");
include_stack.push_back(std::pair<string, int> include_stack.push_back(std::pair<string, int>
(journal->sources.back(), linenum - 1)); (journal->sources.back(), linenum - 1));
count += journal->session->read_journal(path, journal, count += journal->session->read_journal(pathname, journal,
account_stack.front()); account_stack.front());
include_stack.pop_back(); include_stack.pop_back();
} }
@ -930,7 +931,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
i++) i++)
err->context.push_back(new include_context((*i).first, (*i).second, err->context.push_back(new include_context((*i).first, (*i).second,
"In file included from")); "In file included from"));
err->context.push_front(new file_context(path, linenum - 1)); err->context.push_front(new file_context(pathname, linenum - 1));
std::cout.flush(); std::cout.flush();
if (errors > 0 && err->context.size() > 1) if (errors > 0 && err->context.size() > 1)

View file

@ -3,16 +3,8 @@
#include "utils.h" #include "utils.h"
#include <boost/date_time/posix_time/posix_time.hpp>
namespace ledger { namespace ledger {
typedef boost::posix_time::ptime ptime;
typedef ptime::time_duration_type time_duration;
typedef boost::gregorian::date date;
typedef boost::gregorian::date_duration date_duration;
typedef boost::posix_time::seconds seconds;
#define SUPPORT_DATE_AND_TIME 1 #define SUPPORT_DATE_AND_TIME 1
#ifdef SUPPORT_DATE_AND_TIME #ifdef SUPPORT_DATE_AND_TIME

View file

@ -77,10 +77,10 @@ void shutdown_memory_tracing()
memory_tracing_active = false; memory_tracing_active = false;
if (live_objects) { if (live_objects) {
IF_DEBUG_("memory.counts") IF_DEBUG("memory.counts")
report_memory(std::cerr, true); report_memory(std::cerr, true);
else else
IF_DEBUG_("memory.counts.live") IF_DEBUG("memory.counts.live")
report_memory(std::cerr); report_memory(std::cerr);
else if (live_objects->size() > 0) else if (live_objects->size() > 0)
report_memory(std::cerr); report_memory(std::cerr);
@ -253,7 +253,7 @@ void trace_ctor_func(void * ptr, const char * cls_name, const char * args,
std::strcat(name, args); std::strcat(name, args);
std::strcat(name, ")"); std::strcat(name, ")");
DEBUG_("verify.memory", "TRACE_CTOR " << ptr << " " << name); 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_pair(ptr, allocation_pair(cls_name, cls_size)));
@ -271,7 +271,7 @@ void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size)
if (! live_objects) return; if (! live_objects) return;
DEBUG_("ledger.trace.debug", "TRACE_DTOR " << ptr << " " << cls_name); DEBUG("ledger.trace.debug", "TRACE_DTOR " << ptr << " " << cls_name);
live_objects_map::iterator i = live_objects->find(ptr); live_objects_map::iterator i = live_objects->find(ptr);
VERIFY(i != live_objects->end()); VERIFY(i != live_objects->end());
@ -494,8 +494,6 @@ bool logger_func(log_level_t level)
#if defined(DEBUG_ON) #if defined(DEBUG_ON)
#include <boost/regex.hpp>
namespace ledger { namespace ledger {
std::string _log_category; std::string _log_category;

View file

@ -16,6 +16,27 @@ namespace ledger {
#endif #endif
} }
// jww (2007-04-30): These Boost includes can go into system.hh as
// soon as GCC fixes it's problem with pre-compiled headers and global
// variables defined in unnamed namespaces.
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/optional.hpp>
#include <boost/regex.hpp>
namespace ledger {
using namespace boost;
typedef posix_time::ptime ptime;
typedef ptime::time_duration_type time_duration;
typedef gregorian::date date;
typedef gregorian::date_duration date_duration;
typedef posix_time::seconds seconds;
typedef filesystem::path path;
}
/********************************************************************** /**********************************************************************
* *
* Default values * Default values
@ -233,20 +254,20 @@ inline bool category_matches(const char * cat) {
cat[_log_category.size()] == '.')); cat[_log_category.size()] == '.'));
} }
#define SHOW_DEBUG_(cat) \ #define SHOW_DEBUG(cat) \
(_log_level >= LOG_DEBUG && category_matches(cat)) (_log_level >= LOG_DEBUG && category_matches(cat))
#define SHOW_DEBUG() SHOW_DEBUG_(_this_category) #define SHOW_DEBUG_() SHOW_DEBUG(_this_category)
#define DEBUG_(cat, msg) \ #define DEBUG(cat, msg) \
(SHOW_DEBUG_(cat) ? ((_log_buffer << msg), logger_func(LOG_DEBUG)) : false) (SHOW_DEBUG(cat) ? ((_log_buffer << msg), logger_func(LOG_DEBUG)) : false)
#define DEBUG(msg) DEBUG_(_this_category, msg) #define DEBUG_(msg) DEBUG(_this_category, msg)
#else // DEBUG_ON #else // DEBUG_ON
#define SHOW_DEBUG_(cat) false #define SHOW_DEBUG(cat) false
#define SHOW_DEBUG() false #define SHOW_DEBUG_() false
#define DEBUG_(cat, msg) #define DEBUG(cat, msg)
#define DEBUG(msg) #define DEBUG_(msg)
#endif // DEBUG_ON #endif // DEBUG_ON
@ -274,8 +295,8 @@ inline bool category_matches(const char * cat) {
#define LOGGER(cat) #define LOGGER(cat)
#define SHOW_TRACE(lvl) false #define SHOW_TRACE(lvl) false
#define SHOW_DEBUG_(cat) false #define SHOW_DEBUG(cat) false
#define SHOW_DEBUG() false #define SHOW_DEBUG_() false
#define SHOW_INFO() false #define SHOW_INFO() false
#define SHOW_WARN() false #define SHOW_WARN() false
#define SHOW_ERROR() false #define SHOW_ERROR() false
@ -283,8 +304,8 @@ inline bool category_matches(const char * cat) {
#define SHOW_CRITICAL() false #define SHOW_CRITICAL() false
#define TRACE(lvl, msg) #define TRACE(lvl, msg)
#define DEBUG(msg) #define DEBUG(cat, msg)
#define DEBUG_(cat, msg) #define DEBUG_(msg)
#define INFO(msg) #define INFO(msg)
#define WARN(msg) #define WARN(msg)
#define ERROR(msg) #define ERROR(msg)
@ -294,8 +315,8 @@ inline bool category_matches(const char * cat) {
#endif // LOGGING_ON #endif // LOGGING_ON
#define IF_TRACE(lvl) if (SHOW_TRACE(lvl)) #define IF_TRACE(lvl) if (SHOW_TRACE(lvl))
#define IF_DEBUG_(cat) if (SHOW_DEBUG_(cat)) #define IF_DEBUG(cat) if (SHOW_DEBUG(cat))
#define IF_DEBUG() if (SHOW_DEBUG()) #define IF_DEBUG_() if (SHOW_DEBUG_())
#define IF_INFO() if (SHOW_INFO()) #define IF_INFO() if (SHOW_INFO())
#define IF_WARN() if (SHOW_WARN()) #define IF_WARN() if (SHOW_WARN())
#define IF_ERROR() if (SHOW_ERROR()) #define IF_ERROR() if (SHOW_ERROR())
@ -330,22 +351,22 @@ void finish_timer(const char * name);
#endif #endif
#if defined(DEBUG_ON) #if defined(DEBUG_ON)
#define DEBUG_START_(name, cat, msg) \ #define DEBUG_START(name, cat, msg) \
(SHOW_DEBUG_(cat) ? \ (SHOW_DEBUG(cat) ? \
((_log_buffer << msg), start_timer(#name, LOG_DEBUG)) : ((void)0)) ((_log_buffer << msg), start_timer(#name, LOG_DEBUG)) : ((void)0))
#define DEBUG_START(name, msg) \ #define DEBUG_START_(name, msg) \
DEBUG_START_(name, _this_category, msg) DEBUG_START_(name, _this_category, msg)
#define DEBUG_STOP_(name, cat) \ #define DEBUG_STOP(name, cat) \
(SHOW_DEBUG_(cat) ? stop_timer(#name) : ((void)0)) (SHOW_DEBUG(cat) ? stop_timer(#name) : ((void)0))
#define DEBUG_STOP(name) \ #define DEBUG_STOP_(name) \
DEBUG_STOP_(name, _this_category) DEBUG_STOP_(name, _this_category)
#define DEBUG_FINISH_(name, cat) \ #define DEBUG_FINISH(name, cat) \
(SHOW_DEBUG_(cat) ? finish_timer(#name) : ((void)0)) (SHOW_DEBUG(cat) ? finish_timer(#name) : ((void)0))
#define DEBUG_FINISH(name) \ #define DEBUG_FINISH_(name) \
DEBUG_FINISH_(name, _this_category) DEBUG_FINISH_(name, _this_category)
#else #else
#define DEBUG_START(name, msg) #define DEBUG_START(name, cat, msg)
#define DEBUG_START_(name, cat, msg) #define DEBUG_START_(name, msg)
#define DEBUG_STOP(name) #define DEBUG_STOP(name)
#define DEBUG_FINISH(name) #define DEBUG_FINISH(name)
#endif #endif

View file

@ -130,7 +130,7 @@ void value_t::destroy()
void value_t::simplify() void value_t::simplify()
{ {
if (realzero()) { if (realzero()) {
DEBUG_("amounts.values.simplify", "Zeroing type " << type); DEBUG("amounts.values.simplify", "Zeroing type " << type);
*this = 0L; *this = 0L;
return; return;
} }
@ -138,19 +138,19 @@ void value_t::simplify()
if (type == BALANCE_PAIR && if (type == BALANCE_PAIR &&
(! ((balance_pair_t *) data)->cost || (! ((balance_pair_t *) data)->cost ||
((balance_pair_t *) data)->cost->realzero())) { ((balance_pair_t *) data)->cost->realzero())) {
DEBUG_("amounts.values.simplify", "Reducing balance pair to balance"); DEBUG("amounts.values.simplify", "Reducing balance pair to balance");
in_place_cast(BALANCE); in_place_cast(BALANCE);
} }
if (type == BALANCE && if (type == BALANCE &&
((balance_t *) data)->amounts.size() == 1) { ((balance_t *) data)->amounts.size() == 1) {
DEBUG_("amounts.values.simplify", "Reducing balance to amount"); DEBUG("amounts.values.simplify", "Reducing balance to amount");
in_place_cast(AMOUNT); in_place_cast(AMOUNT);
} }
if (type == AMOUNT && if (type == AMOUNT &&
! ((amount_t *) data)->commodity()) { ! ((amount_t *) data)->commodity()) {
DEBUG_("amounts.values.simplify", "Reducing amount to integer"); DEBUG("amounts.values.simplify", "Reducing amount to integer");
in_place_cast(INTEGER); in_place_cast(INTEGER);
} }
} }

View file

@ -48,7 +48,7 @@ int document_t::register_name(const string& name)
names.push_back(name); names.push_back(name);
index = names.size() - 1; index = names.size() - 1;
DEBUG_("xml.lookup", this << " Inserting name: " << names.back()); DEBUG("xml.lookup", this << " Inserting name: " << names.back());
std::pair<names_map::iterator, bool> result = std::pair<names_map::iterator, bool> result =
names_index.insert(names_pair(names.back(), index)); names_index.insert(names_pair(names.back(), index));
@ -63,7 +63,7 @@ int document_t::lookup_name_id(const string& name) const
if ((id = lookup_builtin_id(name)) != -1) if ((id = lookup_builtin_id(name)) != -1)
return id; return id;
DEBUG_("xml.lookup", this << " Finding name: " << name); DEBUG("xml.lookup", this << " Finding name: " << name);
names_map::const_iterator i = names_index.find(name); names_map::const_iterator i = names_index.find(name);
if (i != names_index.end()) if (i != names_index.end())
@ -268,7 +268,7 @@ static void startElement(void *userData, const char *name, const char **attrs)
{ {
document_t::parser_t * parser = static_cast<document_t::parser_t *>(userData); document_t::parser_t * parser = static_cast<document_t::parser_t *>(userData);
DEBUG_("xml.parse", "startElement(" << name << ")"); DEBUG("xml.parse", "startElement(" << name << ")");
if (parser->pending) { if (parser->pending) {
parent_node_t * node = create_node<parent_node_t>(parser); parent_node_t * node = create_node<parent_node_t>(parser);
@ -295,7 +295,7 @@ static void endElement(void *userData, const char *name)
{ {
document_t::parser_t * parser = static_cast<document_t::parser_t *>(userData); document_t::parser_t * parser = static_cast<document_t::parser_t *>(userData);
DEBUG_("xml.parse", "endElement(" << name << ")"); DEBUG("xml.parse", "endElement(" << name << ")");
if (parser->pending) { if (parser->pending) {
terminal_node_t * node = create_node<terminal_node_t>(parser); terminal_node_t * node = create_node<terminal_node_t>(parser);
@ -317,7 +317,7 @@ static void dataHandler(void *userData, const char *s, int len)
{ {
document_t::parser_t * parser = static_cast<document_t::parser_t *>(userData); document_t::parser_t * parser = static_cast<document_t::parser_t *>(userData);
DEBUG_("xml.parse", "dataHandler(" << string(s, len) << ")"); DEBUG("xml.parse", "dataHandler(" << string(s, len) << ")");
bool all_whitespace = true; bool all_whitespace = true;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {

View file

@ -475,7 +475,7 @@ xpath_t::op_t * xpath_t::wrap_mask(const string& pattern)
void xpath_t::scope_t::define(const string& name, op_t * def) void xpath_t::scope_t::define(const string& name, op_t * def)
{ {
DEBUG_("ledger.xpath.syms", "Defining '" << name << "' = " << def); DEBUG("ledger.xpath.syms", "Defining '" << name << "' = " << def);
std::pair<symbol_map::iterator, bool> result std::pair<symbol_map::iterator, bool> result
= symbols.insert(symbol_pair(name, def)); = symbols.insert(symbol_pair(name, def));
@ -548,7 +548,7 @@ xpath_t::op_t::~op_t()
{ {
TRACE_DTOR(xpath_t::op_t); TRACE_DTOR(xpath_t::op_t);
DEBUG_("ledger.xpath.memory", "Destroying " << this); DEBUG("ledger.xpath.memory", "Destroying " << this);
assert(refc == 0); assert(refc == 0);
switch (kind) { switch (kind) {

View file

@ -424,21 +424,21 @@ public:
} }
void release() const { void release() const {
DEBUG_("ledger.xpath.memory", DEBUG("ledger.xpath.memory",
"Releasing " << this << ", refc now " << refc - 1); "Releasing " << this << ", refc now " << refc - 1);
assert(refc > 0); assert(refc > 0);
if (--refc == 0) if (--refc == 0)
delete this; delete this;
} }
op_t * acquire() { op_t * acquire() {
DEBUG_("ledger.xpath.memory", DEBUG("ledger.xpath.memory",
"Acquiring " << this << ", refc now " << refc + 1); "Acquiring " << this << ", refc now " << refc + 1);
assert(refc >= 0); assert(refc >= 0);
refc++; refc++;
return this; return this;
} }
const op_t * acquire() const { const op_t * acquire() const {
DEBUG_("ledger.xpath.memory", DEBUG("ledger.xpath.memory",
"Acquiring " << this << ", refc now " << refc + 1); "Acquiring " << this << ", refc now " << refc + 1);
assert(refc >= 0); assert(refc >= 0);
refc++; refc++;