summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-11 16:03:50 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-11 17:02:25 -0400
commitdea2aed0b509734ec4e1cd163ac2a4f013000da2 (patch)
tree7908da76c67ae5172882306a319bf26df81b73b4 /src
parentd580079df892c30d023b3211d6c4611c17b11f8f (diff)
downloadfork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.gz
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.bz2
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.zip
Untabified all source files
Diffstat (limited to 'src')
-rw-r--r--src/account.cc70
-rw-r--r--src/account.h90
-rw-r--r--src/accum.cc20
-rw-r--r--src/accum.h2
-rw-r--r--src/amount.cc380
-rw-r--r--src/amount.h24
-rw-r--r--src/annotate.cc64
-rw-r--r--src/annotate.h28
-rw-r--r--src/archive.cc48
-rw-r--r--src/archive.h2
-rw-r--r--src/balance.cc36
-rw-r--r--src/balance.h66
-rw-r--r--src/chain.cc118
-rw-r--r--src/chain.h10
-rw-r--r--src/commodity.cc322
-rw-r--r--src/commodity.h96
-rw-r--r--src/compare.cc8
-rw-r--r--src/compare.h6
-rw-r--r--src/convert.cc70
-rw-r--r--src/csv.cc66
-rw-r--r--src/draft.cc444
-rw-r--r--src/emacs.cc6
-rw-r--r--src/error.cc24
-rw-r--r--src/error.h52
-rw-r--r--src/expr.cc62
-rw-r--r--src/expr.h10
-rw-r--r--src/exprbase.h20
-rw-r--r--src/filters.cc498
-rw-r--r--src/filters.h200
-rw-r--r--src/format.cc280
-rw-r--r--src/format.h36
-rw-r--r--src/generate.cc80
-rw-r--r--src/generate.h36
-rw-r--r--src/global.cc74
-rw-r--r--src/global.h16
-rw-r--r--src/interactive.cc60
-rw-r--r--src/item.cc114
-rw-r--r--src/item.h40
-rw-r--r--src/iterators.cc94
-rw-r--r--src/iterators.h8
-rw-r--r--src/journal.cc18
-rw-r--r--src/journal.h44
-rw-r--r--src/lookup.cc184
-rw-r--r--src/lookup.h4
-rw-r--r--src/main.cc86
-rw-r--r--src/mask.cc10
-rw-r--r--src/mask.h10
-rw-r--r--src/op.cc218
-rw-r--r--src/op.h44
-rw-r--r--src/option.cc108
-rw-r--r--src/option.h108
-rw-r--r--src/output.cc60
-rw-r--r--src/output.h14
-rw-r--r--src/parser.cc284
-rw-r--r--src/parser.h30
-rw-r--r--src/pool.cc144
-rw-r--r--src/pool.h52
-rw-r--r--src/post.cc136
-rw-r--r--src/post.h68
-rw-r--r--src/precmd.cc28
-rw-r--r--src/predicate.h12
-rw-r--r--src/print.cc182
-rw-r--r--src/print.h10
-rw-r--r--src/pstream.h30
-rw-r--r--src/py_account.cc64
-rw-r--r--src/py_amount.cc82
-rw-r--r--src/py_balance.cc30
-rw-r--r--src/py_commodity.cc192
-rw-r--r--src/py_format.cc6
-rw-r--r--src/py_item.cc54
-rw-r--r--src/py_journal.cc86
-rw-r--r--src/py_post.cc78
-rw-r--r--src/py_times.cc26
-rw-r--r--src/py_utils.cc42
-rw-r--r--src/py_value.cc58
-rw-r--r--src/py_xact.cc34
-rw-r--r--src/pyfstream.h12
-rw-r--r--src/pyinterp.cc108
-rw-r--r--src/pyinterp.h8
-rw-r--r--src/pyutils.h22
-rw-r--r--src/query.cc150
-rw-r--r--src/query.h180
-rw-r--r--src/quotes.cc32
-rw-r--r--src/quotes.h2
-rw-r--r--src/report.cc456
-rw-r--r--src/report.h286
-rw-r--r--src/scope.cc8
-rw-r--r--src/scope.h24
-rw-r--r--src/session.cc48
-rw-r--r--src/session.h6
-rw-r--r--src/stats.cc14
-rw-r--r--src/stream.cc8
-rw-r--r--src/stream.h2
-rw-r--r--src/temps.cc10
-rw-r--r--src/temps.h4
-rw-r--r--src/textual.cc580
-rw-r--r--src/timelog.cc36
-rw-r--r--src/timelog.h12
-rw-r--r--src/times.cc884
-rw-r--r--src/times.h98
-rw-r--r--src/token.cc132
-rw-r--r--src/token.h84
-rw-r--r--src/unistring.h24
-rw-r--r--src/utils.cc98
-rw-r--r--src/utils.h166
-rw-r--r--src/value.cc360
-rw-r--r--src/value.h126
-rw-r--r--src/xact.cc468
-rw-r--r--src/xact.h8
-rw-r--r--src/xml.cc22
110 files changed, 5397 insertions, 5397 deletions
diff --git a/src/account.cc b/src/account.cc
index 37ff83f3..4170a4d2 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -44,14 +44,14 @@ account_t::~account_t()
foreach (accounts_map::value_type& pair, accounts) {
if (! pair.second->has_flags(ACCOUNT_TEMP) ||
- has_flags(ACCOUNT_TEMP)) {
+ has_flags(ACCOUNT_TEMP)) {
checked_delete(pair.second);
}
}
}
account_t * account_t::find_account(const string& name,
- const bool auto_create)
+ const bool auto_create)
{
accounts_map::const_iterator i = accounts.find(name);
if (i != accounts.end())
@@ -111,7 +111,7 @@ namespace {
foreach (accounts_map::value_type& pair, account->accounts)
if (account_t * a = find_account_re_(pair.second, regexp))
- return a;
+ return a;
return NULL;
}
@@ -135,13 +135,13 @@ string account_t::fullname() const
if (! _fullname.empty()) {
return _fullname;
} else {
- const account_t * first = this;
- string fullname = name;
+ const account_t * first = this;
+ string fullname = name;
while (first->parent) {
first = first->parent;
if (! first->name.empty())
- fullname = first->name + ":" + fullname;
+ fullname = first->name + ":" + fullname;
}
_fullname = fullname;
@@ -161,7 +161,7 @@ string account_t::partial_name(bool flat) const
std::size_t count = acct->children_with_flags(ACCOUNT_EXT_TO_DISPLAY);
assert(count > 0);
if (count > 1 || acct->has_xflags(ACCOUNT_EXT_TO_DISPLAY))
- break;
+ break;
}
pname = acct->name + ":" + pname;
}
@@ -179,7 +179,7 @@ namespace {
{
in_context_t<account_t> env(scope, "&b");
return string_value(env->partial_name(env.has(0) ?
- env.get<bool>(0) : false));
+ env.get<bool>(0) : false));
}
value_t get_account(account_t& account) { // this gets the name
@@ -230,12 +230,12 @@ namespace {
{
std::size_t depth = 0;
for (const account_t * acct = account.parent;
- acct && acct->parent;
- acct = acct->parent) {
+ acct && acct->parent;
+ acct = acct->parent) {
std::size_t count = acct->children_with_flags(ACCOUNT_EXT_TO_DISPLAY);
assert(count > 0);
if (count > 1 || acct->has_xflags(ACCOUNT_EXT_TO_DISPLAY))
- depth++;
+ depth++;
}
std::ostringstream out;
@@ -269,7 +269,7 @@ namespace {
foreach (post_t * p, account.posts) {
bind_scope_t bound_scope(scope, *p);
if (expr.calc(bound_scope).to_boolean())
- return true;
+ return true;
}
return false;
}
@@ -284,14 +284,14 @@ namespace {
foreach (post_t * p, account.posts) {
bind_scope_t bound_scope(scope, *p);
if (! expr.calc(bound_scope).to_boolean())
- return false;
+ return false;
}
return true;
}
}
expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (kind != symbol_t::FUNCTION)
return NULL;
@@ -407,7 +407,7 @@ bool account_t::children_with_xdata() const
{
foreach (const accounts_map::value_type& pair, accounts)
if (pair.second->has_xdata() ||
- pair.second->children_with_xdata())
+ pair.second->children_with_xdata())
return true;
return false;
@@ -420,7 +420,7 @@ std::size_t account_t::children_with_flags(xdata_t::flags_t flags) const
foreach (const accounts_map::value_type& pair, accounts)
if (pair.second->has_xflags(flags) ||
- pair.second->children_with_flags(flags))
+ pair.second->children_with_flags(flags))
count++;
// Although no immediately children were visited, if any progeny at all were
@@ -434,11 +434,11 @@ std::size_t account_t::children_with_flags(xdata_t::flags_t flags) const
account_t::xdata_t::details_t&
account_t::xdata_t::details_t::operator+=(const details_t& other)
{
- posts_count += other.posts_count;
- posts_virtuals_count += other.posts_virtuals_count;
- posts_cleared_count += other.posts_cleared_count;
- posts_last_7_count += other.posts_last_7_count;
- posts_last_30_count += other.posts_last_30_count;
+ posts_count += other.posts_count;
+ posts_virtuals_count += other.posts_virtuals_count;
+ posts_cleared_count += other.posts_cleared_count;
+ posts_last_7_count += other.posts_last_7_count;
+ posts_last_30_count += other.posts_last_30_count;
posts_this_month_count += other.posts_this_month_count;
if (! is_valid(earliest_post) ||
@@ -461,9 +461,9 @@ account_t::xdata_t::details_t::operator+=(const details_t& other)
filenames.insert(other.filenames.begin(), other.filenames.end());
accounts_referenced.insert(other.accounts_referenced.begin(),
- other.accounts_referenced.end());
+ other.accounts_referenced.end());
payees_referenced.insert(other.payees_referenced.begin(),
- other.payees_referenced.end());
+ other.payees_referenced.end());
return *this;
}
@@ -487,10 +487,10 @@ value_t account_t::amount(const optional<expr_t&>& expr) const
for (; i != posts.end(); i++) {
if ((*i)->xdata().has_flags(POST_EXT_VISITED)) {
- if (! (*i)->xdata().has_flags(POST_EXT_CONSIDERED)) {
- (*i)->add_to_value(xdata_->self_details.total, expr);
- (*i)->xdata().add_flags(POST_EXT_CONSIDERED);
- }
+ if (! (*i)->xdata().has_flags(POST_EXT_CONSIDERED)) {
+ (*i)->add_to_value(xdata_->self_details.total, expr);
+ (*i)->xdata().add_flags(POST_EXT_CONSIDERED);
+ }
}
xdata_->self_details.last_post = i;
}
@@ -502,10 +502,10 @@ value_t account_t::amount(const optional<expr_t&>& expr) const
for (; i != xdata_->reported_posts.end(); i++) {
if ((*i)->xdata().has_flags(POST_EXT_VISITED)) {
- if (! (*i)->xdata().has_flags(POST_EXT_CONSIDERED)) {
- (*i)->add_to_value(xdata_->self_details.total, expr);
- (*i)->xdata().add_flags(POST_EXT_CONSIDERED);
- }
+ if (! (*i)->xdata().has_flags(POST_EXT_CONSIDERED)) {
+ (*i)->add_to_value(xdata_->self_details.total, expr);
+ (*i)->xdata().add_flags(POST_EXT_CONSIDERED);
+ }
}
xdata_->self_details.last_reported_post = i;
}
@@ -525,7 +525,7 @@ value_t account_t::total(const optional<expr_t&>& expr) const
foreach (const accounts_map::value_type& pair, accounts) {
temp = pair.second->total(expr);
if (! temp.is_null())
- add_or_set_value(xdata_->family_details.total, temp);
+ add_or_set_value(xdata_->family_details.total, temp);
}
temp = amount(expr);
@@ -562,7 +562,7 @@ account_t::family_details(bool gather_all) const
}
void account_t::xdata_t::details_t::update(post_t& post,
- bool gather_all)
+ bool gather_all)
{
posts_count++;
@@ -592,10 +592,10 @@ void account_t::xdata_t::details_t::update(post_t& post,
posts_cleared_count++;
if (! is_valid(earliest_cleared_post) ||
- post.date() < earliest_cleared_post)
+ post.date() < earliest_cleared_post)
earliest_cleared_post = post.date();
if (! is_valid(latest_cleared_post) ||
- post.date() > latest_cleared_post)
+ post.date() > latest_cleared_post)
latest_cleared_post = post.date();
}
diff --git a/src/account.h b/src/account.h
index 0a3a75e4..d22d2bb3 100644
--- a/src/account.h
+++ b/src/account.h
@@ -55,24 +55,24 @@ typedef std::map<const string, account_t *> accounts_map;
class account_t : public supports_flags<>, public scope_t
{
-#define ACCOUNT_NORMAL 0x00 // no flags at all, a basic account
-#define ACCOUNT_KNOWN 0x01
-#define ACCOUNT_TEMP 0x02 // account is a temporary object
-#define ACCOUNT_GENERATED 0x04 // account never actually existed
+#define ACCOUNT_NORMAL 0x00 // no flags at all, a basic account
+#define ACCOUNT_KNOWN 0x01
+#define ACCOUNT_TEMP 0x02 // account is a temporary object
+#define ACCOUNT_GENERATED 0x04 // account never actually existed
public:
- account_t * parent;
- string name;
+ account_t * parent;
+ string name;
optional<string> note;
unsigned short depth;
- accounts_map accounts;
- posts_list posts;
+ accounts_map accounts;
+ posts_list posts;
mutable string _fullname;
account_t(account_t * _parent = NULL,
- const string& _name = "",
- const optional<string>& _note = none)
+ const string& _name = "",
+ const optional<string>& _note = none)
: supports_flags<>(), scope_t(), parent(_parent),
name(_name), note(_note),
depth(static_cast<unsigned short>(parent ? parent->depth + 1 : 0)) {
@@ -107,7 +107,7 @@ public:
account_t * find_account_re(const string& regexp);
typedef transform_iterator<function<account_t *(accounts_map::value_type&)>,
- accounts_map::iterator>
+ accounts_map::iterator>
accounts_map_seconds_iterator;
accounts_map_seconds_iterator accounts_begin() {
@@ -132,7 +132,7 @@ public:
}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
bool valid() const;
@@ -140,50 +140,50 @@ public:
struct xdata_t : public supports_flags<>
{
-#define ACCOUNT_EXT_SORT_CALC 0x01
+#define ACCOUNT_EXT_SORT_CALC 0x01
#define ACCOUNT_EXT_HAS_NON_VIRTUALS 0x02
#define ACCOUNT_EXT_HAS_UNB_VIRTUALS 0x04
#define ACCOUNT_EXT_AUTO_VIRTUALIZE 0x08
#define ACCOUNT_EXT_VISITED 0x10
#define ACCOUNT_EXT_MATCHING 0x20
-#define ACCOUNT_EXT_TO_DISPLAY 0x40
-#define ACCOUNT_EXT_DISPLAYED 0x80
+#define ACCOUNT_EXT_TO_DISPLAY 0x40
+#define ACCOUNT_EXT_DISPLAYED 0x80
struct details_t
{
- value_t total;
- bool calculated;
- bool gathered;
-
- std::size_t posts_count;
- std::size_t posts_virtuals_count;
- std::size_t posts_cleared_count;
- std::size_t posts_last_7_count;
- std::size_t posts_last_30_count;
- std::size_t posts_this_month_count;
-
- date_t earliest_post;
- date_t earliest_cleared_post;
- date_t latest_post;
- date_t latest_cleared_post;
-
- std::set<path> filenames;
- std::set<string> accounts_referenced;
- std::set<string> payees_referenced;
+ value_t total;
+ bool calculated;
+ bool gathered;
+
+ std::size_t posts_count;
+ std::size_t posts_virtuals_count;
+ std::size_t posts_cleared_count;
+ std::size_t posts_last_7_count;
+ std::size_t posts_last_30_count;
+ std::size_t posts_this_month_count;
+
+ date_t earliest_post;
+ date_t earliest_cleared_post;
+ date_t latest_post;
+ date_t latest_cleared_post;
+
+ std::set<path> filenames;
+ std::set<string> accounts_referenced;
+ std::set<string> payees_referenced;
optional<posts_list::const_iterator> last_post;
optional<posts_list::const_iterator> last_reported_post;
details_t()
- : calculated(false),
- gathered(false),
+ : calculated(false),
+ gathered(false),
- posts_count(0),
- posts_virtuals_count(0),
- posts_cleared_count(0),
- posts_last_7_count(0),
- posts_last_30_count(0),
- posts_this_month_count(0) {}
+ posts_count(0),
+ posts_virtuals_count(0),
+ posts_cleared_count(0),
+ posts_last_7_count(0),
+ posts_last_30_count(0),
+ posts_this_month_count(0) {}
details_t& operator+=(const details_t& other);
@@ -202,9 +202,9 @@ public:
}
xdata_t(const xdata_t& other)
: supports_flags<>(other.flags()),
- self_details(other.self_details),
- family_details(other.family_details),
- sort_values(other.sort_values)
+ self_details(other.self_details),
+ family_details(other.family_details),
+ sort_values(other.sort_values)
{
TRACE_CTOR(account_t::xdata_t, "copy");
}
diff --git a/src/accum.cc b/src/accum.cc
index 55f5f0a4..157f459d 100644
--- a/src/accum.cc
+++ b/src/accum.cc
@@ -49,17 +49,17 @@ std::streamsize straccbuf::xsputn(const char * s, std::streamsize num)
bool matched = false;
for (const char * p = str.c_str(); *p; p++) {
if (*p == '%') {
- const char * q = p + 1;
- if (*q && *q != '%' && std::isdigit(*q) &&
- std::string::size_type(*q - '0') == index) {
- p++;
- buf << std::string(s, num);
- matched = true;
- } else {
- buf << *p;
- }
+ const char * q = p + 1;
+ if (*q && *q != '%' && std::isdigit(*q) &&
+ std::string::size_type(*q - '0') == index) {
+ p++;
+ buf << std::string(s, num);
+ matched = true;
+ } else {
+ buf << *p;
+ }
} else {
- buf << *p;
+ buf << *p;
}
}
if (! matched)
diff --git a/src/accum.h b/src/accum.h
index cf74cb74..236a7714 100644
--- a/src/accum.h
+++ b/src/accum.h
@@ -47,7 +47,7 @@ namespace ledger {
class straccbuf : public std::streambuf
{
protected:
- std::string str; // accumulator
+ std::string str; // accumulator
std::string::size_type index;
public:
diff --git a/src/amount.cc b/src/amount.cc
index 01caf4ac..9817f464 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -56,8 +56,8 @@ struct amount_t::bigint_t : public supports_flags<>
#define BIGINT_BULK_ALLOC 0x01
#define BIGINT_KEEP_PREC 0x02
- mpq_t val;
- precision_t prec;
+ mpq_t val;
+ precision_t prec;
uint_least32_t refc;
#define MP(bigint) ((bigint)->val)
@@ -68,7 +68,7 @@ struct amount_t::bigint_t : public supports_flags<>
}
bigint_t(const bigint_t& other)
: supports_flags<>(static_cast<uint_least8_t>
- (other.flags() & ~BIGINT_BULK_ALLOC)),
+ (other.flags() & ~BIGINT_BULK_ALLOC)),
prec(other.prec), refc(1) {
TRACE_CTOR(bigint_t, "copy");
mpq_init(val);
@@ -87,7 +87,7 @@ struct amount_t::bigint_t : public supports_flags<>
}
if (flags() & ~(BIGINT_BULK_ALLOC | BIGINT_KEEP_PREC)) {
DEBUG("ledger.validate",
- "amount_t::bigint_t: flags() & ~(BULK_ALLOC | KEEP_PREC)");
+ "amount_t::bigint_t: flags() & ~(BULK_ALLOC | KEEP_PREC)");
return false;
}
return true;
@@ -111,18 +111,18 @@ private:
bool amount_t::is_initialized = false;
namespace {
- void stream_out_mpq(std::ostream& out,
- mpq_t quant,
- amount_t::precision_t precision,
- int zeros_prec = -1,
- const optional<commodity_t&>& comm = none)
+ void stream_out_mpq(std::ostream& out,
+ mpq_t quant,
+ amount_t::precision_t precision,
+ int zeros_prec = -1,
+ const optional<commodity_t&>& comm = none)
{
char * buf = NULL;
try {
IF_DEBUG("amount.convert") {
- char * tbuf = mpq_get_str(NULL, 10, quant);
- DEBUG("amount.convert", "Rational to convert = " << tbuf);
- std::free(tbuf);
+ char * tbuf = mpq_get_str(NULL, 10, quant);
+ DEBUG("amount.convert", "Rational to convert = " << tbuf);
+ std::free(tbuf);
}
// Convert the rational number to a floating-point, extending the
@@ -131,7 +131,7 @@ namespace {
mp_prec_t num_prec = mpz_sizeinbase(mpq_numref(quant), 2);
num_prec += amount_t::extend_by_digits*64;
if (num_prec < MPFR_PREC_MIN)
- num_prec = MPFR_PREC_MIN;
+ num_prec = MPFR_PREC_MIN;
DEBUG("amount.convert", "num prec = " << num_prec);
mpfr_set_prec(tempfnum, num_prec);
@@ -140,7 +140,7 @@ namespace {
mp_prec_t den_prec = mpz_sizeinbase(mpq_denref(quant), 2);
den_prec += amount_t::extend_by_digits*64;
if (den_prec < MPFR_PREC_MIN)
- den_prec = MPFR_PREC_MIN;
+ den_prec = MPFR_PREC_MIN;
DEBUG("amount.convert", "den prec = " << den_prec);
mpfr_set_prec(tempfden, den_prec);
@@ -150,73 +150,73 @@ namespace {
mpfr_div(tempfb, tempfnum, tempfden, GMP_RNDN);
if (mpfr_asprintf(&buf, "%.*RNf", precision, tempfb) < 0)
- throw_(amount_error,
- _("Cannot output amount to a floating-point representation"));
-
+ throw_(amount_error,
+ _("Cannot output amount to a floating-point representation"));
+
DEBUG("amount.convert", "mpfr_print = " << buf
- << " (precision " << precision
- << ", zeros_prec " << zeros_prec << ")");
+ << " (precision " << precision
+ << ", zeros_prec " << zeros_prec << ")");
if (zeros_prec >= 0) {
- string::size_type index = std::strlen(buf);
- string::size_type point = 0;
- for (string::size_type i = 0; i < index; i++) {
- if (buf[i] == '.') {
- point = i;
- break;
- }
- }
- if (point > 0) {
- while (--index >= (point + 1 + zeros_prec) && buf[index] == '0')
- buf[index] = '\0';
- if (index >= (point + zeros_prec) && buf[index] == '.')
- buf[index] = '\0';
- }
+ string::size_type index = std::strlen(buf);
+ string::size_type point = 0;
+ for (string::size_type i = 0; i < index; i++) {
+ if (buf[i] == '.') {
+ point = i;
+ break;
+ }
+ }
+ if (point > 0) {
+ while (--index >= (point + 1 + zeros_prec) && buf[index] == '0')
+ buf[index] = '\0';
+ if (index >= (point + zeros_prec) && buf[index] == '.')
+ buf[index] = '\0';
+ }
}
if (comm) {
- int integer_digits = 0;
- if (comm && comm->has_flags(COMMODITY_STYLE_THOUSANDS)) {
- // Count the number of integer digits
- for (const char * p = buf; *p; p++) {
- if (*p == '.')
- break;
- else if (*p != '-')
- integer_digits++;
- }
- }
-
- for (const char * p = buf; *p; p++) {
- if (*p == '.') {
- if (commodity_t::decimal_comma_by_default ||
- (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA)))
- out << ',';
- else
- out << *p;
- assert(integer_digits <= 3);
- }
- else if (*p == '-') {
- out << *p;
- }
- else {
- out << *p;
-
- if (integer_digits > 3 && --integer_digits % 3 == 0) {
- if (commodity_t::decimal_comma_by_default ||
- (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA)))
- out << '.';
- else
- out << ',';
- }
- }
- }
+ int integer_digits = 0;
+ if (comm && comm->has_flags(COMMODITY_STYLE_THOUSANDS)) {
+ // Count the number of integer digits
+ for (const char * p = buf; *p; p++) {
+ if (*p == '.')
+ break;
+ else if (*p != '-')
+ integer_digits++;
+ }
+ }
+
+ for (const char * p = buf; *p; p++) {
+ if (*p == '.') {
+ if (commodity_t::decimal_comma_by_default ||
+ (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA)))
+ out << ',';
+ else
+ out << *p;
+ assert(integer_digits <= 3);
+ }
+ else if (*p == '-') {
+ out << *p;
+ }
+ else {
+ out << *p;
+
+ if (integer_digits > 3 && --integer_digits % 3 == 0) {
+ if (commodity_t::decimal_comma_by_default ||
+ (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA)))
+ out << '.';
+ else
+ out << ',';
+ }
+ }
+ }
} else {
- out << buf;
+ out << buf;
}
}
catch (...) {
if (buf != NULL)
- mpfr_free_str(buf);
+ mpfr_free_str(buf);
throw;
}
if (buf != NULL)
@@ -288,7 +288,7 @@ void amount_t::_copy(const amount_t& amt)
} else {
quantity = amt.quantity;
DEBUG("amounts.refs",
- quantity << " refc++, now " << (quantity->refc + 1));
+ quantity << " refc++, now " << (quantity->refc + 1));
quantity->refc++;
}
}
@@ -391,8 +391,8 @@ int amount_t::compare(const amount_t& amt) const
if (has_commodity() && amt.has_commodity() &&
commodity() != amt.commodity())
throw_(amount_error,
- _("Cannot compare amounts with different commodities: %1 and %2")
- << commodity().symbol() << amt.commodity().symbol());
+ _("Cannot compare amounts with different commodities: %1 and %2")
+ << commodity().symbol() << amt.commodity().symbol());
return mpq_cmp(MP(quantity), MP(amt.quantity));
}
@@ -426,9 +426,9 @@ amount_t& amount_t::operator+=(const amount_t& amt)
if (has_commodity() && amt.has_commodity() &&
commodity() != amt.commodity())
throw_(amount_error,
- _("Adding amounts with different commodities: %1 != %2")
- << (has_commodity() ? commodity().symbol() : _("NONE"))
- << (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
+ _("Adding amounts with different commodities: %1 != %2")
+ << (has_commodity() ? commodity().symbol() : _("NONE"))
+ << (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
_dup();
@@ -457,9 +457,9 @@ amount_t& amount_t::operator-=(const amount_t& amt)
if (has_commodity() && amt.has_commodity() &&
commodity() != amt.commodity())
throw_(amount_error,
- _("Subtracting amounts with different commodities: %1 != %2")
- << (has_commodity() ? commodity().symbol() : _("NONE"))
- << (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
+ _("Subtracting amounts with different commodities: %1 != %2")
+ << (has_commodity() ? commodity().symbol() : _("NONE"))
+ << (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
_dup();
@@ -527,7 +527,7 @@ amount_t& amount_t::operator/=(const amount_t& amt)
mpq_div(MP(quantity), MP(quantity), MP(amt.quantity));
quantity->prec =
static_cast<precision_t>(quantity->prec + amt.quantity->prec +
- extend_by_digits);
+ extend_by_digits);
if (! has_commodity())
commodity_ = amt.commodity_;
@@ -550,7 +550,7 @@ amount_t::precision_t amount_t::precision() const
{
if (! quantity)
throw_(amount_error,
- _("Cannot determine precision of an uninitialized amount"));
+ _("Cannot determine precision of an uninitialized amount"));
return quantity->prec;
}
@@ -559,7 +559,7 @@ bool amount_t::keep_precision() const
{
if (! quantity)
throw_(amount_error,
- _("Cannot determine if precision of an uninitialized amount is kept"));
+ _("Cannot determine if precision of an uninitialized amount is kept"));
return quantity->has_flags(BIGINT_KEEP_PREC);
}
@@ -568,7 +568,7 @@ void amount_t::set_keep_precision(const bool keep) const
{
if (! quantity)
throw_(amount_error,
- _("Cannot set whether to keep the precision of an uninitialized amount"));
+ _("Cannot set whether to keep the precision of an uninitialized amount"));
if (keep)
quantity->add_flags(BIGINT_KEEP_PREC);
@@ -580,7 +580,7 @@ amount_t::precision_t amount_t::display_precision() const
{
if (! quantity)
throw_(amount_error,
- _("Cannot determine display precision of an uninitialized amount"));
+ _("Cannot determine display precision of an uninitialized amount"));
commodity_t& comm(commodity());
@@ -632,7 +632,7 @@ void amount_t::in_place_truncate()
_dup();
DEBUG("amount.truncate",
- "Truncating " << *this << " to precision " << display_precision());
+ "Truncating " << *this << " to precision " << display_precision());
std::ostringstream out;
stream_out_mpq(out, MP(quantity), display_precision());
@@ -704,9 +704,9 @@ void amount_t::in_place_unreduce()
if (! quantity)
throw_(amount_error, _("Cannot unreduce an uninitialized amount"));
- amount_t temp = *this;
- commodity_t * comm = commodity_;
- bool shifted = false;
+ amount_t temp = *this;
+ commodity_t * comm = commodity_;
+ bool shifted = false;
while (comm && comm->larger()) {
amount_t next_temp = temp / comm->larger()->number();
@@ -725,57 +725,57 @@ void amount_t::in_place_unreduce()
optional<amount_t>
amount_t::value(const optional<datetime_t>& moment,
- const optional<commodity_t&>& in_terms_of) const
+ const optional<commodity_t&>& in_terms_of) const
{
if (quantity) {
#if defined(DEBUG_ON)
DEBUG("commodity.prices.find",
- "amount_t::value of " << commodity().symbol());
+ "amount_t::value of " << commodity().symbol());
if (moment)
DEBUG("commodity.prices.find",
- "amount_t::value: moment = " << *moment);
+ "amount_t::value: moment = " << *moment);
if (in_terms_of)
DEBUG("commodity.prices.find",
- "amount_t::value: in_terms_of = " << in_terms_of->symbol());
+ "amount_t::value: in_terms_of = " << in_terms_of->symbol());
#endif
if (has_commodity() &&
- (in_terms_of || ! commodity().has_flags(COMMODITY_PRIMARY))) {
+ (in_terms_of || ! commodity().has_flags(COMMODITY_PRIMARY))) {
optional<price_point_t> point;
optional<commodity_t&> comm(in_terms_of);
if (comm && commodity().referent() == comm->referent()) {
- return *this;
+ return *this;
}
else if (has_annotation() && annotation().price) {
- if (annotation().has_flags(ANNOTATION_PRICE_FIXATED)) {
- point = price_point_t();
- point->price = *annotation().price;
- }
- else if (! in_terms_of) {
- comm = annotation().price->commodity();
- }
+ if (annotation().has_flags(ANNOTATION_PRICE_FIXATED)) {
+ point = price_point_t();
+ point->price = *annotation().price;
+ }
+ else if (! in_terms_of) {
+ comm = annotation().price->commodity();
+ }
}
if (! point) {
- point = commodity().find_price(comm, moment);
- // Whether a price was found or not, check whether we should attempt
- // to download a price from the Internet. This is done if (a) no
- // price was found, or (b) the price is "stale" according to the
- // setting of --price-exp.
- if (point)
- point = commodity().check_for_updated_price(point, moment, comm);
+ point = commodity().find_price(comm, moment);
+ // Whether a price was found or not, check whether we should attempt
+ // to download a price from the Internet. This is done if (a) no
+ // price was found, or (b) the price is "stale" according to the
+ // setting of --price-exp.
+ if (point)
+ point = commodity().check_for_updated_price(point, moment, comm);
}
if (point) {
- amount_t price(point->price);
- price.multiply(*this, true);
- price.in_place_round();
- return price;
+ amount_t price(point->price);
+ price.multiply(*this, true);
+ price.in_place_round();
+ return price;
}
}
} else {
throw_(amount_error,
- _("Cannot determine value of an uninitialized amount"));
+ _("Cannot determine value of an uninitialized amount"));
}
return none;
}
@@ -813,7 +813,7 @@ bool amount_t::is_zero() const
return true;
}
else if (mpz_cmp(mpq_numref(MP(quantity)),
- mpq_denref(MP(quantity))) > 0) {
+ mpq_denref(MP(quantity))) > 0) {
DEBUG("amount.is_zero", "Numerator is larger than the denominator");
return false;
}
@@ -825,9 +825,9 @@ bool amount_t::is_zero() const
string output = out.str();
if (! output.empty()) {
- for (const char * p = output.c_str(); *p; p++)
- if (*p != '0' && *p != '.' && *p != '-')
- return false;
+ for (const char * p = output.c_str(); *p; p++)
+ if (*p != '0' && *p != '.' && *p != '-')
+ return false;
}
return true;
}
@@ -863,7 +863,7 @@ bool amount_t::fits_in_long() const
commodity_t& amount_t::commodity() const
{
return (has_commodity() ?
- *commodity_ : *commodity_pool_t::current_pool->null_commodity);
+ *commodity_ : *commodity_pool_t::current_pool->null_commodity);
}
bool amount_t::has_commodity() const
@@ -873,13 +873,13 @@ bool amount_t::has_commodity() const
void amount_t::annotate(const annotation_t& details)
{
- commodity_t * this_base;
+ commodity_t * this_base;
annotated_commodity_t * this_ann = NULL;
if (! quantity)
throw_(amount_error, _("Cannot annotate the commodity of an uninitialized amount"));
else if (! has_commodity())
- return; // ignore attempt to annotate a "bare commodity
+ return; // ignore attempt to annotate a "bare commodity
if (commodity().has_annotation()) {
this_ann = &as_annotated_commodity(commodity());
@@ -890,7 +890,7 @@ void amount_t::annotate(const annotation_t& details)
assert(this_base);
DEBUG("amounts.commodities", "Annotating commodity for amount "
- << *this << std::endl << details);
+ << *this << std::endl << details);
if (commodity_t * ann_comm =
this_base->pool().find_or_create(*this_base, details))
@@ -907,10 +907,10 @@ bool amount_t::has_annotation() const
{
if (! quantity)
throw_(amount_error,
- _("Cannot determine if an uninitialized amount's commodity is annotated"));
+ _("Cannot determine if an uninitialized amount's commodity is annotated"));
assert(! has_commodity() || ! commodity().has_annotation() ||
- as_annotated_commodity(commodity()).details);
+ as_annotated_commodity(commodity()).details);
return has_commodity() && commodity().has_annotation();
}
@@ -918,11 +918,11 @@ annotation_t& amount_t::annotation()
{
if (! quantity)
throw_(amount_error,
- _("Cannot return commodity annotation details of an uninitialized amount"));
+ _("Cannot return commodity annotation details of an uninitialized amount"));
if (! commodity().has_annotation())
throw_(amount_error,
- _("Request for annotation details from an unannotated amount"));
+ _("Request for annotation details from an unannotated amount"));
annotated_commodity_t& ann_comm(as_annotated_commodity(commodity()));
return ann_comm.details;
@@ -932,7 +932,7 @@ amount_t amount_t::strip_annotations(const keep_details_t& what_to_keep) const
{
if (! quantity)
throw_(amount_error,
- _("Cannot strip commodity annotations from an uninitialized amount"));
+ _("Cannot strip commodity annotations from an uninitialized amount"));
if (! what_to_keep.keep_all(commodity())) {
amount_t t(*this);
@@ -949,7 +949,7 @@ namespace {
char buf[256];
char c = peek_next_nonws(in);
READ_INTO(in, buf, 255, c,
- std::isdigit(c) || c == '-' || c == '.' || c == ',');
+ std::isdigit(c) || c == '-' || c == '.' || c == ',');
string::size_type len = std::strlen(buf);
while (len > 0 && ! std::isdigit(buf[len - 1])) {
@@ -971,7 +971,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
string symbol;
string quant;
annotation_t details;
- bool negative = false;
+ bool negative = false;
commodity_t::flags_t comm_flags = COMMODITY_STYLE_DEFAULTS;
@@ -988,28 +988,28 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) {
if (std::isspace(n))
- comm_flags |= COMMODITY_STYLE_SEPARATED;
+ comm_flags |= COMMODITY_STYLE_SEPARATED;
commodity_t::parse_symbol(in, symbol);
if (! symbol.empty())
- comm_flags |= COMMODITY_STYLE_SUFFIXED;
+ comm_flags |= COMMODITY_STYLE_SUFFIXED;
if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n'))
- details.parse(in);
+ details.parse(in);
}
} else {
commodity_t::parse_symbol(in, symbol);
if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) {
if (std::isspace(static_cast<char>(in.peek())))
- comm_flags |= COMMODITY_STYLE_SEPARATED;
+ comm_flags |= COMMODITY_STYLE_SEPARATED;
parse_quantity(in, quant);
if (! quant.empty() && ! in.eof() &&
- ((n = static_cast<char>(in.peek())) != '\n'))
- details.parse(in);
+ ((n = static_cast<char>(in.peek())) != '\n'))
+ details.parse(in);
}
}
@@ -1059,7 +1059,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
if (details)
commodity_ =
- commodity_pool_t::current_pool->find_or_create(*commodity_, details);
+ commodity_pool_t::current_pool->find_or_create(*commodity_, details);
}
// Quickly scan through and verify the correctness of the amount's use of
@@ -1083,59 +1083,59 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
if (ch == '.') {
if (no_more_periods)
- throw_(amount_error, _("Too many periods in amount"));
+ throw_(amount_error, _("Too many periods in amount"));
if (decimal_comma_style) {
- if (decimal_offset % 3 != 0)
- throw_(amount_error, _("Incorrect use of thousand-mark period"));
- comm_flags |= COMMODITY_STYLE_THOUSANDS;
- no_more_commas = true;
+ if (decimal_offset % 3 != 0)
+ throw_(amount_error, _("Incorrect use of thousand-mark period"));
+ comm_flags |= COMMODITY_STYLE_THOUSANDS;
+ no_more_commas = true;
} else {
- if (last_comma != string::npos) {
- decimal_comma_style = true;
- if (decimal_offset % 3 != 0)
- throw_(amount_error, _("Incorrect use of thousand-mark period"));
- } else {
- no_more_periods = true;
- new_quantity->prec = decimal_offset;
- decimal_offset = 0;
- }
+ if (last_comma != string::npos) {
+ decimal_comma_style = true;
+ if (decimal_offset % 3 != 0)
+ throw_(amount_error, _("Incorrect use of thousand-mark period"));
+ } else {
+ no_more_periods = true;
+ new_quantity->prec = decimal_offset;
+ decimal_offset = 0;
+ }
}
if (last_period == string::npos)
- last_period = string_index;
+ last_period = string_index;
}
else if (ch == ',') {
if (no_more_commas)
- throw_(amount_error, _("Too many commas in amount"));
+ throw_(amount_error, _("Too many commas in amount"));
if (decimal_comma_style) {
- if (last_period != string::npos) {
- throw_(amount_error, _("Incorrect use of decimal comma"));
- } else {
- no_more_commas = true;
- new_quantity->prec = decimal_offset;
- decimal_offset = 0;
- }
+ if (last_period != string::npos) {
+ throw_(amount_error, _("Incorrect use of decimal comma"));
+ } else {
+ no_more_commas = true;
+ new_quantity->prec = decimal_offset;
+ decimal_offset = 0;
+ }
} else {
- if (decimal_offset % 3 != 0) {
- if (last_comma != string::npos ||
- last_period != string::npos) {
- throw_(amount_error, _("Incorrect use of thousand-mark comma"));
- } else {
- decimal_comma_style = true;
- no_more_commas = true;
- new_quantity->prec = decimal_offset;
- decimal_offset = 0;
- }
- } else {
- comm_flags |= COMMODITY_STYLE_THOUSANDS;
- no_more_periods = true;
- }
+ if (decimal_offset % 3 != 0) {
+ if (last_comma != string::npos ||
+ last_period != string::npos) {
+ throw_(amount_error, _("Incorrect use of thousand-mark comma"));
+ } else {
+ decimal_comma_style = true;
+ no_more_commas = true;
+ new_quantity->prec = decimal_offset;
+ decimal_offset = 0;
+ }
+ } else {
+ comm_flags |= COMMODITY_STYLE_THOUSANDS;
+ no_more_periods = true;
+ }
}
if (last_comma == string::npos)
- last_comma = string_index;
+ last_comma = string_index;
}
else {
decimal_offset++;
@@ -1163,11 +1163,11 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
string::size_type len = quant.length();
scoped_array<char> buf(new char[len + 1]);
const char * p = quant.c_str();
- char * t = buf.get();
+ char * t = buf.get();
while (*p) {
if (*p == ',' || *p == '.')
- p++;
+ p++;
*t++ = *p++;
}
*t = '\0';
@@ -1193,7 +1193,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
quantity = new_quantity.release();
if (! flags.has_flags(PARSE_NO_REDUCE))
- in_place_reduce(); // will not throw an exception
+ in_place_reduce(); // will not throw an exception
VERIFY(valid());
@@ -1201,7 +1201,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
}
void amount_t::parse_conversion(const string& larger_str,
- const string& smaller_str)
+ const string& smaller_str)
{
amount_t larger, smaller;
@@ -1213,7 +1213,7 @@ void amount_t::parse_conversion(const string& larger_str,
if (larger.commodity()) {
larger.commodity().set_smaller(smaller);
larger.commodity().add_flags(smaller.commodity().flags() |
- COMMODITY_NOMARKET);
+ COMMODITY_NOMARKET);
}
if (smaller.commodity())
smaller.commodity().set_larger(larger);
@@ -1239,7 +1239,7 @@ void amount_t::print(std::ostream& _out, const uint_least8_t flags) const
}
stream_out_mpq(out, MP(quantity), display_precision(),
- comm ? commodity().precision() : 0, comm);
+ comm ? commodity().precision() : 0, comm);
if (comm.has_flags(COMMODITY_STYLE_SUFFIXED)) {
if (comm.has_flags(COMMODITY_STYLE_SEPARATED))
@@ -1325,7 +1325,7 @@ void serialize(Archive& ar, MP_RAT& mpq, const unsigned int /* version */)
template <class Archive>
void serialize(Archive& ar, long unsigned int& integer,
- const unsigned int /* version */)
+ const unsigned int /* version */)
{
ar & make_binary_object(&integer, sizeof(long unsigned int));
}
@@ -1336,23 +1336,23 @@ void serialize(Archive& ar, long unsigned int& integer,
BOOST_CLASS_EXPORT(ledger::annotated_commodity_t)
template void boost::serialization::serialize(boost::archive::binary_iarchive&,
- MP_INT&, const unsigned int);
+ MP_INT&, const unsigned int);
template void boost::serialization::serialize(boost::archive::binary_oarchive&,
- MP_INT&, const unsigned int);
+ MP_INT&, const unsigned int);
template void boost::serialization::serialize(boost::archive::binary_iarchive&,
- MP_RAT&, const unsigned int);
+ MP_RAT&, const unsigned int);
template void boost::serialization::serialize(boost::archive::binary_oarchive&,
- MP_RAT&, const unsigned int);
+ MP_RAT&, const unsigned int);
template void boost::serialization::serialize(boost::archive::binary_iarchive&,
- long unsigned int&,
- const unsigned int);
+ long unsigned int&,
+ const unsigned int);
template void boost::serialization::serialize(boost::archive::binary_oarchive&,
- long unsigned int&,
- const unsigned int);
+ long unsigned int&,
+ const unsigned int);
template void ledger::amount_t::serialize(boost::archive::binary_iarchive&,
- const unsigned int);
+ const unsigned int);
template void ledger::amount_t::serialize(boost::archive::binary_oarchive&,
- const unsigned int);
+ const unsigned int);
#endif // HAVE_BOOST_SERIALIZATION
diff --git a/src/amount.h b/src/amount.h
index be4c5e45..929251d8 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -91,9 +91,9 @@ typedef basic_flags_t<parse_flags_enum_t, uint_least8_t> parse_flags_t;
*/
class amount_t
: public ordered_field_operators<amount_t,
- ordered_field_operators<amount_t, double,
- ordered_field_operators<amount_t, unsigned long,
- ordered_field_operators<amount_t, long> > > >
+ ordered_field_operators<amount_t, double,
+ ordered_field_operators<amount_t, unsigned long,
+ ordered_field_operators<amount_t, long> > > >
{
public:
/** Ready the amount subsystem for use.
@@ -125,8 +125,8 @@ protected:
struct bigint_t;
- bigint_t * quantity;
- commodity_t * commodity_;
+ bigint_t * quantity;
+ commodity_t * commodity_;
public:
/** @name Constructors
@@ -399,8 +399,8 @@ public:
$100.00.
*/
optional<amount_t>
- value(const optional<datetime_t>& moment = none,
- const optional<commodity_t&>& in_terms_of = none) const;
+ value(const optional<datetime_t>& moment = none,
+ const optional<commodity_t&>& in_terms_of = none) const;
amount_t price() const;
@@ -646,16 +646,16 @@ public:
parse(string, flags_t) also parses an amount from a string.
*/
bool parse(std::istream& in,
- const parse_flags_t& flags = PARSE_DEFAULT);
+ const parse_flags_t& flags = PARSE_DEFAULT);
bool parse(const string& str,
- const parse_flags_t& flags = PARSE_DEFAULT) {
+ const parse_flags_t& flags = PARSE_DEFAULT) {
std::istringstream stream(str);
bool result = parse(stream, flags);
return result;
}
static void parse_conversion(const string& larger_str,
- const string& smaller_str);
+ const string& smaller_str);
/*@}*/
@@ -683,7 +683,7 @@ public:
#define AMOUNT_PRINT_ELIDE_COMMODITY_QUOTES 0x08
void print(std::ostream& out,
- const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
+ const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
/*@}*/
@@ -760,7 +760,7 @@ inline std::istream& operator>>(std::istream& in, amount_t& amt) {
}
void to_xml(std::ostream& out, const amount_t& amt,
- bool commodity_details = false);
+ bool commodity_details = false);
} // namespace ledger
diff --git a/src/annotate.cc b/src/annotate.cc
index e1e64ac2..08b73443 100644
--- a/src/annotate.cc
+++ b/src/annotate.cc
@@ -47,20 +47,20 @@ void annotation_t::parse(std::istream& in)
char c = peek_next_nonws(in);
if (c == '{') {
if (price)
- throw_(amount_error, _("Commodity specifies more than one price"));
+ throw_(amount_error, _("Commodity specifies more than one price"));
in.get(c);
c = peek_next_nonws(in);
if (c == '=') {
- in.get(c);
- add_flags(ANNOTATION_PRICE_FIXATED);
+ in.get(c);
+ add_flags(ANNOTATION_PRICE_FIXATED);
}
READ_INTO(in, buf, 255, c, c != '}');
if (c == '}')
- in.get(c);
+ in.get(c);
else
- throw_(amount_error, _("Commodity price lacks closing brace"));
+ throw_(amount_error, _("Commodity price lacks closing brace"));
amount_t temp;
temp.parse(buf, PARSE_NO_MIGRATE);
@@ -70,27 +70,27 @@ void annotation_t::parse(std::istream& in)
}
else if (c == '[') {
if (date)
- throw_(amount_error, _("Commodity specifies more than one date"));
+ throw_(amount_error, _("Commodity specifies more than one date"));
in.get(c);
READ_INTO(in, buf, 255, c, c != ']');
if (c == ']')
- in.get(c);
+ in.get(c);
else
- throw_(amount_error, _("Commodity date lacks closing bracket"));
+ throw_(amount_error, _("Commodity date lacks closing bracket"));
date = parse_date(buf);
}
else if (c == '(') {
if (tag)
- throw_(amount_error, _("Commodity specifies more than one tag"));
+ throw_(amount_error, _("Commodity specifies more than one tag"));
in.get(c);
READ_INTO(in, buf, 255, c, c != ')');
if (c == ')')
- in.get(c);
+ in.get(c);
else
- throw_(amount_error, _("Commodity tag lacks closing parenthesis"));
+ throw_(amount_error, _("Commodity tag lacks closing parenthesis"));
tag = buf;
}
@@ -104,20 +104,20 @@ void annotation_t::parse(std::istream& in)
#if defined(DEBUG_ON)
if (SHOW_DEBUG("amounts.commodities") && *this) {
DEBUG("amounts.commodities",
- "Parsed commodity annotations: " << std::endl << *this);
+ "Parsed commodity annotations: " << std::endl << *this);
}
#endif
}
void annotation_t::print(std::ostream& out, bool keep_base,
- bool no_computed_annotations) const
+ bool no_computed_annotations) const
{
if (price &&
(! no_computed_annotations || ! has_flags(ANNOTATION_PRICE_CALCULATED)))
out << " {"
- << (has_flags(ANNOTATION_PRICE_FIXATED) ? "=" : "")
- << (keep_base ? *price : price->unreduced())
- << '}';
+ << (has_flags(ANNOTATION_PRICE_FIXATED) ? "=" : "")
+ << (keep_base ? *price : price->unreduced())
+ << '}';
if (date &&
(! no_computed_annotations || ! has_flags(ANNOTATION_DATE_CALCULATED)))
@@ -131,7 +131,7 @@ void annotation_t::print(std::ostream& out, bool keep_base,
bool keep_details_t::keep_all(const commodity_t& comm) const
{
return (! comm.has_annotation() ||
- (keep_price && keep_date && keep_tag && ! only_actuals));
+ (keep_price && keep_date && keep_tag && ! only_actuals));
}
bool keep_details_t::keep_any(const commodity_t& comm) const
@@ -159,22 +159,22 @@ commodity_t&
annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep)
{
DEBUG("commodity.annotated.strip",
- "Reducing commodity " << *this << std::endl
- << " keep price " << what_to_keep.keep_price << " "
- << " keep date " << what_to_keep.keep_date << " "
- << " keep tag " << what_to_keep.keep_tag);
+ "Reducing commodity " << *this << std::endl
+ << " keep price " << what_to_keep.keep_price << " "
+ << " keep date " << what_to_keep.keep_date << " "
+ << " keep tag " << what_to_keep.keep_tag);
commodity_t * new_comm;
- bool keep_price = (what_to_keep.keep_price &&
- (! what_to_keep.only_actuals ||
- ! details.has_flags(ANNOTATION_PRICE_CALCULATED)));
- bool keep_date = (what_to_keep.keep_date &&
- (! what_to_keep.only_actuals ||
- ! details.has_flags(ANNOTATION_DATE_CALCULATED)));
- bool keep_tag = (what_to_keep.keep_tag &&
- (! what_to_keep.only_actuals ||
- ! details.has_flags(ANNOTATION_TAG_CALCULATED)));
+ bool keep_price = (what_to_keep.keep_price &&
+ (! what_to_keep.only_actuals ||
+ ! details.has_flags(ANNOTATION_PRICE_CALCULATED)));
+ bool keep_date = (what_to_keep.keep_date &&
+ (! what_to_keep.only_actuals ||
+ ! details.has_flags(ANNOTATION_DATE_CALCULATED)));
+ bool keep_tag = (what_to_keep.keep_tag &&
+ (! what_to_keep.only_actuals ||
+ ! details.has_flags(ANNOTATION_TAG_CALCULATED)));
if ((keep_price && details.price) ||
(keep_date && details.date) ||
@@ -182,8 +182,8 @@ annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep)
{
new_comm = pool().find_or_create
(referent(), annotation_t(keep_price ? details.price : none,
- keep_date ? details.date : none,
- keep_tag ? details.tag : none));
+ keep_date ? details.date : none,
+ keep_tag ? details.tag : none));
} else {
new_comm = &referent();
}
diff --git a/src/annotate.h b/src/annotate.h
index 4f2f1b04..b590ca45 100644
--- a/src/annotate.h
+++ b/src/annotate.h
@@ -49,7 +49,7 @@
namespace ledger {
struct annotation_t : public supports_flags<>,
- public equality_comparable<annotation_t>
+ public equality_comparable<annotation_t>
{
#define ANNOTATION_PRICE_CALCULATED 0x01
#define ANNOTATION_PRICE_FIXATED 0x02
@@ -61,8 +61,8 @@ struct annotation_t : public supports_flags<>,
optional<string> tag;
explicit annotation_t(const optional<amount_t>& _price = none,
- const optional<date_t>& _date = none,
- const optional<string>& _tag = none)
+ const optional<date_t>& _date = none,
+ const optional<string>& _tag = none)
: supports_flags<>(), price(_price), date(_date), tag(_tag) {
TRACE_CTOR(annotation_t, "const optional<amount_t>& + date_t + string");
}
@@ -81,14 +81,14 @@ struct annotation_t : public supports_flags<>,
bool operator==(const annotation_t& rhs) const {
return (price == rhs.price &&
- date == rhs.date &&
- tag == rhs.tag);
+ date == rhs.date &&
+ tag == rhs.tag);
}
void parse(std::istream& in);
void print(std::ostream& out, bool keep_base = false,
- bool no_computed_annotations = false) const;
+ bool no_computed_annotations = false) const;
bool valid() const {
assert(*this);
@@ -142,9 +142,9 @@ struct keep_details_t
bool only_actuals;
explicit keep_details_t(bool _keep_price = false,
- bool _keep_date = false,
- bool _keep_tag = false,
- bool _only_actuals = false)
+ bool _keep_date = false,
+ bool _keep_tag = false,
+ bool _only_actuals = false)
: keep_price(_keep_price),
keep_date(_keep_date),
keep_tag(_keep_tag),
@@ -188,7 +188,7 @@ private:
};
inline std::ostream& operator<<(std::ostream& out,
- const annotation_t& details) {
+ const annotation_t& details) {
details.print(out);
return out;
}
@@ -196,8 +196,8 @@ inline std::ostream& operator<<(std::ostream& out,
class annotated_commodity_t
: public commodity_t,
public equality_comparable<annotated_commodity_t,
- equality_comparable2<annotated_commodity_t, commodity_t,
- noncopyable> >
+ equality_comparable2<annotated_commodity_t, commodity_t,
+ noncopyable> >
{
protected:
friend class commodity_pool_t;
@@ -205,7 +205,7 @@ protected:
commodity_t * ptr;
explicit annotated_commodity_t(commodity_t * _ptr,
- const annotation_t& _details)
+ const annotation_t& _details)
: commodity_t(_ptr->parent_, _ptr->base), ptr(_ptr), details(_details) {
TRACE_CTOR(annotated_commodity_t, "commodity_t *, annotation_t");
annotated = true;
@@ -232,7 +232,7 @@ public:
virtual commodity_t& strip_annotations(const keep_details_t& what_to_keep);
virtual void write_annotations(std::ostream& out,
- bool no_computed_annotations = false) const;
+ bool no_computed_annotations = false) const;
#if defined(HAVE_BOOST_SERIALIZATION)
private:
diff --git a/src/archive.cc b/src/archive.cc
index e7fc072e..28760512 100644
--- a/src/archive.cc
+++ b/src/archive.cc
@@ -59,9 +59,9 @@ BOOST_CLASS_EXPORT(ledger::auto_xact_t)
BOOST_CLASS_EXPORT(ledger::period_xact_t)
template void ledger::journal_t::serialize(boost::archive::binary_oarchive&,
- const unsigned int);
+ const unsigned int);
template void ledger::journal_t::serialize(boost::archive::binary_iarchive&,
- const unsigned int);
+ const unsigned int);
namespace ledger {
namespace {
@@ -113,7 +113,7 @@ bool archive_t::read_header()
iarchive >> *this;
DEBUG("archive.journal",
- "Version number: " << std::hex << ARCHIVE_VERSION << std::dec);
+ "Version number: " << std::hex << ARCHIVE_VERSION << std::dec);
DEBUG("archive.journal", "Number of sources: " << sources.size());
#if defined(DEBUG_ON)
@@ -152,7 +152,7 @@ bool archive_t::should_load(const std::list<path>& data_files)
if (data_files.size() != sources.size()) {
DEBUG("archive.journal", "No, number of sources doesn't match: "
- << data_files.size() << " != " << sources.size());
+ << data_files.size() << " != " << sources.size());
return false;
}
@@ -171,23 +171,23 @@ bool archive_t::should_load(const std::list<path>& data_files)
DEBUG("archive.journal", "Comparing against source file: " << *i.filename);
if (*i.filename == p) {
- if (! exists(*i.filename)) {
- DEBUG("archive.journal",
- "No, a referent source no longer exists: " << *i.filename);
- return false;
- }
-
- if (i.modtime != posix_time::from_time_t(last_write_time(p))) {
- DEBUG("archive.journal", "No, a source's modtime has changed: " << p);
- return false;
- }
-
- if (i.size != file_size(p)) {
- DEBUG("archive.journal", "No, a source's size has changed: " << p);
- return false;
- }
-
- found++;
+ if (! exists(*i.filename)) {
+ DEBUG("archive.journal",
+ "No, a referent source no longer exists: " << *i.filename);
+ return false;
+ }
+
+ if (i.modtime != posix_time::from_time_t(last_write_time(p))) {
+ DEBUG("archive.journal", "No, a source's modtime has changed: " << p);
+ return false;
+ }
+
+ if (i.size != file_size(p)) {
+ DEBUG("archive.journal", "No, a source's size has changed: " << p);
+ return false;
+ }
+
+ found++;
}
}
}
@@ -225,7 +225,7 @@ bool archive_t::should_save(journal_t& journal)
if (! exists(*i.filename)) {
DEBUG("archive.journal",
- "No, a source no longer exists: " << *i.filename);
+ "No, a source no longer exists: " << *i.filename);
return false;
}
@@ -258,11 +258,11 @@ void archive_t::save(journal_t& journal)
boost::archive::binary_oarchive oa(stream);
DEBUG("archive.journal", "Creating archive with version "
- << std::hex << ARCHIVE_VERSION << std::dec);
+ << std::hex << ARCHIVE_VERSION << std::dec);
oa << *this;
DEBUG("archive.journal",
- "Archiving journal with " << sources.size() << " sources");
+ "Archiving journal with " << sources.size() << " sources");
oa << journal;
INFO_FINISH(archive);
diff --git a/src/archive.h b/src/archive.h
index e954cd3e..1ebf3496 100644
--- a/src/archive.h
+++ b/src/archive.h
@@ -48,7 +48,7 @@ namespace ledger {
class archive_t
{
- path file;
+ path file;
std::list<journal_t::fileinfo_t> sources;
diff --git a/src/balance.cc b/src/balance.cc
index a8bc649d..7ce9d994 100644
--- a/src/balance.cc
+++ b/src/balance.cc
@@ -35,7 +35,7 @@
#include "commodity.h"
#include "annotate.h"
#include "pool.h"
-#include "unistring.h" // for justify()
+#include "unistring.h" // for justify()
namespace ledger {
@@ -71,7 +71,7 @@ balance_t& balance_t::operator+=(const amount_t& amt)
{
if (amt.is_null())
throw_(balance_error,
- _("Cannot add an uninitialized amount to a balance"));
+ _("Cannot add an uninitialized amount to a balance"));
if (amt.is_realzero())
return *this;
@@ -96,7 +96,7 @@ balance_t& balance_t::operator-=(const amount_t& amt)
{
if (amt.is_null())
throw_(balance_error,
- _("Cannot subtract an uninitialized amount from a balance"));
+ _("Cannot subtract an uninitialized amount from a balance"));
if (amt.is_realzero())
return *this;
@@ -116,7 +116,7 @@ balance_t& balance_t::operator*=(const amount_t& amt)
{
if (amt.is_null())
throw_(balance_error,
- _("Cannot multiply a balance by an uninitialized amount"));
+ _("Cannot multiply a balance by an uninitialized amount"));
if (is_realzero()) {
;
@@ -138,12 +138,12 @@ balance_t& balance_t::operator*=(const amount_t& amt)
amounts.begin()->second *= amt;
else
throw_(balance_error,
- _("Cannot multiply a balance with annotated commodities by a commoditized amount"));
+ _("Cannot multiply a balance with annotated commodities by a commoditized amount"));
}
else {
assert(amounts.size() > 1);
throw_(balance_error,
- _("Cannot multiply a multi-commodity balance by a commoditized amount"));
+ _("Cannot multiply a multi-commodity balance by a commoditized amount"));
}
return *this;
}
@@ -152,7 +152,7 @@ balance_t& balance_t::operator/=(const amount_t& amt)
{
if (amt.is_null())
throw_(balance_error,
- _("Cannot divide a balance by an uninitialized amount"));
+ _("Cannot divide a balance by an uninitialized amount"));
if (is_realzero()) {
;
@@ -174,19 +174,19 @@ balance_t& balance_t::operator/=(const amount_t& amt)
amounts.begin()->second /= amt;
else
throw_(balance_error,
- _("Cannot divide a balance with annotated commodities by a commoditized amount"));
+ _("Cannot divide a balance with annotated commodities by a commoditized amount"));
}
else {
assert(amounts.size() > 1);
throw_(balance_error,
- _("Cannot divide a multi-commodity balance by a commoditized amount"));
+ _("Cannot divide a multi-commodity balance by a commoditized amount"));
}
return *this;
}
optional<balance_t>
balance_t::value(const optional<datetime_t>& moment,
- const optional<commodity_t&>& in_terms_of) const
+ const optional<commodity_t&>& in_terms_of) const
{
balance_t temp;
bool resolved = false;
@@ -223,11 +223,11 @@ balance_t::commodity_amount(const optional<const commodity_t&>& commodity) const
// Try stripping annotations before giving an error.
balance_t temp(strip_annotations(keep_details_t()));
if (temp.amounts.size() == 1)
- return temp.commodity_amount(commodity);
+ return temp.commodity_amount(commodity);
throw_(amount_error,
- _("Requested amount of a balance with multiple commodities: %1")
- << temp);
+ _("Requested amount of a balance with multiple commodities: %1")
+ << temp);
}
}
else if (amounts.size() > 0) {
@@ -251,9 +251,9 @@ balance_t::strip_annotations(const keep_details_t& what_to_keep) const
}
void balance_t::print(std::ostream& out,
- const int first_width,
- const int latter_width,
- const uint_least8_t flags) const
+ const int first_width,
+ const int latter_width,
+ const uint_least8_t flags) const
{
bool first = true;
int lwidth = latter_width;
@@ -269,7 +269,7 @@ void balance_t::print(std::ostream& out,
sorted.push_back(&pair.second);
std::stable_sort(sorted.begin(), sorted.end(),
- commodity_t::compare_by_commodity());
+ commodity_t::compare_by_commodity());
foreach (const amount_t * amount, sorted) {
int width;
@@ -284,7 +284,7 @@ void balance_t::print(std::ostream& out,
std::ostringstream buf;
amount->print(buf, flags);
justify(out, buf.str(), width, flags & AMOUNT_PRINT_RIGHT_JUSTIFY,
- flags & AMOUNT_PRINT_COLORIZE && amount->sign() < 0);
+ flags & AMOUNT_PRINT_COLORIZE && amount->sign() < 0);
}
if (first) {
diff --git a/src/balance.h b/src/balance.h
index 12d7bc02..ac22f3e7 100644
--- a/src/balance.h
+++ b/src/balance.h
@@ -65,19 +65,19 @@ DECLARE_EXCEPTION(balance_error, std::runtime_error);
*/
class balance_t
: public equality_comparable<balance_t,
- equality_comparable<balance_t, amount_t,
- equality_comparable<balance_t, double,
- equality_comparable<balance_t, unsigned long,
- equality_comparable<balance_t, long,
- additive<balance_t,
- additive<balance_t, amount_t,
- additive<balance_t, double,
- additive<balance_t, unsigned long,
- additive<balance_t, long,
- multiplicative<balance_t, amount_t,
- multiplicative<balance_t, double,
- multiplicative<balance_t, unsigned long,
- multiplicative<balance_t, long> > > > > > > > > > > > > >
+ equality_comparable<balance_t, amount_t,
+ equality_comparable<balance_t, double,
+ equality_comparable<balance_t, unsigned long,
+ equality_comparable<balance_t, long,
+ additive<balance_t,
+ additive<balance_t, amount_t,
+ additive<balance_t, double,
+ additive<balance_t, unsigned long,
+ additive<balance_t, long,
+ multiplicative<balance_t, amount_t,
+ multiplicative<balance_t, double,
+ multiplicative<balance_t, unsigned long,
+ multiplicative<balance_t, long> > > > > > > > > > > > > >
{
public:
typedef std::map<commodity_t *, amount_t> amounts_map;
@@ -111,7 +111,7 @@ public:
TRACE_CTOR(balance_t, "const amount_t&");
if (amt.is_null())
throw_(balance_error,
- _("Cannot initialize a balance from an uninitialized amount"));
+ _("Cannot initialize a balance from an uninitialized amount"));
if (! amt.is_realzero())
amounts.insert(amounts_map::value_type(&amt.commodity(), amt));
}
@@ -153,7 +153,7 @@ public:
balance_t& operator=(const amount_t& amt) {
if (amt.is_null())
throw_(balance_error,
- _("Cannot assign an uninitialized amount to a balance"));
+ _("Cannot assign an uninitialized amount to a balance"));
amounts.clear();
if (! amt.is_realzero())
@@ -187,17 +187,17 @@ public:
bool operator==(const balance_t& bal) const {
amounts_map::const_iterator i, j;
for (i = amounts.begin(), j = bal.amounts.begin();
- i != amounts.end() && j != bal.amounts.end();
- i++, j++) {
+ i != amounts.end() && j != bal.amounts.end();
+ i++, j++) {
if (! (i->first == j->first && i->second == j->second))
- return false;
+ return false;
}
return i == amounts.end() && j == bal.amounts.end();
}
bool operator==(const amount_t& amt) const {
if (amt.is_null())
throw_(balance_error,
- _("Cannot compare a balance to an uninitialized amount"));
+ _("Cannot compare a balance to an uninitialized amount"));
if (amt.is_realzero())
return amounts.empty();
@@ -384,8 +384,8 @@ public:
}
optional<balance_t>
- value(const optional<datetime_t>& moment = none,
- const optional<commodity_t&>& in_terms_of = none) const;
+ value(const optional<datetime_t>& moment = none,
+ const optional<commodity_t&>& in_terms_of = none) const;
balance_t price() const;
@@ -417,7 +417,7 @@ public:
foreach (const amounts_map::value_type& pair, amounts)
if (pair.second.is_nonzero())
- return true;
+ return true;
return false;
}
@@ -427,7 +427,7 @@ public:
foreach (const amounts_map::value_type& pair, amounts)
if (! pair.second.is_zero())
- return false;
+ return false;
return true;
}
@@ -437,7 +437,7 @@ public:
foreach (const amounts_map::value_type& pair, amounts)
if (! pair.second.is_realzero())
- return false;
+ return false;
return true;
}
@@ -468,7 +468,7 @@ public:
return amounts.begin()->second;
else
throw_(balance_error,
- _("Cannot convert a balance with multiple commodities to an amount"));
+ _("Cannot convert a balance with multiple commodities to an amount"));
return amount_t();
}
@@ -529,10 +529,10 @@ public:
* relative amounts of those commodities. There is no option to
* change this behavior.
*/
- void print(std::ostream& out,
- const int first_width = -1,
- const int latter_width = -1,
- const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
+ void print(std::ostream& out,
+ const int first_width = -1,
+ const int latter_width = -1,
+ const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
/**
* Debugging methods. There are two methods defined to help with
@@ -550,9 +550,9 @@ public:
bool first = true;
foreach (const amounts_map::value_type& pair, amounts) {
if (first)
- first = false;
+ first = false;
else
- out << ", ";
+ out << ", ";
pair.second.print(out);
}
out << ")";
@@ -561,8 +561,8 @@ public:
bool valid() const {
foreach (const amounts_map::value_type& pair, amounts)
if (! pair.second.valid()) {
- DEBUG("ledger.validate", "balance_t: ! pair.second.valid()");
- return false;
+ DEBUG("ledger.validate", "balance_t: ! pair.second.valid()");
+ return false;
}
return true;
}
diff --git a/src/chain.cc b/src/chain.cc
index 9a74cdca..49e0e470 100644
--- a/src/chain.cc
+++ b/src/chain.cc
@@ -40,7 +40,7 @@
namespace ledger {
post_handler_ptr chain_pre_post_handlers(post_handler_ptr base_handler,
- report_t& report)
+ report_t& report)
{
post_handler_ptr handler(base_handler);
@@ -52,11 +52,11 @@ post_handler_ptr chain_pre_post_handlers(post_handler_ptr base_handler,
// This filter_posts will only pass through posts matching the `predicate'.
if (report.HANDLED(limit_)) {
DEBUG("report.predicate",
- "Report predicate expression = " << report.HANDLER(limit_).str());
+ "Report predicate expression = " << report.HANDLER(limit_).str());
handler.reset(new filter_posts
- (handler, predicate_t(report.HANDLER(limit_).str(),
- report.what_to_keep()),
- report));
+ (handler, predicate_t(report.HANDLER(limit_).str(),
+ report.what_to_keep()),
+ report));
}
// budget_posts takes a set of posts from a data file and uses them to
@@ -68,7 +68,7 @@ post_handler_ptr chain_pre_post_handlers(post_handler_ptr base_handler,
if (report.budget_flags != BUDGET_NO_BUDGET) {
budget_posts * budget_handler = new budget_posts(handler,
- report.budget_flags);
+ report.budget_flags);
budget_handler->add_period_xacts(report.session.journal->period_xacts);
handler.reset(budget_handler);
@@ -78,41 +78,41 @@ post_handler_ptr chain_pre_post_handlers(post_handler_ptr base_handler,
// the filter get reported.
if (report.HANDLED(limit_))
handler.reset(new filter_posts
- (handler, predicate_t(report.HANDLER(limit_).str(),
- report.what_to_keep()),
- report));
+ (handler, predicate_t(report.HANDLER(limit_).str(),
+ report.what_to_keep()),
+ report));
}
else if (report.HANDLED(forecast_while_)) {
forecast_posts * forecast_handler
= new forecast_posts(handler,
- predicate_t(report.HANDLER(forecast_while_).str(),
- report.what_to_keep()),
- report,
- report.HANDLED(forecast_years_) ?
- static_cast<std::size_t>
- (report.HANDLER(forecast_years_).value.to_long()) :
- 5UL);
+ predicate_t(report.HANDLER(forecast_while_).str(),
+ report.what_to_keep()),
+ report,
+ report.HANDLED(forecast_years_) ?
+ static_cast<std::size_t>
+ (report.HANDLER(forecast_years_).value.to_long()) :
+ 5UL);
forecast_handler->add_period_xacts(report.session.journal->period_xacts);
handler.reset(forecast_handler);
// See above, under budget_posts.
if (report.HANDLED(limit_))
handler.reset(new filter_posts
- (handler, predicate_t(report.HANDLER(limit_).str(),
- report.what_to_keep()),
- report));
+ (handler, predicate_t(report.HANDLER(limit_).str(),
+ report.what_to_keep()),
+ report));
}
return handler;
}
post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
- report_t& report,
- bool for_accounts_report)
+ report_t& report,
+ bool for_accounts_report)
{
- post_handler_ptr handler(base_handler);
- predicate_t display_predicate;
- predicate_t only_predicate;
+ post_handler_ptr handler(base_handler);
+ predicate_t display_predicate;
+ predicate_t only_predicate;
display_filter_posts * display_filter = NULL;
assert(report.HANDLED(amount_));
@@ -123,34 +123,34 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
// Make sure only forecast postings which match are allowed through
if (report.HANDLED(forecast_while_)) {
handler.reset(new filter_posts
- (handler, predicate_t(report.HANDLER(forecast_while_).str(),
- report.what_to_keep()),
- report));
+ (handler, predicate_t(report.HANDLER(forecast_while_).str(),
+ report.what_to_keep()),
+ report));
}
// truncate_xacts cuts off a certain number of _xacts_ from being
// displayed. It does not affect calculation.
if (report.HANDLED(head_) || report.HANDLED(tail_))
handler.reset
- (new truncate_xacts(handler,
- report.HANDLED(head_) ?
- report.HANDLER(head_).value.to_int() : 0,
- report.HANDLED(tail_) ?
- report.HANDLER(tail_).value.to_int() : 0));
+ (new truncate_xacts(handler,
+ report.HANDLED(head_) ?
+ report.HANDLER(head_).value.to_int() : 0,
+ report.HANDLED(tail_) ?
+ report.HANDLER(tail_).value.to_int() : 0));
// changed_value_posts adds virtual posts to the list to account for changes
// in market value of commodities, which otherwise would affect the running
// total unpredictably.
display_filter = new display_filter_posts(handler, report,
- report.HANDLED(revalued) &&
- ! report.HANDLED(no_rounding));
+ report.HANDLED(revalued) &&
+ ! report.HANDLED(no_rounding));
handler.reset(display_filter);
// filter_posts will only pass through posts matching the
// `display_predicate'.
if (report.HANDLED(display_)) {
display_predicate = predicate_t(report.HANDLER(display_).str(),
- report.what_to_keep());
+ report.what_to_keep());
handler.reset(new filter_posts(handler, display_predicate, report));
}
}
@@ -161,21 +161,21 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
if (report.HANDLED(revalued) &&
(! for_accounts_report || report.HANDLED(unrealized)))
handler.reset(new changed_value_posts(handler, report, for_accounts_report,
- report.HANDLED(unrealized),
- display_filter));
+ report.HANDLED(unrealized),
+ display_filter));
// calc_posts computes the running total. When this appears will determine,
// for example, whether filtered posts are included or excluded from the
// running total.
handler.reset(new calc_posts(handler, expr, (! for_accounts_report ||
- (report.HANDLED(revalued) &&
- report.HANDLED(unrealized)))));
+ (report.HANDLED(revalued) &&
+ report.HANDLED(unrealized)))));
// filter_posts will only pass through posts matching the
// `secondary_predicate'.
if (report.HANDLED(only_)) {
only_predicate = predicate_t(report.HANDLER(only_).str(),
- report.what_to_keep());
+ report.what_to_keep());
handler.reset(new filter_posts(handler, only_predicate, report));
}
@@ -184,13 +184,13 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
// value expression.
if (report.HANDLED(sort_)) {
if (report.HANDLED(sort_xacts_))
- handler.reset(new sort_xacts(handler, report.HANDLER(sort_).str()));
+ handler.reset(new sort_xacts(handler, report.HANDLER(sort_).str()));
else
- handler.reset(new sort_posts(handler, report.HANDLER(sort_).str()));
+ handler.reset(new sort_posts(handler, report.HANDLER(sort_).str()));
}
#if 0
else if (! report.HANDLED(period_) &&
- ! report.HANDLED(unsorted)) {
+ ! report.HANDLED(unsorted)) {
handler.reset(new sort_posts(handler, "date"));
}
#endif
@@ -199,8 +199,8 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
// with a subtotaled post for each commodity used.
if (report.HANDLED(collapse))
handler.reset(new collapse_posts(handler, report, expr,
- display_predicate, only_predicate,
- report.HANDLED(collapse_if_zero)));
+ display_predicate, only_predicate,
+ report.HANDLED(collapse_if_zero)));
// subtotal_posts combines all the posts it receives into one subtotal
// xact, which has one post for each commodity in each account.
@@ -225,37 +225,37 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
// weekly or monthly.
if (report.HANDLED(period_)) {
handler.reset(new interval_posts(handler, expr,
- report.HANDLER(period_).str(),
- report.HANDLED(exact),
- report.HANDLED(empty)));
+ report.HANDLER(period_).str(),
+ report.HANDLED(exact),
+ report.HANDLED(empty)));
handler.reset(new sort_posts(handler, "date"));
}
if (report.HANDLED(date_))
handler.reset(new transfer_details(handler, transfer_details::SET_DATE,
- report.session.journal->master,
- report.HANDLER(date_).str(),
- report));
+ report.session.journal->master,
+ report.HANDLER(date_).str(),
+ report));
if (report.HANDLED(account_)) {
handler.reset(new transfer_details(handler, transfer_details::SET_ACCOUNT,
- report.session.journal->master,
- report.HANDLER(account_).str(),
- report));
+ report.session.journal->master,
+ report.HANDLER(account_).str(),
+ report));
}
else if (report.HANDLED(pivot_)) {
string pivot = report.HANDLER(pivot_).str();
pivot = string("\"") + pivot + ":\" + tag(\"" + pivot + "\")";
handler.reset(new transfer_details(handler, transfer_details::SET_ACCOUNT,
- report.session.journal->master, pivot,
- report));
+ report.session.journal->master, pivot,
+ report));
}
if (report.HANDLED(payee_))
handler.reset(new transfer_details(handler, transfer_details::SET_PAYEE,
- report.session.journal->master,
- report.HANDLER(payee_).str(),
- report));
+ report.session.journal->master,
+ report.HANDLER(payee_).str(),
+ report));
// related_posts will pass along all posts related to the post received. If
// the `related_all' handler is on, then all the xact's posts are passed;
diff --git a/src/chain.h b/src/chain.h
index 1a50a077..7bd76712 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -94,17 +94,17 @@ class report_t;
post_handler_ptr
chain_pre_post_handlers(post_handler_ptr base_handler,
- report_t& report);
+ report_t& report);
post_handler_ptr
chain_post_handlers(post_handler_ptr base_handler,
- report_t& report,
- bool for_accounts_report = false);
+ report_t& report,
+ bool for_accounts_report = false);
inline post_handler_ptr
chain_handlers(post_handler_ptr handler,
- report_t& report,
- bool for_accounts_report = false) {
+ report_t& report,
+ bool for_accounts_report = false) {
handler = chain_post_handlers(handler, report, for_accounts_report);
handler = chain_pre_post_handlers(handler, report);
return handler;
diff --git a/src/commodity.cc b/src/commodity.cc
index 44d14c56..230113e8 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -41,13 +41,13 @@ namespace ledger {
bool commodity_t::decimal_comma_by_default = false;
void commodity_t::history_t::add_price(commodity_t& source,
- const datetime_t& date,
- const amount_t& price,
- const bool reflexive)
+ const datetime_t& date,
+ const amount_t& price,
+ const bool reflexive)
{
DEBUG("commodity.prices.add", "add_price to " << source
- << (reflexive ? " (secondary)" : " (primary)")
- << " : " << date << ", " << price);
+ << (reflexive ? " (secondary)" : " (primary)")
+ << " : " << date << ", " << price);
history_map::iterator i = prices.find(date);
if (i != prices.end()) {
@@ -64,7 +64,7 @@ void commodity_t::history_t::add_price(commodity_t& source,
price.commodity().add_price(date, inverse, false);
} else {
DEBUG("commodity.prices.add",
- "marking commodity " << source.symbol() << " as primary");
+ "marking commodity " << source.symbol() << " as primary");
source.add_flags(COMMODITY_PRIMARY);
}
}
@@ -81,15 +81,15 @@ bool commodity_t::history_t::remove_price(const datetime_t& date)
void commodity_t::varied_history_t::
add_price(commodity_t& source,
- const datetime_t& date,
- const amount_t& price,
- const bool reflexive)
+ const datetime_t& date,
+ const amount_t& price,
+ const bool reflexive)
{
optional<history_t&> hist = history(price.commodity());
if (! hist) {
std::pair<history_by_commodity_map::iterator, bool> result
= histories.insert(history_by_commodity_map::value_type
- (&price.commodity(), history_t()));
+ (&price.commodity(), history_t()));
assert(result.second);
hist = (*result.first).second;
@@ -100,7 +100,7 @@ void commodity_t::varied_history_t::
}
bool commodity_t::varied_history_t::remove_price(const datetime_t& date,
- commodity_t& comm)
+ commodity_t& comm)
{
DEBUG("commodity.prices.add", "varied_remove_price: " << date << ", " << comm);
@@ -111,21 +111,21 @@ bool commodity_t::varied_history_t::remove_price(const datetime_t& date,
optional<price_point_t>
commodity_t::history_t::find_price(const optional<datetime_t>& moment,
- const optional<datetime_t>& oldest
+ const optional<datetime_t>& oldest
#if defined(DEBUG_ON)
- , const int indent
+ , const int indent
#endif
- ) const
+ ) const
{
price_point_t point;
bool found = false;
#if defined(DEBUG_ON)
-#define DEBUG_INDENT(cat, indent) \
- do { \
- if (SHOW_DEBUG(cat)) \
- for (int i = 0; i < indent; i++) \
- ledger::_log_buffer << " "; \
+#define DEBUG_INDENT(cat, indent) \
+ do { \
+ if (SHOW_DEBUG(cat)) \
+ for (int i = 0; i < indent; i++) \
+ ledger::_log_buffer << " "; \
} while (false)
#else
#define DEBUG_INDENT(cat, indent)
@@ -171,15 +171,15 @@ commodity_t::history_t::find_price(const optional<datetime_t>& moment,
} else {
point.when = (*i).first;
if (*moment < point.when) {
- if (i != prices.begin()) {
- --i;
- point.when = (*i).first;
- point.price = (*i).second;
- found = true;
- }
+ if (i != prices.begin()) {
+ --i;
+ point.when = (*i).first;
+ point.price = (*i).second;
+ found = true;
+ }
} else {
- point.price = (*i).second;
- found = true;
+ point.price = (*i).second;
+ found = true;
}
DEBUG_INDENT("commodity.prices.find", indent);
@@ -205,23 +205,23 @@ commodity_t::history_t::find_price(const optional<datetime_t>& moment,
else {
DEBUG_INDENT("commodity.prices.find", indent);
DEBUG("commodity.prices.find",
- "returning price: " << point.when << ", " << point.price);
+ "returning price: " << point.when << ", " << point.price);
return point;
}
}
optional<price_point_t>
commodity_t::varied_history_t::find_price(const commodity_t& source,
- const optional<commodity_t&>& commodity,
- const optional<datetime_t>& moment,
- const optional<datetime_t>& oldest
+ const optional<commodity_t&>& commodity,
+ const optional<datetime_t>& moment,
+ const optional<datetime_t>& oldest
#if defined(DEBUG_ON)
- , const int indent
+ , const int indent
#endif
- ) const
+ ) const
{
optional<price_point_t> point;
- optional<datetime_t> limit = oldest;
+ optional<datetime_t> limit = oldest;
#if defined(VERIFY_ON)
if (commodity) {
@@ -266,61 +266,61 @@ commodity_t::varied_history_t::find_price(const commodity_t& source,
DEBUG_INDENT("commodity.prices.find", indent + 1);
DEBUG("commodity.prices.find",
- "searching for price via commodity '" << comm << "'");
+ "searching for price via commodity '" << comm << "'");
point = hist.second.find_price(moment, limit
#if defined(DEBUG_ON)
- , indent + 2
+ , indent + 2
#endif
- );
+ );
assert(! point || point->price.commodity() == comm);
if (point) {
optional<price_point_t> xlat;
if (commodity && comm != *commodity) {
- DEBUG_INDENT("commodity.prices.find", indent + 1);
- DEBUG("commodity.prices.find", "looking for translation price");
+ DEBUG_INDENT("commodity.prices.find", indent + 1);
+ DEBUG("commodity.prices.find", "looking for translation price");
- xlat = comm.find_price(commodity, moment, limit, true
+ xlat = comm.find_price(commodity, moment, limit, true
#if defined(DEBUG_ON)
- , indent + 2
+ , indent + 2
#endif
- );
- if (xlat) {
- DEBUG_INDENT("commodity.prices.find", indent + 1);
- DEBUG("commodity.prices.find", "found translated price "
- << xlat->price << " from " << xlat->when);
-
- point->price = xlat->price * point->price;
- if (xlat->when < point->when) {
- point->when = xlat->when;
-
- DEBUG_INDENT("commodity.prices.find", indent + 1);
- DEBUG("commodity.prices.find",
- "adjusting date of result back to " << point->when);
- }
- } else {
- DEBUG_INDENT("commodity.prices.find", indent + 1);
- DEBUG("commodity.prices.find", "saw no translated price there");
- continue;
- }
+ );
+ if (xlat) {
+ DEBUG_INDENT("commodity.prices.find", indent + 1);
+ DEBUG("commodity.prices.find", "found translated price "
+ << xlat->price << " from " << xlat->when);
+
+ point->price = xlat->price * point->price;
+ if (xlat->when < point->when) {
+ point->when = xlat->when;
+
+ DEBUG_INDENT("commodity.prices.find", indent + 1);
+ DEBUG("commodity.prices.find",
+ "adjusting date of result back to " << point->when);
+ }
+ } else {
+ DEBUG_INDENT("commodity.prices.find", indent + 1);
+ DEBUG("commodity.prices.find", "saw no translated price there");
+ continue;
+ }
}
assert(! commodity || point->price.commodity() == *commodity);
DEBUG_INDENT("commodity.prices.find", indent + 1);
DEBUG("commodity.prices.find",
- "saw a price there: " << point->price << " from " << point->when);
+ "saw a price there: " << point->price << " from " << point->when);
if (! limit || point->when > *limit) {
- limit = point->when;
- best = *point;
- found = true;
+ limit = point->when;
+ best = *point;
+ found = true;
- DEBUG_INDENT("commodity.prices.find", indent + 1);
- DEBUG("commodity.prices.find",
- "search limit adjusted to " << *limit);
+ DEBUG_INDENT("commodity.prices.find", indent + 1);
+ DEBUG("commodity.prices.find",
+ "search limit adjusted to " << *limit);
}
} else {
DEBUG_INDENT("commodity.prices.find", indent + 1);
@@ -331,7 +331,7 @@ commodity_t::varied_history_t::find_price(const commodity_t& source,
if (found) {
DEBUG_INDENT("commodity.prices.find", indent);
DEBUG("commodity.download",
- "found price " << best.price << " from " << best.when);
+ "found price " << best.price << " from " << best.when);
return best;
}
return none;
@@ -358,13 +358,13 @@ commodity_t::varied_history_t::history(const optional<commodity_t&>& commodity)
optional<price_point_t>
commodity_t::find_price(const optional<commodity_t&>& commodity,
- const optional<datetime_t>& moment,
- const optional<datetime_t>& oldest,
- const bool nested
+ const optional<datetime_t>& moment,
+ const optional<datetime_t>& oldest,
+ const bool nested
#if defined(DEBUG_ON)
- , const int indent
+ , const int indent
#endif
- ) const
+ ) const
{
if (! has_flags(COMMODITY_WALKED) && base->varied_history) {
optional<base_t::time_and_commodity_t> pair;
@@ -375,26 +375,26 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
if (! nested) {
pair = base_t::time_and_commodity_t
- (base_t::optional_time_pair_t(moment, oldest),
- commodity ? &(*commodity) : NULL);
+ (base_t::optional_time_pair_t(moment, oldest),
+ commodity ? &(*commodity) : NULL);
DEBUG_INDENT("commodity.prices.find", indent);
DEBUG("commodity.prices.find", "looking for memoized args: "
- << (moment ? format_datetime(*moment) : "NONE") << ", "
- << (oldest ? format_datetime(*oldest) : "NONE") << ", "
- << (commodity ? commodity->symbol() : "NONE"));
+ << (moment ? format_datetime(*moment) : "NONE") << ", "
+ << (oldest ? format_datetime(*oldest) : "NONE") << ", "
+ << (commodity ? commodity->symbol() : "NONE"));
base_t::memoized_price_map::iterator i = base->price_map.find(*pair);
if (i != base->price_map.end()) {
- DEBUG_INDENT("commodity.prices.find", indent);
- DEBUG("commodity.prices.find", "found! returning: "
- << ((*i).second ? (*i).second->price : amount_t(0L)));
+ DEBUG_INDENT("commodity.prices.find", indent);
+ DEBUG("commodity.prices.find", "found! returning: "
+ << ((*i).second ? (*i).second->price : amount_t(0L)));
#if defined(VERIFY_ON)
- IF_VERIFY() {
- found = true;
- checkpoint = (*i).second;
- } else
+ IF_VERIFY() {
+ found = true;
+ checkpoint = (*i).second;
+ } else
#endif // defined(VERIFY_ON)
- return (*i).second;
+ return (*i).second;
}
}
@@ -406,11 +406,11 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
DEBUG("commodity.prices.find", "manually finding price...");
point = base->varied_history->find_price(*this, commodity,
- moment, oldest
+ moment, oldest
#if defined(DEBUG_ON)
- , indent
+ , indent
#endif
- );
+ );
}
catch (...) {
const_cast<commodity_t&>(*this).drop_flags(COMMODITY_WALKED);
@@ -427,19 +427,19 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
if (! nested && pair) {
if (base->price_map.size() > base_t::max_price_map_size) {
- DEBUG_INDENT("commodity.prices.find", indent);
- DEBUG("commodity.prices.find",
- "price map has grown too large, clearing it by half");
+ DEBUG_INDENT("commodity.prices.find", indent);
+ DEBUG("commodity.prices.find",
+ "price map has grown too large, clearing it by half");
- for (std::size_t i = 0; i < base_t::max_price_map_size >> 1; i++)
- base->price_map.erase(base->price_map.begin());
+ for (std::size_t i = 0; i < base_t::max_price_map_size >> 1; i++)
+ base->price_map.erase(base->price_map.begin());
}
DEBUG_INDENT("commodity.prices.find", indent);
DEBUG("commodity.prices.find",
- "remembered: " << (point ? point->price : amount_t(0L)));
+ "remembered: " << (point ? point->price : amount_t(0L)));
base->price_map.insert
- (base_t::memoized_price_map::value_type(*pair, point));
+ (base_t::memoized_price_map::value_type(*pair, point));
}
return point;
}
@@ -448,8 +448,8 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
optional<price_point_t>
commodity_t::check_for_updated_price(const optional<price_point_t>& point,
- const optional<datetime_t>& moment,
- const optional<commodity_t&>& in_terms_of)
+ const optional<datetime_t>& moment,
+ const optional<commodity_t&>& in_terms_of)
{
if (pool().get_quotes && ! has_flags(COMMODITY_NOMARKET)) {
bool exceeds_leeway = true;
@@ -457,28 +457,28 @@ commodity_t::check_for_updated_price(const optional<price_point_t>& point,
if (point) {
time_duration_t::sec_type seconds_diff;
if (moment) {
- seconds_diff = (*moment - point->when).total_seconds();
- DEBUG("commodity.download", "moment = " << *moment);
- DEBUG("commodity.download", "slip.moment = " << seconds_diff);
+ seconds_diff = (*moment - point->when).total_seconds();
+ DEBUG("commodity.download", "moment = " << *moment);
+ DEBUG("commodity.download", "slip.moment = " << seconds_diff);
} else {
- seconds_diff = (TRUE_CURRENT_TIME() - point->when).total_seconds();
- DEBUG("commodity.download", "slip.now = " << seconds_diff);
+ seconds_diff = (TRUE_CURRENT_TIME() - point->when).total_seconds();
+ DEBUG("commodity.download", "slip.now = " << seconds_diff);
}
DEBUG("commodity.download", "leeway = " << pool().quote_leeway);
if (seconds_diff < pool().quote_leeway)
- exceeds_leeway = false;
+ exceeds_leeway = false;
}
if (exceeds_leeway) {
DEBUG("commodity.download",
- "attempting to download a more current quote...");
+ "attempting to download a more current quote...");
if (optional<price_point_t> quote =
- pool().get_commodity_quote(*this, in_terms_of)) {
- if (! in_terms_of ||
- (quote->price.has_commodity() &&
- quote->price.commodity() == *in_terms_of))
- return quote;
+ pool().get_commodity_quote(*this, in_terms_of)) {
+ if (! in_terms_of ||
+ (quote->price.has_commodity() &&
+ quote->price.commodity() == *in_terms_of))
+ return quote;
}
}
}
@@ -568,43 +568,43 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
while (_p - buf < 255 && in.good() && ! in.eof() && c != '\n') {
std::size_t bytes = 0;
std::ptrdiff_t size = _p - buf;
- unsigned char d = c;
+ unsigned char d = c;
// Check for the start of a UTF-8 multi-byte encoded string
if (d >= 192 && d <= 223 && size < 254)
- bytes = 2;
+ bytes = 2;
else if (d >= 224 && d <= 239 && size < 253)
- bytes = 3;
+ bytes = 3;
else if (d >= 240 && d <= 247 && size < 252)
- bytes = 4;
+ bytes = 4;
else if (d >= 248 && d <= 251 && size < 251)
- bytes = 5;
+ bytes = 5;
else if (d >= 252 && d <= 253 && size < 250)
- bytes = 6;
+ bytes = 6;
else if (d >= 254) // UTF-8 encoding error
- break;
-
- if (bytes > 0) { // we're looking at a UTF-8 encoding
- for (std::size_t i = 0; i < bytes; i++) {
- in.get(c);
- if (in.bad() || in.eof())
- throw_(amount_error, _("Invalid UTF-8 encoding for commodity name"));
- *_p++ = c;
- }
+ break;
+
+ if (bytes > 0) { // we're looking at a UTF-8 encoding
+ for (std::size_t i = 0; i < bytes; i++) {
+ in.get(c);
+ if (in.bad() || in.eof())
+ throw_(amount_error, _("Invalid UTF-8 encoding for commodity name"));
+ *_p++ = c;
+ }
}
else if (invalid_chars[static_cast<unsigned char>(c)]) {
- break;
+ break;
}
else {
- in.get(c);
- if (in.eof())
- break;
- if (c == '\\') {
- in.get(c);
- if (in.eof())
- throw_(amount_error, _("Backslash at end of commodity name"));
- }
- *_p++ = c;
+ in.get(c);
+ if (in.eof())
+ break;
+ if (c == '\\') {
+ in.get(c);
+ if (in.eof())
+ throw_(amount_error, _("Backslash at end of commodity name"));
+ }
+ *_p++ = c;
}
c = static_cast<char>(in.peek());
@@ -657,7 +657,7 @@ bool commodity_t::valid() const
{
if (symbol().empty() && this != pool().null_commodity) {
DEBUG("ledger.validate",
- "commodity_t: symbol().empty() && this != null_commodity");
+ "commodity_t: symbol().empty() && this != null_commodity");
return false;
}
@@ -675,7 +675,7 @@ bool commodity_t::valid() const
}
bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
- const amount_t * right) const
+ const amount_t * right) const
{
commodity_t& leftcomm(left->commodity());
commodity_t& rightcomm(right->commodity());
@@ -707,14 +707,14 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
amount_t rightprice(*arightcomm.details.price);
if (leftprice.commodity() == rightprice.commodity()) {
- return (leftprice - rightprice).sign() < 0;
+ return (leftprice - rightprice).sign() < 0;
} else {
- // Since we have two different amounts, there's really no way
- // to establish a true sorting order; we'll just do it based
- // on the numerical values.
- leftprice.clear_commodity();
- rightprice.clear_commodity();
- return (leftprice - rightprice).sign() < 0;
+ // Since we have two different amounts, there's really no way
+ // to establish a true sorting order; we'll just do it based
+ // on the numerical values.
+ leftprice.clear_commodity();
+ rightprice.clear_commodity();
+ return (leftprice - rightprice).sign() < 0;
}
}
@@ -725,7 +725,7 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
if (aleftcomm.details.date && arightcomm.details.date) {
gregorian::date_duration diff =
- *aleftcomm.details.date - *arightcomm.details.date;
+ *aleftcomm.details.date - *arightcomm.details.date;
return diff.is_negative();
}
@@ -743,7 +743,7 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
}
void to_xml(std::ostream& out, const commodity_t& comm,
- bool commodity_details)
+ bool commodity_details)
{
push_xml x(out, "commodity", true);
@@ -769,21 +769,21 @@ void to_xml(std::ostream& out, const commodity_t& comm,
push_xml y(out, "varied-history");
foreach (const commodity_t::history_by_commodity_map::value_type& pair,
- comm.varied_history()->histories) {
- {
- push_xml z(out, "symbol");
- out << y.guard(pair.first->symbol());
- }
- {
- push_xml z(out, "history");
-
- foreach (const commodity_t::history_map::value_type& inner_pair,
- pair.second.prices) {
- push_xml w(out, "price-point");
- to_xml(out, inner_pair.first);
- to_xml(out, inner_pair.second);
- }
- }
+ comm.varied_history()->histories) {
+ {
+ push_xml z(out, "symbol");
+ out << y.guard(pair.first->symbol());
+ }
+ {
+ push_xml z(out, "history");
+
+ foreach (const commodity_t::history_map::value_type& inner_pair,
+ pair.second.prices) {
+ push_xml w(out, "price-point");
+ to_xml(out, inner_pair.first);
+ to_xml(out, inner_pair.second);
+ }
+ }
}
}
}
diff --git a/src/commodity.h b/src/commodity.h
index 42f15f33..f2275d0e 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -92,19 +92,19 @@ public:
{
history_map prices;
- void add_price(commodity_t& source,
- const datetime_t& date,
- const amount_t& price,
- const bool reflexive = true);
+ void add_price(commodity_t& source,
+ const datetime_t& date,
+ const amount_t& price,
+ const bool reflexive = true);
bool remove_price(const datetime_t& date);
optional<price_point_t>
find_price(const optional<datetime_t>& moment = none,
- const optional<datetime_t>& oldest = none
+ const optional<datetime_t>& oldest = none
#if defined(DEBUG_ON)
- , const int indent = 0
+ , const int indent = 0
#endif
- ) const;
+ ) const;
#if defined(HAVE_BOOST_SERIALIZATION)
private:
@@ -125,21 +125,21 @@ public:
{
history_by_commodity_map histories;
- void add_price(commodity_t& source,
- const datetime_t& date,
- const amount_t& price,
- const bool reflexive = true);
+ void add_price(commodity_t& source,
+ const datetime_t& date,
+ const amount_t& price,
+ const bool reflexive = true);
bool remove_price(const datetime_t& date, commodity_t& commodity);
optional<price_point_t>
- find_price(const commodity_t& source,
- const optional<commodity_t&>& commodity = none,
- const optional<datetime_t>& moment = none,
- const optional<datetime_t>& oldest = none
+ find_price(const commodity_t& source,
+ const optional<commodity_t&>& commodity = none,
+ const optional<datetime_t>& moment = none,
+ const optional<datetime_t>& oldest = none
#if defined(DEBUG_ON)
- , const int indent = 0
+ , const int indent = 0
#endif
- ) const;
+ ) const;
optional<history_t&>
history(const optional<commodity_t&>& commodity = none);
@@ -169,26 +169,26 @@ protected:
#define COMMODITY_STYLE_SEPARATED 0x002
#define COMMODITY_STYLE_DECIMAL_COMMA 0x004
#define COMMODITY_STYLE_THOUSANDS 0x008
-#define COMMODITY_NOMARKET 0x010
-#define COMMODITY_BUILTIN 0x020
-#define COMMODITY_WALKED 0x040
-#define COMMODITY_KNOWN 0x080
-#define COMMODITY_PRIMARY 0x100
+#define COMMODITY_NOMARKET 0x010
+#define COMMODITY_BUILTIN 0x020
+#define COMMODITY_WALKED 0x040
+#define COMMODITY_KNOWN 0x080
+#define COMMODITY_PRIMARY 0x100
- string symbol;
+ string symbol;
amount_t::precision_t precision;
- optional<string> name;
- optional<string> note;
+ optional<string> name;
+ optional<string> note;
optional<varied_history_t> varied_history;
- optional<amount_t> smaller;
- optional<amount_t> larger;
+ optional<amount_t> smaller;
+ optional<amount_t> larger;
typedef std::pair<optional<datetime_t>,
- optional<datetime_t> > optional_time_pair_t;
+ optional<datetime_t> > optional_time_pair_t;
typedef std::pair<optional_time_pair_t,
- commodity_t *> time_and_commodity_t;
+ commodity_t *> time_and_commodity_t;
typedef std::map<time_and_commodity_t,
- optional<price_point_t> > memoized_price_map;
+ optional<price_point_t> > memoized_price_map;
static const std::size_t max_price_map_size = 16;
mutable memoized_price_map price_map;
@@ -198,10 +198,10 @@ protected:
public:
explicit base_t(const string& _symbol)
: supports_flags<uint_least16_t>
- (commodity_t::decimal_comma_by_default ?
- static_cast<uint_least16_t>(COMMODITY_STYLE_DECIMAL_COMMA) :
- static_cast<uint_least16_t>(COMMODITY_STYLE_DEFAULTS)),
- symbol(_symbol), precision(0), searched(false) {
+ (commodity_t::decimal_comma_by_default ?
+ static_cast<uint_least16_t>(COMMODITY_STYLE_DECIMAL_COMMA) :
+ static_cast<uint_least16_t>(COMMODITY_STYLE_DEFAULTS)),
+ symbol(_symbol), precision(0), searched(false) {
TRACE_CTOR(base_t, "const string&");
}
virtual ~base_t() {
@@ -237,10 +237,10 @@ protected:
commodity_pool_t * parent_;
optional<string> qualified_symbol;
optional<string> mapping_key_;
- bool annotated;
+ bool annotated;
- explicit commodity_t(commodity_pool_t * _parent,
- const shared_ptr<base_t>& _base)
+ explicit commodity_t(commodity_pool_t * _parent,
+ const shared_ptr<base_t>& _base)
: delegates_flags<uint_least16_t>(*_base.get()), base(_base),
parent_(_parent), annotated(false) {
TRACE_CTOR(commodity_t, "commodity_pool_t *, shared_ptr<base_t>");
@@ -349,36 +349,36 @@ public:
// base->varied_history object.
void add_price(const datetime_t& date, const amount_t& price,
- const bool reflexive = true) {
+ const bool reflexive = true) {
if (! base->varied_history)
base->varied_history = varied_history_t();
base->varied_history->add_price(*this, date, price, reflexive);
DEBUG("commodity.prices.find", "Price added, clearing price_map");
- base->price_map.clear(); // a price was added, invalid the map
+ base->price_map.clear(); // a price was added, invalid the map
}
bool remove_price(const datetime_t& date, commodity_t& commodity) {
if (base->varied_history) {
base->varied_history->remove_price(date, commodity);
DEBUG("commodity.prices.find", "Price removed, clearing price_map");
- base->price_map.clear(); // a price was added, invalid the map
+ base->price_map.clear(); // a price was added, invalid the map
}
return false;
}
optional<price_point_t>
find_price(const optional<commodity_t&>& commodity = none,
- const optional<datetime_t>& moment = none,
- const optional<datetime_t>& oldest = none,
- const bool nested = false
+ const optional<datetime_t>& moment = none,
+ const optional<datetime_t>& oldest = none,
+ const bool nested = false
#if defined(DEBUG_ON)
- , const int indent = 0
+ , const int indent = 0
#endif
- ) const;
+ ) const;
optional<price_point_t>
check_for_updated_price(const optional<price_point_t>& point,
- const optional<datetime_t>& moment,
- const optional<commodity_t&>& in_terms_of);
+ const optional<datetime_t>& moment,
+ const optional<commodity_t&>& in_terms_of);
// Methods related to parsing, reading, writing, etc., the commodity
// itself.
@@ -432,7 +432,7 @@ inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) {
}
void to_xml(std::ostream& out, const commodity_t& comm,
- bool commodity_details = false);
+ bool commodity_details = false);
} // namespace ledger
diff --git a/src/compare.cc b/src/compare.cc
index f3c13cea..99e430a7 100644
--- a/src/compare.cc
+++ b/src/compare.cc
@@ -39,7 +39,7 @@
namespace ledger {
void push_sort_value(std::list<sort_value_t>& sort_values,
- expr_t::ptr_op_t node, scope_t& scope)
+ expr_t::ptr_op_t node, scope_t& scope)
{
if (node->kind == expr_t::op_t::O_CONS) {
push_sort_value(sort_values, node->left(), scope);
@@ -54,11 +54,11 @@ void push_sort_value(std::list<sort_value_t>& sort_values,
sort_values.push_back(sort_value_t());
sort_values.back().inverted = inverted;
- sort_values.back().value = expr_t(node).calc(scope).simplified();
+ sort_values.back().value = expr_t(node).calc(scope).simplified();
if (sort_values.back().value.is_null())
throw_(calc_error,
- _("Could not determine sorting value based an expression"));
+ _("Could not determine sorting value based an expression"));
}
}
@@ -106,7 +106,7 @@ bool compare_items<account_t>::operator()(account_t * left, account_t * right)
}
DEBUG("value.sort", "Comparing accounts " << left->fullname()
- << " <> " << right->fullname());
+ << " <> " << right->fullname());
return sort_value_is_less_than(lxdata.sort_values, rxdata.sort_values);
}
diff --git a/src/compare.h b/src/compare.h
index eeecd7cf..0ba9d424 100644
--- a/src/compare.h
+++ b/src/compare.h
@@ -50,7 +50,7 @@ class post_t;
class account_t;
void push_sort_value(std::list<sort_value_t>& sort_values,
- expr_t::ptr_op_t node, scope_t& scope);
+ expr_t::ptr_op_t node, scope_t& scope);
template <typename T>
class compare_items
@@ -84,14 +84,14 @@ bool compare_items<T>::operator()(T * left, T * right)
{
assert(left); assert(right);
return sort_value_is_less_than(find_sort_values(left),
- find_sort_values(right));
+ find_sort_values(right));
}
template <>
bool compare_items<post_t>::operator()(post_t * left, post_t * right);
template <>
bool compare_items<account_t>::operator()(account_t * left,
- account_t * right);
+ account_t * right);
} // namespace ledger
diff --git a/src/convert.cc b/src/convert.cc
index adb82dd4..f33a6b2e 100644
--- a/src/convert.cc
+++ b/src/convert.cc
@@ -46,8 +46,8 @@ namespace ledger {
value_t convert_command(call_scope_t& scope)
{
interactive_t args(scope, "s");
- report_t& report(find_scope<report_t>(scope));
- journal_t& journal(*report.session.journal.get());
+ report_t& report(find_scope<report_t>(scope));
+ journal_t& journal(*report.session.journal.get());
string bucket_name;
if (report.HANDLED(account_))
@@ -69,16 +69,16 @@ value_t convert_command(call_scope_t& scope)
xact_posts_iterator xact_iter(*xact);
while ((post = xact_iter()) != NULL) {
if (post->account == bucket)
- break;
+ break;
}
if (post) {
post_map_t::iterator i = post_map.find(post->amount);
if (i == post_map.end()) {
- std::list<post_t *> post_list;
- post_list.push_back(post);
- post_map.insert(post_map_t::value_type(post->amount, post_list));
+ std::list<post_t *> post_list;
+ post_list.push_back(post);
+ post_map.insert(post_map_t::value_type(post->amount, post_list));
} else {
- (*i).second.push_back(post);
+ (*i).second.push_back(post);
}
}
}
@@ -95,7 +95,7 @@ value_t convert_command(call_scope_t& scope)
while (xact_t * xact = reader.read_xact(journal, bucket)) {
if (report.HANDLED(invert)) {
foreach (post_t * post, xact->posts)
- post->amount.in_place_negate();
+ post->amount.in_place_negate();
}
bool matched = false;
@@ -103,46 +103,46 @@ value_t convert_command(call_scope_t& scope)
if (i != post_map.end()) {
std::list<post_t *>& post_list((*i).second);
foreach (post_t * post, post_list) {
- if (xact->code && post->xact->code &&
- *xact->code == *post->xact->code) {
- matched = true;
- break;
- }
- else if (xact->actual_date() == post->actual_date()) {
- matched = true;
- break;
- }
+ if (xact->code && post->xact->code &&
+ *xact->code == *post->xact->code) {
+ matched = true;
+ break;
+ }
+ else if (xact->actual_date() == post->actual_date()) {
+ matched = true;
+ break;
+ }
}
}
if (matched) {
DEBUG("convert.csv", "Ignored xact with code: " << *xact->code);
- checked_delete(xact); // ignore it
+ checked_delete(xact); // ignore it
}
else {
if (xact->posts.front()->account == NULL) {
- xacts_iterator xi;
- xi.xacts_i = current_xacts.begin();
- xi.xacts_end = current_xacts.end();
- xi.xacts_uninitialized = false;
-
- // jww (2010-03-07): Bind this logic to an option: --auto-match
- if (account_t * acct =
- lookup_probable_account(xact->payee, xi, bucket).second)
- xact->posts.front()->account = acct;
- else
- xact->posts.front()->account = unknown;
+ xacts_iterator xi;
+ xi.xacts_i = current_xacts.begin();
+ xi.xacts_end = current_xacts.end();
+ xi.xacts_uninitialized = false;
+
+ // jww (2010-03-07): Bind this logic to an option: --auto-match
+ if (account_t * acct =
+ lookup_probable_account(xact->payee, xi, bucket).second)
+ xact->posts.front()->account = acct;
+ else
+ xact->posts.front()->account = unknown;
}
if (! journal.add_xact(xact)) {
- checked_delete(xact);
- throw_(std::runtime_error,
- _("Failed to finalize derived transaction (check commodities)"));
+ checked_delete(xact);
+ throw_(std::runtime_error,
+ _("Failed to finalize derived transaction (check commodities)"));
}
else {
- xact_posts_iterator xact_iter(*xact);
- while (post_t * post = xact_iter())
- formatter(*post);
+ xact_posts_iterator xact_iter(*xact);
+ while (post_t * post = xact_iter())
+ formatter(*post);
}
}
}
diff --git a/src/csv.cc b/src/csv.cc
index 5a74232f..53a1ad98 100644
--- a/src/csv.cc
+++ b/src/csv.cc
@@ -51,29 +51,29 @@ string csv_reader::read_field(std::istream& in)
while (in.good() && ! in.eof()) {
in.get(x);
if (x == '\\') {
- in.get(x);
+ in.get(x);
}
else if (x == '"' && in.peek() == '"') {
- in.get(x);
+ in.get(x);
}
else if (x == c) {
- if (x == '|')
- in.unget();
- else if (in.peek() == ',')
- in.get(c);
- break;
+ if (x == '|')
+ in.unget();
+ else if (in.peek() == ',')
+ in.get(c);
+ break;
}
if (x != '\0')
- field += x;
+ field += x;
}
}
else {
while (in.good() && ! in.eof()) {
in.get(c);
if (c == ',')
- break;
+ break;
if (c != '\0')
- field += c;
+ field += c;
}
}
trim(field);
@@ -144,7 +144,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
xact->set_state(item_t::CLEARED);
- xact->pos = position_t();
+ xact->pos = position_t();
xact->pos->pathname = "jww (2010-03-05): unknown";
xact->pos->beg_pos = in.tellg();
xact->pos->beg_line = 0;
@@ -153,7 +153,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
post->xact = xact.get();
#if 0
- post->pos = position_t();
+ post->pos = position_t();
post->pos->pathname = pathname;
post->pos->beg_pos = line_beg_pos;
post->pos->beg_line = linenum;
@@ -163,7 +163,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
post->set_state(item_t::CLEARED);
post->account = NULL;
- int n = 0;
+ int n = 0;
amount_t amt;
string total;
@@ -173,12 +173,12 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
switch (index[n]) {
case FIELD_DATE:
if (field.empty())
- goto restart;
+ goto restart;
try {
- xact->_date = parse_date(field);
+ xact->_date = parse_date(field);
}
catch (date_error&) {
- goto restart;
+ goto restart;
}
break;
@@ -188,21 +188,21 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
case FIELD_CODE:
if (! field.empty())
- xact->code = field;
+ xact->code = field;
break;
case FIELD_PAYEE: {
bool found = false;
foreach (payee_mapping_t& value, journal.payee_mappings) {
- DEBUG("csv.mappings", "Looking for payee mapping: " << value.first);
- if (value.first.match(field)) {
- xact->payee = value.second;
- found = true;
- break;
- }
+ DEBUG("csv.mappings", "Looking for payee mapping: " << value.first);
+ if (value.first.match(field)) {
+ xact->payee = value.second;
+ found = true;
+ break;
+ }
}
if (! found)
- xact->payee = field;
+ xact->payee = field;
break;
}
@@ -210,8 +210,8 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
std::istringstream amount_str(field);
amt.parse(amount_str, PARSE_NO_REDUCE);
if (! amt.has_commodity() &&
- commodity_pool_t::current_pool->default_commodity)
- amt.set_commodity(*commodity_pool_t::current_pool->default_commodity);
+ commodity_pool_t::current_pool->default_commodity)
+ amt.set_commodity(*commodity_pool_t::current_pool->default_commodity);
post->amount = amt;
break;
}
@@ -220,9 +220,9 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
std::istringstream amount_str(field);
amt.parse(amount_str, PARSE_NO_REDUCE);
if (! amt.has_commodity() &&
- commodity_pool_t::current_pool->default_commodity)
- amt.set_commodity
- (*commodity_pool_t::current_pool->default_commodity);
+ commodity_pool_t::current_pool->default_commodity)
+ amt.set_commodity
+ (*commodity_pool_t::current_pool->default_commodity);
post->cost = amt;
break;
}
@@ -237,7 +237,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
case FIELD_UNKNOWN:
if (! names[n].empty() && ! field.empty())
- xact->set_tag(names[n], field);
+ xact->set_tag(names[n], field);
break;
}
n++;
@@ -245,7 +245,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
#if 0
xact->set_tag(_("Imported"),
- string(format_date(CURRENT_DATE(), FMT_WRITTEN)));
+ string(format_date(CURRENT_DATE(), FMT_WRITTEN)));
xact->set_tag(_("Original"), string(line));
xact->set_tag(_("SHA1"), string(sha1sum(line)));
#endif
@@ -268,7 +268,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
post->xact = xact.get();
#if 0
- post->pos = position_t();
+ post->pos = position_t();
post->pos->pathname = pathname;
post->pos->beg_pos = line_beg_pos;
post->pos->beg_line = linenum;
@@ -285,7 +285,7 @@ xact_t * csv_reader::read_xact(journal_t& journal, account_t * bucket)
std::istringstream assigned_amount_str(total);
amt.parse(assigned_amount_str, PARSE_NO_REDUCE);
if (! amt.has_commodity() &&
- commodity_pool_t::current_pool->default_commodity)
+ commodity_pool_t::current_pool->default_commodity)
amt.set_commodity(*commodity_pool_t::current_pool->default_commodity);
post->assigned_amount = amt;
}
diff --git a/src/draft.cc b/src/draft.cc
index d9f191b6..ba78fc42 100644
--- a/src/draft.cc
+++ b/src/draft.cc
@@ -57,45 +57,45 @@ void draft_t::xact_template_t::dump(std::ostream& out) const
if (payee_mask.empty())
out << _("Payee mask: INVALID (template expression will cause an error)")
- << std::endl;
+ << std::endl;
else
out << _("Payee mask: ") << payee_mask << std::endl;
if (posts.empty()) {
out << std::endl
- << _("<Posting copied from last related transaction>")
- << std::endl;
+ << _("<Posting copied from last related transaction>")
+ << std::endl;
} else {
bool has_only_from = true;
bool has_only_to = true;
foreach (const post_template_t& post, posts) {
if (post.from)
- has_only_to = false;
+ has_only_to = false;
else
- has_only_from = false;
+ has_only_from = false;
}
foreach (const post_template_t& post, posts) {
straccstream accum;
out << std::endl
- << ACCUM(accum << _("[Posting \"%1\"]")
- << (post.from ? _("from") : _("to")))
- << std::endl;
+ << ACCUM(accum << _("[Posting \"%1\"]")
+ << (post.from ? _("from") : _("to")))
+ << std::endl;
if (post.account_mask)
- out << _(" Account mask: ") << *post.account_mask << std::endl;
+ out << _(" Account mask: ") << *post.account_mask << std::endl;
else if (post.from)
- out << _(" Account mask: <use last of last related accounts>") << std::endl;
+ out << _(" Account mask: <use last of last related accounts>") << std::endl;
else
- out << _(" Account mask: <use first of last related accounts>") << std::endl;
+ out << _(" Account mask: <use first of last related accounts>") << std::endl;
if (post.amount)
- out << _(" Amount: ") << *post.amount << std::endl;
+ out << _(" Amount: ") << *post.amount << std::endl;
if (post.cost)
- out << _(" Cost: ") << *post.cost_operator
- << " " << *post.cost << std::endl;
+ out << _(" Cost: ") << *post.cost_operator
+ << " " << *post.cost << std::endl;
}
}
}
@@ -104,7 +104,7 @@ void draft_t::parse_args(const value_t& args)
{
regex date_mask(_("([0-9]+(?:[-/.][0-9]+)?(?:[-/.][0-9]+))?"));
smatch what;
- bool check_for_date = true;
+ bool check_for_date = true;
tmpl = xact_template_t();
@@ -116,16 +116,16 @@ void draft_t::parse_args(const value_t& args)
for (; begin != end; begin++) {
if (check_for_date &&
- regex_match((*begin).to_string(), what, date_mask)) {
+ regex_match((*begin).to_string(), what, date_mask)) {
tmpl->date = parse_date(what[0]);
check_for_date = false;
}
else if (check_for_date &&
- bool(weekday = string_to_day_of_week(what[0]))) {
+ bool(weekday = string_to_day_of_week(what[0]))) {
short dow = static_cast<short>(*weekday);
date_t date = CURRENT_DATE() - date_duration(1);
while (date.day_of_week() != dow)
- date -= date_duration(1);
+ date -= date_duration(1);
tmpl->date = date;
check_for_date = false;
}
@@ -133,80 +133,80 @@ void draft_t::parse_args(const value_t& args)
string arg = (*begin).to_string();
if (arg == "at") {
- if (begin == end)
- throw std::runtime_error(_("Invalid xact command arguments"));
- tmpl->payee_mask = (*++begin).to_string();
+ if (begin == end)
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ tmpl->payee_mask = (*++begin).to_string();
}
else if (arg == "to" || arg == "from") {
- if (! post || post->account_mask) {
- tmpl->posts.push_back(xact_template_t::post_template_t());
- post = &tmpl->posts.back();
- }
- if (begin == end)
- throw std::runtime_error(_("Invalid xact command arguments"));
- post->account_mask = mask_t((*++begin).to_string());
- post->from = arg == "from";
+ if (! post || post->account_mask) {
+ tmpl->posts.push_back(xact_template_t::post_template_t());
+ post = &tmpl->posts.back();
+ }
+ if (begin == end)
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ post->account_mask = mask_t((*++begin).to_string());
+ post->from = arg == "from";
}
else if (arg == "on") {
- if (begin == end)
- throw std::runtime_error(_("Invalid xact command arguments"));
- tmpl->date = parse_date((*++begin).to_string());
- check_for_date = false;
+ if (begin == end)
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ tmpl->date = parse_date((*++begin).to_string());
+ check_for_date = false;
}
else if (arg == "code") {
- if (begin == end)
- throw std::runtime_error(_("Invalid xact command arguments"));
- tmpl->code = (*++begin).to_string();
+ if (begin == end)
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ tmpl->code = (*++begin).to_string();
}
else if (arg == "note") {
- if (begin == end)
- throw std::runtime_error(_("Invalid xact command arguments"));
- tmpl->note = (*++begin).to_string();
+ if (begin == end)
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ tmpl->note = (*++begin).to_string();
}
else if (arg == "rest") {
- ; // just ignore this argument
+ ; // just ignore this argument
}
else if (arg == "@" || arg == "@@") {
- amount_t cost;
- post->cost_operator = arg;
- if (begin == end)
- throw std::runtime_error(_("Invalid xact command arguments"));
- arg = (*++begin).to_string();
- if (! cost.parse(arg, PARSE_SOFT_FAIL | PARSE_NO_MIGRATE))
- throw std::runtime_error(_("Invalid xact command arguments"));
- post->cost = cost;
+ amount_t cost;
+ post->cost_operator = arg;
+ if (begin == end)
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ arg = (*++begin).to_string();
+ if (! cost.parse(arg, PARSE_SOFT_FAIL | PARSE_NO_MIGRATE))
+ throw std::runtime_error(_("Invalid xact command arguments"));
+ post->cost = cost;
}
else {
- // Without a preposition, it is either:
- //
- // A payee, if we have not seen one
- // An account or an amount, if we have
- // An account if an amount has just been seen
- // An amount if an account has just been seen
-
- if (tmpl->payee_mask.empty()) {
- tmpl->payee_mask = arg;
- } else {
- amount_t amt;
- optional<mask_t> account;
-
- if (! amt.parse(arg, PARSE_SOFT_FAIL | PARSE_NO_MIGRATE))
- account = mask_t(arg);
-
- if (! post ||
- (account && post->account_mask) ||
- (! account && post->amount)) {
- tmpl->posts.push_back(xact_template_t::post_template_t());
- post = &tmpl->posts.back();
- }
-
- if (account) {
- post->account_mask = account;
- } else {
- post->amount = amt;
- post = NULL; // an amount concludes this posting
- }
- }
+ // Without a preposition, it is either:
+ //
+ // A payee, if we have not seen one
+ // An account or an amount, if we have
+ // An account if an amount has just been seen
+ // An amount if an account has just been seen
+
+ if (tmpl->payee_mask.empty()) {
+ tmpl->payee_mask = arg;
+ } else {
+ amount_t amt;
+ optional<mask_t> account;
+
+ if (! amt.parse(arg, PARSE_SOFT_FAIL | PARSE_NO_MIGRATE))
+ account = mask_t(arg);
+
+ if (! post ||
+ (account && post->account_mask) ||
+ (! account && post->amount)) {
+ tmpl->posts.push_back(xact_template_t::post_template_t());
+ post = &tmpl->posts.back();
+ }
+
+ if (account) {
+ post->account_mask = account;
+ } else {
+ post->amount = amt;
+ post = NULL; // an amount concludes this posting
+ }
+ }
}
}
}
@@ -217,14 +217,14 @@ void draft_t::parse_args(const value_t& args)
// A single account at the end of the line is the "from" account
if (tmpl->posts.size() > 1 &&
- tmpl->posts.back().account_mask && ! tmpl->posts.back().amount)
+ tmpl->posts.back().account_mask && ! tmpl->posts.back().amount)
tmpl->posts.back().from = true;
foreach (xact_template_t::post_template_t& post, tmpl->posts) {
if (post.from)
- has_only_to = false;
+ has_only_to = false;
else
- has_only_from = false;
+ has_only_from = false;
}
if (has_only_from) {
@@ -252,17 +252,17 @@ xact_t * draft_t::insert(journal_t& journal)
xacts_iterator xi(journal);
if (xact_t * xact = lookup_probable_account(tmpl->payee_mask.str(), xi).first) {
DEBUG("draft.xact", "Found payee by lookup: transaction on line "
- << xact->pos->beg_line);
+ << xact->pos->beg_line);
matching = xact;
} else {
for (xacts_list::reverse_iterator j = journal.xacts.rbegin();
- j != journal.xacts.rend();
- j++) {
+ j != journal.xacts.rend();
+ j++) {
if (tmpl->payee_mask.match((*j)->payee)) {
- matching = *j;
- DEBUG("draft.xact",
- "Found payee match: transaction on line " << (*j)->pos->beg_line);
- break;
+ matching = *j;
+ DEBUG("draft.xact",
+ "Found payee match: transaction on line " << (*j)->pos->beg_line);
+ break;
}
}
}
@@ -308,13 +308,13 @@ xact_t * draft_t::insert(journal_t& journal)
DEBUG("draft.xact", "Template had no postings, copying from match");
foreach (post_t * post, matching->posts) {
- added->add_post(new post_t(*post));
- added->posts.back()->set_state(item_t::UNCLEARED);
+ added->add_post(new post_t(*post));
+ added->posts.back()->set_state(item_t::UNCLEARED);
}
} else {
throw_(std::runtime_error,
- _("No accounts, and no past transaction matching '%1'")
- << tmpl->payee_mask);
+ _("No accounts, and no past transaction matching '%1'")
+ << tmpl->payee_mask);
}
} else {
DEBUG("draft.xact", "Template had postings");
@@ -322,9 +322,9 @@ xact_t * draft_t::insert(journal_t& journal)
bool any_post_has_amount = false;
foreach (xact_template_t::post_template_t& post, tmpl->posts) {
if (post.amount) {
- DEBUG("draft.xact", " and at least one has an amount specified");
- any_post_has_amount = true;
- break;
+ DEBUG("draft.xact", " and at least one has an amount specified");
+ any_post_has_amount = true;
+ break;
}
}
@@ -334,158 +334,158 @@ xact_t * draft_t::insert(journal_t& journal)
commodity_t * found_commodity = NULL;
if (matching) {
- if (post.account_mask) {
- DEBUG("draft.xact",
- "Looking for matching posting based on account mask");
-
- foreach (post_t * x, matching->posts) {
- if (post.account_mask->match(x->account->fullname())) {
- new_post.reset(new post_t(*x));
- DEBUG("draft.xact",
- "Founding posting from line " << x->pos->beg_line);
- break;
- }
- }
- } else {
- if (post.from) {
- for (posts_list::reverse_iterator j = matching->posts.rbegin();
- j != matching->posts.rend();
- j++) {
- if ((*j)->must_balance()) {
- new_post.reset(new post_t(**j));
- DEBUG("draft.xact",
- "Copied last real posting from matching");
- break;
- }
- }
- } else {
- for (posts_list::iterator j = matching->posts.begin();
- j != matching->posts.end();
- j++) {
- if ((*j)->must_balance()) {
- new_post.reset(new post_t(**j));
- DEBUG("draft.xact",
- "Copied first real posting from matching");
- break;
- }
- }
- }
- }
+ if (post.account_mask) {
+ DEBUG("draft.xact",
+ "Looking for matching posting based on account mask");
+
+ foreach (post_t * x, matching->posts) {
+ if (post.account_mask->match(x->account->fullname())) {
+ new_post.reset(new post_t(*x));
+ DEBUG("draft.xact",
+ "Founding posting from line " << x->pos->beg_line);
+ break;
+ }
+ }
+ } else {
+ if (post.from) {
+ for (posts_list::reverse_iterator j = matching->posts.rbegin();
+ j != matching->posts.rend();
+ j++) {
+ if ((*j)->must_balance()) {
+ new_post.reset(new post_t(**j));
+ DEBUG("draft.xact",
+ "Copied last real posting from matching");
+ break;
+ }
+ }
+ } else {
+ for (posts_list::iterator j = matching->posts.begin();
+ j != matching->posts.end();
+ j++) {
+ if ((*j)->must_balance()) {
+ new_post.reset(new post_t(**j));
+ DEBUG("draft.xact",
+ "Copied first real posting from matching");
+ break;
+ }
+ }
+ }
+ }
}
if (! new_post.get()) {
- new_post.reset(new post_t);
- DEBUG("draft.xact", "New posting was NULL, creating a blank one");
+ new_post.reset(new post_t);
+ DEBUG("draft.xact", "New posting was NULL, creating a blank one");
}
if (! new_post->account) {
- DEBUG("draft.xact", "New posting still needs an account");
+ DEBUG("draft.xact", "New posting still needs an account");
- if (post.account_mask) {
- DEBUG("draft.xact", "The template has an account mask");
+ if (post.account_mask) {
+ DEBUG("draft.xact", "The template has an account mask");
- account_t * acct = NULL;
- if (! acct) {
- acct = journal.find_account_re(post.account_mask->str());
+ account_t * acct = NULL;
+ if (! acct) {
+ acct = journal.find_account_re(post.account_mask->str());
#if defined(DEBUG_ON)
- if (acct)
- DEBUG("draft.xact", "Found account as a regular expression");
+ if (acct)
+ DEBUG("draft.xact", "Found account as a regular expression");
#endif
- }
- if (! acct) {
- acct = journal.find_account(post.account_mask->str());
+ }
+ if (! acct) {
+ acct = journal.find_account(post.account_mask->str());
#if defined(DEBUG_ON)
- if (acct)
- DEBUG("draft.xact", "Found (or created) account by name");
+ if (acct)
+ DEBUG("draft.xact", "Found (or created) account by name");
#endif
- }
-
- // Find out the default commodity to use by looking at the last
- // commodity used in that account
- for (xacts_list::reverse_iterator j = journal.xacts.rbegin();
- j != journal.xacts.rend();
- j++) {
- foreach (post_t * x, (*j)->posts) {
- if (x->account == acct && ! x->amount.is_null()) {
- new_post.reset(new post_t(*x));
- DEBUG("draft.xact",
- "Found account in journal postings, setting new posting");
- break;
- }
- }
- }
-
- new_post->account = acct;
- DEBUG("draft.xact",
- "Set new posting's account to: " << acct->fullname());
- } else {
- if (post.from) {
- new_post->account = journal.find_account(_("Liabilities:Unknown"));
- DEBUG("draft.xact",
- "Set new posting's account to: Liabilities:Unknown");
- } else {
- new_post->account = journal.find_account(_("Expenses:Unknown"));
- DEBUG("draft.xact",
- "Set new posting's account to: Expenses:Unknown");
- }
- }
+ }
+
+ // Find out the default commodity to use by looking at the last
+ // commodity used in that account
+ for (xacts_list::reverse_iterator j = journal.xacts.rbegin();
+ j != journal.xacts.rend();
+ j++) {
+ foreach (post_t * x, (*j)->posts) {
+ if (x->account == acct && ! x->amount.is_null()) {
+ new_post.reset(new post_t(*x));
+ DEBUG("draft.xact",
+ "Found account in journal postings, setting new posting");
+ break;
+ }
+ }
+ }
+
+ new_post->account = acct;
+ DEBUG("draft.xact",
+ "Set new posting's account to: " << acct->fullname());
+ } else {
+ if (post.from) {
+ new_post->account = journal.find_account(_("Liabilities:Unknown"));
+ DEBUG("draft.xact",
+ "Set new posting's account to: Liabilities:Unknown");
+ } else {
+ new_post->account = journal.find_account(_("Expenses:Unknown"));
+ DEBUG("draft.xact",
+ "Set new posting's account to: Expenses:Unknown");
+ }
+ }
}
assert(new_post->account);
if (new_post.get() && ! new_post->amount.is_null()) {
- found_commodity = &new_post->amount.commodity();
-
- if (any_post_has_amount) {
- new_post->amount = amount_t();
- DEBUG("draft.xact", "New posting has an amount, but we cleared it");
- } else {
- any_post_has_amount = true;
- DEBUG("draft.xact", "New posting has an amount, and we're using it");
- }
+ found_commodity = &new_post->amount.commodity();
+
+ if (any_post_has_amount) {
+ new_post->amount = amount_t();
+ DEBUG("draft.xact", "New posting has an amount, but we cleared it");
+ } else {
+ any_post_has_amount = true;
+ DEBUG("draft.xact", "New posting has an amount, and we're using it");
+ }
}
if (post.amount) {
- new_post->amount = *post.amount;
- DEBUG("draft.xact", "Copied over posting amount");
+ new_post->amount = *post.amount;
+ DEBUG("draft.xact", "Copied over posting amount");
- if (post.from) {
- new_post->amount.in_place_negate();
- DEBUG("draft.xact", "Negated new posting amount");
- }
+ if (post.from) {
+ new_post->amount.in_place_negate();
+ DEBUG("draft.xact", "Negated new posting amount");
+ }
}
if (post.cost) {
- if (post.cost->sign() < 0)
- throw parse_error(_("A posting's cost may not be negative"));
-
- post.cost->in_place_unround();
-
- if (*post.cost_operator == "@") {
- // For the sole case where the cost might be uncommoditized,
- // guarantee that the commodity of the cost after multiplication
- // is the same as it was before.
- commodity_t& cost_commodity(post.cost->commodity());
- *post.cost *= new_post->amount;
- post.cost->set_commodity(cost_commodity);
- }
- else if (new_post->amount.sign() < 0) {
- new_post->cost->in_place_negate();
- }
-
- new_post->cost = *post.cost;
- DEBUG("draft.xact", "Copied over posting cost");
+ if (post.cost->sign() < 0)
+ throw parse_error(_("A posting's cost may not be negative"));
+
+ post.cost->in_place_unround();
+
+ if (*post.cost_operator == "@") {
+ // For the sole case where the cost might be uncommoditized,
+ // guarantee that the commodity of the cost after multiplication
+ // is the same as it was before.
+ commodity_t& cost_commodity(post.cost->commodity());
+ *post.cost *= new_post->amount;
+ post.cost->set_commodity(cost_commodity);
+ }
+ else if (new_post->amount.sign() < 0) {
+ new_post->cost->in_place_negate();
+ }
+
+ new_post->cost = *post.cost;
+ DEBUG("draft.xact", "Copied over posting cost");
}
if (found_commodity &&
- ! new_post->amount.is_null() &&
- ! new_post->amount.has_commodity()) {
- new_post->amount.set_commodity(*found_commodity);
- DEBUG("draft.xact", "Set posting amount commodity to: "
- << new_post->amount.commodity());
-
- new_post->amount = new_post->amount.rounded();
- DEBUG("draft.xact",
- "Rounded posting amount to: " << new_post->amount);
+ ! new_post->amount.is_null() &&
+ ! new_post->amount.has_commodity()) {
+ new_post->amount.set_commodity(*found_commodity);
+ DEBUG("draft.xact", "Set posting amount commodity to: "
+ << new_post->amount.commodity());
+
+ new_post->amount = new_post->amount.rounded();
+ DEBUG("draft.xact",
+ "Rounded posting amount to: " << new_post->amount);
}
added->add_post(new_post.release());
@@ -498,7 +498,7 @@ xact_t * draft_t::insert(journal_t& journal)
if (! journal.add_xact(added.get()))
throw_(std::runtime_error,
- _("Failed to finalize derived transaction (check commodities)"));
+ _("Failed to finalize derived transaction (check commodities)"));
return added.release();
}
diff --git a/src/emacs.cc b/src/emacs.cc
index 3c8bb256..7abdfd7f 100644
--- a/src/emacs.cc
+++ b/src/emacs.cc
@@ -42,11 +42,11 @@ void format_emacs_posts::write_xact(xact_t& xact)
{
if (xact.pos)
out << "\"" << xact.pos->pathname << "\" "
- << xact.pos->beg_line << " ";
+ << xact.pos->beg_line << " ";
else
out << "\"\" " << -1 << " ";
- tm when = gregorian::to_tm(xact.date());
+ tm when = gregorian::to_tm(xact.date());
std::time_t date = std::mktime(&when);
out << "(" << (date / 65536) << " " << (date % 65536) << " 0) ";
@@ -86,7 +86,7 @@ void format_emacs_posts::operator()(post_t& post)
out << " (" << -1 << " ";
out << "\"" << post.reported_account()->fullname() << "\" \""
- << post.amount << "\"";
+ << post.amount << "\"";
switch (post.state()) {
case item_t::CLEARED:
diff --git a/src/error.cc b/src/error.cc
index 4b3a7786..39ac63ea 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -55,9 +55,9 @@ string file_context(const path& file, const std::size_t line)
return buf.str();
}
-string line_context(const string& line,
- const string::size_type pos,
- const string::size_type end_pos)
+string line_context(const string& line,
+ const string::size_type pos,
+ const string::size_type end_pos)
{
std::ostringstream buf;
buf << " " << line << "\n";
@@ -66,24 +66,24 @@ string line_context(const string& line,
buf << " ";
if (end_pos == 0) {
for (string::size_type i = 0; i < pos; i += 1)
- buf << " ";
+ buf << " ";
buf << "^";
} else {
for (string::size_type i = 0; i < end_pos; i += 1) {
- if (i >= pos)
- buf << "^";
- else
- buf << " ";
+ if (i >= pos)
+ buf << "^";
+ else
+ buf << " ";
}
}
}
return buf.str();
}
-string source_context(const path& file,
- const istream_pos_type pos,
- const istream_pos_type end_pos,
- const string& prefix)
+string source_context(const path& file,
+ const istream_pos_type pos,
+ const istream_pos_type end_pos,
+ const string& prefix)
{
const std::streamoff len = end_pos - pos;
if (! len || file == path("/dev/stdin"))
diff --git a/src/error.h b/src/error.h
index b8b011eb..b9960b03 100644
--- a/src/error.h
+++ b/src/error.h
@@ -56,9 +56,9 @@ inline void throw_func(const string& message) {
throw T(message);
}
-#define throw_(cls, msg) \
- ((_desc_buffer << ACCUM(_desc_accum << msg)), \
- _desc_accum.clear(), \
+#define throw_(cls, msg) \
+ ((_desc_buffer << ACCUM(_desc_accum << msg)), \
+ _desc_accum.clear(), \
throw_func<cls>(_desc_buffer.str()))
inline void warning_func(const string& message) {
@@ -67,38 +67,38 @@ inline void warning_func(const string& message) {
_desc_buffer.str("");
}
-#define warning_(msg) \
- ((_desc_buffer << ACCUM(_desc_accum << msg)), \
- _desc_accum.clear(), \
+#define warning_(msg) \
+ ((_desc_buffer << ACCUM(_desc_accum << msg)), \
+ _desc_accum.clear(), \
warning_func(_desc_buffer.str()))
-extern straccstream _ctxt_accum;
+extern straccstream _ctxt_accum;
extern std::ostringstream _ctxt_buffer;
-#define add_error_context(msg) \
- ((long(_ctxt_buffer.tellp()) == 0) ? \
- ((_ctxt_buffer << ACCUM(_ctxt_accum << msg)), \
- _ctxt_accum.clear()) : \
- ((_ctxt_buffer << std::endl << ACCUM(_ctxt_accum << msg)), \
+#define add_error_context(msg) \
+ ((long(_ctxt_buffer.tellp()) == 0) ? \
+ ((_ctxt_buffer << ACCUM(_ctxt_accum << msg)), \
+ _ctxt_accum.clear()) : \
+ ((_ctxt_buffer << std::endl << ACCUM(_ctxt_accum << msg)), \
_ctxt_accum.clear()))
string error_context();
string file_context(const path& file, std::size_t line);
-string line_context(const string& line,
- const string::size_type pos = 0,
- const string::size_type end_pos = 0);
-
-string source_context(const path& file,
- const istream_pos_type pos,
- const istream_pos_type end_pos,
- const string& prefix = "");
-
-#define DECLARE_EXCEPTION(name, kind) \
- class name : public kind { \
- public: \
- explicit name(const string& why) throw() : kind(why) {} \
- virtual ~name() throw() {} \
+string line_context(const string& line,
+ const string::size_type pos = 0,
+ const string::size_type end_pos = 0);
+
+string source_context(const path& file,
+ const istream_pos_type pos,
+ const istream_pos_type end_pos,
+ const string& prefix = "");
+
+#define DECLARE_EXCEPTION(name, kind) \
+ class name : public kind { \
+ public: \
+ explicit name(const string& why) throw() : kind(why) {} \
+ virtual ~name() throw() {} \
}
} // namespace ledger
diff --git a/src/expr.cc b/src/expr.cc
index 62058e0b..defa5b79 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -37,7 +37,7 @@
namespace ledger {
void expr_t::parse(std::istream& in, const parse_flags_t& flags,
- const optional<string>& original_string)
+ const optional<string>& original_string)
{
parser_t parser;
istream_pos_type start_pos = in.tellg();
@@ -78,36 +78,36 @@ value_t expr_t::real_calc(scope_t& scope)
}
catch (const std::exception& err) {
if (locus) {
- string current_context = error_context();
-
- add_error_context(_("While evaluating value expression:"));
- add_error_context(op_context(ptr, locus));
-
- if (SHOW_INFO()) {
- add_error_context(_("The value expression tree was:"));
- std::ostringstream buf;
- ptr->dump(buf, 0);
-
- std::istringstream in(buf.str());
- std::ostringstream out;
- char linebuf[1024];
- bool first = true;
- while (in.good() && ! in.eof()) {
- in.getline(linebuf, 1023);
- std::streamsize len = in.gcount();
- if (len > 0) {
- if (first)
- first = false;
- else
- out << '\n';
- out << " " << linebuf;
- }
- }
- add_error_context(out.str());
- }
-
- if (! current_context.empty())
- add_error_context(current_context);
+ string current_context = error_context();
+
+ add_error_context(_("While evaluating value expression:"));
+ add_error_context(op_context(ptr, locus));
+
+ if (SHOW_INFO()) {
+ add_error_context(_("The value expression tree was:"));
+ std::ostringstream buf;
+ ptr->dump(buf, 0);
+
+ std::istringstream in(buf.str());
+ std::ostringstream out;
+ char linebuf[1024];
+ bool first = true;
+ while (in.good() && ! in.eof()) {
+ in.getline(linebuf, 1023);
+ std::streamsize len = in.gcount();
+ if (len > 0) {
+ if (first)
+ first = false;
+ else
+ out << '\n';
+ out << " " << linebuf;
+ }
+ }
+ add_error_context(out.str());
+ }
+
+ if (! current_context.empty())
+ add_error_context(current_context);
}
throw;
}
diff --git a/src/expr.h b/src/expr.h
index 09285966..fa49cdc4 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -56,7 +56,7 @@ class expr_t : public expr_base_t<value_t>
public:
class op_t;
- typedef intrusive_ptr<op_t> ptr_op_t;
+ typedef intrusive_ptr<op_t> ptr_op_t;
typedef intrusive_ptr<const op_t> const_ptr_op_t;
protected:
@@ -112,13 +112,13 @@ public:
return parse(stream, flags, str);
}
- virtual void parse(std::istream& in,
- const parse_flags_t& flags = PARSE_DEFAULT,
- const optional<string>& original_string = none);
+ virtual void parse(std::istream& in,
+ const parse_flags_t& flags = PARSE_DEFAULT,
+ const optional<string>& original_string = none);
virtual void compile(scope_t& scope);
virtual value_t real_calc(scope_t& scope);
- bool is_constant() const;
+ bool is_constant() const;
value_t& constant_value();
const value_t& constant_value() const;
bool is_function() const;
diff --git a/src/exprbase.h b/src/exprbase.h
index 0c096ab4..7eee0398 100644
--- a/src/exprbase.h
+++ b/src/exprbase.h
@@ -78,7 +78,7 @@ public:
protected:
scope_t * context;
string str;
- bool compiled;
+ bool compiled;
virtual result_type real_calc(scope_t& scope) = 0;
@@ -117,7 +117,7 @@ public:
return str;
}
void set_text(const string& txt) {
- str = txt;
+ str = txt;
compiled = false;
}
@@ -126,11 +126,11 @@ public:
return parse(stream, flags, str);
}
virtual void parse(std::istream&,
- const parse_flags_t& = PARSE_DEFAULT,
- const optional<string>& original_string = none) {
+ const parse_flags_t& = PARSE_DEFAULT,
+ const optional<string>& original_string = none) {
set_text(original_string ? *original_string : "<stream>");
}
-
+
void mark_uncompiled() {
compiled = false;
}
@@ -157,8 +157,8 @@ public:
if (! compiled) {
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) {
- DEBUG("expr.compile", "Before compilation:");
- dump(*_log_stream);
+ DEBUG("expr.compile", "Before compilation:");
+ dump(*_log_stream);
}
#endif // defined(DEBUG_ON)
@@ -167,8 +167,8 @@ public:
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) {
- DEBUG("expr.compile", "After compilation:");
- dump(*_log_stream);
+ DEBUG("expr.compile", "After compilation:");
+ dump(*_log_stream);
}
#endif // defined(DEBUG_ON)
}
@@ -249,7 +249,7 @@ private:
template <typename ResultType>
std::ostream& operator<<(std::ostream& out,
- const expr_base_t<ResultType>& expr) {
+ const expr_base_t<ResultType>& expr) {
expr.print(out);
return out;
}
diff --git a/src/filters.cc b/src/filters.cc
index 2c2a0d5a..819e3d97 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -76,7 +76,7 @@ void post_splitter::operator()(post_t& post)
(*i).second.push_back(&post);
} else {
std::pair<value_to_posts_map::iterator, bool> inserted
- = posts_map.insert(value_to_posts_map::value_type(result, posts_list()));
+ = posts_map.insert(value_to_posts_map::value_type(result, posts_list()));
assert(inserted.second);
(*inserted.first).second.push_back(&post);
}
@@ -84,7 +84,7 @@ void post_splitter::operator()(post_t& post)
}
pass_down_posts::pass_down_posts(post_handler_ptr handler,
- posts_iterator& iter)
+ posts_iterator& iter)
: item_handler<post_t>(handler)
{
TRACE_CTOR(pass_down_posts, "post_handler_ptr, posts_iterator");
@@ -129,16 +129,16 @@ void truncate_xacts::flush()
bool print = false;
if (head_count) {
if (head_count > 0 && i < head_count)
- print = true;
+ print = true;
else if (head_count < 0 && i >= - head_count)
- print = true;
+ print = true;
}
if (! print && tail_count) {
if (tail_count > 0 && l - i <= tail_count)
- print = true;
+ print = true;
else if (tail_count < 0 && l - i > - tail_count)
- print = true;
+ print = true;
}
if (print)
@@ -173,7 +173,7 @@ void truncate_xacts::operator()(post_t& post)
void sort_posts::post_accumulated_posts()
{
std::stable_sort(posts.begin(), posts.end(),
- compare_items<post_t>(sort_order));
+ compare_items<post_t>(sort_order));
foreach (post_t * post, posts) {
post->xdata().drop_flags(POST_EXT_SORT_CALC);
@@ -185,30 +185,30 @@ void sort_posts::post_accumulated_posts()
namespace {
void split_string(const string& str, const char ch,
- std::list<string>& strings)
+ std::list<string>& strings)
{
const char * b = str.c_str();
for (const char * p = b; *p; p++) {
if (*p == ch) {
- strings.push_back(string(b, p - b));
- b = p + 1;
+ strings.push_back(string(b, p - b));
+ b = p + 1;
}
}
strings.push_back(string(b));
}
account_t * create_temp_account_from_path(std::list<string>& account_names,
- temporaries_t& temps,
- account_t * master)
+ temporaries_t& temps,
+ account_t * master)
{
account_t * new_account = NULL;
foreach (const string& name, account_names) {
if (new_account) {
- new_account = new_account->find_account(name);
+ new_account = new_account->find_account(name);
} else {
- new_account = master->find_account(name, false);
- if (! new_account)
- new_account = &temps.create_account(name, master);
+ new_account = master->find_account(name, false);
+ if (! new_account)
+ new_account = &temps.create_account(name, master);
}
}
@@ -243,7 +243,7 @@ void anonymize_posts::render_commodity(amount_t& amt)
if (amt.has_annotation())
amt.set_commodity
(*commodity_pool_t::current_pool->find_or_create(buf.str(),
- amt.annotation()));
+ amt.annotation()));
else
amt.set_commodity
(*commodity_pool_t::current_pool->find_or_create(buf.str()));
@@ -256,9 +256,9 @@ void anonymize_posts::render_commodity(amount_t& amt)
void anonymize_posts::operator()(post_t& post)
{
- SHA1 sha;
+ SHA1 sha;
uint_least32_t message_digest[5];
- bool copy_xact_details = false;
+ bool copy_xact_details = false;
if (last_xact != post.xact) {
temps.copy_xact(*post.xact);
@@ -342,15 +342,15 @@ void calc_posts::operator()(post_t& post)
namespace {
void handle_value(const value_t& value,
- account_t * account,
- xact_t * xact,
- temporaries_t& temps,
- post_handler_ptr handler,
- const date_t& date = date_t(),
- const bool act_date_p = true,
- const value_t& total = value_t(),
- const bool direct_amount = false,
- const bool mark_visited = false)
+ account_t * account,
+ xact_t * xact,
+ temporaries_t& temps,
+ post_handler_ptr handler,
+ const date_t& date = date_t(),
+ const bool act_date_p = true,
+ const value_t& total = value_t(),
+ const bool direct_amount = false,
+ const bool mark_visited = false)
{
post_t& post = temps.create_post(*xact, account);
post.add_flags(ITEM_GENERATED);
@@ -359,11 +359,11 @@ namespace {
// such. This allows subtotal reports to show "(Account)" for accounts
// that contain only virtual posts.
if (account && account->has_xdata() &&
- account->xdata().has_flags(ACCOUNT_EXT_AUTO_VIRTUALIZE)) {
+ account->xdata().has_flags(ACCOUNT_EXT_AUTO_VIRTUALIZE)) {
if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS)) {
- post.add_flags(POST_VIRTUAL);
- if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS))
- post.add_flags(POST_MUST_BALANCE);
+ post.add_flags(POST_VIRTUAL);
+ if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS))
+ post.add_flags(POST_MUST_BALANCE);
}
}
@@ -371,9 +371,9 @@ namespace {
if (is_valid(date)) {
if (act_date_p)
- xdata.date = date;
+ xdata.date = date;
else
- xdata.value_date = date;
+ xdata.value_date = date;
}
value_t temp(value);
@@ -442,29 +442,29 @@ void collapse_posts::report_subtotal()
date_t latest_date;
foreach (post_t * post, component_posts) {
- date_t date = post->date();
+ date_t date = post->date();
date_t value_date = post->value_date();
if (! is_valid(earliest_date) || date < earliest_date)
- earliest_date = date;
+ earliest_date = date;
if (! is_valid(latest_date) || value_date > latest_date)
- latest_date = value_date;
+ latest_date = value_date;
}
xact_t& xact = temps.create_xact();
- xact.payee = last_xact->payee;
- xact._date = (is_valid(earliest_date) ?
- earliest_date : last_xact->_date);
+ xact.payee = last_xact->payee;
+ xact._date = (is_valid(earliest_date) ?
+ earliest_date : last_xact->_date);
DEBUG("filters.collapse", "Pseudo-xact date = " << *xact._date);
DEBUG("filters.collapse", "earliest date = " << earliest_date);
DEBUG("filters.collapse", "latest date = " << latest_date);
handle_value(/* value= */ subtotal,
- /* account= */ &totals_account,
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ latest_date,
- /* act_date_p= */ false);
+ /* account= */ &totals_account,
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ latest_date,
+ /* act_date_p= */ false);
}
component_posts.clear();
@@ -497,26 +497,26 @@ void related_posts::flush()
if (posts.size() > 0) {
foreach (post_t * post, posts) {
if (post->xact) {
- foreach (post_t * r_post, post->xact->posts) {
- post_t::xdata_t& xdata(r_post->xdata());
- if (! xdata.has_flags(POST_EXT_HANDLED) &&
- (! xdata.has_flags(POST_EXT_RECEIVED) ?
- ! r_post->has_flags(ITEM_GENERATED | POST_VIRTUAL) :
- also_matching)) {
- xdata.add_flags(POST_EXT_HANDLED);
- item_handler<post_t>::operator()(*r_post);
- }
- }
+ foreach (post_t * r_post, post->xact->posts) {
+ post_t::xdata_t& xdata(r_post->xdata());
+ if (! xdata.has_flags(POST_EXT_HANDLED) &&
+ (! xdata.has_flags(POST_EXT_RECEIVED) ?
+ ! r_post->has_flags(ITEM_GENERATED | POST_VIRTUAL) :
+ also_matching)) {
+ xdata.add_flags(POST_EXT_HANDLED);
+ item_handler<post_t>::operator()(*r_post);
+ }
+ }
} else {
- // This code should only be reachable from the "output"
- // command, since that is the only command which attempts to
- // output auto or period xacts.
- post_t::xdata_t& xdata(post->xdata());
- if (! xdata.has_flags(POST_EXT_HANDLED) &&
- ! post->has_flags(ITEM_GENERATED)) {
- xdata.add_flags(POST_EXT_HANDLED);
- item_handler<post_t>::operator()(*post);
- }
+ // This code should only be reachable from the "output"
+ // command, since that is the only command which attempts to
+ // output auto or period xacts.
+ post_t::xdata_t& xdata(post->xdata());
+ if (! xdata.has_flags(POST_EXT_HANDLED) &&
+ ! post->has_flags(ITEM_GENERATED)) {
+ xdata.add_flags(POST_EXT_HANDLED);
+ item_handler<post_t>::operator()(*post);
+ }
}
}
}
@@ -525,15 +525,15 @@ void related_posts::flush()
}
display_filter_posts::display_filter_posts(post_handler_ptr handler,
- report_t& _report,
- bool _show_rounding)
+ report_t& _report,
+ bool _show_rounding)
: item_handler<post_t>(handler), report(_report),
show_rounding(_show_rounding),
rounding_account(temps.create_account(_("<Rounding>"))),
revalued_account(temps.create_account(_("<Revalued>")))
{
TRACE_CTOR(display_filter_posts,
- "post_handler_ptr, report_t&, account_t&, bool");
+ "post_handler_ptr, report_t&, account_t&, bool");
display_amount_expr = report.HANDLER(display_amount_).expr;
display_total_expr = report.HANDLER(display_total_).expr;
@@ -548,7 +548,7 @@ bool display_filter_posts::output_rounding(post_t& post)
new_display_total = display_total_expr.calc(bound_scope);
DEBUG("filters.changed_value.rounding",
- "rounding.new_display_total = " << new_display_total);
+ "rounding.new_display_total = " << new_display_total);
}
// Allow the posting to be displayed if:
@@ -565,29 +565,29 @@ bool display_filter_posts::output_rounding(post_t& post)
if (value_t repriced_amount = display_amount_expr.calc(bound_scope)) {
if (! last_display_total.is_null()) {
DEBUG("filters.changed_value.rounding",
- "rounding.repriced_amount = " << repriced_amount);
+ "rounding.repriced_amount = " << repriced_amount);
value_t precise_display_total(new_display_total.truncated() -
- repriced_amount.truncated());
+ repriced_amount.truncated());
DEBUG("filters.changed_value.rounding",
- "rounding.precise_display_total = " << precise_display_total);
+ "rounding.precise_display_total = " << precise_display_total);
DEBUG("filters.changed_value.rounding",
- "rounding.last_display_total = " << last_display_total);
+ "rounding.last_display_total = " << last_display_total);
if (value_t diff = precise_display_total - last_display_total) {
- DEBUG("filters.changed_value.rounding",
- "rounding.diff = " << diff);
-
- handle_value(/* value= */ diff,
- /* account= */ &rounding_account,
- /* xact= */ post.xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ date_t(),
- /* act_date_p= */ true,
- /* total= */ precise_display_total,
- /* direct_amount= */ true);
+ DEBUG("filters.changed_value.rounding",
+ "rounding.diff = " << diff);
+
+ handle_value(/* value= */ diff,
+ /* account= */ &rounding_account,
+ /* xact= */ post.xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ date_t(),
+ /* act_date_p= */ true,
+ /* total= */ precise_display_total,
+ /* direct_amount= */ true);
}
}
if (show_rounding)
@@ -605,23 +605,23 @@ void display_filter_posts::operator()(post_t& post)
}
changed_value_posts::changed_value_posts
- (post_handler_ptr handler,
- report_t& _report,
- bool _for_accounts_report,
- bool _show_unrealized,
+ (post_handler_ptr handler,
+ report_t& _report,
+ bool _for_accounts_report,
+ bool _show_unrealized,
display_filter_posts * _display_filter)
: item_handler<post_t>(handler), report(_report),
for_accounts_report(_for_accounts_report),
show_unrealized(_show_unrealized), last_post(NULL),
revalued_account(_display_filter ? _display_filter->revalued_account :
- temps.create_account(_("<Revalued>"))),
+ temps.create_account(_("<Revalued>"))),
display_filter(_display_filter)
{
TRACE_CTOR(changed_value_posts, "post_handler_ptr, report_t&, bool");
- total_expr = (report.HANDLED(revalued_total_) ?
- report.HANDLER(revalued_total_).expr :
- report.HANDLER(display_total_).expr);
+ total_expr = (report.HANDLED(revalued_total_) ?
+ report.HANDLER(revalued_total_).expr :
+ report.HANDLER(display_total_).expr);
display_total_expr = report.HANDLER(display_total_).expr;
changed_values_only = report.HANDLED(revalued_only);
@@ -671,51 +671,51 @@ void changed_value_posts::output_revaluation(post_t& post, const date_t& date)
post.xdata().date = date_t();
DEBUG("filters.changed_value",
- "output_revaluation(last_total) = " << last_total);
+ "output_revaluation(last_total) = " << last_total);
DEBUG("filters.changed_value",
- "output_revaluation(repriced_total) = " << repriced_total);
+ "output_revaluation(repriced_total) = " << repriced_total);
if (! last_total.is_null()) {
if (value_t diff = repriced_total - last_total) {
DEBUG("filters.changed_value", "output_revaluation(strip(diff)) = "
- << diff.strip_annotations(report.what_to_keep()));
+ << diff.strip_annotations(report.what_to_keep()));
xact_t& xact = temps.create_xact();
xact.payee = _("Commodities revalued");
xact._date = is_valid(date) ? date : post.value_date();
if (! for_accounts_report) {
- handle_value
- (/* value= */ diff,
- /* account= */ &revalued_account,
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ *xact._date,
- /* act_date_p= */ true,
- /* total= */ repriced_total);
+ handle_value
+ (/* value= */ diff,
+ /* account= */ &revalued_account,
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ *xact._date,
+ /* act_date_p= */ true,
+ /* total= */ repriced_total);
}
else if (show_unrealized) {
- handle_value
- (/* value= */ - diff,
- /* account= */ (diff < 0L ?
- losses_equity_account :
- gains_equity_account),
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ *xact._date,
- /* act_date_p= */ true,
- /* total= */ value_t(),
- /* direct_amount= */ false,
- /* mark_visited= */ true);
+ handle_value
+ (/* value= */ - diff,
+ /* account= */ (diff < 0L ?
+ losses_equity_account :
+ gains_equity_account),
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ *xact._date,
+ /* act_date_p= */ true,
+ /* total= */ value_t(),
+ /* direct_amount= */ false,
+ /* mark_visited= */ true);
}
}
}
}
-void changed_value_posts::output_intermediate_prices(post_t& post,
- const date_t& current)
+void changed_value_posts::output_intermediate_prices(post_t& post,
+ const date_t& current)
{
// To fix BZ#199, examine the balance of last_post and determine whether the
// price of that amount changed after its date and before the new post's
@@ -783,24 +783,24 @@ void changed_value_posts::output_intermediate_prices(post_t& post,
commodity_t::history_map all_prices;
foreach (const balance_t::amounts_map::value_type& amt_comm,
- display_total.as_balance().amounts) {
+ display_total.as_balance().amounts) {
if (optional<commodity_t::varied_history_t&> hist =
- amt_comm.first->varied_history()) {
- foreach
- (const commodity_t::history_by_commodity_map::value_type& comm_hist,
- hist->histories) {
- foreach (const commodity_t::history_map::value_type& price,
- comm_hist.second.prices) {
- if (price.first.date() > post.value_date() &&
- price.first.date() < current) {
- DEBUG("filters.revalued", post.value_date() << " < "
- << price.first.date() << " < " << current);
- DEBUG("filters.revalued", "inserting "
- << price.second << " at " << price.first.date());
- all_prices.insert(price);
- }
- }
- }
+ amt_comm.first->varied_history()) {
+ foreach
+ (const commodity_t::history_by_commodity_map::value_type& comm_hist,
+ hist->histories) {
+ foreach (const commodity_t::history_map::value_type& price,
+ comm_hist.second.prices) {
+ if (price.first.date() > post.value_date() &&
+ price.first.date() < current) {
+ DEBUG("filters.revalued", post.value_date() << " < "
+ << price.first.date() << " < " << current);
+ DEBUG("filters.revalued", "inserting "
+ << price.second << " at " << price.first.date());
+ all_prices.insert(price);
+ }
+ }
+ }
}
}
@@ -813,7 +813,7 @@ void changed_value_posts::output_intermediate_prices(post_t& post,
// This insert will fail if a later price has already been inserted
// for that date.
DEBUG("filters.revalued",
- "re-inserting " << price.second << " at " << price.first.date());
+ "re-inserting " << price.second << " at " << price.first.date());
pricing_dates.insert(date_map::value_type(price.first.date(), true));
}
@@ -849,8 +849,8 @@ void changed_value_posts::operator()(post_t& post)
last_post = &post;
}
-void subtotal_posts::report_subtotal(const char * spec_fmt,
- const optional<date_interval_t>& interval)
+void subtotal_posts::report_subtotal(const char * spec_fmt,
+ const optional<date_interval_t>& interval)
{
if (component_posts.empty())
return;
@@ -860,12 +860,12 @@ void subtotal_posts::report_subtotal(const char * spec_fmt,
if (! range_start || ! range_finish) {
foreach (post_t * post, component_posts) {
- date_t date = post->date();
+ date_t date = post->date();
date_t value_date = post->value_date();
if (! range_start || date < *range_start)
- range_start = date;
+ range_start = date;
if (! range_finish || value_date > *range_finish)
- range_finish = value_date;
+ range_finish = value_date;
}
}
component_posts.clear();
@@ -876,7 +876,7 @@ void subtotal_posts::report_subtotal(const char * spec_fmt,
}
else if (date_format) {
out_date << "- " << format_date(*range_finish, FMT_CUSTOM,
- date_format->c_str());
+ date_format->c_str());
}
else {
out_date << "- " << format_date(*range_finish);
@@ -888,12 +888,12 @@ void subtotal_posts::report_subtotal(const char * spec_fmt,
foreach (values_map::value_type& pair, values)
handle_value(/* value= */ pair.second.value,
- /* account= */ pair.second.account,
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ *range_finish,
- /* act_date_p= */ false);
+ /* account= */ pair.second.account,
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ *range_finish,
+ /* act_date_p= */ false);
values.clear();
}
@@ -952,25 +952,25 @@ void interval_posts::operator()(post_t& post)
report_subtotal(last_interval);
if (generate_empty_posts) {
- for (++last_interval; interval != last_interval; ++last_interval) {
- // Generate a null posting, so the intervening periods can be
- // seen when -E is used, or if the calculated amount ends up being
- // non-zero
- xact_t& null_xact = temps.create_xact();
- null_xact._date = last_interval.inclusive_end();
-
- post_t& null_post = temps.create_post(null_xact, &empty_account);
- null_post.add_flags(POST_CALCULATED);
- null_post.amount = 0L;
-
- last_post = &null_post;
- subtotal_posts::operator()(null_post);
-
- report_subtotal(last_interval);
- }
- assert(interval == last_interval);
+ for (++last_interval; interval != last_interval; ++last_interval) {
+ // Generate a null posting, so the intervening periods can be
+ // seen when -E is used, or if the calculated amount ends up being
+ // non-zero
+ xact_t& null_xact = temps.create_xact();
+ null_xact._date = last_interval.inclusive_end();
+
+ post_t& null_post = temps.create_post(null_xact, &empty_account);
+ null_post.add_flags(POST_CALCULATED);
+ null_post.amount = 0L;
+
+ last_post = &null_post;
+ subtotal_posts::operator()(null_post);
+
+ report_subtotal(last_interval);
+ }
+ assert(interval == last_interval);
} else {
- last_interval = interval;
+ last_interval = interval;
}
} else {
last_interval = interval;
@@ -1001,22 +1001,22 @@ void posts_as_equity::report_subtotal()
foreach (values_map::value_type& pair, values) {
if (pair.second.value.is_balance()) {
foreach (const balance_t::amounts_map::value_type& amount_pair,
- pair.second.value.as_balance().amounts)
- handle_value(/* value= */ amount_pair.second,
- /* account= */ pair.second.account,
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ finish,
- /* act_date_p= */ false);
+ pair.second.value.as_balance().amounts)
+ handle_value(/* value= */ amount_pair.second,
+ /* account= */ pair.second.account,
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ finish,
+ /* act_date_p= */ false);
} else {
handle_value(/* value= */ pair.second.value,
- /* account= */ pair.second.account,
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ finish,
- /* act_date_p= */ false);
+ /* account= */ pair.second.account,
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ finish,
+ /* act_date_p= */ false);
}
total += pair.second.value;
}
@@ -1024,7 +1024,7 @@ void posts_as_equity::report_subtotal()
if (total.is_balance()) {
foreach (const balance_t::amounts_map::value_type& pair,
- total.as_balance().amounts) {
+ total.as_balance().amounts) {
post_t& balance_post = temps.create_post(xact, balance_account);
balance_post.amount = - pair.second;
(*handler)(balance_post);
@@ -1052,7 +1052,7 @@ void by_payee_posts::operator()(post_t& post)
if (i == payee_subtotals.end()) {
payee_subtotals_pair
temp(post.xact->payee,
- shared_ptr<subtotal_posts>(new subtotal_posts(handler, amount_expr)));
+ shared_ptr<subtotal_posts>(new subtotal_posts(handler, amount_expr)));
std::pair<payee_subtotals_map::iterator, bool> result
= payee_subtotals.insert(temp);
@@ -1085,22 +1085,22 @@ void transfer_details::operator()(post_t& post)
case SET_ACCOUNT: {
string account_name = substitute.to_string();
if (! account_name.empty() &&
- account_name[account_name.length() - 1] != ':') {
- account_t * prev_account = temp.account;
- temp.account->remove_post(&temp);
-
- account_name += ':';
- account_name += prev_account->fullname();
-
- std::list<string> account_names;
- split_string(account_name, ':', account_names);
- temp.account = create_temp_account_from_path(account_names, temps,
- xact.journal->master);
- temp.account->add_post(&temp);
-
- temp.account->add_flags(prev_account->flags());
- if (prev_account->has_xdata())
- temp.account->xdata().add_flags(prev_account->xdata().flags());
+ account_name[account_name.length() - 1] != ':') {
+ account_t * prev_account = temp.account;
+ temp.account->remove_post(&temp);
+
+ account_name += ':';
+ account_name += prev_account->fullname();
+
+ std::list<string> account_names;
+ split_string(account_name, ':', account_names);
+ temp.account = create_temp_account_from_path(account_names, temps,
+ xact.journal->master);
+ temp.account->add_post(&temp);
+
+ temp.account->add_flags(prev_account->flags());
+ if (prev_account->has_xdata())
+ temp.account->xdata().add_flags(prev_account->xdata().flags());
}
break;
}
@@ -1153,41 +1153,41 @@ void budget_posts::report_budget_items(const date_t& date)
foreach (pending_posts_list::value_type& pair, pending_posts) {
optional<date_t> begin = pair.first.start;
if (! begin) {
- if (! pair.first.find_period(date))
- continue;
- begin = pair.first.start;
+ if (! pair.first.find_period(date))
+ continue;
+ begin = pair.first.start;
}
assert(begin);
if (*begin <= date &&
- (! pair.first.finish || *begin < *pair.first.finish)) {
- post_t& post = *pair.second;
+ (! pair.first.finish || *begin < *pair.first.finish)) {
+ post_t& post = *pair.second;
- DEBUG("budget.generate", "Reporting budget for "
- << post.reported_account()->fullname());
+ DEBUG("budget.generate", "Reporting budget for "
+ << post.reported_account()->fullname());
- xact_t& xact = temps.create_xact();
- xact.payee = _("Budget transaction");
- xact._date = begin;
+ xact_t& xact = temps.create_xact();
+ xact.payee = _("Budget transaction");
+ xact._date = begin;
- post_t& temp = temps.copy_post(post, xact);
- temp.amount.in_place_negate();
+ post_t& temp = temps.copy_post(post, xact);
+ temp.amount.in_place_negate();
- if (flags & BUDGET_WRAP_VALUES) {
- value_t seq;
- seq.push_back(0L);
- seq.push_back(temp.amount);
+ if (flags & BUDGET_WRAP_VALUES) {
+ value_t seq;
+ seq.push_back(0L);
+ seq.push_back(temp.amount);
- temp.xdata().compound_value = seq;
- temp.xdata().add_flags(POST_EXT_COMPOUND);
- }
+ temp.xdata().compound_value = seq;
+ temp.xdata().add_flags(POST_EXT_COMPOUND);
+ }
- ++pair.first;
- begin = *pair.first.start;
+ ++pair.first;
+ begin = *pair.first.start;
- item_handler<post_t>::operator()(temp);
+ item_handler<post_t>::operator()(temp);
- reported = true;
+ reported = true;
}
}
} while (reported);
@@ -1199,14 +1199,14 @@ void budget_posts::operator()(post_t& post)
foreach (pending_posts_list::value_type& pair, pending_posts) {
for (account_t * acct = post.reported_account();
- acct;
- acct = acct->parent) {
+ acct;
+ acct = acct->parent) {
if (acct == (*pair.second).reported_account()) {
- post_in_budget = true;
- // Report the post as if it had occurred in the parent account.
- if (post.reported_account() != acct)
- post.set_reported_account(acct);
- goto handle;
+ post_in_budget = true;
+ // Report the post as if it had occurred in the parent account.
+ if (post.reported_account() != acct)
+ post.set_reported_account(acct);
+ goto handle;
}
}
}
@@ -1274,10 +1274,10 @@ void forecast_posts::flush()
// period contains the earliest starting date.
pending_posts_list::iterator least = pending_posts.begin();
for (pending_posts_list::iterator i = ++pending_posts.begin();
- i != pending_posts.end();
- i++) {
+ i != pending_posts.end();
+ i++) {
if (*(*i).first.start < *(*least).first.start)
- least = i;
+ least = i;
}
date_t& begin = *(*least).first.start;
@@ -1293,10 +1293,10 @@ void forecast_posts::flush()
assert(next > begin);
if (static_cast<std::size_t>((next - last).days()) >
- static_cast<std::size_t>(365U) * forecast_years) {
+ static_cast<std::size_t>(365U) * forecast_years) {
DEBUG("filters.forecast",
- "Forecast transaction exceeds " << forecast_years
- << " years beyond today");
+ "Forecast transaction exceeds " << forecast_years
+ << " years beyond today");
pending_posts.erase(least);
continue;
}
@@ -1309,15 +1309,15 @@ void forecast_posts::flush()
// "Forecast transaction".
post_t& post = *(*least).second;
xact_t& xact = temps.create_xact();
- xact.payee = _("Forecast transaction");
- xact._date = begin;
+ xact.payee = _("Forecast transaction");
+ xact._date = begin;
post_t& temp = temps.copy_post(post, xact);
// Submit the generated posting
DEBUG("filters.forecast",
- "Forecast transaction: " << temp.date()
- << " " << temp.account->fullname()
- << " " << temp.amount);
+ "Forecast transaction: " << temp.date()
+ << " " << temp.account->fullname()
+ << " " << temp.amount);
item_handler<post_t>::operator()(temp);
// If the generated posting matches the user's report query, check whether
@@ -1327,9 +1327,9 @@ void forecast_posts::flush()
DEBUG("filters.forecast", " matches report query");
bind_scope_t bound_scope(context, temp);
if (! pred(bound_scope)) {
- DEBUG("filters.forecast", " fails to match continuation criteria");
- pending_posts.erase(least);
- continue;
+ DEBUG("filters.forecast", " fails to match continuation criteria");
+ pending_posts.erase(least);
+ continue;
}
}
}
@@ -1337,10 +1337,10 @@ void forecast_posts::flush()
item_handler<post_t>::flush();
}
-pass_down_accounts::pass_down_accounts(acct_handler_ptr handler,
- accounts_iterator& iter,
- const optional<predicate_t>& _pred,
- const optional<scope_t&>& _context)
+pass_down_accounts::pass_down_accounts(acct_handler_ptr handler,
+ accounts_iterator& iter,
+ const optional<predicate_t>& _pred,
+ const optional<scope_t&>& _context)
: item_handler<account_t>(handler), pred(_pred), context(_context)
{
TRACE_CTOR(pass_down_accounts, "acct_handler_ptr, accounts_iterator, ...");
@@ -1351,7 +1351,7 @@ pass_down_accounts::pass_down_accounts(acct_handler_ptr handler,
} else {
bind_scope_t bound_scope(*context, *account);
if ((*pred)(bound_scope))
- item_handler<account_t>::operator()(*account);
+ item_handler<account_t>::operator()(*account);
}
}
diff --git a/src/filters.h b/src/filters.h
index ffca9d1e..e981dcd4 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -62,17 +62,17 @@ public:
typedef function<void (const value_t&)> custom_flusher_t;
protected:
- value_to_posts_map posts_map;
- post_handler_ptr post_chain;
- report_t& report;
- expr_t group_by_expr;
- custom_flusher_t preflush_func;
+ value_to_posts_map posts_map;
+ post_handler_ptr post_chain;
+ report_t& report;
+ expr_t group_by_expr;
+ custom_flusher_t preflush_func;
optional<custom_flusher_t> postflush_func;
public:
post_splitter(post_handler_ptr _post_chain,
- report_t& _report,
- expr_t _group_by_expr)
+ report_t& _report,
+ expr_t _group_by_expr)
: post_chain(_post_chain), report(_report),
group_by_expr(_group_by_expr),
preflush_func(bind(&post_splitter::print_title, this, _1)) {
@@ -192,7 +192,7 @@ class truncate_xacts : public item_handler<post_t>
public:
truncate_xacts(post_handler_ptr handler,
- int _head_count, int _tail_count)
+ int _head_count, int _tail_count)
: item_handler<post_t>(handler),
head_count(_head_count), tail_count(_tail_count),
completed(false), xacts_seen(0), last_xact(NULL) {
@@ -267,12 +267,12 @@ public:
sort_xacts(post_handler_ptr handler, const expr_t& _sort_order)
: sorter(handler, _sort_order) {
TRACE_CTOR(sort_xacts,
- "post_handler_ptr, const value_expr&");
+ "post_handler_ptr, const value_expr&");
}
sort_xacts(post_handler_ptr handler, const string& _sort_order)
: sorter(handler, _sort_order) {
TRACE_CTOR(sort_xacts,
- "post_handler_ptr, const string&");
+ "post_handler_ptr, const string&");
}
virtual ~sort_xacts() {
TRACE_DTOR(sort_xacts);
@@ -308,9 +308,9 @@ class filter_posts : public item_handler<post_t>
filter_posts();
public:
- filter_posts(post_handler_ptr handler,
- const predicate_t& predicate,
- scope_t& _context)
+ filter_posts(post_handler_ptr handler,
+ const predicate_t& predicate,
+ scope_t& _context)
: item_handler<post_t>(handler), pred(predicate), context(_context) {
TRACE_CTOR(filter_posts, "post_handler_ptr, predicate_t, scope_t&");
}
@@ -336,10 +336,10 @@ class anonymize_posts : public item_handler<post_t>
{
typedef std::map<commodity_t *, std::size_t> commodity_index_map;
- temporaries_t temps;
+ temporaries_t temps;
commodity_index_map comms;
std::size_t next_comm_id;
- xact_t * last_xact;
+ xact_t * last_xact;
anonymize_posts();
@@ -374,8 +374,8 @@ class calc_posts : public item_handler<post_t>
public:
calc_posts(post_handler_ptr handler,
- expr_t& _amount_expr,
- bool _calc_running_total = false)
+ expr_t& _amount_expr,
+ bool _calc_running_total = false)
: item_handler<post_t>(handler), last_post(NULL),
amount_expr(_amount_expr), calc_running_total(_calc_running_total) {
TRACE_CTOR(calc_posts, "post_handler_ptr, expr_t&, bool");
@@ -396,16 +396,16 @@ public:
class collapse_posts : public item_handler<post_t>
{
- expr_t& amount_expr;
- predicate_t display_predicate;
- predicate_t only_predicate;
- value_t subtotal;
- std::size_t count;
- xact_t * last_xact;
- post_t * last_post;
+ expr_t& amount_expr;
+ predicate_t display_predicate;
+ predicate_t only_predicate;
+ value_t subtotal;
+ std::size_t count;
+ xact_t * last_xact;
+ post_t * last_post;
temporaries_t temps;
- account_t& totals_account;
- bool only_collapse_if_zero;
+ account_t& totals_account;
+ bool only_collapse_if_zero;
std::list<post_t *> component_posts;
report_t& report;
@@ -413,11 +413,11 @@ class collapse_posts : public item_handler<post_t>
public:
collapse_posts(post_handler_ptr handler,
- report_t& _report,
- expr_t& _amount_expr,
- predicate_t _display_predicate,
- predicate_t _only_predicate,
- bool _only_collapse_if_zero = false)
+ report_t& _report,
+ expr_t& _amount_expr,
+ predicate_t _display_predicate,
+ predicate_t _only_predicate,
+ bool _only_collapse_if_zero = false)
: item_handler<post_t>(handler), amount_expr(_amount_expr),
display_predicate(_display_predicate),
only_predicate(_only_predicate), count(0),
@@ -459,17 +459,17 @@ public:
class related_posts : public item_handler<post_t>
{
posts_list posts;
- bool also_matching;
+ bool also_matching;
related_posts();
public:
related_posts(post_handler_ptr handler,
- const bool _also_matching = false)
+ const bool _also_matching = false)
: item_handler<post_t>(handler),
also_matching(_also_matching) {
TRACE_CTOR(related_posts,
- "post_handler_ptr, const bool");
+ "post_handler_ptr, const bool");
}
virtual ~related_posts() throw() {
TRACE_DTOR(related_posts);
@@ -492,22 +492,22 @@ class display_filter_posts : public item_handler<post_t>
// This filter requires that calc_posts be used at some point
// later in the chain.
- expr_t display_amount_expr;
- expr_t display_total_expr;
+ expr_t display_amount_expr;
+ expr_t display_total_expr;
report_t& report;
- bool show_rounding;
- value_t last_display_total;
- temporaries_t temps;
- account_t& rounding_account;
+ bool show_rounding;
+ value_t last_display_total;
+ temporaries_t temps;
+ account_t& rounding_account;
display_filter_posts();
public:
- account_t& revalued_account;
+ account_t& revalued_account;
display_filter_posts(post_handler_ptr handler,
- report_t& _report,
- bool _show_rounding);
+ report_t& _report,
+ bool _show_rounding);
virtual ~display_filter_posts() {
TRACE_DTOR(display_filter_posts);
@@ -534,30 +534,30 @@ class changed_value_posts : public item_handler<post_t>
// This filter requires that calc_posts be used at some point
// later in the chain.
- expr_t total_expr;
- expr_t display_total_expr;
- report_t& report;
- bool changed_values_only;
- bool for_accounts_report;
- bool show_unrealized;
- post_t * last_post;
- value_t last_total;
+ expr_t total_expr;
+ expr_t display_total_expr;
+ report_t& report;
+ bool changed_values_only;
+ bool for_accounts_report;
+ bool show_unrealized;
+ post_t * last_post;
+ value_t last_total;
value_t repriced_total;
- temporaries_t temps;
- account_t& revalued_account;
- account_t * gains_equity_account;
- account_t * losses_equity_account;
+ temporaries_t temps;
+ account_t& revalued_account;
+ account_t * gains_equity_account;
+ account_t * losses_equity_account;
display_filter_posts * display_filter;
changed_value_posts();
public:
- changed_value_posts(post_handler_ptr handler,
- report_t& _report,
- bool _for_accounts_report,
- bool _show_unrealized,
- display_filter_posts * _display_filter);
+ changed_value_posts(post_handler_ptr handler,
+ report_t& _report,
+ bool _for_accounts_report,
+ bool _show_unrealized,
+ display_filter_posts * _display_filter);
virtual ~changed_value_posts() {
TRACE_DTOR(changed_value_posts);
@@ -593,8 +593,8 @@ protected:
acct_value_t();
public:
- account_t * account;
- value_t value;
+ account_t * account;
+ value_t value;
acct_value_t(account_t * a) : account(a) {
TRACE_CTOR(acct_value_t, "account_t *");
@@ -615,26 +615,26 @@ protected:
typedef std::pair<string, acct_value_t> values_pair;
protected:
- expr_t& amount_expr;
- values_map values;
+ expr_t& amount_expr;
+ values_map values;
optional<string> date_format;
temporaries_t temps;
std::list<post_t *> component_posts;
public:
subtotal_posts(post_handler_ptr handler, expr_t& _amount_expr,
- const optional<string>& _date_format = none)
+ const optional<string>& _date_format = none)
: item_handler<post_t>(handler), amount_expr(_amount_expr),
date_format(_date_format) {
TRACE_CTOR(subtotal_posts,
- "post_handler_ptr, expr_t&, const optional<string>&");
+ "post_handler_ptr, expr_t&, const optional<string>&");
}
virtual ~subtotal_posts() {
TRACE_DTOR(subtotal_posts);
}
void report_subtotal(const char * spec_fmt = NULL,
- const optional<date_interval_t>& interval = none);
+ const optional<date_interval_t>& interval = none);
virtual void flush() {
if (values.size() > 0)
@@ -658,27 +658,27 @@ class interval_posts : public subtotal_posts
date_interval_t start_interval;
date_interval_t interval;
date_interval_t last_interval;
- post_t * last_post;
- account_t& empty_account;
- bool exact_periods;
- bool generate_empty_posts;
+ post_t * last_post;
+ account_t& empty_account;
+ bool exact_periods;
+ bool generate_empty_posts;
interval_posts();
public:
- interval_posts(post_handler_ptr _handler,
- expr_t& amount_expr,
- const date_interval_t& _interval,
- bool _exact_periods = false,
- bool _generate_empty_posts = false)
+ interval_posts(post_handler_ptr _handler,
+ expr_t& amount_expr,
+ const date_interval_t& _interval,
+ bool _exact_periods = false,
+ bool _generate_empty_posts = false)
: subtotal_posts(_handler, amount_expr), start_interval(_interval),
interval(start_interval), last_post(NULL),
empty_account(temps.create_account(_("<None>"))),
exact_periods(_exact_periods),
generate_empty_posts(_generate_empty_posts) {
TRACE_CTOR(interval_posts,
- "post_handler_ptr, expr_t&, date_interval_t, bool, bool");
+ "post_handler_ptr, expr_t&, date_interval_t, bool, bool");
}
virtual ~interval_posts() throw() {
TRACE_DTOR(interval_posts);
@@ -689,7 +689,7 @@ public:
virtual void flush() {
if (last_post && interval.duration) {
if (interval.is_valid())
- report_subtotal(interval);
+ report_subtotal(interval);
subtotal_posts::flush();
}
}
@@ -741,7 +741,7 @@ class by_payee_posts : public item_handler<post_t>
typedef std::map<string, shared_ptr<subtotal_posts> > payee_subtotals_map;
typedef std::pair<string, shared_ptr<subtotal_posts> > payee_subtotals_pair;
- expr_t& amount_expr;
+ expr_t& amount_expr;
payee_subtotals_map payee_subtotals;
by_payee_posts();
@@ -768,9 +768,9 @@ class by_payee_posts : public item_handler<post_t>
class transfer_details : public item_handler<post_t>
{
- account_t * master;
- expr_t expr;
- scope_t& scope;
+ account_t * master;
+ expr_t expr;
+ scope_t& scope;
temporaries_t temps;
transfer_details();
@@ -783,14 +783,14 @@ public:
} which_element;
transfer_details(post_handler_ptr handler,
- element_t _which_element,
- account_t * _master,
- const expr_t& _expr,
- scope_t& _scope)
+ element_t _which_element,
+ account_t * _master,
+ const expr_t& _expr,
+ scope_t& _scope)
: item_handler<post_t>(handler), master(_master),
expr(_expr), scope(_scope), which_element(_which_element) {
TRACE_CTOR(transfer_details,
- "post_handler_ptr, element_t, account_t *, expr_t, scope_t&");
+ "post_handler_ptr, element_t, account_t *, expr_t, scope_t&");
}
virtual ~transfer_details() {
TRACE_DTOR(transfer_details);
@@ -840,7 +840,7 @@ class generate_posts : public item_handler<post_t>
protected:
typedef std::pair<date_interval_t, post_t *> pending_posts_pair;
- typedef std::list<pending_posts_pair> pending_posts_list;
+ typedef std::list<pending_posts_pair> pending_posts_list;
pending_posts_list pending_posts;
temporaries_t temps;
@@ -870,7 +870,7 @@ public:
class budget_posts : public generate_posts
{
#define BUDGET_NO_BUDGET 0x00
-#define BUDGET_BUDGETED 0x01
+#define BUDGET_BUDGETED 0x01
#define BUDGET_UNBUDGETED 0x02
#define BUDGET_WRAP_VALUES 0x04
@@ -880,7 +880,7 @@ class budget_posts : public generate_posts
public:
budget_posts(post_handler_ptr handler,
- uint_least8_t _flags = BUDGET_BUDGETED)
+ uint_least8_t _flags = BUDGET_BUDGETED)
: generate_posts(handler), flags(_flags) {
TRACE_CTOR(budget_posts, "post_handler_ptr, uint_least8_t");
}
@@ -895,19 +895,19 @@ public:
class forecast_posts : public generate_posts
{
- predicate_t pred;
- scope_t& context;
+ predicate_t pred;
+ scope_t& context;
const std::size_t forecast_years;
public:
forecast_posts(post_handler_ptr handler,
- const predicate_t& predicate,
- scope_t& _context,
- const std::size_t _forecast_years)
+ const predicate_t& predicate,
+ scope_t& _context,
+ const std::size_t _forecast_years)
: generate_posts(handler), pred(predicate), context(_context),
forecast_years(_forecast_years) {
TRACE_CTOR(forecast_posts,
- "post_handler_ptr, predicate_t, scope_t&, std::size_t");
+ "post_handler_ptr, predicate_t, scope_t&, std::size_t");
}
virtual ~forecast_posts() throw() {
TRACE_DTOR(forecast_posts);
@@ -937,10 +937,10 @@ class pass_down_accounts : public item_handler<account_t>
optional<scope_t&> context;
public:
- pass_down_accounts(acct_handler_ptr handler,
- accounts_iterator& iter,
- const optional<predicate_t>& _pred = none,
- const optional<scope_t&>& _context = none);
+ pass_down_accounts(acct_handler_ptr handler,
+ accounts_iterator& iter,
+ const optional<predicate_t>& _pred = none,
+ const optional<scope_t&>& _context = none);
virtual ~pass_down_accounts() {
TRACE_DTOR(pass_down_accounts);
diff --git a/src/format.cc b/src/format.cc
index c546926e..bde39882 100644
--- a/src/format.cc
+++ b/src/format.cc
@@ -37,8 +37,8 @@
namespace ledger {
-format_t::elision_style_t format_t::default_style = TRUNCATE_TRAILING;
-bool format_t::default_style_changed = false;
+format_t::elision_style_t format_t::default_style = TRUNCATE_TRAILING;
+bool format_t::default_style_changed = false;
void format_t::element_t::dump(std::ostream& out) const
{
@@ -88,14 +88,14 @@ namespace {
// Don't gobble up any whitespace
const char * base = p;
while (p >= base && std::isspace(*p))
- p--;
+ p--;
}
return expr;
}
}
format_t::element_t * format_t::parse_elements(const string& fmt,
- const optional<format_t&>& tmpl)
+ const optional<format_t&>& tmpl)
{
std::auto_ptr<element_t> result;
@@ -147,8 +147,8 @@ format_t::element_t * format_t::parse_elements(const string& fmt,
while (*p == '-') {
switch (*p) {
case '-':
- current->add_flags(ELEMENT_ALIGN_LEFT);
- break;
+ current->add_flags(ELEMENT_ALIGN_LEFT);
+ break;
}
++p;
}
@@ -164,12 +164,12 @@ format_t::element_t * format_t::parse_elements(const string& fmt,
++p;
num = 0;
while (*p && std::isdigit(*p)) {
- num *= 10;
- num += *p++ - '0';
+ num *= 10;
+ num += *p++ - '0';
}
current->max_width = num;
if (current->min_width == 0)
- current->min_width = current->max_width;
+ current->min_width = current->max_width;
}
switch (*p) {
@@ -180,25 +180,25 @@ format_t::element_t * format_t::parse_elements(const string& fmt,
case '$': {
if (! tmpl)
- throw_(format_error, _("Prior field reference, but no template"));
+ throw_(format_error, _("Prior field reference, but no template"));
p++;
if (*p == '0' || (! std::isdigit(*p) &&
- *p != 'A' && *p != 'B' && *p != 'C' &&
- *p != 'D' && *p != 'E' && *p != 'F'))
- throw_(format_error, _("%$ field reference must be a digit from 1-9"));
+ *p != 'A' && *p != 'B' && *p != 'C' &&
+ *p != 'D' && *p != 'E' && *p != 'F'))
+ throw_(format_error, _("%$ field reference must be a digit from 1-9"));
unsigned int index = std::isdigit(*p) ? *p - '0' : (*p - 'A' + 10);
element_t * tmpl_elem = tmpl->elements.get();
for (unsigned int i = 1; i < index && tmpl_elem; i++) {
- tmpl_elem = tmpl_elem->next.get();
- while (tmpl_elem && tmpl_elem->type != element_t::EXPR)
- tmpl_elem = tmpl_elem->next.get();
+ tmpl_elem = tmpl_elem->next.get();
+ while (tmpl_elem && tmpl_elem->type != element_t::EXPR)
+ tmpl_elem = tmpl_elem->next.get();
}
if (! tmpl_elem)
- throw_(format_error, _("%$ reference to a non-existent prior field"));
+ throw_(format_error, _("%$ reference to a non-existent prior field"));
*current = *tmpl_elem;
break;
@@ -214,87 +214,87 @@ format_t::element_t * format_t::parse_elements(const string& fmt,
// Wrap the subexpression in calls to justify and scrub
if (format_amount) {
- if (! *p || *(p + 1) != '}')
- throw_(format_error, _("Expected closing brace"));
- else
- p++;
+ if (! *p || *(p + 1) != '}')
+ throw_(format_error, _("Expected closing brace"));
+ else
+ p++;
- expr_t::ptr_op_t op = boost::get<expr_t>(current->data).get_op();
+ expr_t::ptr_op_t op = boost::get<expr_t>(current->data).get_op();
- expr_t::ptr_op_t amount_op;
- expr_t::ptr_op_t colorize_op;
- if (op->kind == expr_t::op_t::O_CONS) {
- amount_op = op->left();
- colorize_op = op->right();
- } else {
- amount_op = op;
- }
+ expr_t::ptr_op_t amount_op;
+ expr_t::ptr_op_t colorize_op;
+ if (op->kind == expr_t::op_t::O_CONS) {
+ amount_op = op->left();
+ colorize_op = op->right();
+ } else {
+ amount_op = op;
+ }
- expr_t::ptr_op_t scrub_node(new expr_t::op_t(expr_t::op_t::IDENT));
- scrub_node->set_ident("scrub");
+ expr_t::ptr_op_t scrub_node(new expr_t::op_t(expr_t::op_t::IDENT));
+ scrub_node->set_ident("scrub");
- expr_t::ptr_op_t call1_node(new expr_t::op_t(expr_t::op_t::O_CALL));
- call1_node->set_left(scrub_node);
- call1_node->set_right(amount_op);
+ expr_t::ptr_op_t call1_node(new expr_t::op_t(expr_t::op_t::O_CALL));
+ call1_node->set_left(scrub_node);
+ call1_node->set_right(amount_op);
- expr_t::ptr_op_t arg1_node(new expr_t::op_t(expr_t::op_t::VALUE));
- expr_t::ptr_op_t arg2_node(new expr_t::op_t(expr_t::op_t::VALUE));
- expr_t::ptr_op_t arg3_node(new expr_t::op_t(expr_t::op_t::VALUE));
+ expr_t::ptr_op_t arg1_node(new expr_t::op_t(expr_t::op_t::VALUE));
+ expr_t::ptr_op_t arg2_node(new expr_t::op_t(expr_t::op_t::VALUE));
+ expr_t::ptr_op_t arg3_node(new expr_t::op_t(expr_t::op_t::VALUE));
- arg1_node->set_value(current->min_width > 0 ?
- long(current->min_width) : -1);
- arg2_node->set_value(current->max_width > 0 ?
- long(current->max_width) : -1);
- arg3_node->set_value(! current->has_flags(ELEMENT_ALIGN_LEFT));
+ arg1_node->set_value(current->min_width > 0 ?
+ long(current->min_width) : -1);
+ arg2_node->set_value(current->max_width > 0 ?
+ long(current->max_width) : -1);
+ arg3_node->set_value(! current->has_flags(ELEMENT_ALIGN_LEFT));
- current->min_width = 0;
- current->max_width = 0;
+ current->min_width = 0;
+ current->max_width = 0;
- expr_t::ptr_op_t args1_node(new expr_t::op_t(expr_t::op_t::O_CONS));
- args1_node->set_left(arg2_node);
- args1_node->set_right(arg3_node);
+ expr_t::ptr_op_t args1_node(new expr_t::op_t(expr_t::op_t::O_CONS));
+ args1_node->set_left(arg2_node);
+ args1_node->set_right(arg3_node);
- expr_t::ptr_op_t args2_node(new expr_t::op_t(expr_t::op_t::O_CONS));
- args2_node->set_left(arg1_node);
- args2_node->set_right(args1_node);
+ expr_t::ptr_op_t args2_node(new expr_t::op_t(expr_t::op_t::O_CONS));
+ args2_node->set_left(arg1_node);
+ args2_node->set_right(args1_node);
- expr_t::ptr_op_t args3_node(new expr_t::op_t(expr_t::op_t::O_CONS));
- args3_node->set_left(call1_node);
- args3_node->set_right(args2_node);
+ expr_t::ptr_op_t args3_node(new expr_t::op_t(expr_t::op_t::O_CONS));
+ args3_node->set_left(call1_node);
+ args3_node->set_right(args2_node);
- expr_t::ptr_op_t seq1_node(new expr_t::op_t(expr_t::op_t::O_SEQ));
- seq1_node->set_left(args3_node);
+ expr_t::ptr_op_t seq1_node(new expr_t::op_t(expr_t::op_t::O_SEQ));
+ seq1_node->set_left(args3_node);
- expr_t::ptr_op_t justify_node(new expr_t::op_t(expr_t::op_t::IDENT));
- justify_node->set_ident("justify");
+ expr_t::ptr_op_t justify_node(new expr_t::op_t(expr_t::op_t::IDENT));
+ justify_node->set_ident("justify");
- expr_t::ptr_op_t call2_node(new expr_t::op_t(expr_t::op_t::O_CALL));
- call2_node->set_left(justify_node);
- call2_node->set_right(seq1_node);
+ expr_t::ptr_op_t call2_node(new expr_t::op_t(expr_t::op_t::O_CALL));
+ call2_node->set_left(justify_node);
+ call2_node->set_right(seq1_node);
- string prev_expr = boost::get<expr_t>(current->data).text();
+ string prev_expr = boost::get<expr_t>(current->data).text();
- if (colorize_op) {
- expr_t::ptr_op_t ansify_if_node(new expr_t::op_t(expr_t::op_t::IDENT));
- ansify_if_node->set_ident("ansify_if");
+ if (colorize_op) {
+ expr_t::ptr_op_t ansify_if_node(new expr_t::op_t(expr_t::op_t::IDENT));
+ ansify_if_node->set_ident("ansify_if");
- expr_t::ptr_op_t args4_node(new expr_t::op_t(expr_t::op_t::O_CONS));
- args4_node->set_left(call2_node);
- args4_node->set_right(colorize_op);
+ expr_t::ptr_op_t args4_node(new expr_t::op_t(expr_t::op_t::O_CONS));
+ args4_node->set_left(call2_node);
+ args4_node->set_right(colorize_op);
- expr_t::ptr_op_t seq2_node(new expr_t::op_t(expr_t::op_t::O_SEQ));
- seq2_node->set_left(args4_node);
+ expr_t::ptr_op_t seq2_node(new expr_t::op_t(expr_t::op_t::O_SEQ));
+ seq2_node->set_left(args4_node);
- expr_t::ptr_op_t call3_node(new expr_t::op_t(expr_t::op_t::O_CALL));
- call3_node->set_left(ansify_if_node);
- call3_node->set_right(seq2_node);
+ expr_t::ptr_op_t call3_node(new expr_t::op_t(expr_t::op_t::O_CALL));
+ call3_node->set_left(ansify_if_node);
+ call3_node->set_right(seq2_node);
- current->data = expr_t(call3_node);
- } else {
- current->data = expr_t(call2_node);
- }
+ current->data = expr_t(call3_node);
+ } else {
+ current->data = expr_t(call2_node);
+ }
- boost::get<expr_t>(current->data).set_text(prev_expr);
+ boost::get<expr_t>(current->data).set_text(prev_expr);
}
break;
}
@@ -335,7 +335,7 @@ string format_t::real_calc(scope_t& scope)
switch (elem->type) {
case element_t::STRING:
if (elem->min_width > 0)
- out.width(elem->min_width);
+ out.width(elem->min_width);
out << boost::get<string>(elem->data);
break;
@@ -343,28 +343,28 @@ string format_t::real_calc(scope_t& scope)
expr_t& expr(boost::get<expr_t>(elem->data));
try {
- expr.compile(scope);
-
- value_t value;
- if (expr.is_function()) {
- call_scope_t args(scope);
- args.push_back(long(elem->max_width));
- value = expr.get_function()(args);
- } else {
- value = expr.calc(scope);
- }
- DEBUG("format.expr", "value = (" << value << ")");
-
- if (elem->min_width > 0)
- value.print(out, static_cast<int>(elem->min_width), -1,
- ! elem->has_flags(ELEMENT_ALIGN_LEFT));
- else
- out << value.to_string();
+ expr.compile(scope);
+
+ value_t value;
+ if (expr.is_function()) {
+ call_scope_t args(scope);
+ args.push_back(long(elem->max_width));
+ value = expr.get_function()(args);
+ } else {
+ value = expr.calc(scope);
+ }
+ DEBUG("format.expr", "value = (" << value << ")");
+
+ if (elem->min_width > 0)
+ value.print(out, static_cast<int>(elem->min_width), -1,
+ ! elem->has_flags(ELEMENT_ALIGN_LEFT));
+ else
+ out << value.to_string();
}
catch (const calc_error&) {
- add_error_context(_("While calculating format expression:"));
- add_error_context(expr.context_to_str());
- throw;
+ add_error_context(_("While calculating format expression:"));
+ add_error_context(expr.context_to_str());
+ throw;
}
break;
}
@@ -376,15 +376,15 @@ string format_t::real_calc(scope_t& scope)
if (elem->max_width > 0 || elem->min_width > 0) {
unistring temp(out.str());
- string result;
+ string result;
if (elem->max_width > 0 && elem->max_width < temp.length()) {
- result = truncate(temp, elem->max_width);
+ result = truncate(temp, elem->max_width);
} else {
- result = temp.extract();
- if (elem->min_width > temp.length())
- for (std::size_t i = 0; i < elem->min_width - temp.length(); i++)
- result += " ";
+ result = temp.extract();
+ if (elem->min_width > temp.length())
+ for (std::size_t i = 0; i < elem->min_width - temp.length(); i++)
+ result += " ";
}
out_str << result;
} else {
@@ -396,8 +396,8 @@ string format_t::real_calc(scope_t& scope)
}
string format_t::truncate(const unistring& ustr,
- const std::size_t width,
- const std::size_t account_abbrev_length)
+ const std::size_t width,
+ const std::size_t account_abbrev_length)
{
assert(width < 4095);
@@ -420,9 +420,9 @@ string format_t::truncate(const unistring& ustr,
case TRUNCATE_MIDDLE:
// This method truncates in the middle.
buf << ustr.extract(0, (width - 2) / 2)
- << ".."
- << ustr.extract(len - ((width - 2) / 2 + (width - 2) % 2),
- (width - 2) / 2 + (width - 2) % 2);
+ << ".."
+ << ustr.extract(len - ((width - 2) / 2 + (width - 2) % 2),
+ (width - 2) / 2 + (width - 2) % 2);
break;
case ABBREVIATE:
@@ -431,46 +431,46 @@ string format_t::truncate(const unistring& ustr,
string::size_type beg = 0;
string strcopy(ustr.extract());
for (string::size_type pos = strcopy.find(':');
- pos != string::npos;
- beg = pos + 1, pos = strcopy.find(':', beg))
- parts.push_back(string(strcopy, beg, pos - beg));
+ pos != string::npos;
+ beg = pos + 1, pos = strcopy.find(':', beg))
+ parts.push_back(string(strcopy, beg, pos - beg));
parts.push_back(string(strcopy, beg));
std::ostringstream result;
std::size_t newlen = len;
for (std::list<string>::iterator i = parts.begin();
- i != parts.end();
- i++) {
- // Don't contract the last element
- std::list<string>::iterator x = i;
- if (++x == parts.end()) {
- result << *i;
- break;
- }
-
- if (newlen > width) {
- unistring temp(*i);
- if (temp.length() > account_abbrev_length) {
- result << temp.extract(0, account_abbrev_length) << ":";
- newlen -= temp.length() - account_abbrev_length;
- } else {
- result << temp.extract() << ":";
- newlen -= temp.length();
- }
- } else {
- result << *i << ":";
- }
+ i != parts.end();
+ i++) {
+ // Don't contract the last element
+ std::list<string>::iterator x = i;
+ if (++x == parts.end()) {
+ result << *i;
+ break;
+ }
+
+ if (newlen > width) {
+ unistring temp(*i);
+ if (temp.length() > account_abbrev_length) {
+ result << temp.extract(0, account_abbrev_length) << ":";
+ newlen -= temp.length() - account_abbrev_length;
+ } else {
+ result << temp.extract() << ":";
+ newlen -= temp.length();
+ }
+ } else {
+ result << *i << ":";
+ }
}
if (newlen > width) {
- // Even abbreviated its too big to show the last account, so
- // abbreviate all but the last and truncate at the beginning.
- unistring temp(result.str());
- assert(temp.length() > width - 2);
- buf << ".." << temp.extract(temp.length() - (width - 2), width - 2);
+ // Even abbreviated its too big to show the last account, so
+ // abbreviate all but the last and truncate at the beginning.
+ unistring temp(result.str());
+ assert(temp.length() > width - 2);
+ buf << ".." << temp.extract(temp.length() - (width - 2), width - 2);
} else {
- buf << result.str();
+ buf << result.str();
}
break;
}
diff --git a/src/format.h b/src/format.h
index 72d44ee5..a0b95567 100644
--- a/src/format.h
+++ b/src/format.h
@@ -61,10 +61,10 @@ class format_t : public expr_base_t<string>
enum kind_t { STRING, EXPR };
- kind_t type;
- std::size_t min_width;
- std::size_t max_width;
- variant<string, expr_t> data;
+ kind_t type;
+ std::size_t min_width;
+ std::size_t max_width;
+ variant<string, expr_t> data;
scoped_ptr<struct element_t> next;
element_t() throw()
@@ -80,11 +80,11 @@ class format_t : public expr_base_t<string>
element_t& operator=(const element_t& elem) {
if (this != &elem) {
- supports_flags<>::operator=(elem);
- type = elem.type;
- min_width = elem.min_width;
- max_width = elem.max_width;
- data = elem.data;
+ supports_flags<>::operator=(elem);
+ type = elem.type;
+ min_width = elem.min_width;
+ max_width = elem.max_width;
+ data = elem.data;
}
return *this;
}
@@ -95,12 +95,12 @@ class format_t : public expr_base_t<string>
out << "\033[31m";
if (elem->has_flags(ELEMENT_ALIGN_LEFT))
- out << std::left;
+ out << std::left;
else
- out << std::right;
+ out << std::right;
if (elem->min_width > 0)
- out.width(elem->min_width);
+ out.width(elem->min_width);
}
void dump(std::ostream& out) const;
@@ -120,7 +120,7 @@ public:
private:
static element_t * parse_elements(const string& fmt,
- const optional<format_t&>& tmpl);
+ const optional<format_t&>& tmpl);
public:
format_t() : base_type() {
@@ -137,7 +137,7 @@ public:
}
void parse_format(const string& _format,
- const optional<format_t&>& tmpl = none) {
+ const optional<format_t&>& tmpl = none) {
elements.reset(parse_elements(_format, tmpl));
set_text(_format);
}
@@ -146,14 +146,14 @@ public:
virtual void dump(std::ostream& out) const {
for (const element_t * elem = elements.get();
- elem;
- elem = elem->next.get())
+ elem;
+ elem = elem->next.get())
elem->dump(out);
}
static string truncate(const unistring& str,
- const std::size_t width,
- const std::size_t account_abbrev_length = 0);
+ const std::size_t width,
+ const std::size_t account_abbrev_length = 0);
};
} // namespace ledger
diff --git a/src/generate.cc b/src/generate.cc
index 3f540b22..fbfca342 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -76,10 +76,10 @@ generate_posts_iterator::generate_posts_iterator
}
void generate_posts_iterator::generate_string(std::ostream& out, int len,
- bool only_alpha)
+ bool only_alpha)
{
DEBUG("generate.post.string",
- "Generating string of length " << len << ", only alpha " << only_alpha);
+ "Generating string of length " << len << ", only alpha " << only_alpha);
int last = -1;
bool first = true;
@@ -87,38 +87,38 @@ void generate_posts_iterator::generate_string(std::ostream& out, int len,
int next = only_alpha ? 3 : three_gen();
bool output = true;
switch (next) {
- case 1: // colon
+ case 1: // colon
if (! first && last == 3 && strlen_gen() % 10 == 0 && i + 1 != len)
- out << ':';
+ out << ':';
else {
- i--;
- output = false;
+ i--;
+ output = false;
}
break;
- case 2: // space
+ case 2: // space
if (! first && last == 3 && strlen_gen() % 20 == 0 && i + 1 != len)
- out << ' ';
+ out << ' ';
else {
- i--;
- output = false;
+ i--;
+ output = false;
}
break;
- case 3: // character
+ case 3: // character
switch (three_gen()) {
- case 1: // uppercase
- out << char(upchar_gen());
- break;
- case 2: // lowercase
- out << char(downchar_gen());
- break;
- case 3: // number
- if (! only_alpha && ! first)
- out << char(numchar_gen());
- else {
- i--;
- output = false;
- }
- break;
+ case 1: // uppercase
+ out << char(upchar_gen());
+ break;
+ case 2: // lowercase
+ out << char(downchar_gen());
+ break;
+ case 3: // number
+ if (! only_alpha && ! first)
+ out << char(numchar_gen());
+ else {
+ i--;
+ output = false;
+ }
+ break;
}
break;
}
@@ -130,7 +130,7 @@ void generate_posts_iterator::generate_string(std::ostream& out, int len,
}
bool generate_posts_iterator::generate_account(std::ostream& out,
- bool no_virtual)
+ bool no_virtual)
{
bool must_balance = true;
bool is_virtual = false;
@@ -164,7 +164,7 @@ bool generate_posts_iterator::generate_account(std::ostream& out,
}
void generate_posts_iterator::generate_commodity(std::ostream& out,
- const string& exclude)
+ const string& exclude)
{
string comm;
do {
@@ -173,21 +173,21 @@ void generate_posts_iterator::generate_commodity(std::ostream& out,
comm = buf.str();
}
while (comm == exclude || comm == "h" || comm == "m" || comm == "s" ||
- comm == "and" || comm == "any" || comm == "all" || comm == "div" ||
- comm == "false" || comm == "or" || comm == "not" ||
- comm == "true" || comm == "if" || comm == "else");
+ comm == "and" || comm == "any" || comm == "all" || comm == "div" ||
+ comm == "false" || comm == "or" || comm == "not" ||
+ comm == "true" || comm == "if" || comm == "else");
out << comm;
}
string generate_posts_iterator::generate_amount(std::ostream& out,
- value_t not_this_amount,
- bool no_negative,
- const string& exclude)
+ value_t not_this_amount,
+ bool no_negative,
+ const string& exclude)
{
std::ostringstream buf;
- if (truth_gen()) { // commodity goes in front
+ if (truth_gen()) { // commodity goes in front
generate_commodity(buf, exclude);
if (truth_gen())
buf << ' ';
@@ -262,7 +262,7 @@ void generate_posts_iterator::generate_cost(std::ostream& out, value_t amount)
buf << " @@ ";
if (! generate_amount(buf, amount, true,
- amount.as_amount().commodity().symbol()).empty())
+ amount.as_amount().commodity().symbol()).empty())
out << buf.str();
}
@@ -362,20 +362,20 @@ post_t * generate_posts_iterator::operator()()
std::istringstream in(buf.str());
try {
if (session.journal->parse(in, session) != 0) {
- VERIFY(session.journal->xacts.back()->valid());
- posts.reset(*session.journal->xacts.back());
- post = posts();
+ VERIFY(session.journal->xacts.back()->valid());
+ posts.reset(*session.journal->xacts.back());
+ post = posts();
}
}
catch (std::exception& err) {
add_error_context(_("While parsing generated transaction (seed %1):")
- << seed);
+ << seed);
add_error_context(buf.str());
throw;
}
catch (int status) {
add_error_context(_("While parsing generated transaction (seed %1):")
- << seed);
+ << seed);
add_error_context(buf.str());
throw;
}
diff --git a/src/generate.h b/src/generate.h
index f0f58064..25ad41ea 100644
--- a/src/generate.h
+++ b/src/generate.h
@@ -53,7 +53,7 @@ class generate_posts_iterator : public posts_iterator
session_t& session;
unsigned int seed;
std::size_t quantity;
- bool allow_invalid;
+ bool allow_invalid;
date_t next_date;
date_t next_eff_date;
@@ -97,9 +97,9 @@ class generate_posts_iterator : public posts_iterator
public:
generate_posts_iterator(session_t& _session,
- unsigned int _seed = 0,
- std::size_t _quantity = 100,
- bool _allow_invalid = false);
+ unsigned int _seed = 0,
+ std::size_t _quantity = 100,
+ bool _allow_invalid = false);
virtual ~generate_posts_iterator() throw() {
TRACE_DTOR(generate_posts_iterator);
@@ -108,21 +108,21 @@ public:
virtual post_t * operator()();
protected:
- void generate_string(std::ostream& out, int len, bool only_alpha = false);
- bool generate_account(std::ostream& out, bool no_virtual = false);
- void generate_commodity(std::ostream& out, const string& exclude = "");
+ void generate_string(std::ostream& out, int len, bool only_alpha = false);
+ bool generate_account(std::ostream& out, bool no_virtual = false);
+ void generate_commodity(std::ostream& out, const string& exclude = "");
string generate_amount(std::ostream& out,
- value_t not_this_amount = NULL_VALUE,
- bool no_negative = false,
- const string& exclude = "");
- bool generate_post(std::ostream& out, bool no_amount = false);
- void generate_cost(std::ostream& out, value_t amount);
- void generate_date(std::ostream& out);
- void generate_state(std::ostream& out);
- void generate_code(std::ostream& out);
- void generate_payee(std::ostream& out);
- void generate_note(std::ostream& out);
- void generate_xact(std::ostream& out);
+ value_t not_this_amount = NULL_VALUE,
+ bool no_negative = false,
+ const string& exclude = "");
+ bool generate_post(std::ostream& out, bool no_amount = false);
+ void generate_cost(std::ostream& out, value_t amount);
+ void generate_date(std::ostream& out);
+ void generate_state(std::ostream& out);
+ void generate_code(std::ostream& out);
+ void generate_payee(std::ostream& out);
+ void generate_note(std::ostream& out);
+ void generate_xact(std::ostream& out);
};
} // namespace ledger
diff --git a/src/global.cc b/src/global.cc
index 35651ddb..eb138f25 100644
--- a/src/global.cc
+++ b/src/global.cc
@@ -113,10 +113,10 @@ void global_scope_t::read_init()
ifstream init(init_file);
if (session().journal->read(init_file, NULL, &report()) > 0 ||
- session().journal->auto_xacts.size() > 0 ||
- session().journal->period_xacts.size() > 0) {
- throw_(parse_error, _("Transactions found in initialization file '%1'")
- << init_file);
+ session().journal->auto_xacts.size() > 0 ||
+ session().journal->period_xacts.size() > 0) {
+ throw_(parse_error, _("Transactions found in initialization file '%1'")
+ << init_file);
}
TRACE_FINISH(init, 1);
@@ -137,7 +137,7 @@ char * global_scope_t::prompt_string()
void global_scope_t::report_error(const std::exception& err)
{
- std::cout.flush(); // first display anything that was pending
+ std::cout.flush(); // first display anything that was pending
if (caught_signal == NONE_CAUGHT) {
// Display any pending error context information
@@ -163,7 +163,7 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
}
strings_list::iterator arg = args.begin();
- string verb = *arg++;
+ string verb = *arg++;
// Look for a precommand first, which is defined as any defined function
// whose name starts with "ledger_precmd_". The difference between a
@@ -180,8 +180,8 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
// then invoke the command.
expr_t::func_t command;
- bool is_precommand = false;
- bind_scope_t bound_scope(*this, report());
+ bool is_precommand = false;
+ bind_scope_t bound_scope(*this, report());
if (bool(command = look_for_precommand(bound_scope, verb)))
is_precommand = true;
@@ -206,11 +206,11 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
report().output_stream
.initialize(report().HANDLED(output_) ?
- optional<path>(path(report().HANDLER(output_).str())) :
- optional<path>(),
- report().HANDLED(pager_) ?
- optional<path>(path(report().HANDLER(pager_).str())) :
- optional<path>());
+ optional<path>(path(report().HANDLER(output_).str())) :
+ optional<path>(),
+ report().HANDLED(pager_) ?
+ optional<path>(path(report().HANDLER(pager_).str())) :
+ optional<path>());
// Now that the output stream is initialized, report the options that will
// participate in this report, if the user specified --options
@@ -316,7 +316,7 @@ option_t<global_scope_t> * global_scope_t::lookup_option(const char * p)
}
expr_t::ptr_op_t global_scope_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
switch (kind) {
case symbol_t::FUNCTION:
@@ -334,9 +334,9 @@ expr_t::ptr_op_t global_scope_t::lookup(const symbol_t::kind_t kind,
switch (*p) {
case 'p':
if (is_eq(p, "push"))
- return MAKE_FUNCTOR(global_scope_t::push_command);
+ return MAKE_FUNCTOR(global_scope_t::push_command);
else if (is_eq(p, "pop"))
- return MAKE_FUNCTOR(global_scope_t::pop_command);
+ return MAKE_FUNCTOR(global_scope_t::pop_command);
break;
}
}
@@ -400,8 +400,8 @@ void global_scope_t::normalize_session_options()
#endif // defined(LOGGING_ON)
}
-expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope,
- const string& verb)
+expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope,
+ const string& verb)
{
if (expr_t::ptr_op_t def = scope.lookup(symbol_t::PRECOMMAND, verb))
return def->as_function();
@@ -410,7 +410,7 @@ expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope,
}
expr_t::func_t global_scope_t::look_for_command(scope_t& scope,
- const string& verb)
+ const string& verb)
{
if (expr_t::ptr_op_t def = scope.lookup(symbol_t::COMMAND, verb))
return def->as_function();
@@ -424,7 +424,7 @@ void global_scope_t::visit_man_page() const
if (pid < 0) {
throw std::logic_error(_("Failed to fork child process"));
}
- else if (pid == 0) { // child
+ else if (pid == 0) { // child
execlp("man", "man", "1", "ledger", NULL);
// We should never, ever reach here
@@ -434,7 +434,7 @@ void global_scope_t::visit_man_page() const
int status = -1;
wait(&status);
- exit(0); // parent
+ exit(0); // parent
}
void handle_debug_options(int argc, char * argv[])
@@ -442,37 +442,37 @@ void handle_debug_options(int argc, char * argv[])
for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
if (std::strcmp(argv[i], "--args-only") == 0) {
- args_only = true;
+ args_only = true;
}
else if (std::strcmp(argv[i], "--verify") == 0) {
#if defined(VERIFY_ON)
- verify_enabled = true; // global in utils.h
+ verify_enabled = true; // global in utils.h
#endif
}
else if (std::strcmp(argv[i], "--verbose") == 0 ||
- std::strcmp(argv[i], "-v") == 0) {
+ std::strcmp(argv[i], "-v") == 0) {
#if defined(LOGGING_ON)
- _log_level = LOG_INFO; // global in utils.h
+ _log_level = LOG_INFO; // global in utils.h
#endif
}
else if (i + 1 < argc && std::strcmp(argv[i], "--debug") == 0) {
#if defined(DEBUG_ON)
- _log_level = LOG_DEBUG; // global in utils.h
- _log_category = argv[i + 1]; // global in utils.h
- i++;
+ _log_level = LOG_DEBUG; // global in utils.h
+ _log_category = argv[i + 1]; // global in utils.h
+ i++;
#endif
}
else if (i + 1 < argc && std::strcmp(argv[i], "--trace") == 0) {
#if defined(TRACING_ON)
- _log_level = LOG_TRACE; // global in utils.h
- try {
- // global in utils.h
- _trace_level = boost::lexical_cast<uint8_t>(argv[i + 1]);
- }
- catch (const boost::bad_lexical_cast& e) {
- throw std::logic_error(_("Argument to --trace must be an integer"));
- }
- i++;
+ _log_level = LOG_TRACE; // global in utils.h
+ try {
+ // global in utils.h
+ _trace_level = boost::lexical_cast<uint8_t>(argv[i + 1]);
+ }
+ catch (const boost::bad_lexical_cast& e) {
+ throw std::logic_error(_("Argument to --trace must be an integer"));
+ }
+ i++;
#endif
}
}
diff --git a/src/global.h b/src/global.h
index 05e3bdb7..87f2495a 100644
--- a/src/global.h
+++ b/src/global.h
@@ -50,16 +50,16 @@ class report_t;
class global_scope_t : public noncopyable, public scope_t
{
shared_ptr<session_t> session_ptr;
- ptr_list<report_t> report_stack;
+ ptr_list<report_t> report_stack;
public:
global_scope_t(char ** envp);
~global_scope_t();
- void read_init();
- void read_environment_settings(char * envp[]);
- strings_list read_command_arguments(scope_t& scope, strings_list args);
- void normalize_session_options();
+ void read_init();
+ void read_environment_settings(char * envp[]);
+ strings_list read_command_arguments(scope_t& scope, strings_list args);
+ void normalize_session_options();
expr_t::func_t look_for_precommand(scope_t& scope, const string& verb);
expr_t::func_t look_for_command(scope_t& scope, const string& verb);
@@ -98,7 +98,7 @@ public:
// open output stream at this point. We want it to get popped off as
// soon as this command terminate so that the stream is closed cleanly.
report_stack.insert(++report_stack.begin(),
- new report_t(report_stack.front()));
+ new report_t(report_stack.front()));
return true;
}
value_t pop_command(call_scope_t&) {
@@ -121,7 +121,7 @@ See LICENSE file included with the distribution for details and disclaimer.");
option_t<global_scope_t> * lookup_option(const char * p);
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
OPTION(global_scope_t, args_only);
OPTION(global_scope_t, debug_);
@@ -152,7 +152,7 @@ See LICENSE file included with the distribution for details and disclaimer.");
OPTION_(global_scope_t, version, DO() { // -v
parent->show_version_info(std::cout);
- throw int(0); // exit immediately
+ throw int(0); // exit immediately
});
};
diff --git a/src/interactive.cc b/src/interactive.cc
index 183a84fd..54c7fd6c 100644
--- a/src/interactive.cc
+++ b/src/interactive.cc
@@ -39,16 +39,16 @@ void interactive_t::verify_arguments() const
{
value_t::sequence_t::const_iterator i;
- const char * p = spec.c_str();
- const char * label = _("unknown");
- bool wrong_arg = false;
- bool dont_skip = false;
- bool optional = *p == '&';
- bool exit_loop = *p == '*';
- std::size_t offset = 1;
- bool is_seq = args.value().is_sequence();
+ const char * p = spec.c_str();
+ const char * label = _("unknown");
+ bool wrong_arg = false;
+ bool dont_skip = false;
+ bool optional = *p == '&';
+ bool exit_loop = *p == '*';
+ std::size_t offset = 1;
+ bool is_seq = args.value().is_sequence();
const value_t * next_arg = NULL;
- string vlabel;
+ string vlabel;
if (is_seq) {
i = args.begin();
@@ -61,45 +61,45 @@ void interactive_t::verify_arguments() const
for (; ! wrong_arg && ! exit_loop && *p && next_arg; p++) {
DEBUG("interactive.verify",
- "Want " << *p << " got: " << next_arg->label());
+ "Want " << *p << " got: " << next_arg->label());
wrong_arg = false;
switch (*p) {
case 'a':
label = _("an amount");
wrong_arg = (! next_arg->is_long() &&
- ! next_arg->is_amount() &&
- ! next_arg->is_balance());
+ ! next_arg->is_amount() &&
+ ! next_arg->is_balance());
break;
case 'b':
label = _("a boolean");
- wrong_arg = false; // booleans are converted
+ wrong_arg = false; // booleans are converted
break;
case 'd':
label = _("a date");
wrong_arg = (! next_arg->is_date() &&
- ! next_arg->is_datetime());
+ ! next_arg->is_datetime());
break;
case 't':
label = _("a date/time");
wrong_arg = (! next_arg->is_date() &&
- ! next_arg->is_datetime());
+ ! next_arg->is_datetime());
break;
case 'i':
case 'l':
label = _("an integer");
if (next_arg->is_long() ||
- (next_arg->is_amount() &&
- ! next_arg->as_amount().has_commodity())) {
+ (next_arg->is_amount() &&
+ ! next_arg->as_amount().has_commodity())) {
wrong_arg = false;
}
else if (next_arg->is_string()) {
wrong_arg = false;
for (const char * q = next_arg->as_string().c_str(); *q; q++) {
- if (! std::isdigit(*q) && *q != '-') {
- wrong_arg = true;
- break;
- }
+ if (! std::isdigit(*q) && *q != '-') {
+ wrong_arg = true;
+ break;
+ }
}
}
else {
@@ -150,14 +150,14 @@ void interactive_t::verify_arguments() const
if (! dont_skip) {
if (is_seq) {
- if (++i != args.end()) {
- next_arg = &(*i);
- offset++;
- } else {
- next_arg = NULL;
- }
+ if (++i != args.end()) {
+ next_arg = &(*i);
+ offset++;
+ } else {
+ next_arg = NULL;
+ }
} else {
- next_arg = NULL;
+ next_arg = NULL;
}
}
dont_skip = false;
@@ -170,8 +170,8 @@ void interactive_t::verify_arguments() const
if (wrong_arg) {
throw_(std::logic_error,
- _("Expected %1 for argument %2, but received %3")
- << label << offset << vlabel);
+ _("Expected %1 for argument %2, but received %3")
+ << label << offset << vlabel);
}
else if (*p && ! optional && ! next_arg) {
throw_(std::logic_error, _("Too few arguments to function"));
diff --git a/src/item.cc b/src/item.cc
index 6a948ae4..8a056e6c 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -58,15 +58,15 @@ bool item_t::has_tag(const string& tag) const
}
bool item_t::has_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask) const
+ const optional<mask_t>& value_mask) const
{
if (metadata) {
foreach (const string_map::value_type& data, *metadata) {
if (tag_mask.match(data.first)) {
- if (! value_mask)
- return true;
- else if (data.second.first)
- return value_mask->match(*data.second.first);
+ if (! value_mask)
+ return true;
+ else if (data.second.first)
+ return value_mask->match(*data.second.first);
}
}
}
@@ -88,14 +88,14 @@ optional<string> item_t::get_tag(const string& tag) const
}
optional<string> item_t::get_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask) const
+ const optional<mask_t>& value_mask) const
{
if (metadata) {
foreach (const string_map::value_type& data, *metadata) {
if (tag_mask.match(data.first) &&
- (! value_mask ||
- (data.second.first && value_mask->match(*data.second.first))))
- return data.second.first;
+ (! value_mask ||
+ (data.second.first && value_mask->match(*data.second.first))))
+ return data.second.first;
}
}
return none;
@@ -103,8 +103,8 @@ optional<string> item_t::get_tag(const mask_t& tag_mask,
item_t::string_map::iterator
item_t::set_tag(const string& tag,
- const optional<string>& value,
- const bool overwrite_existing)
+ const optional<string>& value,
+ const bool overwrite_existing)
{
assert(! tag.empty());
@@ -112,7 +112,7 @@ item_t::set_tag(const string& tag,
metadata = string_map();
DEBUG("item.meta", "Setting tag '" << tag << "' to value '"
- << (value ? *value : string("<none>")) << "'");
+ << (value ? *value : string("<none>")) << "'");
optional<string> data = value;
if (data && data->empty())
@@ -132,22 +132,22 @@ item_t::set_tag(const string& tag,
}
void item_t::parse_tags(const char * p, bool overwrite_existing,
- optional<date_t::year_type> current_year)
+ optional<date_t::year_type> current_year)
{
if (const char * b = std::strchr(p, '[')) {
if (*(b + 1) != '\0' &&
- (std::isdigit(*(b + 1)) || *(b + 1) == '=')) {
+ (std::isdigit(*(b + 1)) || *(b + 1) == '=')) {
if (const char * e = std::strchr(p, ']')) {
- char buf[256];
- std::strncpy(buf, b + 1, e - b - 1);
- buf[e - b - 1] = '\0';
-
- if (char * p = std::strchr(buf, '=')) {
- *p++ = '\0';
- _date_eff = parse_date(p, current_year);
- }
- if (buf[0])
- _date = parse_date(buf, current_year);
+ char buf[256];
+ std::strncpy(buf, b + 1, e - b - 1);
+ buf[e - b - 1] = '\0';
+
+ if (char * p = std::strchr(buf, '=')) {
+ *p++ = '\0';
+ _date_eff = parse_date(p, current_year);
+ }
+ if (buf[0])
+ _date = parse_date(buf, current_year);
}
}
}
@@ -166,16 +166,16 @@ void item_t::parse_tags(const char * p, bool overwrite_existing,
const string::size_type len = std::strlen(q);
if (! tag.empty()) {
string_map::iterator i = set_tag(tag, string(p + (q - buf.get())),
- overwrite_existing);
+ overwrite_existing);
(*i).second.second = true;
break;
}
else if (q[0] == ':' && q[len - 1] == ':') { // a series of tags
for (char * r = std::strtok(q + 1, ":");
- r;
- r = std::strtok(NULL, ":")) {
- string_map::iterator i = set_tag(r, none, overwrite_existing);
- (*i).second.second = true;
+ r;
+ r = std::strtok(NULL, ":")) {
+ string_map::iterator i = set_tag(r, none, overwrite_existing);
+ (*i).second.second = true;
}
}
else if (q[len - 1] == ':') { // a metadata setting
@@ -185,7 +185,7 @@ void item_t::parse_tags(const char * p, bool overwrite_existing,
}
void item_t::append_note(const char * p, bool overwrite_existing,
- optional<date_t::year_type> current_year)
+ optional<date_t::year_type> current_year)
{
if (note) {
*note += '\n';
@@ -235,21 +235,21 @@ namespace {
if (args.size() == 1) {
if (args[0].is_string())
- return item.has_tag(args[0].as_string());
+ return item.has_tag(args[0].as_string());
else if (args[0].is_mask())
- return item.has_tag(args[0].as_mask());
+ return item.has_tag(args[0].as_mask());
else
- throw_(std::runtime_error,
- _("Expected string or mask for argument 1, but received %1")
- << args[0].label());
+ throw_(std::runtime_error,
+ _("Expected string or mask for argument 1, but received %1")
+ << args[0].label());
}
else if (args.size() == 2) {
if (args[0].is_mask() && args[1].is_mask())
- return item.has_tag(args[0].to_mask(), args[1].to_mask());
+ return item.has_tag(args[0].to_mask(), args[1].to_mask());
else
- throw_(std::runtime_error,
- _("Expected masks for arguments 1 and 2, but received %1 and %2")
- << args[0].label() << args[1].label());
+ throw_(std::runtime_error,
+ _("Expected masks for arguments 1 and 2, but received %1 and %2")
+ << args[0].label() << args[1].label());
}
else if (args.size() == 0) {
throw_(std::runtime_error, _("Too few arguments to function"));
@@ -267,21 +267,21 @@ namespace {
if (args.size() == 1) {
if (args[0].is_string())
- str = item.get_tag(args[0].as_string());
+ str = item.get_tag(args[0].as_string());
else if (args[0].is_mask())
- str = item.get_tag(args[0].as_mask());
+ str = item.get_tag(args[0].as_mask());
else
- throw_(std::runtime_error,
- _("Expected string or mask for argument 1, but received %1")
- << args[0].label());
+ throw_(std::runtime_error,
+ _("Expected string or mask for argument 1, but received %1")
+ << args[0].label());
}
else if (args.size() == 2) {
if (args[0].is_mask() && args[1].is_mask())
- str = item.get_tag(args[0].to_mask(), args[1].to_mask());
+ str = item.get_tag(args[0].to_mask(), args[1].to_mask());
else
- throw_(std::runtime_error,
- _("Expected masks for arguments 1 and 2, but received %1 and %2")
- << args[0].label() << args[1].label());
+ throw_(std::runtime_error,
+ _("Expected masks for arguments 1 and 2, but received %1 and %2")
+ << args[0].label() << args[1].label());
}
else if (args.size() == 0) {
throw_(std::runtime_error, _("Too few arguments to function"));
@@ -355,13 +355,13 @@ value_t get_comment(item_t& item)
bool need_separator = false;
for (const char * p = item.note->c_str(); *p; p++) {
if (*p == '\n') {
- need_separator = true;
+ need_separator = true;
} else {
- if (need_separator) {
- buf << "\n ;";
- need_separator = false;
- }
- buf << *p;
+ if (need_separator) {
+ buf << "\n ;";
+ need_separator = false;
+ }
+ buf << *p;
}
}
return string_value(buf.str());
@@ -369,7 +369,7 @@ value_t get_comment(item_t& item)
}
expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (kind != symbol_t::FUNCTION)
return NULL;
@@ -502,7 +502,7 @@ bool item_t::valid() const
void print_item(std::ostream& out, const item_t& item, const string& prefix)
{
out << source_context(item.pos->pathname, item.pos->beg_pos,
- item.pos->end_pos, prefix);
+ item.pos->end_pos, prefix);
}
string item_context(const item_t& item, const string& desc)
@@ -528,7 +528,7 @@ string item_context(const item_t& item, const string& desc)
if (item.pos->beg_line != item.pos->end_line)
out << _(", lines ") << item.pos->beg_line << "-"
- << item.pos->end_line << ":\n";
+ << item.pos->end_line << ":\n";
else
out << _(", line ") << item.pos->beg_line << ":\n";
diff --git a/src/item.h b/src/item.h
index 92b29844..25130d6d 100644
--- a/src/item.h
+++ b/src/item.h
@@ -50,10 +50,10 @@ struct position_t
{
path pathname;
istream_pos_type beg_pos;
- std::size_t beg_line;
+ std::size_t beg_line;
istream_pos_type end_pos;
- std::size_t end_line;
- std::size_t sequence;
+ std::size_t end_line;
+ std::size_t sequence;
position_t()
: beg_pos(0), beg_line(0), end_pos(0), end_line(0), sequence(0) {
@@ -100,16 +100,16 @@ private:
class item_t : public supports_flags<uint_least16_t>, public scope_t
{
public:
-#define ITEM_NORMAL 0x00 // no flags at all, a basic posting
-#define ITEM_GENERATED 0x01 // posting was not found in a journal
-#define ITEM_TEMP 0x02 // posting is a managed temporary
+#define ITEM_NORMAL 0x00 // no flags at all, a basic posting
+#define ITEM_GENERATED 0x01 // posting was not found in a journal
+#define ITEM_TEMP 0x02 // posting is a managed temporary
enum state_t { UNCLEARED = 0, CLEARED, PENDING };
typedef std::pair<optional<string>, bool> tag_data_t;
- typedef std::map<string, tag_data_t> string_map;
+ typedef std::map<string, tag_data_t> string_map;
- state_t _state;
+ state_t _state;
optional<date_t> _date;
optional<date_t> _date_eff;
optional<string> note;
@@ -151,21 +151,21 @@ public:
virtual bool has_tag(const string& tag) const;
virtual bool has_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask = none) const;
+ const optional<mask_t>& value_mask = none) const;
virtual optional<string> get_tag(const string& tag) const;
virtual optional<string> get_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask = none) const;
+ const optional<mask_t>& value_mask = none) const;
virtual string_map::iterator
- set_tag(const string& tag,
- const optional<string>& value = none,
- const bool overwrite_existing = true);
+ set_tag(const string& tag,
+ const optional<string>& value = none,
+ const bool overwrite_existing = true);
virtual void parse_tags(const char * p, bool overwrite_existing = true,
- optional<date_t::year_type> current_year = none);
+ optional<date_t::year_type> current_year = none);
virtual void append_note(const char * p, bool overwrite_existing = true,
- optional<date_t::year_type> current_year = none);
+ optional<date_t::year_type> current_year = none);
static bool use_effective_date;
@@ -173,7 +173,7 @@ public:
assert(_date);
if (use_effective_date)
if (optional<date_t> effective = effective_date())
- return *effective;
+ return *effective;
return *_date;
}
virtual date_t actual_date() const {
@@ -192,7 +192,7 @@ public:
}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
bool valid() const;
@@ -217,9 +217,9 @@ private:
};
value_t get_comment(item_t& item);
-void print_item(std::ostream& out, const item_t& item,
- const string& prefix = "");
-string item_context(const item_t& item, const string& desc);
+void print_item(std::ostream& out, const item_t& item,
+ const string& prefix = "");
+string item_context(const item_t& item, const string& desc);
} // namespace ledger
diff --git a/src/iterators.cc b/src/iterators.cc
index ade1d4b3..b63a10e9 100644
--- a/src/iterators.cc
+++ b/src/iterators.cc
@@ -91,47 +91,47 @@ void posts_commodities_iterator::reset(journal_t& journal)
foreach (commodity_t * comm, commodities) {
if (optional<commodity_t::varied_history_t&> history =
- comm->varied_history()) {
+ comm->varied_history()) {
account_t * account = journal.master->find_account(comm->symbol());
foreach (commodity_t::history_by_commodity_map::value_type& pair,
- history->histories) {
- foreach (commodity_t::history_map::value_type& hpair,
- pair.second.prices) {
- xact_t * xact;
- string symbol = hpair.second.commodity().symbol();
-
- std::map<string, xact_t *>::iterator i =
- xacts_by_commodity.find(symbol);
- if (i != xacts_by_commodity.end()) {
- xact = (*i).second;
- } else {
- xact = &temps.create_xact();
- xact_temps.push_back(xact);
- xact->payee = symbol;
- xact->_date = hpair.first.date();
- xacts_by_commodity.insert
- (std::pair<string, xact_t *>(symbol, xact));
- }
-
- bool post_already_exists = false;
-
- foreach (post_t * post, xact->posts) {
- if (post->_date == hpair.first.date() &&
- post->amount == hpair.second) {
- post_already_exists = true;
- break;
- }
- }
-
- if (! post_already_exists) {
- post_t& temp = temps.create_post(*xact, account);
- temp._date = hpair.first.date();
- temp.amount = hpair.second;
-
- temp.xdata().datetime = hpair.first;
- }
- }
+ history->histories) {
+ foreach (commodity_t::history_map::value_type& hpair,
+ pair.second.prices) {
+ xact_t * xact;
+ string symbol = hpair.second.commodity().symbol();
+
+ std::map<string, xact_t *>::iterator i =
+ xacts_by_commodity.find(symbol);
+ if (i != xacts_by_commodity.end()) {
+ xact = (*i).second;
+ } else {
+ xact = &temps.create_xact();
+ xact_temps.push_back(xact);
+ xact->payee = symbol;
+ xact->_date = hpair.first.date();
+ xacts_by_commodity.insert
+ (std::pair<string, xact_t *>(symbol, xact));
+ }
+
+ bool post_already_exists = false;
+
+ foreach (post_t * post, xact->posts) {
+ if (post->_date == hpair.first.date() &&
+ post->amount == hpair.second) {
+ post_already_exists = true;
+ break;
+ }
+ }
+
+ if (! post_already_exists) {
+ post_t& temp = temps.create_post(*xact, account);
+ temp._date = hpair.first.date();
+ temp.amount = hpair.second;
+
+ temp.xdata().datetime = hpair.first;
+ }
+ }
}
}
}
@@ -162,7 +162,7 @@ post_t * posts_commodities_iterator::operator()()
account_t * basic_accounts_iterator::operator()()
{
while (! accounts_i.empty() &&
- accounts_i.back() == accounts_end.back()) {
+ accounts_i.back() == accounts_end.back()) {
accounts_i.pop_back();
accounts_end.pop_back();
}
@@ -187,14 +187,14 @@ void sorted_accounts_iterator::push_back(account_t& account)
push_all(account, accounts_list.back());
std::stable_sort(accounts_list.back().begin(),
- accounts_list.back().end(),
- compare_items<account_t>(sort_cmp));
+ accounts_list.back().end(),
+ compare_items<account_t>(sort_cmp));
#if defined(DEBUG_ON)
if (SHOW_DEBUG("accounts.sorted")) {
foreach (account_t * account, accounts_list.back())
- DEBUG("accounts.sorted",
- "Account (flat): " << account->fullname());
+ DEBUG("accounts.sorted",
+ "Account (flat): " << account->fullname());
}
#endif
} else {
@@ -206,7 +206,7 @@ void sorted_accounts_iterator::push_back(account_t& account)
}
void sorted_accounts_iterator::push_all(account_t& account,
- accounts_deque_t& deque)
+ accounts_deque_t& deque)
{
foreach (accounts_map::value_type& pair, account.accounts) {
deque.push_back(pair.second);
@@ -215,13 +215,13 @@ void sorted_accounts_iterator::push_all(account_t& account,
}
void sorted_accounts_iterator::sort_accounts(account_t& account,
- accounts_deque_t& deque)
+ accounts_deque_t& deque)
{
foreach (accounts_map::value_type& pair, account.accounts)
deque.push_back(pair.second);
std::stable_sort(deque.begin(), deque.end(),
- compare_items<account_t>(sort_cmp));
+ compare_items<account_t>(sort_cmp));
#if defined(DEBUG_ON)
if (SHOW_DEBUG("accounts.sorted")) {
@@ -234,7 +234,7 @@ void sorted_accounts_iterator::sort_accounts(account_t& account,
account_t * sorted_accounts_iterator::operator()()
{
while (! sorted_accounts_i.empty() &&
- sorted_accounts_i.back() == sorted_accounts_end.back()) {
+ sorted_accounts_i.back() == sorted_accounts_end.back()) {
sorted_accounts_i.pop_back();
sorted_accounts_end.pop_back();
assert(! accounts_list.empty());
diff --git a/src/iterators.h b/src/iterators.h
index 5e9f5fbe..5113d3b2 100644
--- a/src/iterators.h
+++ b/src/iterators.h
@@ -142,8 +142,8 @@ class posts_commodities_iterator : public posts_iterator
{
protected:
journal_posts_iterator journal_posts;
- xacts_iterator xacts;
- xact_posts_iterator posts;
+ xacts_iterator xacts;
+ xact_posts_iterator posts;
temporaries_t temps;
xacts_list xact_temps;
@@ -203,13 +203,13 @@ class sorted_accounts_iterator : public accounts_iterator
typedef std::deque<account_t *> accounts_deque_t;
- std::list<accounts_deque_t> accounts_list;
+ std::list<accounts_deque_t> accounts_list;
std::list<accounts_deque_t::const_iterator> sorted_accounts_i;
std::list<accounts_deque_t::const_iterator> sorted_accounts_end;
public:
sorted_accounts_iterator(account_t& account,
- const expr_t& _sort_cmp, bool _flatten_all)
+ const expr_t& _sort_cmp, bool _flatten_all)
: sort_cmp(_sort_cmp), flatten_all(_flatten_all) {
TRACE_CTOR(sorted_accounts_iterator, "const expr_t&, bool, account_t&");
push_back(account);
diff --git a/src/journal.cc b/src/journal.cc
index 158fac42..fd6d3eac 100644
--- a/src/journal.cc
+++ b/src/journal.cc
@@ -145,9 +145,9 @@ bool journal_t::remove_xact(xact_t * xact)
}
std::size_t journal_t::read(std::istream& in,
- const path& pathname,
- account_t * master_alt,
- scope_t * scope)
+ const path& pathname,
+ account_t * master_alt,
+ scope_t * scope)
{
std::size_t count = 0;
try {
@@ -156,13 +156,13 @@ std::size_t journal_t::read(std::istream& in,
if (! scope)
throw_(std::runtime_error,
- _("No default scope in which to read journal file '%1'")
- << pathname);
+ _("No default scope in which to read journal file '%1'")
+ << pathname);
value_t strict = expr_t("strict").calc(*scope);
count = parse(in, *scope, master_alt ? master_alt : master,
- &pathname, strict.to_boolean());
+ &pathname, strict.to_boolean());
}
catch (...) {
clear_xdata();
@@ -178,14 +178,14 @@ std::size_t journal_t::read(std::istream& in,
}
std::size_t journal_t::read(const path& pathname,
- account_t * master,
- scope_t * scope)
+ account_t * master,
+ scope_t * scope)
{
path filename = resolve_path(pathname);
if (! exists(filename))
throw_(std::runtime_error,
- _("Cannot read journal file '%1'") << filename);
+ _("Cannot read journal file '%1'") << filename);
ifstream stream(filename);
std::size_t count = read(stream, filename, master, scope);
diff --git a/src/journal.h b/src/journal.h
index a407c02c..ca6b6e4f 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -55,7 +55,7 @@ class period_xact_t;
class account_t;
class scope_t;
-typedef std::list<xact_t *> xacts_list;
+typedef std::list<xact_t *> xacts_list;
typedef std::list<auto_xact_t *> auto_xacts_list;
typedef std::list<period_xact_t *> period_xacts_list;
@@ -70,9 +70,9 @@ public:
struct fileinfo_t
{
optional<path> filename;
- uintmax_t size;
- datetime_t modtime;
- bool from_stream;
+ uintmax_t size;
+ datetime_t modtime;
+ bool from_stream;
fileinfo_t() : size(0), from_stream(true) {
TRACE_CTOR(journal_t::fileinfo_t, "");
@@ -85,7 +85,7 @@ public:
}
fileinfo_t(const fileinfo_t& info)
: filename(info.filename), size(info.size),
- modtime(info.modtime), from_stream(info.from_stream)
+ modtime(info.modtime), from_stream(info.from_stream)
{
TRACE_CTOR(journal_t::fileinfo_t, "copy");
}
@@ -109,11 +109,11 @@ public:
#endif // HAVE_BOOST_SERIALIZATION
};
- account_t * master;
- account_t * bucket;
- xacts_list xacts;
- auto_xacts_list auto_xacts;
- period_xacts_list period_xacts;
+ account_t * master;
+ account_t * bucket;
+ xacts_list xacts;
+ auto_xacts_list auto_xacts;
+ period_xacts_list period_xacts;
std::list<fileinfo_t> sources;
payee_mappings_t payee_mappings;
account_mappings_t account_mappings;
@@ -135,8 +135,8 @@ public:
// These four methods are delegated to the current session, since all
// accounts processed are gathered together at the session level.
- void add_account(account_t * acct);
- bool remove_account(account_t * acct);
+ void add_account(account_t * acct);
+ bool remove_account(account_t * acct);
account_t * find_account(const string& name, bool auto_create = true);
account_t * find_account_re(const string& regexp);
@@ -164,18 +164,18 @@ public:
}
std::size_t read(std::istream& in,
- const path& pathname,
- account_t * master = NULL,
- scope_t * scope = NULL);
- std::size_t read(const path& pathname,
- account_t * master = NULL,
- scope_t * scope = NULL);
+ const path& pathname,
+ account_t * master = NULL,
+ scope_t * scope = NULL);
+ std::size_t read(const path& pathname,
+ account_t * master = NULL,
+ scope_t * scope = NULL);
std::size_t parse(std::istream& in,
- scope_t& session_scope,
- account_t * master = NULL,
- const path * original_file = NULL,
- bool strict = false);
+ scope_t& session_scope,
+ account_t * master = NULL,
+ const path * original_file = NULL,
+ bool strict = false);
bool has_xdata();
void clear_xdata();
diff --git a/src/lookup.cc b/src/lookup.cc
index 40b6c185..221397ca 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -43,7 +43,7 @@ namespace {
struct score_sorter {
bool operator()(const score_entry_t& left,
- const score_entry_t& right) const {
+ const score_entry_t& right) const {
return left.second > right.second;
}
};
@@ -53,7 +53,7 @@ namespace {
struct usage_sorter {
bool operator()(const account_use_pair& left,
- const account_use_pair& right) const {
+ const account_use_pair& right) const {
return left.second > right.second;
}
};
@@ -61,8 +61,8 @@ namespace {
std::pair<xact_t *, account_t *>
lookup_probable_account(const string& ident,
- xacts_iterator& iter_func,
- account_t * ref_account)
+ xacts_iterator& iter_func,
+ account_t * ref_account)
{
scorecard_t scores;
@@ -76,11 +76,11 @@ lookup_probable_account(const string& ident,
#endif
DEBUG("lookup.account",
- "Looking up identifier '" << lowered_ident.extract() << "'");
+ "Looking up identifier '" << lowered_ident.extract() << "'");
#if defined(DEBUG_ON)
if (ref_account != NULL)
DEBUG("lookup.account",
- " with reference account: " << ref_account->fullname());
+ " with reference account: " << ref_account->fullname());
#endif
while (xact_t * xact = iter_func()) {
@@ -109,17 +109,17 @@ lookup_probable_account(const string& ident,
DEBUG("lookup", "Considering payee: " << value_key.extract());
- std::size_t index = 0;
- std::size_t last_match_pos = unistring::npos;
- int bonus = 0;
- int score = 0;
- std::size_t pos;
+ std::size_t index = 0;
+ std::size_t last_match_pos = unistring::npos;
+ int bonus = 0;
+ int score = 0;
+ std::size_t pos;
char_positions_map positions;
// Walk each letter in the source identifier
foreach (const uint32_t& ch, lowered_ident.utf32chars) {
- int addend = 0;
- bool added_bonus = false;
+ int addend = 0;
+ bool added_bonus = false;
std::size_t value_len = value_key.length();
pos = value_key.find(ch);
@@ -131,76 +131,76 @@ lookup_probable_account(const string& ident,
char_positions_map::iterator pi = positions.find(ch);
while (pi != positions.end() &&
- pos != unistring::npos && pos <= (*pi).second &&
- (*pi).second + 1 < value_len)
- pos = value_key.find(ch, (*pi).second + 1);
+ pos != unistring::npos && pos <= (*pi).second &&
+ (*pi).second + 1 < value_len)
+ pos = value_key.find(ch, (*pi).second + 1);
if (pos != unistring::npos) {
- if (pi != positions.end())
- (*pi).second = pos;
- else
- positions.insert(char_positions_map::value_type(ch, pos));
-
- // If it occurs in the same order as the source identifier -- that is,
- // without intervening letters to break the pattern -- it's worth 10
- // points. Plus, an extra point is added for every letter in chains
- // of 3 or more.
-
- if (last_match_pos == unistring::npos ?
- index == 0 && pos == 0 : pos == last_match_pos + 1) {
- DEBUG("lookup",
- " char " << index << " in-sequence match with bonus " << bonus);
- addend += 10;
- if (bonus > 2)
- addend += bonus - 2;
- bonus++;
- added_bonus = true;
-
- last_match_pos = pos;
- }
-
- // If it occurs in the same general sequence as the source identifier,
- // it's worth 5 points, plus an extra point if it's within the next 3
- // characters, and an extra point if it's preceded by a non-alphabetic
- // character.
- //
- // If the letter occurs at all in the target identifier, it's worth 1
- // point, plus an extra point if it's within 3 characters, and an
- // extra point if it's preceded by a non-alphabetic character.
-
- else {
- bool in_order_match = (last_match_pos != unistring::npos &&
- pos > last_match_pos);
- DEBUG("lookup", " char " << index << " " <<
- (in_order_match ? "in-order" : "out-of-order")
- << " match" << (in_order_match && pos - index < 3 ?
- " with proximity bonus of 1" : ""));
-
- if (pos < index)
- addend += 1;
- else
- addend += 5;
-
- if (in_order_match && pos - index < 3)
- addend++;
+ if (pi != positions.end())
+ (*pi).second = pos;
+ else
+ positions.insert(char_positions_map::value_type(ch, pos));
+
+ // If it occurs in the same order as the source identifier -- that is,
+ // without intervening letters to break the pattern -- it's worth 10
+ // points. Plus, an extra point is added for every letter in chains
+ // of 3 or more.
+
+ if (last_match_pos == unistring::npos ?
+ index == 0 && pos == 0 : pos == last_match_pos + 1) {
+ DEBUG("lookup",
+ " char " << index << " in-sequence match with bonus " << bonus);
+ addend += 10;
+ if (bonus > 2)
+ addend += bonus - 2;
+ bonus++;
+ added_bonus = true;
+
+ last_match_pos = pos;
+ }
+
+ // If it occurs in the same general sequence as the source identifier,
+ // it's worth 5 points, plus an extra point if it's within the next 3
+ // characters, and an extra point if it's preceded by a non-alphabetic
+ // character.
+ //
+ // If the letter occurs at all in the target identifier, it's worth 1
+ // point, plus an extra point if it's within 3 characters, and an
+ // extra point if it's preceded by a non-alphabetic character.
+
+ else {
+ bool in_order_match = (last_match_pos != unistring::npos &&
+ pos > last_match_pos);
+ DEBUG("lookup", " char " << index << " " <<
+ (in_order_match ? "in-order" : "out-of-order")
+ << " match" << (in_order_match && pos - index < 3 ?
+ " with proximity bonus of 1" : ""));
+
+ if (pos < index)
+ addend += 1;
+ else
+ addend += 5;
+
+ if (in_order_match && pos - index < 3)
+ addend++;
#if !defined(HAVE_BOOST_REGEX_UNICODE)
- if (pos == 0 || (pos > 0 && !std::isalnum(value_key[pos - 1])))
- addend++;
+ if (pos == 0 || (pos > 0 && !std::isalnum(value_key[pos - 1])))
+ addend++;
#else
- // jww (2010-03-07): Not yet implemented
+ // jww (2010-03-07): Not yet implemented
#endif
- last_match_pos = pos;
- }
+ last_match_pos = pos;
+ }
// If the letter does not appear at all, decrease the score by 1
} else {
- last_match_pos = unistring::npos;
+ last_match_pos = unistring::npos;
- DEBUG("lookup", " char " << index << " does not match");
- addend--;
+ DEBUG("lookup", " char " << index << " does not match");
+ addend--;
}
// Finally, decay what is to be added to the score based on its position
@@ -211,9 +211,9 @@ lookup_probable_account(const string& ident,
// divisor for the addend.
if ((int(index / 5) + 1) > 1) {
- DEBUG("lookup",
- " discounting the addend by / " << (int(index / 5) + 1));
- addend = int(double(addend) / (int(index / 5) + 1));
+ DEBUG("lookup",
+ " discounting the addend by / " << (int(index / 5) + 1));
+ addend = int(double(addend) / (int(index / 5) + 1));
}
DEBUG("lookup", " final addend is " << addend);
@@ -221,7 +221,7 @@ lookup_probable_account(const string& ident,
DEBUG("lookup", " score is " << score);
if (! added_bonus)
- bonus = 0;
+ bonus = 0;
index++;
}
@@ -238,26 +238,26 @@ lookup_probable_account(const string& ident,
std::stable_sort(scores.begin(), scores.end(), score_sorter());
- scorecard_t::iterator si = scores.begin();
- int decay = 0;
- xact_t * best_xact = si != scores.end() ? (*si).first : NULL;
- account_use_map account_usage;
+ scorecard_t::iterator si = scores.begin();
+ int decay = 0;
+ xact_t * best_xact = si != scores.end() ? (*si).first : NULL;
+ account_use_map account_usage;
for (int i = 0; i < 5 && si != scores.end(); i++, si++) {
DEBUG("lookup.account",
- "Payee: " << std::setw(5) << std::right << (*si).second <<
- " - " << (*si).first->payee);
+ "Payee: " << std::setw(5) << std::right << (*si).second <<
+ " - " << (*si).first->payee);
foreach (post_t * post, (*si).first->posts) {
if (! post->has_flags(ITEM_TEMP | ITEM_GENERATED) &&
- post->account != ref_account &&
- ! post->account->has_flags(ACCOUNT_TEMP | ACCOUNT_GENERATED)) {
- account_use_map::iterator x = account_usage.find(post->account);
- if (x == account_usage.end())
- account_usage.insert(account_use_pair(post->account,
- ((*si).second - decay)));
- else
- (*x).second += ((*si).second - decay);
+ post->account != ref_account &&
+ ! post->account->has_flags(ACCOUNT_TEMP | ACCOUNT_GENERATED)) {
+ account_use_map::iterator x = account_usage.find(post->account);
+ if (x == account_usage.end())
+ account_usage.insert(account_use_pair(post->account,
+ ((*si).second - decay)));
+ else
+ (*x).second += ((*si).second - decay);
}
decay++;
}
@@ -267,14 +267,14 @@ lookup_probable_account(const string& ident,
#if defined(DEBUG_ON)
if (SHOW_DEBUG("lookup.account")) {
foreach (const account_use_pair& value, account_usage) {
- DEBUG("lookup.account",
- "Account: " << value.second << " - " << value.first->fullname());
+ DEBUG("lookup.account",
+ "Account: " << value.second << " - " << value.first->fullname());
}
}
#endif
return std::pair<xact_t *, account_t *>
(best_xact, (*std::max_element(account_usage.begin(), account_usage.end(),
- usage_sorter())).first);
+ usage_sorter())).first);
} else {
return std::pair<xact_t *, account_t *>(best_xact, NULL);
}
diff --git a/src/lookup.h b/src/lookup.h
index 53cb5837..7776be80 100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -48,8 +48,8 @@ namespace ledger {
std::pair<xact_t *, account_t *>
lookup_probable_account(const string& ident,
- xacts_iterator& iter_func,
- account_t * ref_account = NULL);
+ xacts_iterator& iter_func,
+ account_t * ref_account = NULL);
} // namespace ledger
diff --git a/src/main.cc b/src/main.cc
index 23593533..e0da3a25 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -31,8 +31,8 @@
#include <system.hh>
-#include "global.h" // This is where the meat of main() is, which
- // was moved there for the sake of clarity here
+#include "global.h" // This is where the meat of main() is, which
+ // was moved there for the sake of clarity here
#include "session.h"
using namespace ledger;
@@ -103,13 +103,13 @@ int main(int argc, char * argv[], char * envp[])
ifstream in(global_scope->HANDLER(script_).str());
while (status == 0 && ! in.eof()) {
- char line[1024];
- in.getline(line, 1023);
+ char line[1024];
+ in.getline(line, 1023);
- char * p = skip_ws(line);
- if (*p && *p != '#')
- status = global_scope->execute_command_wrapper(split_arguments(p),
- true);
+ char * p = skip_ws(line);
+ if (*p && *p != '#')
+ status = global_scope->execute_command_wrapper(split_arguments(p),
+ true);
}
}
else if (! args.empty()) {
@@ -133,53 +133,53 @@ int main(int argc, char * argv[], char * envp[])
#endif
while (char * p = readline(global_scope->prompt_string())) {
- char * expansion = NULL;
- int result;
-
- result = history_expand(skip_ws(p), &expansion);
-
- if (result < 0 || result == 2) {
- if (expansion)
- std::free(expansion);
- std::free(p);
- throw_(std::logic_error,
- _("Failed to expand history reference '%1'") << p);
- }
- else if (expansion) {
- add_history(expansion);
- }
+ char * expansion = NULL;
+ int result;
+
+ result = history_expand(skip_ws(p), &expansion);
+
+ if (result < 0 || result == 2) {
+ if (expansion)
+ std::free(expansion);
+ std::free(p);
+ throw_(std::logic_error,
+ _("Failed to expand history reference '%1'") << p);
+ }
+ else if (expansion) {
+ add_history(expansion);
+ }
#else // HAVE_LIBEDIT
while (! std::cin.eof()) {
- std::cout << global_scope->prompt_string();
- char line[1024];
- std::cin.getline(line, 1023);
+ std::cout << global_scope->prompt_string();
+ char line[1024];
+ std::cin.getline(line, 1023);
- char * p = skip_ws(line);
+ char * p = skip_ws(line);
#endif // HAVE_LIBEDIT
- check_for_signal();
+ check_for_signal();
- if (*p && *p != '#') {
- if (std::strncmp(p, "quit", 4) == 0)
- exit_loop = true;
- else
- global_scope->execute_command_wrapper(split_arguments(p), true);
- }
+ if (*p && *p != '#') {
+ if (std::strncmp(p, "quit", 4) == 0)
+ exit_loop = true;
+ else
+ global_scope->execute_command_wrapper(split_arguments(p), true);
+ }
#ifdef HAVE_LIBEDIT
- if (expansion)
- std::free(expansion);
- std::free(p);
+ if (expansion)
+ std::free(expansion);
+ std::free(p);
#endif
- if (exit_loop)
- break;
+ if (exit_loop)
+ break;
}
- status = 0; // report success
+ status = 0; // report success
}
}
catch (const std::exception& err) {
@@ -187,11 +187,11 @@ int main(int argc, char * argv[], char * envp[])
global_scope->report_error(err);
else
std::cerr << "Exception during initialization: " << err.what()
- << std::endl;
+ << std::endl;
}
catch (int _status) {
- status = _status; // used for a "quick" exit, and is used only
- // if help text (such as --help) was displayed
+ status = _status; // used for a "quick" exit, and is used only
+ // if help text (such as --help) was displayed
}
// If memory verification is being performed (which can be very slow), clean
diff --git a/src/mask.cc b/src/mask.cc
index cd516fe2..52907cfe 100644
--- a/src/mask.cc
+++ b/src/mask.cc
@@ -66,17 +66,17 @@ mask_t& mask_t::assign_glob(const string& pat)
break;
case '[':
while (i < len && pat[i] != ']')
- re_pat += pat[i++];
+ re_pat += pat[i++];
if (i < len)
- re_pat += pat[i];
+ re_pat += pat[i];
break;
case '\\':
if (i + 1 < len) {
- re_pat += pat[++i];
- break;
+ re_pat += pat[++i];
+ break;
} else {
- // fallthrough...
+ // fallthrough...
}
default:
re_pat += pat[i];
diff --git a/src/mask.h b/src/mask.h
index ed9e8ac1..e72347ad 100644
--- a/src/mask.h
+++ b/src/mask.h
@@ -85,13 +85,13 @@ public:
bool match(const string& text) const {
#if defined(HAVE_BOOST_REGEX_UNICODE)
DEBUG("mask.match",
- "Matching: \"" << text << "\" =~ /" << str() << "/ = "
- << (boost::u32regex_search(text, expr) ? "true" : "false"));
+ "Matching: \"" << text << "\" =~ /" << str() << "/ = "
+ << (boost::u32regex_search(text, expr) ? "true" : "false"));
return boost::u32regex_search(text, expr);
#else
DEBUG("mask.match",
- "Matching: \"" << text << "\" =~ /" << str() << "/ = "
- << (boost::regex_search(text, expr) ? "true" : "false"));
+ "Matching: \"" << text << "\" =~ /" << str() << "/ = "
+ << (boost::regex_search(text, expr) ? "true" : "false"));
return boost::regex_search(text, expr);
#endif
}
@@ -107,7 +107,7 @@ public:
unistring ustr;
std::basic_string<UChar32> expr_str = expr.str();
std::copy(expr_str.begin(), expr_str.end(),
- std::back_inserter(ustr.utf32chars));
+ std::back_inserter(ustr.utf32chars));
return ustr.extract();
#else
return expr.str();
diff --git a/src/op.cc b/src/op.cc
index ca720535..9497e068 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -40,7 +40,7 @@ namespace ledger {
namespace {
value_t split_cons_expr(expr_t::ptr_op_t op, scope_t& scope,
- std::vector<expr_t>& exprs)
+ std::vector<expr_t>& exprs)
{
value_t seq;
@@ -50,16 +50,16 @@ namespace {
expr_t::ptr_op_t next = op->right();
while (next) {
- expr_t::ptr_op_t value_op;
- if (next->kind == expr_t::op_t::O_CONS) {
- value_op = next->left();
- next = next->right();
- } else {
- value_op = next;
- next = NULL;
- }
- exprs.push_back(expr_t(value_op, &scope));
- seq.push_back(value_t(exprs.back()));
+ expr_t::ptr_op_t value_op;
+ if (next->kind == expr_t::op_t::O_CONS) {
+ value_op = next->left();
+ next = next->right();
+ } else {
+ value_op = next;
+ next = NULL;
+ }
+ exprs.push_back(expr_t(value_op, &scope));
+ seq.push_back(value_t(exprs.back()));
}
} else {
exprs.push_back(expr_t(op, &scope));
@@ -80,8 +80,8 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth)
// not be found there.
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) {
- DEBUG("expr.compile", "Found definition:");
- def->dump(*_log_stream, 0);
+ DEBUG("expr.compile", "Found definition:");
+ def->dump(*_log_stream, 0);
}
#endif // defined(DEBUG_ON)
return copy(def);
@@ -102,9 +102,9 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth)
break;
case O_CALL:
if (left()->left()->is_ident())
- scope.define(symbol_t::FUNCTION, left()->left()->as_ident(), this);
+ scope.define(symbol_t::FUNCTION, left()->left()->as_ident(), this);
else
- throw_(compile_error, _("Invalid function definition"));
+ throw_(compile_error, _("Invalid function definition"));
break;
default:
throw_(compile_error, _("Invalid function definition"));
@@ -114,8 +114,8 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth)
ptr_op_t lhs(left()->compile(scope, depth));
ptr_op_t rhs(kind > UNARY_OPERATORS && has_right() ?
- (kind == O_LOOKUP ? right() :
- right()->compile(scope, depth)) : NULL);
+ (kind == O_LOOKUP ? right() :
+ right()->compile(scope, depth)) : NULL);
if (lhs == left() && (! rhs || rhs == right()))
return this;
@@ -170,31 +170,31 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
case O_DEFINE: {
call_scope_t& call_args(downcast<call_scope_t>(scope));
- std::size_t args_count = call_args.size();
- std::size_t args_index = 0;
+ std::size_t args_count = call_args.size();
+ std::size_t args_index = 0;
assert(left()->kind == O_CALL);
for (ptr_op_t sym = left()->right();
- sym;
- sym = sym->has_right() ? sym->right() : NULL) {
+ sym;
+ sym = sym->has_right() ? sym->right() : NULL) {
ptr_op_t varname = sym;
if (sym->kind == O_CONS)
- varname = sym->left();
+ varname = sym->left();
if (! varname->is_ident())
- throw_(calc_error, _("Invalid function definition"));
+ throw_(calc_error, _("Invalid function definition"));
else if (args_index == args_count)
- scope.define(symbol_t::FUNCTION, varname->as_ident(),
- wrap_value(false));
+ scope.define(symbol_t::FUNCTION, varname->as_ident(),
+ wrap_value(false));
else
- scope.define(symbol_t::FUNCTION, varname->as_ident(),
- wrap_value(call_args[args_index++]));
+ scope.define(symbol_t::FUNCTION, varname->as_ident(),
+ wrap_value(call_args[args_index++]));
}
if (args_index < args_count)
throw_(calc_error,
- _("Too many arguments in function call (saw %1)") << args_count);
+ _("Too many arguments in function call (saw %1)") << args_count);
result = right()->calc(scope, locus, depth + 1);
break;
@@ -203,24 +203,24 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
case O_LOOKUP:
if (value_t obj = left()->calc(scope, locus, depth + 1)) {
if (obj.is_scope()) {
- if (obj.as_scope() == NULL) {
- throw_(calc_error, _("Left operand of . operator is NULL"));
- } else {
- scope_t& objscope(*obj.as_scope());
- if (ptr_op_t member =
- objscope.lookup(symbol_t::FUNCTION, right()->as_ident())) {
- result = member->calc(objscope, NULL, depth + 1);
- break;
- }
- }
+ if (obj.as_scope() == NULL) {
+ throw_(calc_error, _("Left operand of . operator is NULL"));
+ } else {
+ scope_t& objscope(*obj.as_scope());
+ if (ptr_op_t member =
+ objscope.lookup(symbol_t::FUNCTION, right()->as_ident())) {
+ result = member->calc(objscope, NULL, depth + 1);
+ break;
+ }
+ }
}
}
if (right()->kind != IDENT)
throw_(calc_error,
- _("Right operand of . operator must be an identifier"));
+ _("Right operand of . operator must be an identifier"));
else
throw_(calc_error,
- _("Failed to lookup member '%1'") << right()->as_ident());
+ _("Failed to lookup member '%1'") << right()->as_ident());
break;
case O_CALL:
@@ -232,13 +232,13 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
if (has_right()) {
if (kind == O_CALL) {
- call_args.set_args(right()->calc(scope, locus, depth + 1));
+ call_args.set_args(right()->calc(scope, locus, depth + 1));
} else {
- // macros defer calculation to the callee
- args_expr = std::vector<expr_t>();
- call_args.set_args(split_cons_expr(right()->kind == O_SEQ ?
- right()->left() : right(),
- scope, *args_expr));
+ // macros defer calculation to the callee
+ args_expr = std::vector<expr_t>();
+ call_args.set_args(split_cons_expr(right()->kind == O_SEQ ?
+ right()->left() : right(),
+ scope, *args_expr));
}
}
@@ -258,45 +258,45 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
case O_MATCH:
result = (right()->calc(scope, locus, depth + 1).as_mask()
- .match(left()->calc(scope, locus, depth + 1).to_string()));
+ .match(left()->calc(scope, locus, depth + 1).to_string()));
break;
case O_EQ:
result = (left()->calc(scope, locus, depth + 1) ==
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_LT:
result = (left()->calc(scope, locus, depth + 1) <
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_LTE:
result = (left()->calc(scope, locus, depth + 1) <=
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_GT:
result = (left()->calc(scope, locus, depth + 1) >
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_GTE:
result = (left()->calc(scope, locus, depth + 1) >=
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_ADD:
result = (left()->calc(scope, locus, depth + 1) +
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_SUB:
result = (left()->calc(scope, locus, depth + 1) -
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_MUL:
result = (left()->calc(scope, locus, depth + 1) *
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_DIV:
result = (left()->calc(scope, locus, depth + 1) /
- right()->calc(scope, locus, depth + 1));
+ right()->calc(scope, locus, depth + 1));
break;
case O_NEG:
@@ -345,16 +345,16 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
ptr_op_t next = right();
while (next) {
- ptr_op_t value_op;
- if (next->kind == O_CONS) {
- value_op = next->left();
- next = next->right();
- } else {
- value_op = next;
- next = NULL;
- }
- temp.push_back(value_op->calc(scope, locus, depth + 1));
- DEBUG("op.cons", "temp now = " << temp);
+ ptr_op_t value_op;
+ if (next->kind == O_CONS) {
+ value_op = next->left();
+ next = next->right();
+ } else {
+ value_op = next;
+ next = NULL;
+ }
+ temp.push_back(value_op->calc(scope, locus, depth + 1));
+ DEBUG("op.cons", "temp now = " << temp);
}
result = temp;
}
@@ -373,15 +373,15 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
if (has_right()) {
ptr_op_t next = right();
while (next) {
- ptr_op_t value_op;
- if (next->kind == O_SEQ) {
- value_op = next->left();
- next = next->right();
- } else {
- value_op = next;
- next = NULL;
- }
- result = value_op->calc(seq_scope, locus, depth + 1);
+ ptr_op_t value_op;
+ if (next->kind == O_SEQ) {
+ value_op = next->left();
+ next = next->right();
+ } else {
+ value_op = next;
+ next = NULL;
+ }
+ result = value_op->calc(seq_scope, locus, depth + 1);
}
}
break;
@@ -415,7 +415,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
namespace {
bool print_cons(std::ostream& out, const expr_t::const_ptr_op_t op,
- const expr_t::op_t::context_t& context)
+ const expr_t::op_t::context_t& context)
{
bool found = false;
@@ -426,15 +426,15 @@ namespace {
if (op->has_right()) {
out << ", ";
if (op->right()->kind == expr_t::op_t::O_CONS)
- found = print_cons(out, op->right(), context);
+ found = print_cons(out, op->right(), context);
else if (op->right()->print(out, context))
- found = true;
+ found = true;
}
return found;
}
bool print_seq(std::ostream& out, const expr_t::const_ptr_op_t op,
- const expr_t::op_t::context_t& context)
+ const expr_t::op_t::context_t& context)
{
bool found = false;
@@ -446,9 +446,9 @@ namespace {
out << "; ";
if (op->right()->kind == expr_t::op_t::O_CONS)
- found = print_cons(out, op->right(), context);
+ found = print_cons(out, op->right(), context);
else if (op->right()->print(out, context))
- found = true;
+ found = true;
}
return found;
@@ -643,13 +643,13 @@ bool expr_t::op_t::print(std::ostream& out, const context_t& context) const
found = true;
if (has_right()) {
if (right()->kind == O_SEQ) {
- if (right()->print(out, context))
- found = true;
+ if (right()->print(out, context))
+ found = true;
} else {
- out << "(";
- if (has_right() && right()->print(out, context))
- found = true;
- out << ")";
+ out << "(";
+ if (has_right() && right()->print(out, context))
+ found = true;
+ out << ")";
}
} else {
out << "()";
@@ -709,32 +709,32 @@ void expr_t::op_t::dump(std::ostream& out, const int depth) const
case O_DEFINE: out << "O_DEFINE"; break;
case O_LOOKUP: out << "O_LOOKUP"; break;
- case O_CALL: out << "O_CALL"; break;
+ case O_CALL: out << "O_CALL"; break;
case O_EXPAND: out << "O_EXPAND"; break;
- case O_MATCH: out << "O_MATCH"; break;
+ case O_MATCH: out << "O_MATCH"; break;
- case O_NOT: out << "O_NOT"; break;
- case O_NEG: out << "O_NEG"; break;
+ case O_NOT: out << "O_NOT"; break;
+ case O_NEG: out << "O_NEG"; break;
- case O_ADD: out << "O_ADD"; break;
- case O_SUB: out << "O_SUB"; break;
- case O_MUL: out << "O_MUL"; break;
- case O_DIV: out << "O_DIV"; break;
+ case O_ADD: out << "O_ADD"; break;
+ case O_SUB: out << "O_SUB"; break;
+ case O_MUL: out << "O_MUL"; break;
+ case O_DIV: out << "O_DIV"; break;
- case O_EQ: out << "O_EQ"; break;
- case O_LT: out << "O_LT"; break;
- case O_LTE: out << "O_LTE"; break;
- case O_GT: out << "O_GT"; break;
- case O_GTE: out << "O_GTE"; break;
+ case O_EQ: out << "O_EQ"; break;
+ case O_LT: out << "O_LT"; break;
+ case O_LTE: out << "O_LTE"; break;
+ case O_GT: out << "O_GT"; break;
+ case O_GTE: out << "O_GTE"; break;
- case O_AND: out << "O_AND"; break;
- case O_OR: out << "O_OR"; break;
+ case O_AND: out << "O_AND"; break;
+ case O_OR: out << "O_OR"; break;
case O_QUERY: out << "O_QUERY"; break;
- case O_COLON: out << "O_COLON"; break;
+ case O_COLON: out << "O_COLON"; break;
- case O_CONS: out << "O_CONS"; break;
- case O_SEQ: out << "O_SEQ"; break;
+ case O_CONS: out << "O_CONS"; break;
+ case O_SEQ: out << "O_SEQ"; break;
case LAST:
default:
@@ -750,7 +750,7 @@ void expr_t::op_t::dump(std::ostream& out, const int depth) const
if (left()) {
left()->dump(out, depth + 1);
if (kind > UNARY_OPERATORS && has_right())
- right()->dump(out, depth + 1);
+ right()->dump(out, depth + 1);
}
else if (kind > UNARY_OPERATORS) {
assert(! has_right());
@@ -759,7 +759,7 @@ void expr_t::op_t::dump(std::ostream& out, const int depth) const
}
string op_context(const expr_t::ptr_op_t op,
- const expr_t::ptr_op_t locus)
+ const expr_t::ptr_op_t locus)
{
ostream_pos_type start_pos, end_pos;
expr_t::op_t::context_t context(op, locus, &start_pos, &end_pos);
@@ -769,9 +769,9 @@ string op_context(const expr_t::ptr_op_t op,
buf << "\n";
for (int i = 0; i <= end_pos; i++) {
if (i > start_pos)
- buf << "^";
+ buf << "^";
else
- buf << " ";
+ buf << " ";
}
}
return buf.str();
diff --git a/src/op.h b/src/op.h
index 936c11f4..27fdea3b 100644
--- a/src/op.h
+++ b/src/op.h
@@ -56,13 +56,13 @@ public:
private:
mutable short refc;
- ptr_op_t left_;
+ ptr_op_t left_;
- variant<ptr_op_t, // used by all binary operators
- value_t, // used by constant VALUE
- string, // used by constant IDENT
- expr_t::func_t // used by terminal FUNCTION
- > data;
+ variant<ptr_op_t, // used by all binary operators
+ value_t, // used by constant VALUE
+ string, // used by constant IDENT
+ expr_t::func_t // used by terminal FUNCTION
+ > data;
public:
enum kind_t {
@@ -225,13 +225,13 @@ public:
private:
void acquire() const {
DEBUG("op.memory",
- "Acquiring " << this << ", refc now " << refc + 1);
+ "Acquiring " << this << ", refc now " << refc + 1);
assert(refc >= 0);
refc++;
}
void release() const {
DEBUG("op.memory",
- "Releasing " << this << ", refc now " << refc - 1);
+ "Releasing " << this << ", refc now " << refc - 1);
assert(refc > 0);
if (--refc == 0)
checked_delete(this);
@@ -253,28 +253,28 @@ private:
public:
static ptr_op_t new_node(kind_t _kind, ptr_op_t _left = NULL,
- ptr_op_t _right = NULL);
+ ptr_op_t _right = NULL);
ptr_op_t compile(scope_t& scope, const int depth = 0);
value_t calc(scope_t& scope, ptr_op_t * locus = NULL,
- const int depth = 0);
+ const int depth = 0);
struct context_t
{
- ptr_op_t expr_op;
- ptr_op_t op_to_find;
+ ptr_op_t expr_op;
+ ptr_op_t op_to_find;
ostream_pos_type * start_pos;
ostream_pos_type * end_pos;
- bool relaxed;
+ bool relaxed;
context_t(const ptr_op_t& _expr_op = NULL,
- const ptr_op_t& _op_to_find = NULL,
- ostream_pos_type * const _start_pos = NULL,
- ostream_pos_type * const _end_pos = NULL,
- const bool _relaxed = true)
+ const ptr_op_t& _op_to_find = NULL,
+ ostream_pos_type * const _start_pos = NULL,
+ ostream_pos_type * const _end_pos = NULL,
+ const bool _relaxed = true)
: expr_op(_expr_op), op_to_find(_op_to_find),
- start_pos(_start_pos), end_pos(_end_pos),
- relaxed(_relaxed) {}
+ start_pos(_start_pos), end_pos(_end_pos),
+ relaxed(_relaxed) {}
};
bool print(std::ostream& out, const context_t& context = context_t()) const;
@@ -300,8 +300,8 @@ private:
ar & temp_op;
}
if (Archive::is_loading::value || kind == VALUE || kind == IDENT ||
- (kind > UNARY_OPERATORS &&
- (! has_right() || ! right()->is_function()))) {
+ (kind > UNARY_OPERATORS &&
+ (! has_right() || ! right()->is_function()))) {
ar & data;
} else {
variant<ptr_op_t, value_t, string, expr_t::func_t> temp_data;
@@ -337,7 +337,7 @@ expr_t::op_t::wrap_functor(const expr_t::func_t& fobj) {
#define WRAP_FUNCTOR(x) expr_t::op_t::wrap_functor(x)
string op_context(const expr_t::ptr_op_t op,
- const expr_t::ptr_op_t locus = NULL);
+ const expr_t::ptr_op_t locus = NULL);
} // namespace ledger
diff --git a/src/option.cc b/src/option.cc
index b375dd8d..16f7713d 100644
--- a/src/option.cc
+++ b/src/option.cc
@@ -44,9 +44,9 @@ namespace {
char * p = buf;
foreach (char ch, name) {
if (ch == '-')
- *p++ = '_';
+ *p++ = '_';
else
- *p++ = ch;
+ *p++ = ch;
}
*p++ = '_';
*p = '\0';
@@ -75,30 +75,30 @@ namespace {
}
void process_option(const string& whence, const expr_t::func_t& opt,
- scope_t& scope, const char * arg, const string& name)
+ scope_t& scope, const char * arg, const string& name)
{
try {
call_scope_t args(scope);
args.push_back(string_value(whence));
if (arg)
- args.push_back(string_value(arg));
+ args.push_back(string_value(arg));
opt(args);
}
catch (const std::exception& err) {
if (name[0] == '-')
- add_error_context(_("While parsing option '%1'") << name);
-
+ add_error_context(_("While parsing option '%1'") << name);
+
else
- add_error_context(_("While parsing environent variable '%1'") << name);
+ add_error_context(_("While parsing environent variable '%1'") << name);
throw;
}
}
}
bool process_option(const string& whence, const string& name, scope_t& scope,
- const char * arg, const string& varname)
+ const char * arg, const string& varname)
{
op_bool_tuple opt(find_option(scope, name));
if (opt.first) {
@@ -109,9 +109,9 @@ bool process_option(const string& whence, const string& name, scope_t& scope,
}
void process_environment(const char ** envp, const string& tag,
- scope_t& scope)
+ scope_t& scope)
{
- const char * tag_p = tag.c_str();
+ const char * tag_p = tag.c_str();
string::size_type tag_len = tag.length();
assert(tag_p);
@@ -123,25 +123,25 @@ void process_environment(const char ** envp, const string& tag,
char * r = buf;
const char * q;
for (q = *p + tag_len;
- *q && *q != '=' && r - buf < 8191;
- q++)
- if (*q == '_')
- *r++ = '-';
- else
- *r++ = static_cast<char>(std::tolower(*q));
+ *q && *q != '=' && r - buf < 8191;
+ q++)
+ if (*q == '_')
+ *r++ = '-';
+ else
+ *r++ = static_cast<char>(std::tolower(*q));
*r = '\0';
if (*q == '=') {
- try {
- string value = string(*p, q - *p);
- if (! value.empty())
- process_option(string("$") + buf, string(buf), scope, q + 1, value);
- }
- catch (const std::exception& err) {
- add_error_context(_("While parsing environment variable option '%1':")
- << *p);
- throw;
- }
+ try {
+ string value = string(*p, q - *p);
+ if (! value.empty())
+ process_option(string("$") + buf, string(buf), scope, q + 1, value);
+ }
+ catch (const std::exception& err) {
+ add_error_context(_("While parsing environment variable option '%1':")
+ << *p);
+ throw;
+ }
}
}
}
@@ -178,9 +178,9 @@ strings_list process_arguments(strings_list args, scope_t& scope)
// --long-option or -s
if ((*i)[1] == '-') {
if ((*i)[2] == '\0') {
- DEBUG("option.args", " it's a --, ending options processing");
- anywhere = false;
- continue;
+ DEBUG("option.args", " it's a --, ending options processing");
+ anywhere = false;
+ continue;
}
DEBUG("option.args", " it's an option string");
@@ -190,26 +190,26 @@ strings_list process_arguments(strings_list args, scope_t& scope)
const char * value = NULL;
if (const char * p = std::strchr(name, '=')) {
- opt_name = string(name, p - name);
- value = ++p;
- DEBUG("option.args", " read option value from option: " << value);
+ opt_name = string(name, p - name);
+ value = ++p;
+ DEBUG("option.args", " read option value from option: " << value);
} else {
- opt_name = name;
+ opt_name = name;
}
op_bool_tuple opt(find_option(scope, opt_name));
if (! opt.first)
- throw_(option_error, _("Illegal option --%1") << name);
+ throw_(option_error, _("Illegal option --%1") << name);
if (opt.second && ! value && ++i != args.end() && value == NULL) {
- value = (*i).c_str();
- DEBUG("option.args", " read option value from arg: " << value);
- if (value == NULL)
- throw_(option_error, _("Missing option argument for --%1") << name);
+ value = (*i).c_str();
+ DEBUG("option.args", " read option value from arg: " << value);
+ if (value == NULL)
+ throw_(option_error, _("Missing option argument for --%1") << name);
}
process_option(string("--") + name,
- opt.first->as_function(), scope, value,
- string("--") + name);
+ opt.first->as_function(), scope, value,
+ string("--") + name);
}
else if ((*i)[1] == '\0') {
throw_(option_error, _("illegal option -%1") << (*i)[0]);
@@ -221,24 +221,24 @@ strings_list process_arguments(strings_list args, scope_t& scope)
int x = 1;
for (char c = (*i)[x]; c != '\0'; x++, c = (*i)[x]) {
- op_bool_tuple opt(find_option(scope, c));
- if (! opt.first)
- throw_(option_error, _("Illegal option -%1") << c);
+ op_bool_tuple opt(find_option(scope, c));
+ if (! opt.first)
+ throw_(option_error, _("Illegal option -%1") << c);
- option_queue.push_back(op_bool_char_tuple(opt.first, opt.second, c));
+ option_queue.push_back(op_bool_char_tuple(opt.first, opt.second, c));
}
foreach (op_bool_char_tuple& o, option_queue) {
- const char * value = NULL;
- if (o.truth && ++i != args.end()) {
- value = (*i).c_str();
- DEBUG("option.args", " read option value from arg: " << value);
- if (value == NULL)
- throw_(option_error,
- _("Missing option argument for -%1") << o.ch);
- }
- process_option(string("-") + o.ch, o.op->as_function(), scope, value,
- string("-") + o.ch);
+ const char * value = NULL;
+ if (o.truth && ++i != args.end()) {
+ value = (*i).c_str();
+ DEBUG("option.args", " read option value from arg: " << value);
+ if (value == NULL)
+ throw_(option_error,
+ _("Missing option argument for -%1") << o.ch);
+ }
+ process_option(string("-") + o.ch, o.op->as_function(), scope, value,
+ string("-") + o.ch);
}
}
}
diff --git a/src/option.h b/src/option.h
index f11497a4..91ff26f9 100644
--- a/src/option.h
+++ b/src/option.h
@@ -52,10 +52,10 @@ template <typename T>
class option_t
{
protected:
- const char * name;
+ const char * name;
string::size_type name_len;
- const char ch;
- bool handled;
+ const char ch;
+ bool handled;
optional<string> source;
option_t& operator=(const option_t&);
@@ -63,7 +63,7 @@ protected:
public:
T * parent;
value_t value;
- bool wants_arg;
+ bool wants_arg;
option_t(const char * _name, const char _ch = '\0')
: name(_name), name_len(std::strlen(name)), ch(_ch),
@@ -93,11 +93,11 @@ public:
out.width(24);
out << std::right << desc();
if (wants_arg) {
- out << " = ";
- value.print(out, 42);
+ out << " = ";
+ value.print(out, 42);
} else {
- out.width(45);
- out << ' ';
+ out.width(45);
+ out << ' ';
}
out << std::left << *source << std::endl;
}
@@ -108,10 +108,10 @@ public:
out << "--";
for (const char * p = name; *p; p++) {
if (*p == '_') {
- if (*(p + 1))
- out << '-';
+ if (*(p + 1))
+ out << '-';
} else {
- out << *p;
+ out << *p;
}
}
if (ch)
@@ -145,7 +145,7 @@ public:
on_with(whence, string_value(str));
}
virtual void on_with(const optional<string>& whence,
- const value_t& val) {
+ const value_t& val) {
handled = true;
value = val;
source = whence;
@@ -162,11 +162,11 @@ public:
virtual void handler(call_scope_t& args) {
if (wants_arg) {
if (args.size() < 2)
- throw_(std::runtime_error, _("No argument provided for %1") << desc());
+ throw_(std::runtime_error, _("No argument provided for %1") << desc());
else if (args.size() > 2)
- throw_(std::runtime_error, _("To many arguments provided for %1") << desc());
+ throw_(std::runtime_error, _("To many arguments provided for %1") << desc());
else if (! args[0].is_string())
- throw_(std::runtime_error, _("Context argument for %1 not a string") << desc());
+ throw_(std::runtime_error, _("Context argument for %1 not a string") << desc());
on_with(args[0].as_string(), args[1]);
}
else if (args.size() < 1) {
@@ -194,9 +194,9 @@ public:
}
else if (wants_arg) {
if (handled)
- return value;
+ return value;
else
- return NULL_VALUE;
+ return NULL_VALUE;
}
else {
return handled;
@@ -204,13 +204,13 @@ public:
}
};
-#define BEGIN(type, name) \
+#define BEGIN(type, name) \
struct name ## option_t : public option_t<type>
-#define CTOR(type, name) \
+#define CTOR(type, name) \
name ## option_t() : option_t<type>(#name)
-#define DECL1(type, name, vartype, var, value) \
- vartype var ; \
+#define DECL1(type, name, vartype, var, value) \
+ vartype var ; \
name ## option_t() : option_t<type>(#name), var(value)
#define DO() virtual void handler_thunk(call_scope_t&)
@@ -220,10 +220,10 @@ public:
#define COPY_OPT(name, other) name ## handler(other.name ## handler)
-#define MAKE_OPT_HANDLER(type, x) \
+#define MAKE_OPT_HANDLER(type, x) \
expr_t::op_t::wrap_functor(bind(&option_t<type>::handler_wrapper, x, _1))
-#define MAKE_OPT_FUNCTOR(type, x) \
+#define MAKE_OPT_FUNCTOR(type, x) \
expr_t::op_t::wrap_functor(bind(&option_t<type>::operator(), x, _1))
inline bool is_eq(const char * p, const char * n) {
@@ -236,57 +236,57 @@ inline bool is_eq(const char * p, const char * n) {
return *p == *n || (! *p && *n == '_' && ! *(n + 1));
}
-#define OPT(name) \
- if (is_eq(p, #name)) \
+#define OPT(name) \
+ if (is_eq(p, #name)) \
return ((name ## handler).parent = this, &(name ## handler))
-#define OPT_ALT(name, alt) \
- if (is_eq(p, #name) || is_eq(p, #alt)) \
+#define OPT_ALT(name, alt) \
+ if (is_eq(p, #name) || is_eq(p, #alt)) \
return ((name ## handler).parent = this, &(name ## handler))
-#define OPT_(name) \
- if (! *(p + 1) || \
- ((name ## handler).wants_arg && \
- *(p + 1) == '_' && ! *(p + 2)) || \
- is_eq(p, #name)) \
+#define OPT_(name) \
+ if (! *(p + 1) || \
+ ((name ## handler).wants_arg && \
+ *(p + 1) == '_' && ! *(p + 2)) || \
+ is_eq(p, #name)) \
return ((name ## handler).parent = this, &(name ## handler))
-#define OPT_CH(name) \
- if (! *(p + 1) || \
- ((name ## handler).wants_arg && \
- *(p + 1) == '_' && ! *(p + 2))) \
+#define OPT_CH(name) \
+ if (! *(p + 1) || \
+ ((name ## handler).wants_arg && \
+ *(p + 1) == '_' && ! *(p + 2))) \
return ((name ## handler).parent = this, &(name ## handler))
#define HANDLER(name) name ## handler
#define HANDLED(name) HANDLER(name)
-#define OPTION(type, name) \
- BEGIN(type, name) \
- { \
- CTOR(type, name) {} \
- } \
+#define OPTION(type, name) \
+ BEGIN(type, name) \
+ { \
+ CTOR(type, name) {} \
+ } \
END(name)
-#define OPTION_(type, name, body) \
- BEGIN(type, name) \
- { \
- CTOR(type, name) {} \
- body \
- } \
+#define OPTION_(type, name, body) \
+ BEGIN(type, name) \
+ { \
+ CTOR(type, name) {} \
+ body \
+ } \
END(name)
-#define OPTION__(type, name, body) \
- BEGIN(type, name) \
- { \
- body \
- } \
+#define OPTION__(type, name, body) \
+ BEGIN(type, name) \
+ { \
+ body \
+ } \
END(name)
bool process_option(const string& whence, const string& name, scope_t& scope,
- const char * arg, const string& varname);
+ const char * arg, const string& varname);
void process_environment(const char ** envp, const string& tag,
- scope_t& scope);
+ scope_t& scope);
strings_list process_arguments(strings_list args, scope_t& scope);
diff --git a/src/output.cc b/src/output.cc
index 5cef19bc..de0444cf 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -40,10 +40,10 @@
namespace ledger {
-format_posts::format_posts(report_t& _report,
- const string& format,
- const optional<string>& _prepend_format,
- std::size_t _prepend_width)
+format_posts::format_posts(report_t& _report,
+ const string& format,
+ const optional<string>& _prepend_format,
+ std::size_t _prepend_width)
: report(_report), prepend_width(_prepend_width),
last_xact(NULL), last_post(NULL), first_report_title(true)
{
@@ -56,9 +56,9 @@ format_posts::format_posts(report_t& _report,
const char * n = p + 2;
if (const char * p = std::strstr(n, "%/")) {
next_lines_format.parse_format(string(n, 0, p - n),
- first_line_format);
+ first_line_format);
between_format.parse_format(string(p + 2),
- first_line_format);
+ first_line_format);
} else {
next_lines_format.parse_format(string(n), first_line_format);
}
@@ -86,16 +86,16 @@ void format_posts::operator()(post_t& post)
if (! report_title.empty()) {
if (first_report_title)
- first_report_title = false;
+ first_report_title = false;
else
- out << '\n';
+ out << '\n';
value_scope_t val_scope(string_value(report_title));
bind_scope_t inner_scope(bound_scope, val_scope);
format_t group_title_format;
group_title_format
- .parse_format(report.HANDLER(group_title_format_).str());
+ .parse_format(report.HANDLER(group_title_format_).str());
out << group_title_format(inner_scope);
@@ -109,8 +109,8 @@ void format_posts::operator()(post_t& post)
if (last_xact != post.xact) {
if (last_xact) {
- bind_scope_t xact_scope(report, *last_xact);
- out << between_format(xact_scope);
+ bind_scope_t xact_scope(report, *last_xact);
+ out << between_format(xact_scope);
}
out << first_line_format(bound_scope);
last_xact = post.xact;
@@ -127,10 +127,10 @@ void format_posts::operator()(post_t& post)
}
}
-format_accounts::format_accounts(report_t& _report,
- const string& format,
- const optional<string>& _prepend_format,
- std::size_t _prepend_width)
+format_accounts::format_accounts(report_t& _report,
+ const string& format,
+ const optional<string>& _prepend_format,
+ std::size_t _prepend_width)
: report(_report), prepend_width(_prepend_width), disp_pred(),
first_report_title(true)
{
@@ -172,16 +172,16 @@ std::size_t format_accounts::post_account(account_t& account, const bool flat)
if (! report_title.empty()) {
if (first_report_title)
- first_report_title = false;
+ first_report_title = false;
else
- out << '\n';
+ out << '\n';
value_scope_t val_scope(string_value(report_title));
bind_scope_t inner_scope(bound_scope, val_scope);
format_t group_title_format;
group_title_format
- .parse_format(report.HANDLER(group_title_format_).str());
+ .parse_format(report.HANDLER(group_title_format_).str());
out << group_title_format(inner_scope);
@@ -203,7 +203,7 @@ std::size_t format_accounts::post_account(account_t& account, const bool flat)
std::pair<std::size_t, std::size_t>
format_accounts::mark_accounts(account_t& account, const bool flat)
{
- std::size_t visited = 0;
+ std::size_t visited = 0;
std::size_t to_display = 0;
foreach (accounts_map::value_type& pair, account.accounts) {
@@ -218,7 +218,7 @@ format_accounts::mark_accounts(account_t& account, const bool flat)
DEBUG("account.display", " it was visited itself");
DEBUG("account.display", " it has " << visited << " visited children");
DEBUG("account.display",
- " it has " << to_display << " children to display");
+ " it has " << to_display << " children to display");
#endif
if (account.parent &&
@@ -226,10 +226,10 @@ format_accounts::mark_accounts(account_t& account, const bool flat)
bind_scope_t bound_scope(report, account);
call_scope_t call_scope(bound_scope);
if ((! flat && to_display > 1) ||
- ((flat || to_display != 1 ||
- account.has_xflags(ACCOUNT_EXT_VISITED)) &&
- (report.HANDLED(empty) || report.fn_display_total(call_scope)) &&
- disp_pred(bound_scope))) {
+ ((flat || to_display != 1 ||
+ account.has_xflags(ACCOUNT_EXT_VISITED)) &&
+ (report.HANDLED(empty) || report.fn_display_total(call_scope)) &&
+ disp_pred(bound_scope))) {
account.xdata().add_flags(ACCOUNT_EXT_TO_DISPLAY);
DEBUG("account.display", "Marking account as TO_DISPLAY");
to_display = 1;
@@ -246,7 +246,7 @@ void format_accounts::flush()
if (report.HANDLED(display_)) {
DEBUG("account.display",
- "Account display predicate: " << report.HANDLER(display_).str());
+ "Account display predicate: " << report.HANDLER(display_).str());
disp_pred.parse(report.HANDLER(display_).str());
}
@@ -265,7 +265,7 @@ void format_accounts::flush()
if (prepend_format) {
static_cast<std::ostream&>(report.output_stream).width(prepend_width);
static_cast<std::ostream&>(report.output_stream)
- << prepend_format(bound_scope);
+ << prepend_format(bound_scope);
}
out << total_line_format(bound_scope);
@@ -346,12 +346,12 @@ void report_commodities::operator()(post_t& post)
annotated_commodity_t& ann_comm(as_annotated_commodity(comm));
if (ann_comm.details.price) {
std::map<commodity_t *, std::size_t>::iterator i =
- commodities.find(&ann_comm.details.price->commodity());
+ commodities.find(&ann_comm.details.price->commodity());
if (i == commodities.end())
- commodities.insert
- (commodities_pair(&ann_comm.details.price->commodity(), 1));
+ commodities.insert
+ (commodities_pair(&ann_comm.details.price->commodity(), 1));
else
- (*i).second++;
+ (*i).second++;
}
}
diff --git a/src/output.h b/src/output.h
index a19c6235..ac3925c4 100644
--- a/src/output.h
+++ b/src/output.h
@@ -69,8 +69,8 @@ protected:
public:
format_posts(report_t& _report, const string& format,
- const optional<string>& _prepend_format = none,
- std::size_t _prepend_width = 0);
+ const optional<string>& _prepend_format = none,
+ std::size_t _prepend_width = 0);
virtual ~format_posts() {
TRACE_DTOR(format_posts);
}
@@ -83,8 +83,8 @@ public:
virtual void operator()(post_t& post);
virtual void clear() {
- last_xact = NULL;
- last_post = NULL;
+ last_xact = NULL;
+ last_post = NULL;
report_title = "";
@@ -109,8 +109,8 @@ protected:
public:
format_accounts(report_t& _report, const string& _format,
- const optional<string>& _prepend_format = none,
- std::size_t _prepend_width = 0);
+ const optional<string>& _prepend_format = none,
+ std::size_t _prepend_width = 0);
virtual ~format_accounts() {
TRACE_DTOR(format_accounts);
}
@@ -123,7 +123,7 @@ public:
}
virtual std::size_t post_account(account_t& account, const bool flat);
- virtual void flush();
+ virtual void flush();
virtual void operator()(account_t& account);
diff --git a/src/parser.cc b/src/parser.cc
index f52949ce..db989f07 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -37,7 +37,7 @@ namespace ledger {
expr_t::ptr_op_t
expr_t::parser_t::parse_value_term(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node;
@@ -60,16 +60,16 @@ expr_t::parser_t::parse_value_term(std::istream& in,
if (tok.kind == token_t::LPAREN) {
op_t::kind_t kind = op_t::O_CALL;
if (ident == "any" || ident == "all")
- kind = op_t::O_EXPAND;
+ kind = op_t::O_EXPAND;
ptr_op_t call_node(new op_t(kind));
call_node->set_left(node);
node = call_node;
- push_token(tok); // let the parser see it again
+ push_token(tok); // let the parser see it again
node->set_right(parse_value_expr(in, tflags.plus_flags(PARSE_SINGLE)));
if (node->has_right() && node->right()->kind == op_t::O_CONS)
- node->set_right(node->right()->left());
+ node->set_right(node->right()->left());
} else {
push_token(tok);
}
@@ -78,7 +78,7 @@ expr_t::parser_t::parse_value_term(std::istream& in,
case token_t::LPAREN:
node = parse_value_expr(in, tflags.plus_flags(PARSE_PARTIAL)
- .minus_flags(PARSE_SINGLE));
+ .minus_flags(PARSE_SINGLE));
tok = next_token(in, tflags, ')');
if (node->kind == op_t::O_CONS) {
@@ -98,7 +98,7 @@ expr_t::parser_t::parse_value_term(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_dot_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_value_term(in, tflags));
@@ -106,16 +106,16 @@ expr_t::parser_t::parse_dot_expr(std::istream& in,
while (true) {
token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (tok.kind == token_t::DOT) {
- ptr_op_t prev(node);
- node = new op_t(op_t::O_LOOKUP);
- node->set_left(prev);
- node->set_right(parse_value_term(in, tflags));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ ptr_op_t prev(node);
+ node = new op_t(op_t::O_LOOKUP);
+ node->set_left(prev);
+ node->set_right(parse_value_term(in, tflags));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
} else {
- push_token(tok);
- break;
+ push_token(tok);
+ break;
}
}
}
@@ -125,7 +125,7 @@ expr_t::parser_t::parse_dot_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_unary_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node;
@@ -136,7 +136,7 @@ expr_t::parser_t::parse_unary_expr(std::istream& in,
ptr_op_t term(parse_dot_expr(in, tflags));
if (! term)
throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ _("%1 operator not followed by argument") << tok.symbol);
// A very quick optimization
if (term->kind == op_t::VALUE) {
@@ -153,7 +153,7 @@ expr_t::parser_t::parse_unary_expr(std::istream& in,
ptr_op_t term(parse_dot_expr(in, tflags));
if (! term)
throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ _("%1 operator not followed by argument") << tok.symbol);
// A very quick optimization
if (term->kind == op_t::VALUE) {
@@ -177,7 +177,7 @@ expr_t::parser_t::parse_unary_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_mul_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_unary_expr(in, tflags));
@@ -186,18 +186,18 @@ expr_t::parser_t::parse_mul_expr(std::istream& in,
token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (tok.kind == token_t::STAR || tok.kind == token_t::SLASH ||
- tok.kind == token_t::KW_DIV) {
- ptr_op_t prev(node);
- node = new op_t(tok.kind == token_t::STAR ?
- op_t::O_MUL : op_t::O_DIV);
- node->set_left(prev);
- node->set_right(parse_unary_expr(in, tflags));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ tok.kind == token_t::KW_DIV) {
+ ptr_op_t prev(node);
+ node = new op_t(tok.kind == token_t::STAR ?
+ op_t::O_MUL : op_t::O_DIV);
+ node->set_left(prev);
+ node->set_right(parse_unary_expr(in, tflags));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
} else {
- push_token(tok);
- break;
+ push_token(tok);
+ break;
}
}
}
@@ -207,7 +207,7 @@ expr_t::parser_t::parse_mul_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_add_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_mul_expr(in, tflags));
@@ -216,18 +216,18 @@ expr_t::parser_t::parse_add_expr(std::istream& in,
token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (tok.kind == token_t::PLUS ||
- tok.kind == token_t::MINUS) {
- ptr_op_t prev(node);
- node = new op_t(tok.kind == token_t::PLUS ?
- op_t::O_ADD : op_t::O_SUB);
- node->set_left(prev);
- node->set_right(parse_mul_expr(in, tflags));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ tok.kind == token_t::MINUS) {
+ ptr_op_t prev(node);
+ node = new op_t(tok.kind == token_t::PLUS ?
+ op_t::O_ADD : op_t::O_SUB);
+ node->set_left(prev);
+ node->set_right(parse_mul_expr(in, tflags));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
} else {
- push_token(tok);
- break;
+ push_token(tok);
+ break;
}
}
}
@@ -237,70 +237,70 @@ expr_t::parser_t::parse_add_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_logic_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_add_expr(in, tflags));
if (node && ! tflags.has_flags(PARSE_SINGLE)) {
while (true) {
- op_t::kind_t kind = op_t::LAST;
+ op_t::kind_t kind = op_t::LAST;
parse_flags_t _flags = tflags;
- token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
- bool negate = false;
+ token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
+ bool negate = false;
switch (tok.kind) {
case token_t::DEFINE:
- kind = op_t::O_DEFINE;
- break;
+ kind = op_t::O_DEFINE;
+ break;
case token_t::EQUAL:
- if (tflags.has_flags(PARSE_NO_ASSIGN))
- tok.rewind(in);
- else
- kind = op_t::O_EQ;
- break;
+ if (tflags.has_flags(PARSE_NO_ASSIGN))
+ tok.rewind(in);
+ else
+ kind = op_t::O_EQ;
+ break;
case token_t::NEQUAL:
- kind = op_t::O_EQ;
- negate = true;
- break;
+ kind = op_t::O_EQ;
+ negate = true;
+ break;
case token_t::MATCH:
- kind = op_t::O_MATCH;
- break;
+ kind = op_t::O_MATCH;
+ break;
case token_t::NMATCH:
- kind = op_t::O_MATCH;
- negate = true;
- break;
+ kind = op_t::O_MATCH;
+ negate = true;
+ break;
case token_t::LESS:
- kind = op_t::O_LT;
- break;
+ kind = op_t::O_LT;
+ break;
case token_t::LESSEQ:
- kind = op_t::O_LTE;
- break;
+ kind = op_t::O_LTE;
+ break;
case token_t::GREATER:
- kind = op_t::O_GT;
- break;
+ kind = op_t::O_GT;
+ break;
case token_t::GREATEREQ:
- kind = op_t::O_GTE;
- break;
+ kind = op_t::O_GTE;
+ break;
default:
- push_token(tok);
- goto exit_loop;
+ push_token(tok);
+ goto exit_loop;
}
if (kind != op_t::LAST) {
- ptr_op_t prev(node);
- node = new op_t(kind);
- node->set_left(prev);
- node->set_right(parse_add_expr(in, _flags));
-
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
-
- if (negate) {
- prev = node;
- node = new op_t(op_t::O_NOT);
- node->set_left(prev);
- }
+ ptr_op_t prev(node);
+ node = new op_t(kind);
+ node->set_left(prev);
+ node->set_right(parse_add_expr(in, _flags));
+
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
+
+ if (negate) {
+ prev = node;
+ node = new op_t(op_t::O_NOT);
+ node->set_left(prev);
+ }
}
}
}
@@ -311,7 +311,7 @@ expr_t::parser_t::parse_logic_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_and_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_logic_expr(in, tflags));
@@ -320,16 +320,16 @@ expr_t::parser_t::parse_and_expr(std::istream& in,
token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (tok.kind == token_t::KW_AND) {
- ptr_op_t prev(node);
- node = new op_t(op_t::O_AND);
- node->set_left(prev);
- node->set_right(parse_logic_expr(in, tflags));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ ptr_op_t prev(node);
+ node = new op_t(op_t::O_AND);
+ node->set_left(prev);
+ node->set_right(parse_logic_expr(in, tflags));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
} else {
- push_token(tok);
- break;
+ push_token(tok);
+ break;
}
}
}
@@ -338,7 +338,7 @@ expr_t::parser_t::parse_and_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_or_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_and_expr(in, tflags));
@@ -347,16 +347,16 @@ expr_t::parser_t::parse_or_expr(std::istream& in,
token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (tok.kind == token_t::KW_OR) {
- ptr_op_t prev(node);
- node = new op_t(op_t::O_OR);
- node->set_left(prev);
- node->set_right(parse_and_expr(in, tflags));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ ptr_op_t prev(node);
+ node = new op_t(op_t::O_OR);
+ node->set_left(prev);
+ node->set_right(parse_and_expr(in, tflags));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
} else {
- push_token(tok);
- break;
+ push_token(tok);
+ break;
}
}
}
@@ -365,7 +365,7 @@ expr_t::parser_t::parse_or_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_querycolon_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_or_expr(in, tflags));
@@ -378,8 +378,8 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
node->set_left(prev);
node->set_right(parse_or_expr(in, tflags));
if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT), ':');
prev = node->right();
@@ -387,42 +387,42 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
subnode->set_left(prev);
subnode->set_right(parse_or_expr(in, tflags));
if (! subnode->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
node->set_right(subnode);
}
else if (tok.kind == token_t::KW_IF) {
ptr_op_t if_op(parse_or_expr(in, tflags));
if (! if_op)
- throw_(parse_error, _("'if' keyword not followed by argument"));
+ throw_(parse_error, _("'if' keyword not followed by argument"));
tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (tok.kind == token_t::KW_ELSE) {
- ptr_op_t else_op(parse_or_expr(in, tflags));
- if (! else_op)
- throw_(parse_error, _("'else' keyword not followed by argument"));
+ ptr_op_t else_op(parse_or_expr(in, tflags));
+ if (! else_op)
+ throw_(parse_error, _("'else' keyword not followed by argument"));
- ptr_op_t subnode = new op_t(op_t::O_COLON);
- subnode->set_left(node);
- subnode->set_right(else_op);
+ ptr_op_t subnode = new op_t(op_t::O_COLON);
+ subnode->set_left(node);
+ subnode->set_right(else_op);
- node = new op_t(op_t::O_QUERY);
- node->set_left(if_op);
- node->set_right(subnode);
+ node = new op_t(op_t::O_QUERY);
+ node->set_left(if_op);
+ node->set_right(subnode);
} else {
- ptr_op_t null_node = new op_t(op_t::VALUE);
- null_node->set_value(NULL_VALUE);
+ ptr_op_t null_node = new op_t(op_t::VALUE);
+ null_node->set_value(NULL_VALUE);
- ptr_op_t subnode = new op_t(op_t::O_COLON);
- subnode->set_left(node);
- subnode->set_right(null_node);
+ ptr_op_t subnode = new op_t(op_t::O_COLON);
+ subnode->set_left(node);
+ subnode->set_right(null_node);
- node = new op_t(op_t::O_QUERY);
- node->set_left(if_op);
- node->set_right(subnode);
+ node = new op_t(op_t::O_QUERY);
+ node->set_left(if_op);
+ node->set_right(subnode);
- push_token(tok);
+ push_token(tok);
}
}
else {
@@ -434,7 +434,7 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
expr_t::ptr_op_t
expr_t::parser_t::parse_value_expr(std::istream& in,
- const parse_flags_t& tflags) const
+ const parse_flags_t& tflags) const
{
ptr_op_t node(parse_querycolon_expr(in, tflags));
@@ -449,21 +449,21 @@ expr_t::parser_t::parse_value_expr(std::istream& in,
node->set_left(prev);
node->set_right(parse_value_expr(in, tflags));
if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol);
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol);
tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
}
if (tok.kind != token_t::TOK_EOF) {
if (tflags.has_flags(PARSE_PARTIAL))
- push_token(tok);
+ push_token(tok);
else
- tok.unexpected();
+ tok.unexpected();
}
}
else if (! tflags.has_flags(PARSE_PARTIAL) &&
- ! tflags.has_flags(PARSE_SINGLE)) {
+ ! tflags.has_flags(PARSE_SINGLE)) {
throw_(parse_error, _("Failed to parse value expression"));
}
@@ -471,9 +471,9 @@ expr_t::parser_t::parse_value_expr(std::istream& in,
}
expr_t::ptr_op_t
-expr_t::parser_t::parse(std::istream& in,
- const parse_flags_t& flags,
- const optional<string>& original_string)
+expr_t::parser_t::parse(std::istream& in,
+ const parse_flags_t& flags,
+ const optional<string>& original_string)
{
try {
ptr_op_t top_node = parse_value_expr(in, flags);
@@ -492,11 +492,11 @@ expr_t::parser_t::parse(std::istream& in,
std::streamoff end_pos = 0;
if (in.good())
- end_pos = in.tellg();
+ end_pos = in.tellg();
std::streamoff pos = end_pos;
if (pos > 0)
- pos -= lookahead.length;
+ pos -= lookahead.length;
DEBUG("parser.error", "original_string = '" << *original_string << "'");
DEBUG("parser.error", " pos = " << pos);
@@ -505,8 +505,8 @@ expr_t::parser_t::parse(std::istream& in,
DEBUG("parser.error", " token length = " << lookahead.length);
add_error_context(line_context(*original_string,
- static_cast<string::size_type>(pos),
- static_cast<string::size_type>(end_pos)));
+ static_cast<string::size_type>(pos),
+ static_cast<string::size_type>(end_pos)));
}
throw;
}
diff --git a/src/parser.h b/src/parser.h
index 2693fc79..93ea994f 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -50,10 +50,10 @@ namespace ledger {
class expr_t::parser_t : public noncopyable
{
mutable token_t lookahead;
- mutable bool use_lookahead;
+ mutable bool use_lookahead;
token_t& next_token(std::istream& in, const parse_flags_t& tflags,
- const char expecting = '\0') const {
+ const char expecting = '\0') const {
if (use_lookahead)
use_lookahead = false;
else
@@ -76,25 +76,25 @@ class expr_t::parser_t : public noncopyable
}
ptr_op_t parse_value_term(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_dot_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_unary_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_mul_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_add_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_logic_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_and_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_or_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_querycolon_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
ptr_op_t parse_value_expr(std::istream& in,
- const parse_flags_t& flags) const;
+ const parse_flags_t& flags) const;
public:
parser_t() : use_lookahead(false) {
@@ -104,9 +104,9 @@ public:
TRACE_DTOR(parser_t);
}
- ptr_op_t parse(std::istream& in,
- const parse_flags_t& flags = PARSE_DEFAULT,
- const optional<string>& original_string = NULL);
+ ptr_op_t parse(std::istream& in,
+ const parse_flags_t& flags = PARSE_DEFAULT,
+ const optional<string>& original_string = NULL);
};
} // namespace ledger
diff --git a/src/pool.cc b/src/pool.cc
index 5285be92..618a43c5 100644
--- a/src/pool.cc
+++ b/src/pool.cc
@@ -67,11 +67,11 @@ commodity_t * commodity_pool_t::create(const string& symbol)
}
DEBUG("pool.commodities",
- "Creating commodity '" << commodity->symbol() << "'");
+ "Creating commodity '" << commodity->symbol() << "'");
std::pair<commodities_map::iterator, bool> result
= commodities.insert(commodities_map::value_type(commodity->mapping_key(),
- commodity.get()));
+ commodity.get()));
assert(result.second);
return commodity.release();
@@ -111,7 +111,7 @@ commodity_pool_t::create(const string& symbol, const annotation_t& details)
}
string commodity_pool_t::make_qualified_name(const commodity_t& comm,
- const annotation_t& details)
+ const annotation_t& details)
{
assert(details);
@@ -125,7 +125,7 @@ string commodity_pool_t::make_qualified_name(const commodity_t& comm,
#if defined(DEBUG_ON)
if (comm.qualified_symbol)
DEBUG("pool.commodities", "make_qualified_name for "
- << *comm.qualified_symbol << std::endl << details);
+ << *comm.qualified_symbol << std::endl << details);
#endif
DEBUG("pool.commodities", "qualified_name is " << name.str());
@@ -154,7 +154,7 @@ commodity_pool_t::find(const string& symbol, const annotation_t& details)
commodity_t *
commodity_pool_t::find_or_create(const string& symbol,
- const annotation_t& details)
+ const annotation_t& details)
{
commodity_t * comm = find_or_create(symbol);
if (! comm)
@@ -167,9 +167,9 @@ commodity_pool_t::find_or_create(const string& symbol,
}
commodity_t *
-commodity_pool_t::create(commodity_t& comm,
- const annotation_t& details,
- const string& mapping_key)
+commodity_pool_t::create(commodity_t& comm,
+ const annotation_t& details,
+ const string& mapping_key)
{
assert(comm);
assert(details);
@@ -182,8 +182,8 @@ commodity_pool_t::create(commodity_t& comm,
assert(! commodity->qualified_symbol->empty());
DEBUG("pool.commodities", "Creating annotated commodity "
- << "symbol " << commodity->symbol()
- << " key " << mapping_key << std::endl << details);
+ << "symbol " << commodity->symbol()
+ << " key " << mapping_key << std::endl << details);
// Add the fully annotated name to the map, so that this symbol may
// quickly be found again.
@@ -191,14 +191,14 @@ commodity_pool_t::create(commodity_t& comm,
std::pair<commodities_map::iterator, bool> result
= commodities.insert(commodities_map::value_type(mapping_key,
- commodity.get()));
+ commodity.get()));
assert(result.second);
return commodity.release();
}
-commodity_t * commodity_pool_t::find_or_create(commodity_t& comm,
- const annotation_t& details)
+commodity_t * commodity_pool_t::find_or_create(commodity_t& comm,
+ const annotation_t& details)
{
assert(comm);
assert(details);
@@ -213,12 +213,12 @@ commodity_t * commodity_pool_t::find_or_create(commodity_t& comm,
return create(comm, details, name);
}
-void commodity_pool_t::exchange(commodity_t& commodity,
- const amount_t& per_unit_cost,
- const datetime_t& moment)
+void commodity_pool_t::exchange(commodity_t& commodity,
+ const amount_t& per_unit_cost,
+ const datetime_t& moment)
{
DEBUG("commodity.prices.add", "exchanging commodity " << commodity
- << " at per unit cost " << per_unit_cost << " on " << moment);
+ << " at per unit cost " << per_unit_cost << " on " << moment);
commodity_t& base_commodity
(commodity.annotated ?
@@ -228,11 +228,11 @@ void commodity_pool_t::exchange(commodity_t& commodity,
}
cost_breakdown_t
-commodity_pool_t::exchange(const amount_t& amount,
- const amount_t& cost,
- const bool is_per_unit,
- const optional<datetime_t>& moment,
- const optional<string>& tag)
+commodity_pool_t::exchange(const amount_t& amount,
+ const amount_t& cost,
+ const bool is_per_unit,
+ const optional<datetime_t>& moment,
+ const optional<string>& tag)
{
DEBUG("commodity.prices.add", "exchange: " << amount << " for " << cost);
DEBUG("commodity.prices.add", "exchange: is-per-unit = " << is_per_unit);
@@ -261,7 +261,7 @@ commodity_pool_t::exchange(const amount_t& amount,
breakdown.final_cost = ! is_per_unit ? cost : cost * amount.abs();
DEBUG("commodity.prices.add",
- "exchange: final-cost = " << breakdown.final_cost);
+ "exchange: final-cost = " << breakdown.final_cost);
if (current_annotation && current_annotation->price)
breakdown.basis_cost
@@ -270,10 +270,10 @@ commodity_pool_t::exchange(const amount_t& amount,
breakdown.basis_cost = breakdown.final_cost;
DEBUG("commodity.prices.add",
- "exchange: basis-cost = " << breakdown.basis_cost);
+ "exchange: basis-cost = " << breakdown.basis_cost);
annotation_t annotation(per_unit_cost, moment ?
- moment->date() : optional<date_t>(), tag);
+ moment->date() : optional<date_t>(), tag);
annotation.add_flags(ANNOTATION_PRICE_CALCULATED);
if (moment)
@@ -284,7 +284,7 @@ commodity_pool_t::exchange(const amount_t& amount,
breakdown.amount = amount_t(amount, annotation);
DEBUG("commodity.prices.add",
- "exchange: amount = " << breakdown.amount);
+ "exchange: amount = " << breakdown.amount);
return breakdown;
}
@@ -328,7 +328,7 @@ commodity_pool_t::parse_price_directive(char * line, bool do_not_add_price)
DEBUG("commodity.download", "Looking up symbol: " << symbol);
if (commodity_t * commodity = find_or_create(symbol)) {
DEBUG("commodity.download", "Adding price for " << symbol << ": "
- << point.when << " " << point.price);
+ << point.when << " " << point.price);
if (! do_not_add_price)
commodity->add_price(point.when, point.price, true);
commodity->add_flags(COMMODITY_KNOWN);
@@ -340,8 +340,8 @@ commodity_pool_t::parse_price_directive(char * line, bool do_not_add_price)
commodity_t *
commodity_pool_t::parse_price_expression(const std::string& str,
- const bool add_prices,
- const optional<datetime_t>& moment)
+ const bool add_prices,
+ const optional<datetime_t>& moment)
{
scoped_array<char> buf(new char[str.length() + 1]);
@@ -354,9 +354,9 @@ commodity_pool_t::parse_price_expression(const std::string& str,
if (commodity_t * commodity = find_or_create(trim_ws(buf.get()))) {
if (price && add_prices) {
for (char * p = std::strtok(price, ";");
- p;
- p = std::strtok(NULL, ";")) {
- commodity->add_price(moment ? *moment : CURRENT_TIME(), amount_t(p));
+ p;
+ p = std::strtok(NULL, ";")) {
+ commodity->add_price(moment ? *moment : CURRENT_TIME(), amount_t(p));
}
}
return commodity;
@@ -364,9 +364,9 @@ commodity_pool_t::parse_price_expression(const std::string& str,
return NULL;
}
-void commodity_pool_t::print_pricemap(std::ostream& out,
- const keep_details_t& keep,
- const optional<datetime_t>& moment)
+void commodity_pool_t::print_pricemap(std::ostream& out,
+ const keep_details_t& keep,
+ const optional<datetime_t>& moment)
{
typedef std::map<commodity_t *, commodity_t *> comm_map_t;
@@ -391,44 +391,44 @@ void commodity_pool_t::print_pricemap(std::ostream& out,
out << "\"" << comm->symbol() << "\";\n";
if (! comm->has_flags(COMMODITY_NOMARKET) &&
- (! commodity_pool_t::current_pool->default_commodity ||
- comm != commodity_pool_t::current_pool->default_commodity)) {
+ (! commodity_pool_t::current_pool->default_commodity ||
+ comm != commodity_pool_t::current_pool->default_commodity)) {
if (optional<commodity_t::varied_history_t&> vhist =
- comm->varied_history()) {
- foreach (const commodity_t::history_by_commodity_map::value_type& pair,
- vhist->histories) {
- datetime_t most_recent;
- amount_t most_recent_amt;
- foreach (const commodity_t::history_map::value_type& inner_pair,
- pair.second.prices) {
- if ((most_recent.is_not_a_date_time() ||
- inner_pair.first > most_recent) &&
- (! moment || inner_pair.first <= moment)) {
- most_recent = inner_pair.first;
- most_recent_amt = inner_pair.second;
- }
- }
-
- if (! most_recent.is_not_a_date_time()) {
- out << " ";
- if (commodity_t::symbol_needs_quotes(comm->symbol()))
- out << comm->symbol();
- else
- out << "\"" << comm->symbol() << "\"";
-
- out << " -> ";
-
- if (commodity_t::symbol_needs_quotes(pair.first->symbol()))
- out << pair.first->symbol();
- else
- out << "\"" << pair.first->symbol() << "\"";
-
- out << " [label=\""
- << most_recent_amt.number() << "\\n"
- << format_date(most_recent.date(), FMT_WRITTEN)
- << "\" fontcolor=\"#008e28\"];\n";
- }
- }
+ comm->varied_history()) {
+ foreach (const commodity_t::history_by_commodity_map::value_type& pair,
+ vhist->histories) {
+ datetime_t most_recent;
+ amount_t most_recent_amt;
+ foreach (const commodity_t::history_map::value_type& inner_pair,
+ pair.second.prices) {
+ if ((most_recent.is_not_a_date_time() ||
+ inner_pair.first > most_recent) &&
+ (! moment || inner_pair.first <= moment)) {
+ most_recent = inner_pair.first;
+ most_recent_amt = inner_pair.second;
+ }
+ }
+
+ if (! most_recent.is_not_a_date_time()) {
+ out << " ";
+ if (commodity_t::symbol_needs_quotes(comm->symbol()))
+ out << comm->symbol();
+ else
+ out << "\"" << comm->symbol() << "\"";
+
+ out << " -> ";
+
+ if (commodity_t::symbol_needs_quotes(pair.first->symbol()))
+ out << pair.first->symbol();
+ else
+ out << "\"" << pair.first->symbol() << "\"";
+
+ out << " [label=\""
+ << most_recent_amt.number() << "\\n"
+ << format_date(most_recent.date(), FMT_WRITTEN)
+ << "\" fontcolor=\"#008e28\"];\n";
+ }
+ }
}
}
}
diff --git a/src/pool.h b/src/pool.h
index ac66d7a6..4b935f69 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -67,19 +67,19 @@ public:
typedef std::map<string, commodity_t *> commodities_map;
commodities_map commodities;
- commodity_t * null_commodity;
- commodity_t * default_commodity;
+ commodity_t * null_commodity;
+ commodity_t * default_commodity;
- bool keep_base; // --base
+ bool keep_base; // --base
optional<path> price_db; // --price-db=
- long quote_leeway; // --leeway=
- bool get_quotes; // --download
+ long quote_leeway; // --leeway=
+ bool get_quotes; // --download
static shared_ptr<commodity_pool_t> current_pool;
function<optional<price_point_t>
- (commodity_t& commodity, const optional<commodity_t&>& in_terms_of)>
+ (commodity_t& commodity, const optional<commodity_t&>& in_terms_of)>
get_commodity_quote;
explicit commodity_pool_t();
@@ -91,7 +91,7 @@ public:
}
string make_qualified_name(const commodity_t& comm,
- const annotation_t& details);
+ const annotation_t& details);
commodity_t * create(const string& symbol);
commodity_t * find(const string& name);
@@ -100,26 +100,26 @@ public:
commodity_t * create(const string& symbol, const annotation_t& details);
commodity_t * find(const string& symbol, const annotation_t& details);
commodity_t * find_or_create(const string& symbol,
- const annotation_t& details);
+ const annotation_t& details);
- commodity_t * create(commodity_t& comm,
- const annotation_t& details,
- const string& mapping_key);
+ commodity_t * create(commodity_t& comm,
+ const annotation_t& details,
+ const string& mapping_key);
- commodity_t * find_or_create(commodity_t& comm,
- const annotation_t& details);
+ commodity_t * find_or_create(commodity_t& comm,
+ const annotation_t& details);
// Exchange one commodity for another, while recording the factored price.
- void exchange(commodity_t& commodity,
- const amount_t& per_unit_cost,
- const datetime_t& moment);
+ void exchange(commodity_t& commodity,
+ const amount_t& per_unit_cost,
+ const datetime_t& moment);
- cost_breakdown_t exchange(const amount_t& amount,
- const amount_t& cost,
- const bool is_per_unit = false,
- const optional<datetime_t>& moment = none,
- const optional<string>& tag = none);
+ cost_breakdown_t exchange(const amount_t& amount,
+ const amount_t& cost,
+ const bool is_per_unit = false,
+ const optional<datetime_t>& moment = none,
+ const optional<string>& tag = none);
// Parse commodity prices from a textual representation
@@ -128,14 +128,14 @@ public:
commodity_t *
parse_price_expression(const std::string& str,
- const bool add_prices = true,
- const optional<datetime_t>& moment = none);
+ const bool add_prices = true,
+ const optional<datetime_t>& moment = none);
// Output the commodity price map for a given date as a DOT file
- void print_pricemap(std::ostream& out,
- const keep_details_t& keep,
- const optional<datetime_t>& moment = none);
+ void print_pricemap(std::ostream& out,
+ const keep_details_t& keep,
+ const optional<datetime_t>& moment = none);
#if defined(HAVE_BOOST_SERIALIZATION)
private:
diff --git a/src/post.cc b/src/post.cc
index e182a731..3ef76f7f 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -50,7 +50,7 @@ bool post_t::has_tag(const string& tag) const
}
bool post_t::has_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask) const
+ const optional<mask_t>& value_mask) const
{
if (item_t::has_tag(tag_mask, value_mask))
return true;
@@ -69,7 +69,7 @@ optional<string> post_t::get_tag(const string& tag) const
}
optional<string> post_t::get_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask) const
+ const optional<mask_t>& value_mask) const
{
if (optional<string> value = item_t::get_tag(tag_mask, value_mask))
return value;
@@ -199,18 +199,18 @@ namespace {
value_t get_commodity(post_t& post) {
if (post.has_xdata() &&
- post.xdata().has_flags(POST_EXT_COMPOUND))
+ post.xdata().has_flags(POST_EXT_COMPOUND))
return string_value(post.xdata().compound_value.to_amount()
- .commodity().symbol());
+ .commodity().symbol());
else
return string_value(post.amount.commodity().symbol());
}
value_t get_commodity_is_primary(post_t& post) {
if (post.has_xdata() &&
- post.xdata().has_flags(POST_EXT_COMPOUND))
+ post.xdata().has_flags(POST_EXT_COMPOUND))
return post.xdata().compound_value.to_amount()
- .commodity().has_flags(COMMODITY_PRIMARY);
+ .commodity().has_flags(COMMODITY_PRIMARY);
else
return post.amount.commodity().has_flags(COMMODITY_PRIMARY);
}
@@ -223,7 +223,7 @@ namespace {
if (post.cost)
return *post.cost;
else if (post.has_xdata() &&
- post.xdata().has_flags(POST_EXT_COMPOUND))
+ post.xdata().has_flags(POST_EXT_COMPOUND))
return post.xdata().compound_value;
else if (post.amount.is_null())
return 0L;
@@ -255,37 +255,37 @@ namespace {
if (env.has(0)) {
if (env.value_at(0).is_long()) {
- if (env.get<long>(0) > 2)
- name = format_t::truncate(env->reported_account()->fullname(),
- env.get<long>(0) - 2,
- 2 /* account_abbrev_length */);
- else
- name = env->reported_account()->fullname();
+ if (env.get<long>(0) > 2)
+ name = format_t::truncate(env->reported_account()->fullname(),
+ env.get<long>(0) - 2,
+ 2 /* account_abbrev_length */);
+ else
+ name = env->reported_account()->fullname();
} else {
- account_t * account = NULL;
- account_t * master = env->account;
- while (master->parent)
- master = master->parent;
-
- if (env.value_at(0).is_string()) {
- name = env.get<string>(0);
- account = master->find_account(name, false);
- }
- else if (env.value_at(0).is_mask()) {
- name = env.get<mask_t>(0).str();
- account = master->find_account_re(name);
- }
- else {
- throw_(std::runtime_error,
- _("Expected string or mask for argument 1, but received %1")
- << env.value_at(0).label());
- }
-
- if (! account)
- throw_(std::runtime_error,
- _("Could not find an account matching ") << env.value_at(0));
- else
- return value_t(static_cast<scope_t *>(account));
+ account_t * account = NULL;
+ account_t * master = env->account;
+ while (master->parent)
+ master = master->parent;
+
+ if (env.value_at(0).is_string()) {
+ name = env.get<string>(0);
+ account = master->find_account(name, false);
+ }
+ else if (env.value_at(0).is_mask()) {
+ name = env.get<mask_t>(0).str();
+ account = master->find_account_re(name);
+ }
+ else {
+ throw_(std::runtime_error,
+ _("Expected string or mask for argument 1, but received %1")
+ << env.value_at(0).label());
+ }
+
+ if (! account)
+ throw_(std::runtime_error,
+ _("Could not find an account matching ") << env.value_at(0));
+ else
+ return value_t(static_cast<scope_t *>(account));
}
} else {
name = env->reported_account()->fullname();
@@ -300,10 +300,10 @@ namespace {
value_t acct = account_name(scope);
if (acct.is_string()) {
if (env->has_flags(POST_VIRTUAL)) {
- if (env->must_balance())
- acct = string_value(string("[") + acct.as_string() + "]");
- else
- acct = string_value(string("(") + acct.as_string() + ")");
+ if (env->must_balance())
+ acct = string_value(string("[") + acct.as_string() + "]");
+ else
+ acct = string_value(string("(") + acct.as_string() + ")");
}
}
return acct;
@@ -330,7 +330,7 @@ namespace {
if (post.has_xdata()) {
post_t::xdata_t& xdata(post.xdata());
if (! xdata.value_date.is_not_a_date())
- return xdata.value_date;
+ return xdata.value_date;
}
return post.date();
}
@@ -353,13 +353,13 @@ namespace {
foreach (post_t * p, post.xact->posts) {
bind_scope_t bound_scope(scope, *p);
if (p == &post && args.has(1) &&
- ! args.get<expr_t&>(1).calc(bound_scope).to_boolean()) {
- // If the user specifies any(EXPR, false), and the context is a
- // posting, then that posting isn't considered by the test.
- ; // skip it
+ ! args.get<expr_t&>(1).calc(bound_scope).to_boolean()) {
+ // If the user specifies any(EXPR, false), and the context is a
+ // posting, then that posting isn't considered by the test.
+ ; // skip it
}
else if (expr.calc(bound_scope).to_boolean()) {
- return true;
+ return true;
}
}
return false;
@@ -375,13 +375,13 @@ namespace {
foreach (post_t * p, post.xact->posts) {
bind_scope_t bound_scope(scope, *p);
if (p == &post && args.has(1) &&
- ! args.get<expr_t&>(1).calc(bound_scope).to_boolean()) {
- // If the user specifies any(EXPR, false), and the context is a
- // posting, then that posting isn't considered by the test.
- ; // skip it
+ ! args.get<expr_t&>(1).calc(bound_scope).to_boolean()) {
+ // If the user specifies any(EXPR, false), and the context is a
+ // posting, then that posting isn't considered by the test.
+ ; // skip it
}
else if (! expr.calc(bound_scope).to_boolean()) {
- return false;
+ return false;
}
}
return true;
@@ -389,7 +389,7 @@ namespace {
}
expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (kind != symbol_t::FUNCTION)
return item_t::lookup(kind, name);
@@ -533,7 +533,7 @@ amount_t post_t::resolve_expr(scope_t& scope, expr_t& expr)
} else {
if (! result.is_amount())
throw_(amount_error,
- _("Amount expressions must result in a simple amount"));
+ _("Amount expressions must result in a simple amount"));
return result.as_amount();
}
}
@@ -571,7 +571,7 @@ bool post_t::valid() const
posts_list::const_iterator i =
std::find(xact->posts.begin(),
- xact->posts.end(), this);
+ xact->posts.end(), this);
if (i == xact->posts.end()) {
DEBUG("ledger.validate", "post_t: ! found");
return false;
@@ -608,7 +608,7 @@ void post_t::add_to_value(value_t& value, const optional<expr_t&>& expr) const
}
else if (expr) {
bind_scope_t bound_scope(*expr->get_context(),
- const_cast<post_t&>(*this));
+ const_cast<post_t&>(*this));
#if 1
value_t temp(expr->calc(bound_scope));
add_or_set_value(value, temp);
@@ -621,7 +621,7 @@ void post_t::add_to_value(value_t& value, const optional<expr_t&>& expr) const
#endif
}
else if (xdata_ && xdata_->has_flags(POST_EXT_VISITED) &&
- ! xdata_->visited_value.is_null()) {
+ ! xdata_->visited_value.is_null()) {
add_or_set_value(value, xdata_->visited_value);
}
else {
@@ -708,18 +708,18 @@ void to_xml(std::ostream& out, const post_t& post)
push_xml y(out, "metadata");
foreach (const item_t::string_map::value_type& pair, *post.metadata) {
if (pair.second.first) {
- push_xml z(out, "variable");
- {
- push_xml z(out, "key");
- out << y.guard(pair.first);
- }
- {
- push_xml z(out, "value");
- out << y.guard(*pair.second.first);
- }
+ push_xml z(out, "variable");
+ {
+ push_xml z(out, "key");
+ out << y.guard(pair.first);
+ }
+ {
+ push_xml z(out, "value");
+ out << y.guard(*pair.second.first);
+ }
} else {
- push_xml z(out, "tag");
- out << y.guard(pair.first);
+ push_xml z(out, "tag");
+ out << y.guard(pair.first);
}
}
}
diff --git a/src/post.h b/src/post.h
index eef58e52..a43e6cd9 100644
--- a/src/post.h
+++ b/src/post.h
@@ -52,33 +52,33 @@ class account_t;
class post_t : public item_t
{
public:
-#define POST_VIRTUAL 0x0010 // the account was specified with (parens)
+#define POST_VIRTUAL 0x0010 // the account was specified with (parens)
#define POST_MUST_BALANCE 0x0020 // posting must balance in the transaction
-#define POST_CALCULATED 0x0040 // posting's amount was calculated
+#define POST_CALCULATED 0x0040 // posting's amount was calculated
#define POST_COST_CALCULATED 0x0080 // posting's cost was calculated
#define POST_COST_IN_FULL 0x0100 // cost specified using @@
#define POST_COST_FIXATED 0x0200 // cost is fixed using = indicator
#define POST_ANONYMIZED 0x0400 // a temporary, anonymous posting
- xact_t * xact; // only set for posts of regular xacts
- account_t * account;
+ xact_t * xact; // only set for posts of regular xacts
+ account_t * account;
- amount_t amount; // can be null until finalization
+ amount_t amount; // can be null until finalization
optional<expr_t> amount_expr;
optional<amount_t> cost;
optional<amount_t> assigned_amount;
post_t(account_t * _account = NULL,
- flags_t _flags = ITEM_NORMAL)
+ flags_t _flags = ITEM_NORMAL)
: item_t(_flags),
xact(NULL), account(_account)
{
TRACE_CTOR(post_t, "account_t *, flags_t");
}
- post_t(account_t * _account,
- const amount_t& _amount,
- flags_t _flags = ITEM_NORMAL,
- const optional<string>& _note = none)
+ post_t(account_t * _account,
+ const amount_t& _amount,
+ flags_t _flags = ITEM_NORMAL,
+ const optional<string>& _note = none)
: item_t(_flags, _note),
xact(NULL), account(_account), amount(_amount)
{
@@ -101,11 +101,11 @@ public:
virtual bool has_tag(const string& tag) const;
virtual bool has_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask = none) const;
+ const optional<mask_t>& value_mask = none) const;
virtual optional<string> get_tag(const string& tag) const;
virtual optional<string> get_tag(const mask_t& tag_mask,
- const optional<mask_t>& value_mask = none) const;
+ const optional<mask_t>& value_mask = none) const;
virtual date_t value_date() const;
virtual date_t date() const;
@@ -117,7 +117,7 @@ public:
}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
amount_t resolve_expr(scope_t& scope, expr_t& expr);
@@ -138,14 +138,14 @@ public:
#define POST_EXT_MATCHES 0x0080
#define POST_EXT_CONSIDERED 0x0100
- value_t visited_value;
- value_t compound_value;
- value_t total;
- std::size_t count;
- date_t date;
- date_t value_date;
- datetime_t datetime;
- account_t * account;
+ value_t visited_value;
+ value_t compound_value;
+ value_t total;
+ std::size_t count;
+ date_t date;
+ date_t value_date;
+ datetime_t datetime;
+ account_t * account;
std::list<sort_value_t> sort_values;
@@ -155,13 +155,13 @@ public:
}
xdata_t(const xdata_t& other)
: supports_flags<uint_least16_t>(other.flags()),
- visited_value(other.visited_value),
- compound_value(other.compound_value),
- total(other.total),
- count(other.count),
- date(other.date),
- account(other.account),
- sort_values(other.sort_values)
+ visited_value(other.visited_value),
+ compound_value(other.compound_value),
+ total(other.total),
+ count(other.count),
+ date(other.date),
+ account(other.account),
+ sort_values(other.sort_values)
{
TRACE_CTOR(post_t::xdata_t, "copy");
}
@@ -192,14 +192,14 @@ public:
}
void add_to_value(value_t& value,
- const optional<expr_t&>& expr = none) const;
+ const optional<expr_t&>& expr = none) const;
void set_reported_account(account_t * account);
account_t * reported_account() {
if (xdata_)
if (account_t * acct = xdata_->account)
- return acct;
+ return acct;
return account;
}
@@ -213,12 +213,12 @@ public:
{
bool operator()(const post_t * left, const post_t * right) const {
gregorian::date_duration duration =
- left->actual_date() - right->actual_date();
+ left->actual_date() - right->actual_date();
if (duration.days() == 0) {
- return ((left->pos ? left->pos->sequence : 0) <
- (right->pos ? right->pos->sequence : 0));
+ return ((left->pos ? left->pos->sequence : 0) <
+ (right->pos ? right->pos->sequence : 0));
} else {
- return duration.days() < 0;
+ return duration.days() < 0;
}
}
};
diff --git a/src/precmd.cc b/src/precmd.cc
index e545a783..43a9835c 100644
--- a/src/precmd.cc
+++ b/src/precmd.cc
@@ -48,27 +48,27 @@ namespace {
{
string str;
{
- std::ostringstream buf;
+ std::ostringstream buf;
- buf << "2004/05/27 Book Store\n"
- << " ; This note applies to all postings. :SecondTag:\n"
- << " Expenses:Books 20 BOOK @ $10\n"
- << " ; Metadata: Some Value\n"
- << " ; :ExampleTag:\n"
- << " ; Here follows a note describing the posting.\n"
- << " Liabilities:MasterCard $-200.00\n";
+ buf << "2004/05/27 Book Store\n"
+ << " ; This note applies to all postings. :SecondTag:\n"
+ << " Expenses:Books 20 BOOK @ $10\n"
+ << " ; Metadata: Some Value\n"
+ << " ; :ExampleTag:\n"
+ << " ; Here follows a note describing the posting.\n"
+ << " Liabilities:MasterCard $-200.00\n";
- str = buf.str();
+ str = buf.str();
}
std::ostream& out(report.output_stream);
out << _("--- Context is first posting of the following transaction ---")
- << std::endl << str << std::endl;
+ << std::endl << str << std::endl;
{
- std::istringstream in(str);
- report.session.journal->parse(in, report.session);
- report.session.journal->clear_xdata();
+ std::istringstream in(str);
+ report.session.journal->parse(in, report.session);
+ report.session.journal->clear_xdata();
}
}
xact_t * first = report.session.journal->xacts.front();
@@ -193,7 +193,7 @@ value_t query_command(call_scope_t& args)
if (query.tokens_remaining()) {
out << std::endl << _("====== Display predicate ======")
- << std::endl << std::endl;
+ << std::endl << std::endl;
query.parse_again();
diff --git a/src/predicate.h b/src/predicate.h
index c21167d7..fc99c3c6 100644
--- a/src/predicate.h
+++ b/src/predicate.h
@@ -66,12 +66,12 @@ public:
predicate_t(const query_t& other);
predicate_t(const string& str, const keep_details_t& _what_to_keep,
- const parse_flags_t& flags = PARSE_DEFAULT)
+ const parse_flags_t& flags = PARSE_DEFAULT)
: expr_t(str, flags), what_to_keep(_what_to_keep) {
TRACE_CTOR(predicate_t, "string, keep_details_t, parse_flags_t");
}
predicate_t(std::istream& in, const keep_details_t& _what_to_keep,
- const parse_flags_t& flags = PARSE_DEFAULT)
+ const parse_flags_t& flags = PARSE_DEFAULT)
: expr_t(in, flags), what_to_keep(_what_to_keep) {
TRACE_CTOR(predicate_t, "std::istream&, keep_details_t, parse_flags_t");
}
@@ -81,10 +81,10 @@ public:
virtual value_t real_calc(scope_t& scope) {
return (*this ?
- expr_t::real_calc(scope)
- .strip_annotations(what_to_keep)
- .to_boolean() :
- true);
+ expr_t::real_calc(scope)
+ .strip_annotations(what_to_keep)
+ .to_boolean() :
+ true);
}
#if defined(HAVE_BOOST_SERIALIZATION)
diff --git a/src/print.cc b/src/print.cc
index 2795c7ad..de35a31d 100644
--- a/src/print.cc
+++ b/src/print.cc
@@ -41,10 +41,10 @@
namespace ledger {
namespace {
- void print_note(std::ostream& out,
- const string& note,
- const std::size_t columns,
- const std::size_t prior_width)
+ void print_note(std::ostream& out,
+ const string& note,
+ const std::size_t columns,
+ const std::size_t prior_width)
{
// The 4 is for four leading spaces at the beginning of the posting, and
// the 3 is for two spaces and a semi-colon before the note.
@@ -56,20 +56,20 @@ namespace {
bool need_separator = false;
for (const char * p = note.c_str(); *p; p++) {
if (*p == '\n') {
- need_separator = true;
+ need_separator = true;
} else {
- if (need_separator) {
- out << "\n ;";
- need_separator = false;
- }
- out << *p;
+ if (need_separator) {
+ out << "\n ;";
+ need_separator = false;
+ }
+ out << *p;
}
}
}
void print_xact(report_t& report, std::ostream& out, xact_t& xact)
{
- format_type_t format_type = FMT_WRITTEN;
+ format_type_t format_type = FMT_WRITTEN;
optional<const char *> format;
if (report.HANDLED(date_format_)) {
@@ -80,15 +80,15 @@ namespace {
std::ostringstream buf;
buf << format_date(item_t::use_effective_date ?
- xact.date() : xact.actual_date(),
- format_type, format);
+ xact.date() : xact.actual_date(),
+ format_type, format);
if (! item_t::use_effective_date && xact.effective_date())
buf << '=' << format_date(*xact.effective_date(),
- format_type, format);
+ format_type, format);
buf << ' ';
buf << (xact.state() == item_t::CLEARED ? "* " :
- (xact.state() == item_t::PENDING ? "! " : ""));
+ (xact.state() == item_t::PENDING ? "! " : ""));
if (xact.code)
buf << '(' << *xact.code << ") ";
@@ -99,7 +99,7 @@ namespace {
out << leader;
std::size_t columns = (report.HANDLED(columns_) ?
- report.HANDLER(columns_).value.to_long() : 80);
+ report.HANDLER(columns_).value.to_long() : 80);
if (xact.note)
print_note(out, *xact.note, columns, unistring(leader).length());
@@ -107,112 +107,112 @@ namespace {
if (xact.metadata) {
foreach (const item_t::string_map::value_type& data, *xact.metadata) {
- if (! data.second.second) {
- out << " ; ";
- if (data.second.first)
- out << data.first << ": " << *data.second.first;
- else
- out << ':' << data.first << ":";
- out << '\n';
- }
+ if (! data.second.second) {
+ out << " ; ";
+ if (data.second.first)
+ out << data.first << ": " << *data.second.first;
+ else
+ out << ':' << data.first << ":";
+ out << '\n';
+ }
}
}
foreach (post_t * post, xact.posts) {
if (! report.HANDLED(generated) &&
- (post->has_flags(ITEM_TEMP | ITEM_GENERATED) &&
- ! post->has_flags(POST_ANONYMIZED)))
- continue;
+ (post->has_flags(ITEM_TEMP | ITEM_GENERATED) &&
+ ! post->has_flags(POST_ANONYMIZED)))
+ continue;
out << " ";
std::ostringstream buf;
if (xact.state() == item_t::UNCLEARED)
- buf << (post->state() == item_t::CLEARED ? "* " :
- (post->state() == item_t::PENDING ? "! " : ""));
+ buf << (post->state() == item_t::CLEARED ? "* " :
+ (post->state() == item_t::PENDING ? "! " : ""));
if (post->has_flags(POST_VIRTUAL)) {
- if (post->has_flags(POST_MUST_BALANCE))
- buf << '[';
- else
- buf << '(';
+ if (post->has_flags(POST_MUST_BALANCE))
+ buf << '[';
+ else
+ buf << '(';
}
buf << post->account->fullname();
if (post->has_flags(POST_VIRTUAL)) {
- if (post->has_flags(POST_MUST_BALANCE))
- buf << ']';
- else
- buf << ')';
+ if (post->has_flags(POST_MUST_BALANCE))
+ buf << ']';
+ else
+ buf << ')';
}
unistring name(buf.str());
std::size_t account_width =
- (report.HANDLER(account_width_).specified ?
- report.HANDLER(account_width_).value.to_long() : 36);
+ (report.HANDLER(account_width_).specified ?
+ report.HANDLER(account_width_).value.to_long() : 36);
if (account_width < name.length())
- account_width = name.length();
+ account_width = name.length();
if (! post->has_flags(POST_CALCULATED) || report.HANDLED(generated)) {
- out << name.extract();
- int slip = (static_cast<int>(account_width) -
- static_cast<int>(name.length()));
- if (slip > 0) {
- out.width(slip);
- out << ' ';
- }
-
- std::ostringstream amtbuf;
-
- string amt;
- if (post->amount_expr) {
- amt = post->amount_expr->text();
- } else {
- int amount_width =
- (report.HANDLER(amount_width_).specified ?
- report.HANDLER(amount_width_).value.to_int() : 12);
-
- std::ostringstream amt_str;
- value_t(post->amount).print(amt_str, amount_width, -1,
- AMOUNT_PRINT_RIGHT_JUSTIFY |
- AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS);
- amt = amt_str.str();
- }
-
- string trimmed_amt(amt);
- trim_left(trimmed_amt);
- int amt_slip = (static_cast<int>(amt.length()) -
- static_cast<int>(trimmed_amt.length()));
- if (slip + amt_slip < 2)
- amtbuf << string(2 - (slip + amt_slip), ' ');
- amtbuf << amt;
-
- if (post->cost &&
- ! post->has_flags(POST_CALCULATED | POST_COST_CALCULATED)) {
- if (post->has_flags(POST_COST_IN_FULL))
- amtbuf << " @@ " << post->cost->abs();
- else
- amtbuf << " @ "
- << (*post->cost / post->amount).abs();
- }
-
- if (post->assigned_amount)
- amtbuf << " = " << post->assigned_amount;
-
- string trailer = amtbuf.str();
- out << trailer;
-
- account_width += unistring(trailer).length();
+ out << name.extract();
+ int slip = (static_cast<int>(account_width) -
+ static_cast<int>(name.length()));
+ if (slip > 0) {
+ out.width(slip);
+ out << ' ';
+ }
+
+ std::ostringstream amtbuf;
+
+ string amt;
+ if (post->amount_expr) {
+ amt = post->amount_expr->text();
+ } else {
+ int amount_width =
+ (report.HANDLER(amount_width_).specified ?
+ report.HANDLER(amount_width_).value.to_int() : 12);
+
+ std::ostringstream amt_str;
+ value_t(post->amount).print(amt_str, amount_width, -1,
+ AMOUNT_PRINT_RIGHT_JUSTIFY |
+ AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS);
+ amt = amt_str.str();
+ }
+
+ string trimmed_amt(amt);
+ trim_left(trimmed_amt);
+ int amt_slip = (static_cast<int>(amt.length()) -
+ static_cast<int>(trimmed_amt.length()));
+ if (slip + amt_slip < 2)
+ amtbuf << string(2 - (slip + amt_slip), ' ');
+ amtbuf << amt;
+
+ if (post->cost &&
+ ! post->has_flags(POST_CALCULATED | POST_COST_CALCULATED)) {
+ if (post->has_flags(POST_COST_IN_FULL))
+ amtbuf << " @@ " << post->cost->abs();
+ else
+ amtbuf << " @ "
+ << (*post->cost / post->amount).abs();
+ }
+
+ if (post->assigned_amount)
+ amtbuf << " = " << post->assigned_amount;
+
+ string trailer = amtbuf.str();
+ out << trailer;
+
+ account_width += unistring(trailer).length();
} else {
- out << buf.str();
+ out << buf.str();
}
if (post->note)
- print_note(out, *post->note, columns, 4 + account_width);
+ print_note(out, *post->note, columns, 4 + account_width);
out << '\n';
}
}
diff --git a/src/print.h b/src/print.h
index f6ef0868..edfe864d 100644
--- a/src/print.h
+++ b/src/print.h
@@ -55,14 +55,14 @@ class report_t;
class print_xacts : public item_handler<post_t>
{
protected:
- typedef std::list<xact_t *> xacts_list;
+ typedef std::list<xact_t *> xacts_list;
typedef std::map<xact_t *, bool> xacts_present_map;
- report_t& report;
+ report_t& report;
xacts_present_map xacts_present;
- xacts_list xacts;
- bool print_raw;
- bool first_title;
+ xacts_list xacts;
+ bool print_raw;
+ bool first_title;
public:
print_xacts(report_t& _report, bool _print_raw = false)
diff --git a/src/pstream.h b/src/pstream.h
index bba2845e..5fac20bd 100644
--- a/src/pstream.h
+++ b/src/pstream.h
@@ -53,44 +53,44 @@ class ptristream : public std::istream
ptrinbuf& operator=(const ptrinbuf&);
protected:
- char * ptr;
+ char * ptr;
std::size_t len;
public:
ptrinbuf(char * _ptr, std::size_t _len) : ptr(_ptr), len(_len) {
if (*ptr && len == 0)
- len = std::strlen(ptr);
+ len = std::strlen(ptr);
- setg(ptr, // beginning of putback area
- ptr, // read position
- ptr+len); // end position
+ setg(ptr, // beginning of putback area
+ ptr, // read position
+ ptr+len); // end position
}
protected:
virtual int_type underflow() {
// is read position before end of buffer?
if (gptr() < egptr())
- return traits_type::to_int_type(*gptr());
+ return traits_type::to_int_type(*gptr());
else
- return EOF;
+ return EOF;
}
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
- ios_base::openmode)
+ ios_base::openmode)
{
switch (way) {
case std::ios::cur:
- setg(ptr, gptr()+off, ptr+len);
- break;
+ setg(ptr, gptr()+off, ptr+len);
+ break;
case std::ios::beg:
- setg(ptr, ptr+off, ptr+len);
- break;
+ setg(ptr, ptr+off, ptr+len);
+ break;
case std::ios::end:
- setg(ptr, egptr()+off, ptr+len);
- break;
+ setg(ptr, egptr()+off, ptr+len);
+ break;
default:
- return pos_type(off_type(-1));
+ return pos_type(off_type(-1));
}
return pos_type(gptr() - ptr);
}
diff --git a/src/py_account.cc b/src/py_account.cc
index 2b860a24..af51ffce 100644
--- a/src/py_account.cc
+++ b/src/py_account.cc
@@ -82,7 +82,7 @@ namespace {
}
account_t * py_find_account_2(journal_t& journal, const string& name,
- const bool auto_create)
+ const bool auto_create)
{
return journal.find_account(name, auto_create);
}
@@ -99,14 +99,14 @@ namespace {
void export_account()
{
- scope().attr("ACCOUNT_EXT_SORT_CALC") = ACCOUNT_EXT_SORT_CALC;
+ scope().attr("ACCOUNT_EXT_SORT_CALC") = ACCOUNT_EXT_SORT_CALC;
scope().attr("ACCOUNT_EXT_HAS_NON_VIRTUALS") = ACCOUNT_EXT_HAS_NON_VIRTUALS;
scope().attr("ACCOUNT_EXT_HAS_UNB_VIRTUALS") = ACCOUNT_EXT_HAS_UNB_VIRTUALS;
scope().attr("ACCOUNT_EXT_AUTO_VIRTUALIZE") = ACCOUNT_EXT_AUTO_VIRTUALIZE;
- scope().attr("ACCOUNT_EXT_VISITED") = ACCOUNT_EXT_VISITED;
- scope().attr("ACCOUNT_EXT_MATCHING") = ACCOUNT_EXT_MATCHING;
+ scope().attr("ACCOUNT_EXT_VISITED") = ACCOUNT_EXT_VISITED;
+ scope().attr("ACCOUNT_EXT_MATCHING") = ACCOUNT_EXT_MATCHING;
scope().attr("ACCOUNT_EXT_TO_DISPLAY") = ACCOUNT_EXT_TO_DISPLAY;
- scope().attr("ACCOUNT_EXT_DISPLAYED") = ACCOUNT_EXT_DISPLAYED;
+ scope().attr("ACCOUNT_EXT_DISPLAYED") = ACCOUNT_EXT_DISPLAYED;
class_< account_t::xdata_t::details_t > ("AccountXDataDetails")
.def_readonly("total", &account_t::xdata_t::details_t::total)
@@ -115,30 +115,30 @@ void export_account()
.def_readonly("posts_count", &account_t::xdata_t::details_t::posts_count)
.def_readonly("posts_virtuals_count",
- &account_t::xdata_t::details_t::posts_virtuals_count)
+ &account_t::xdata_t::details_t::posts_virtuals_count)
.def_readonly("posts_cleared_count",
- &account_t::xdata_t::details_t::posts_cleared_count)
+ &account_t::xdata_t::details_t::posts_cleared_count)
.def_readonly("posts_last_7_count",
- &account_t::xdata_t::details_t::posts_last_7_count)
+ &account_t::xdata_t::details_t::posts_last_7_count)
.def_readonly("posts_last_30_count",
- &account_t::xdata_t::details_t::posts_last_30_count)
+ &account_t::xdata_t::details_t::posts_last_30_count)
.def_readonly("posts_this_month_count",
- &account_t::xdata_t::details_t::posts_this_month_count)
+ &account_t::xdata_t::details_t::posts_this_month_count)
.def_readonly("earliest_post",
- &account_t::xdata_t::details_t::earliest_post)
+ &account_t::xdata_t::details_t::earliest_post)
.def_readonly("earliest_cleared_post",
- &account_t::xdata_t::details_t::earliest_cleared_post)
+ &account_t::xdata_t::details_t::earliest_cleared_post)
.def_readonly("latest_post",
- &account_t::xdata_t::details_t::latest_post)
+ &account_t::xdata_t::details_t::latest_post)
.def_readonly("latest_cleared_post",
- &account_t::xdata_t::details_t::latest_cleared_post)
+ &account_t::xdata_t::details_t::latest_cleared_post)
.def_readonly("filenames", &account_t::xdata_t::details_t::filenames)
.def_readonly("accounts_referenced",
- &account_t::xdata_t::details_t::accounts_referenced)
+ &account_t::xdata_t::details_t::accounts_referenced)
.def_readonly("payees_referenced",
- &account_t::xdata_t::details_t::payees_referenced)
+ &account_t::xdata_t::details_t::payees_referenced)
.def(self += self)
@@ -148,8 +148,8 @@ void export_account()
class_< account_t::xdata_t > ("AccountXData")
#if 1
.add_property("flags",
- &supports_flags<uint_least16_t>::flags,
- &supports_flags<uint_least16_t>::set_flags)
+ &supports_flags<uint_least16_t>::flags,
+ &supports_flags<uint_least16_t>::set_flags)
.def("has_flags", &supports_flags<uint_least16_t>::has_flags)
.def("clear_flags", &supports_flags<uint_least16_t>::clear_flags)
.def("add_flags", &supports_flags<uint_least16_t>::add_flags)
@@ -163,14 +163,14 @@ void export_account()
;
scope().attr("ACCOUNT_NORMAL") = ACCOUNT_NORMAL;
- scope().attr("ACCOUNT_KNOWN") = ACCOUNT_KNOWN;
- scope().attr("ACCOUNT_TEMP") = ACCOUNT_TEMP;
+ scope().attr("ACCOUNT_KNOWN") = ACCOUNT_KNOWN;
+ scope().attr("ACCOUNT_TEMP") = ACCOUNT_TEMP;
class_< account_t > ("Account")
#if 1
.add_property("flags",
- &supports_flags<>::flags,
- &supports_flags<>::set_flags)
+ &supports_flags<>::flags,
+ &supports_flags<>::set_flags)
.def("has_flags", &supports_flags<>::has_flags)
.def("clear_flags", &supports_flags<>::clear_flags)
.def("add_flags", &supports_flags<>::add_flags)
@@ -178,8 +178,8 @@ void export_account()
#endif
.add_property("parent",
- make_getter(&account_t::parent,
- return_internal_reference<>()))
+ make_getter(&account_t::parent,
+ return_internal_reference<>()))
.def_readwrite("name", &account_t::name)
.def_readwrite("note", &account_t::note)
@@ -195,9 +195,9 @@ void export_account()
.def("remove_account", &account_t::remove_account)
.def("find_account", &account_t::find_account,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("find_account_re", &account_t::find_account,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("add_post", &account_t::add_post)
.def("remove_post", &account_t::remove_post)
@@ -208,24 +208,24 @@ void export_account()
.def("__getitem__", accounts_getitem, return_internal_reference<>())
.def("__iter__", python::range<return_internal_reference<> >
- (&account_t::accounts_begin, &account_t::accounts_end))
+ (&account_t::accounts_begin, &account_t::accounts_end))
.def("accounts", python::range<return_internal_reference<> >
- (&account_t::accounts_begin, &account_t::accounts_end))
+ (&account_t::accounts_begin, &account_t::accounts_end))
.def("posts", python::range<return_internal_reference<> >
- (&account_t::posts_begin, &account_t::posts_end))
+ (&account_t::posts_begin, &account_t::posts_end))
.def("has_xdata", &account_t::has_xdata)
.def("clear_xdata", &account_t::clear_xdata)
.def("xdata", py_xdata,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("amount", &account_t::amount)
.def("total", &account_t::total)
.def("self_details", &account_t::self_details,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("family_details", &account_t::family_details,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("has_xflags", &account_t::has_xflags)
.def("children_with_flags", &account_t::children_with_flags)
diff --git a/src/py_amount.cc b/src/py_amount.cc
index c5962446..3cb9f0eb 100644
--- a/src/py_amount.cc
+++ b/src/py_amount.cc
@@ -48,12 +48,12 @@ namespace {
return amount.value(CURRENT_TIME());
}
boost::optional<amount_t> py_value_1(const amount_t& amount,
- commodity_t& in_terms_of) {
+ commodity_t& in_terms_of) {
return amount.value(CURRENT_TIME(), in_terms_of);
}
boost::optional<amount_t> py_value_2(const amount_t& amount,
- commodity_t& in_terms_of,
- datetime_t& moment) {
+ commodity_t& in_terms_of,
+ datetime_t& moment) {
return amount.value(moment, in_terms_of);
}
@@ -63,7 +63,7 @@ namespace {
amount.parse(instr, flags);
} else {
PyErr_SetString(PyExc_IOError,
- _("Argument to amount.parse(file) is not a file object"));
+ _("Argument to amount.parse(file) is not a file object"));
}
}
void py_parse_1(amount_t& amount, object in) {
@@ -83,7 +83,7 @@ namespace {
amount.print(outstr);
} else {
PyErr_SetString(PyExc_IOError,
- _("Argument to amount.print_(file) is not a file object"));
+ _("Argument to amount.print_(file) is not a file object"));
}
}
@@ -104,9 +104,9 @@ namespace {
} // unnamed namespace
-#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_ArithmeticError, err.what()); \
+#define EXC_TRANSLATOR(type) \
+ void exc_translate_ ## type(const type& err) { \
+ PyErr_SetString(PyExc_ArithmeticError, err.what()); \
}
EXC_TRANSLATOR(amount_error)
@@ -120,24 +120,24 @@ void export_amount()
.staticmethod("shutdown")
.add_static_property("is_initialized",
- make_getter(&amount_t::is_initialized),
- make_setter(&amount_t::is_initialized))
+ make_getter(&amount_t::is_initialized),
+ make_setter(&amount_t::is_initialized))
.add_static_property("stream_fullstrings",
- make_getter(&amount_t::stream_fullstrings),
- make_setter(&amount_t::stream_fullstrings))
+ make_getter(&amount_t::stream_fullstrings),
+ make_setter(&amount_t::stream_fullstrings))
.def(init<long>())
.def(init<std::string>())
.def("exact", &amount_t::exact, args("value"),
- _("Construct an amount object whose display precision is always equal to its\n\
+ _("Construct an amount object whose display precision is always equal to its\n\
internal precision."))
.staticmethod("exact")
.def(init<amount_t>())
.def("compare", &amount_t::compare, args("amount"),
- _("Compare two amounts for equality, returning <0, 0 or >0."))
+ _("Compare two amounts for equality, returning <0, 0 or >0."))
.def(self == self)
.def(self == long())
@@ -168,40 +168,40 @@ internal precision."))
.def(self += self)
.def(self += long())
- .def(self + self)
- .def(self + long())
- .def(long() + self)
+ .def(self + self)
+ .def(self + long())
+ .def(long() + self)
.def(self -= self)
.def(self -= long())
- .def(self - self)
- .def(self - long())
- .def(long() - self)
+ .def(self - self)
+ .def(self - long())
+ .def(long() - self)
.def(self *= self)
.def(self *= long())
- .def(self * self)
- .def(self * long())
- .def(long() * self)
+ .def(self * self)
+ .def(self * long())
+ .def(long() * self)
.def(self /= self)
.def(self /= long())
- .def(self / self)
- .def(self / long())
- .def(long() / self)
+ .def(self / self)
+ .def(self / long())
+ .def(long() / self)
.add_property("precision", &amount_t::precision)
.add_property("display_precision", &amount_t::display_precision)
.add_property("keep_precision",
- &amount_t::keep_precision,
- &amount_t::set_keep_precision)
+ &amount_t::keep_precision,
+ &amount_t::set_keep_precision)
.def("negated", &amount_t::negated)
.def("in_place_negate", &amount_t::in_place_negate,
- return_internal_reference<>())
+ return_internal_reference<>())
.def(- self)
.def("abs", &amount_t::abs)
@@ -211,27 +211,27 @@ internal precision."))
.def("rounded", &amount_t::rounded)
.def("in_place_round", &amount_t::in_place_round,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("truncated", &amount_t::truncated)
.def("in_place_truncate", &amount_t::in_place_truncate,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("floored", &amount_t::floored)
.def("in_place_floor", &amount_t::in_place_floor,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("unrounded", &amount_t::unrounded)
.def("in_place_unround", &amount_t::in_place_unround,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("reduced", &amount_t::reduced)
.def("in_place_reduce", &amount_t::in_place_reduce,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("unreduced", &amount_t::unreduced)
.def("in_place_unreduce", &amount_t::in_place_unreduce,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("value", py_value_0)
.def("value", py_value_1, args("in_terms_of"))
@@ -260,10 +260,10 @@ internal precision."))
.def("quantity_string", &amount_t::quantity_string)
.add_property("commodity",
- make_function(&amount_t::commodity,
- return_value_policy<reference_existing_object>()),
- make_function(&amount_t::set_commodity,
- with_custodian_and_ward<1, 2>()))
+ make_function(&amount_t::commodity,
+ return_value_policy<reference_existing_object>()),
+ make_function(&amount_t::set_commodity,
+ with_custodian_and_ward<1, 2>()))
.def("has_commodity", &amount_t::has_commodity)
.def("clear_commodity", &amount_t::clear_commodity)
@@ -272,8 +272,8 @@ internal precision."))
.def("annotate", &amount_t::annotate)
.def("has_annotation", &amount_t::has_annotation)
.add_property("annotation",
- make_function(py_amount_annotation,
- return_internal_reference<>()))
+ make_function(py_amount_annotation,
+ return_internal_reference<>()))
.def("strip_annotations", py_strip_annotations_0)
.def("strip_annotations", py_strip_annotations_1)
diff --git a/src/py_balance.cc b/src/py_balance.cc
index 03a73ff6..eba5761d 100644
--- a/src/py_balance.cc
+++ b/src/py_balance.cc
@@ -48,12 +48,12 @@ namespace {
return balance.value(CURRENT_TIME());
}
boost::optional<balance_t> py_value_1(const balance_t& balance,
- commodity_t& in_terms_of) {
+ commodity_t& in_terms_of) {
return balance.value(CURRENT_TIME(), in_terms_of);
}
boost::optional<balance_t> py_value_2(const balance_t& balance,
- commodity_t& in_terms_of,
- datetime_t& moment) {
+ commodity_t& in_terms_of,
+ datetime_t& moment) {
return balance.value(moment, in_terms_of);
}
@@ -64,7 +64,7 @@ namespace {
boost::optional<amount_t>
py_commodity_amount_1(const balance_t& balance,
- const boost::optional<const commodity_t&>& commodity) {
+ const boost::optional<const commodity_t&>& commodity) {
return balance.commodity_amount(commodity);
}
@@ -74,7 +74,7 @@ namespace {
balance.print(outstr);
} else {
PyErr_SetString(PyExc_IOError,
- _("Argument to balance.print_(file) is not a file object"));
+ _("Argument to balance.print_(file) is not a file object"));
}
}
@@ -111,9 +111,9 @@ namespace {
} // unnamed namespace
-#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_ArithmeticError, err.what()); \
+#define EXC_TRANSLATOR(type) \
+ void exc_translate_ ## type(const type& err) { \
+ PyErr_SetString(PyExc_ArithmeticError, err.what()); \
}
EXC_TRANSLATOR(balance_error)
@@ -162,7 +162,7 @@ void export_balance()
.def("negated", &balance_t::negated)
.def("in_place_negate", &balance_t::in_place_negate,
- return_internal_reference<>())
+ return_internal_reference<>())
.def(- self)
.def("abs", &balance_t::abs)
@@ -173,27 +173,27 @@ void export_balance()
.def("rounded", &balance_t::rounded)
.def("in_place_round", &balance_t::in_place_round,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("truncated", &balance_t::truncated)
.def("in_place_truncate", &balance_t::in_place_truncate,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("floored", &balance_t::floored)
.def("in_place_floor", &balance_t::in_place_floor,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("unrounded", &balance_t::unrounded)
.def("in_place_unround", &balance_t::in_place_unround,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("reduced", &balance_t::reduced)
.def("in_place_reduce", &balance_t::in_place_reduce,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("unreduced", &balance_t::unreduced)
.def("in_place_unreduce", &balance_t::in_place_unreduce,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("value", py_value_0)
.def("value", py_value_1, args("in_terms_of"))
diff --git a/src/py_commodity.cc b/src/py_commodity.cc
index fc7e8c3e..783171dd 100644
--- a/src/py_commodity.cc
+++ b/src/py_commodity.cc
@@ -44,38 +44,38 @@ using namespace boost::python;
namespace {
commodity_t * py_create_1(commodity_pool_t& pool,
- const string& symbol)
+ const string& symbol)
{
return pool.create(symbol);
}
- commodity_t * py_create_2(commodity_pool_t& pool,
- const string& symbol,
- const annotation_t& details)
+ commodity_t * py_create_2(commodity_pool_t& pool,
+ const string& symbol,
+ const annotation_t& details)
{
return pool.create(symbol, details);
}
commodity_t * py_find_or_create_1(commodity_pool_t& pool,
- const string& symbol)
+ const string& symbol)
{
return pool.find_or_create(symbol);
}
- commodity_t * py_find_or_create_2(commodity_pool_t& pool,
- const string& symbol,
- const annotation_t& details)
+ commodity_t * py_find_or_create_2(commodity_pool_t& pool,
+ const string& symbol,
+ const annotation_t& details)
{
return pool.find_or_create(symbol, details);
}
commodity_t * py_find_1(commodity_pool_t& pool,
- const string& name)
+ const string& name)
{
return pool.find(name);
}
commodity_t * py_find_2(commodity_pool_t& pool,
- const string& symbol,
- const annotation_t& details)
+ const string& symbol,
+ const annotation_t& details)
{
return pool.find(symbol, details);
}
@@ -83,25 +83,25 @@ namespace {
// Exchange one commodity for another, while recording the factored price.
void py_exchange_2(commodity_pool_t& pool,
- commodity_t& commodity,
- const amount_t& per_unit_cost)
+ commodity_t& commodity,
+ const amount_t& per_unit_cost)
{
pool.exchange(commodity, per_unit_cost, CURRENT_TIME());
}
void py_exchange_3(commodity_pool_t& pool,
- commodity_t& commodity,
- const amount_t& per_unit_cost,
- const datetime_t& moment)
+ commodity_t& commodity,
+ const amount_t& per_unit_cost,
+ const datetime_t& moment)
{
pool.exchange(commodity, per_unit_cost, moment);
}
- cost_breakdown_t py_exchange_5(commodity_pool_t& pool,
- const amount_t& amount,
- const amount_t& cost,
- const bool is_per_unit,
- const boost::optional<datetime_t>& moment,
- const boost::optional<string>& tag)
+ cost_breakdown_t py_exchange_5(commodity_pool_t& pool,
+ const amount_t& amount,
+ const amount_t& cost,
+ const bool is_per_unit,
+ const boost::optional<datetime_t>& moment,
+ const boost::optional<string>& tag)
{
return pool.exchange(amount, cost, is_per_unit, moment, tag);
}
@@ -112,7 +112,7 @@ namespace {
pool.commodities.find(symbol);
if (i == pool.commodities.end()) {
PyErr_SetString(PyExc_ValueError,
- (string("Could not find commodity ") + symbol).c_str());
+ (string("Could not find commodity ") + symbol).c_str());
throw boost::python::error_already_set();
}
return (*i).second;
@@ -178,12 +178,12 @@ namespace {
}
void py_add_price_2(commodity_t& commodity,
- const datetime_t& date, const amount_t& price) {
+ const datetime_t& date, const amount_t& price) {
commodity.add_price(date, price);
}
void py_add_price_3(commodity_t& commodity, const datetime_t& date,
- const amount_t& price, const bool reflexive) {
+ const amount_t& price, const bool reflexive) {
commodity.add_price(date, price, reflexive);
}
@@ -212,7 +212,7 @@ namespace {
return comm.strip_annotations(keep_details_t());
}
commodity_t& py_strip_annotations_1(commodity_t& comm,
- const keep_details_t& keep) {
+ const keep_details_t& keep) {
return comm.strip_annotations(keep);
}
@@ -220,7 +220,7 @@ namespace {
return comm.strip_annotations(keep_details_t());
}
commodity_t& py_strip_ann_annotations_1(annotated_commodity_t& comm,
- const keep_details_t& keep) {
+ const keep_details_t& keep) {
return comm.strip_annotations(keep);
}
@@ -228,7 +228,7 @@ namespace {
return ann.price;
}
boost::optional<amount_t> py_set_price(annotation_t& ann,
- const boost::optional<amount_t>& price) {
+ const boost::optional<amount_t>& price) {
return ann.price = price;
}
@@ -243,41 +243,41 @@ void export_commodity()
class_< commodity_pool_t, shared_ptr<commodity_pool_t>,
boost::noncopyable > ("CommodityPool", no_init)
.add_property("null_commodity",
- make_getter(&commodity_pool_t::null_commodity,
- return_internal_reference<>()))
+ make_getter(&commodity_pool_t::null_commodity,
+ return_internal_reference<>()))
.add_property("default_commodity",
- make_getter(&commodity_pool_t::default_commodity,
- return_internal_reference<>()),
- make_setter(&commodity_pool_t::default_commodity,
- with_custodian_and_ward<1, 2>()))
+ make_getter(&commodity_pool_t::default_commodity,
+ return_internal_reference<>()),
+ make_setter(&commodity_pool_t::default_commodity,
+ with_custodian_and_ward<1, 2>()))
.add_property("keep_base",
- make_getter(&commodity_pool_t::keep_base),
- make_setter(&commodity_pool_t::keep_base))
+ make_getter(&commodity_pool_t::keep_base),
+ make_setter(&commodity_pool_t::keep_base))
.add_property("price_db",
- make_getter(&commodity_pool_t::price_db),
- make_setter(&commodity_pool_t::price_db))
+ make_getter(&commodity_pool_t::price_db),
+ make_setter(&commodity_pool_t::price_db))
.add_property("quote_leeway",
- make_getter(&commodity_pool_t::quote_leeway),
- make_setter(&commodity_pool_t::quote_leeway))
+ make_getter(&commodity_pool_t::quote_leeway),
+ make_setter(&commodity_pool_t::quote_leeway))
.add_property("get_quotes",
- make_getter(&commodity_pool_t::get_quotes),
- make_setter(&commodity_pool_t::get_quotes))
+ make_getter(&commodity_pool_t::get_quotes),
+ make_setter(&commodity_pool_t::get_quotes))
.add_property("get_commodity_quote",
- make_getter(&commodity_pool_t::get_commodity_quote),
- make_setter(&commodity_pool_t::get_commodity_quote))
+ make_getter(&commodity_pool_t::get_commodity_quote),
+ make_setter(&commodity_pool_t::get_commodity_quote))
.def("make_qualified_name", &commodity_pool_t::make_qualified_name)
.def("create", py_create_1,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("create", py_create_2,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("find_or_create", py_find_or_create_1,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("find_or_create", py_find_or_create_2,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("find", py_find_1, return_value_policy<reference_existing_object>())
.def("find", py_find_2, return_value_policy<reference_existing_object>())
@@ -288,46 +288,46 @@ void export_commodity()
.def("parse_price_directive", &commodity_pool_t::parse_price_directive)
.def("parse_price_expression", &commodity_pool_t::parse_price_expression,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("__getitem__", py_pool_getitem,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("keys", py_pool_keys)
.def("has_key", py_pool_contains)
.def("__contains__", py_pool_contains)
.def("__iter__",
- python::range<return_value_policy<reference_existing_object> >
- (py_pool_commodities_begin, py_pool_commodities_end))
+ python::range<return_value_policy<reference_existing_object> >
+ (py_pool_commodities_begin, py_pool_commodities_end))
.def("iteritems",
- python::range<return_value_policy<reference_existing_object> >
- (py_pool_commodities_begin, py_pool_commodities_end))
+ python::range<return_value_policy<reference_existing_object> >
+ (py_pool_commodities_begin, py_pool_commodities_end))
.def("iterkeys", python::range<>(py_pool_commodities_keys_begin,
- py_pool_commodities_keys_end))
+ py_pool_commodities_keys_end))
.def("itervalues",
- python::range<return_value_policy<reference_existing_object> >
- (py_pool_commodities_values_begin, py_pool_commodities_values_end))
+ python::range<return_value_policy<reference_existing_object> >
+ (py_pool_commodities_values_begin, py_pool_commodities_values_end))
;
map_value_type_converter<commodity_pool_t::commodities_map>();
scope().attr("commodities") = commodity_pool_t::current_pool;
- scope().attr("COMMODITY_STYLE_DEFAULTS") = COMMODITY_STYLE_DEFAULTS;
- scope().attr("COMMODITY_STYLE_SUFFIXED") = COMMODITY_STYLE_SUFFIXED;
- scope().attr("COMMODITY_STYLE_SEPARATED") = COMMODITY_STYLE_SEPARATED;
+ scope().attr("COMMODITY_STYLE_DEFAULTS") = COMMODITY_STYLE_DEFAULTS;
+ scope().attr("COMMODITY_STYLE_SUFFIXED") = COMMODITY_STYLE_SUFFIXED;
+ scope().attr("COMMODITY_STYLE_SEPARATED") = COMMODITY_STYLE_SEPARATED;
scope().attr("COMMODITY_STYLE_DECIMAL_COMMA") = COMMODITY_STYLE_DECIMAL_COMMA;
- scope().attr("COMMODITY_STYLE_THOUSANDS") = COMMODITY_STYLE_THOUSANDS;
- scope().attr("COMMODITY_NOMARKET") = COMMODITY_NOMARKET;
- scope().attr("COMMODITY_BUILTIN") = COMMODITY_BUILTIN;
- scope().attr("COMMODITY_WALKED") = COMMODITY_WALKED;
- scope().attr("COMMODITY_KNOWN") = COMMODITY_KNOWN;
- scope().attr("COMMODITY_PRIMARY") = COMMODITY_PRIMARY;
+ scope().attr("COMMODITY_STYLE_THOUSANDS") = COMMODITY_STYLE_THOUSANDS;
+ scope().attr("COMMODITY_NOMARKET") = COMMODITY_NOMARKET;
+ scope().attr("COMMODITY_BUILTIN") = COMMODITY_BUILTIN;
+ scope().attr("COMMODITY_WALKED") = COMMODITY_WALKED;
+ scope().attr("COMMODITY_KNOWN") = COMMODITY_KNOWN;
+ scope().attr("COMMODITY_PRIMARY") = COMMODITY_PRIMARY;
class_< commodity_t, boost::noncopyable > ("Commodity", no_init)
#if 1
.add_property("flags",
- &supports_flags<uint_least16_t>::flags,
- &supports_flags<uint_least16_t>::set_flags)
+ &supports_flags<uint_least16_t>::flags,
+ &supports_flags<uint_least16_t>::set_flags)
.def("has_flags", &delegates_flags<uint_least16_t>::has_flags)
.def("clear_flags", &delegates_flags<uint_least16_t>::clear_flags)
.def("add_flags", &delegates_flags<uint_least16_t>::add_flags)
@@ -335,8 +335,8 @@ void export_commodity()
#endif
.add_static_property("decimal_comma_by_default",
- make_getter(&commodity_t::decimal_comma_by_default),
- make_setter(&commodity_t::decimal_comma_by_default))
+ make_getter(&commodity_t::decimal_comma_by_default),
+ make_setter(&commodity_t::decimal_comma_by_default))
.def("__str__", &commodity_t::symbol)
.def("__unicode__", py_commodity_unicode)
@@ -348,18 +348,18 @@ void export_commodity()
.staticmethod("symbol_needs_quotes")
.add_property("referent",
- make_function(py_commodity_referent,
- return_value_policy<reference_existing_object>()))
+ make_function(py_commodity_referent,
+ return_value_policy<reference_existing_object>()))
.def("has_annotation", &commodity_t::has_annotation)
.def("strip_annotations", py_strip_annotations_0,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("strip_annotations", py_strip_annotations_1,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("write_annotations", &commodity_t::write_annotations)
.def("pool", &commodity_t::pool,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.add_property("base_symbol", &commodity_t::base_symbol)
.add_property("symbol", &commodity_t::symbol)
@@ -368,14 +368,14 @@ void export_commodity()
.add_property("name", &commodity_t::name, &commodity_t::set_name)
.add_property("note", &commodity_t::note, &commodity_t::set_note)
.add_property("precision", &commodity_t::precision,
- &commodity_t::set_precision)
+ &commodity_t::set_precision)
.add_property("smaller", &commodity_t::smaller, &commodity_t::set_smaller)
.add_property("larger", &commodity_t::larger, &commodity_t::set_larger)
.def("add_price", py_add_price_2)
.def("add_price", py_add_price_3)
.def("remove_price", &commodity_t::remove_price,
- with_custodian_and_ward<1, 3>())
+ with_custodian_and_ward<1, 3>())
.def("find_price", &commodity_t::find_price)
.def("check_for_updated_price", &commodity_t::check_for_updated_price)
@@ -385,7 +385,7 @@ void export_commodity()
class_< annotation_t > ("Annotation", no_init)
#if 1
.add_property("flags", &supports_flags<>::flags,
- &supports_flags<>::set_flags)
+ &supports_flags<>::set_flags)
.def("has_flags", &supports_flags<>::has_flags)
.def("clear_flags", &supports_flags<>::clear_flags)
.def("add_flags", &supports_flags<>::add_flags)
@@ -394,11 +394,11 @@ void export_commodity()
.add_property("price", py_price, py_set_price)
.add_property("date",
- make_getter(&annotation_t::date),
- make_setter(&annotation_t::date))
+ make_getter(&annotation_t::date),
+ make_setter(&annotation_t::date))
.add_property("tag",
- make_getter(&annotation_t::tag),
- make_setter(&annotation_t::tag))
+ make_getter(&annotation_t::tag),
+ make_setter(&annotation_t::tag))
.def("__nonzero__", &annotation_t::operator bool)
@@ -411,17 +411,17 @@ void export_commodity()
.def(init<bool, bool, bool, bool>())
.add_property("keep_price",
- make_getter(&keep_details_t::keep_price),
- make_setter(&keep_details_t::keep_price))
+ make_getter(&keep_details_t::keep_price),
+ make_setter(&keep_details_t::keep_price))
.add_property("keep_date",
- make_getter(&keep_details_t::keep_date),
- make_setter(&keep_details_t::keep_date))
+ make_getter(&keep_details_t::keep_date),
+ make_setter(&keep_details_t::keep_date))
.add_property("keep_tag",
- make_getter(&keep_details_t::keep_tag),
- make_setter(&keep_details_t::keep_tag))
+ make_getter(&keep_details_t::keep_tag),
+ make_setter(&keep_details_t::keep_tag))
.add_property("only_actuals",
- make_getter(&keep_details_t::only_actuals),
- make_setter(&keep_details_t::only_actuals))
+ make_getter(&keep_details_t::only_actuals),
+ make_setter(&keep_details_t::only_actuals))
.def("keep_all", py_keep_all_0)
.def("keep_all", py_keep_all_1)
@@ -433,20 +433,20 @@ void export_commodity()
annotated_commodity_t, boost::noncopyable >
("AnnotatedCommodity", no_init)
.add_property("details",
- make_getter(&annotated_commodity_t::details),
- make_setter(&annotated_commodity_t::details))
+ make_getter(&annotated_commodity_t::details),
+ make_setter(&annotated_commodity_t::details))
.def(self == self)
.def(self == other<commodity_t>())
.add_property("referent",
- make_function(py_annotated_commodity_referent,
- return_value_policy<reference_existing_object>()))
+ make_function(py_annotated_commodity_referent,
+ return_value_policy<reference_existing_object>()))
.def("strip_annotations", py_strip_ann_annotations_0,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("strip_annotations", py_strip_ann_annotations_1,
- return_value_policy<reference_existing_object>())
+ return_value_policy<reference_existing_object>())
.def("write_annotations", &annotated_commodity_t::write_annotations)
;
}
diff --git a/src/py_format.cc b/src/py_format.cc
index 36f89ae5..ce7052ac 100644
--- a/src/py_format.cc
+++ b/src/py_format.cc
@@ -37,9 +37,9 @@ namespace ledger {
using namespace boost::python;
-#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_ArithmeticError, err.what()); \
+#define EXC_TRANSLATOR(type) \
+ void exc_translate_ ## type(const type& err) { \
+ PyErr_SetString(PyExc_ArithmeticError, err.what()); \
}
//EXC_TRANSLATOR(format_error)
diff --git a/src/py_item.cc b/src/py_item.cc
index edebd532..65d89119 100644
--- a/src/py_item.cc
+++ b/src/py_item.cc
@@ -49,7 +49,7 @@ namespace {
return item.has_tag(tag_mask);
}
bool py_has_tag_2m(item_t& item, const mask_t& tag_mask,
- const boost::optional<mask_t>& value_mask) {
+ const boost::optional<mask_t>& value_mask) {
return item.has_tag(tag_mask, value_mask);
}
@@ -60,15 +60,15 @@ namespace {
return item.get_tag(tag_mask);
}
boost::optional<string> py_get_tag_2m(item_t& item, const mask_t& tag_mask,
- const boost::optional<mask_t>& value_mask) {
+ const boost::optional<mask_t>& value_mask) {
return item.get_tag(tag_mask, value_mask);
}
} // unnamed namespace
-#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_ArithmeticError, err.what()); \
+#define EXC_TRANSLATOR(type) \
+ void exc_translate_ ## type(const type& err) { \
+ PyErr_SetString(PyExc_ArithmeticError, err.what()); \
}
//EXC_TRANSLATOR(item_error)
@@ -77,25 +77,25 @@ void export_item()
{
class_< position_t > ("Position")
.add_property("pathname",
- make_getter(&position_t::pathname),
- make_setter(&position_t::pathname))
+ make_getter(&position_t::pathname),
+ make_setter(&position_t::pathname))
.add_property("beg_pos",
- make_getter(&position_t::beg_pos),
- make_setter(&position_t::beg_pos))
+ make_getter(&position_t::beg_pos),
+ make_setter(&position_t::beg_pos))
.add_property("beg_line",
- make_getter(&position_t::beg_line),
- make_setter(&position_t::beg_line))
+ make_getter(&position_t::beg_line),
+ make_setter(&position_t::beg_line))
.add_property("end_pos",
- make_getter(&position_t::end_pos),
- make_setter(&position_t::end_pos))
+ make_getter(&position_t::end_pos),
+ make_setter(&position_t::end_pos))
.add_property("end_line",
- make_getter(&position_t::end_line),
- make_setter(&position_t::end_line))
+ make_getter(&position_t::end_line),
+ make_setter(&position_t::end_line))
;
- scope().attr("ITEM_NORMAL") = ITEM_NORMAL;
+ scope().attr("ITEM_NORMAL") = ITEM_NORMAL;
scope().attr("ITEM_GENERATED") = ITEM_GENERATED;
- scope().attr("ITEM_TEMP") = ITEM_TEMP;
+ scope().attr("ITEM_TEMP") = ITEM_TEMP;
enum_< item_t::state_t > ("State")
.value("Uncleared", item_t::UNCLEARED)
@@ -110,7 +110,7 @@ void export_item()
#endif
#if 1
.add_property("flags", &supports_flags<>::flags,
- &supports_flags<>::set_flags)
+ &supports_flags<>::set_flags)
.def("has_flags", &supports_flags<>::has_flags)
.def("clear_flags", &supports_flags<>::clear_flags)
.def("add_flags", &supports_flags<>::add_flags)
@@ -118,14 +118,14 @@ void export_item()
#endif
.add_property("note",
- make_getter(&item_t::note),
- make_setter(&item_t::note))
+ make_getter(&item_t::note),
+ make_setter(&item_t::note))
.add_property("pos",
- make_getter(&item_t::pos),
- make_setter(&item_t::pos))
+ make_getter(&item_t::pos),
+ make_setter(&item_t::pos))
.add_property("metadata",
- make_getter(&item_t::metadata),
- make_setter(&item_t::metadata))
+ make_getter(&item_t::metadata),
+ make_setter(&item_t::metadata))
.def("copy_details", &item_t::copy_details)
@@ -148,12 +148,12 @@ void export_item()
.def("append_note", &item_t::append_note)
.add_static_property("use_effective_date",
- make_getter(&item_t::use_effective_date),
- make_setter(&item_t::use_effective_date))
+ make_getter(&item_t::use_effective_date),
+ make_setter(&item_t::use_effective_date))
.add_property("date", &item_t::date, make_setter(&item_t::_date))
.add_property("effective_date", &item_t::effective_date,
- make_setter(&item_t::_date_eff))
+ make_setter(&item_t::_date_eff))
.add_property("state", &item_t::state, &item_t::set_state)
diff --git a/src/py_journal.cc b/src/py_journal.cc
index cd25d134..fc4f671b 100644
--- a/src/py_journal.cc
+++ b/src/py_journal.cc
@@ -126,7 +126,7 @@ namespace {
}
account_t * py_find_account_2(journal_t& journal, const string& name,
- const bool auto_create)
+ const bool auto_create)
{
return journal.find_account(name, auto_create);
}
@@ -138,14 +138,14 @@ namespace {
struct collector_wrapper
{
- journal_t& journal;
+ journal_t& journal;
report_t report;
collect_posts * posts_collector;
post_handler_ptr chain;
collector_wrapper(journal_t& _journal, report_t& base)
: journal(_journal), report(base),
- posts_collector(new collect_posts) {}
+ posts_collector(new collect_posts) {}
~collector_wrapper() {
journal.clear_xdata();
}
@@ -167,31 +167,31 @@ namespace {
{
if (journal.has_xdata()) {
PyErr_SetString(PyExc_RuntimeError,
- _("Cannot have multiple journal collections open at once"));
+ _("Cannot have multiple journal collections open at once"));
throw_error_already_set();
}
report_t& current_report(downcast<report_t>(*scope_t::default_scope));
shared_ptr<collector_wrapper> coll(new collector_wrapper(journal,
- current_report));
+ current_report));
std::auto_ptr<journal_t> save_journal
(current_report.session.journal.release());
current_report.session.journal.reset(&journal);
try {
strings_list remaining =
- process_arguments(split_arguments(query.c_str()), coll->report);
+ process_arguments(split_arguments(query.c_str()), coll->report);
coll->report.normalize_options("register");
value_t args;
foreach (const string& arg, remaining)
- args.push_back(string_value(arg));
+ args.push_back(string_value(arg));
coll->report.parse_query_args(args, "@Journal.collect");
journal_posts_iterator walker(coll->journal);
coll->chain =
- chain_post_handlers(post_handler_ptr(coll->posts_collector),
- coll->report);
+ chain_post_handlers(post_handler_ptr(coll->posts_collector),
+ coll->report);
pass_down_posts(coll->chain, walker);
}
catch (...) {
@@ -227,36 +227,36 @@ void export_journal()
shared_ptr<collect_posts>, boost::noncopyable >("PostCollector")
.def("__len__", &collect_posts::length)
.def("__iter__", python::range<return_internal_reference<1,
- with_custodian_and_ward_postcall<1, 0> > >
- (&collect_posts::begin, &collect_posts::end))
+ with_custodian_and_ward_postcall<1, 0> > >
+ (&collect_posts::begin, &collect_posts::end))
;
class_< collector_wrapper, shared_ptr<collector_wrapper>,
boost::noncopyable >("PostCollectorWrapper", no_init)
.def("__len__", &collector_wrapper::length)
.def("__getitem__", posts_getitem, return_internal_reference<1,
- with_custodian_and_ward_postcall<0, 1> >())
+ with_custodian_and_ward_postcall<0, 1> >())
.def("__iter__",
- python::range<return_value_policy<reference_existing_object,
- with_custodian_and_ward_postcall<0, 1> > >
- (&collector_wrapper::begin, &collector_wrapper::end))
+ python::range<return_value_policy<reference_existing_object,
+ with_custodian_and_ward_postcall<0, 1> > >
+ (&collector_wrapper::begin, &collector_wrapper::end))
;
class_< journal_t::fileinfo_t > ("FileInfo")
.def(init<path>())
.add_property("filename",
- make_getter(&journal_t::fileinfo_t::filename),
- make_setter(&journal_t::fileinfo_t::filename))
+ make_getter(&journal_t::fileinfo_t::filename),
+ make_setter(&journal_t::fileinfo_t::filename))
.add_property("size",
- make_getter(&journal_t::fileinfo_t::size),
- make_setter(&journal_t::fileinfo_t::size))
+ make_getter(&journal_t::fileinfo_t::size),
+ make_setter(&journal_t::fileinfo_t::size))
.add_property("modtime",
- make_getter(&journal_t::fileinfo_t::modtime),
- make_setter(&journal_t::fileinfo_t::modtime))
+ make_getter(&journal_t::fileinfo_t::modtime),
+ make_setter(&journal_t::fileinfo_t::modtime))
.add_property("from_stream",
- make_getter(&journal_t::fileinfo_t::from_stream),
- make_setter(&journal_t::fileinfo_t::from_stream))
+ make_getter(&journal_t::fileinfo_t::from_stream),
+ make_setter(&journal_t::fileinfo_t::from_stream))
;
class_< journal_t, boost::noncopyable > ("Journal")
@@ -264,28 +264,28 @@ void export_journal()
.def(init<string>())
.add_property("master",
- make_getter(&journal_t::master,
- return_internal_reference<1,
- with_custodian_and_ward_postcall<1, 0> >()))
+ make_getter(&journal_t::master,
+ return_internal_reference<1,
+ with_custodian_and_ward_postcall<1, 0> >()))
.add_property("bucket",
- make_getter(&journal_t::bucket,
- return_internal_reference<1,
- with_custodian_and_ward_postcall<1, 0> >()),
- make_setter(&journal_t::bucket))
+ make_getter(&journal_t::bucket,
+ return_internal_reference<1,
+ with_custodian_and_ward_postcall<1, 0> >()),
+ make_setter(&journal_t::bucket))
.add_property("was_loaded", make_getter(&journal_t::was_loaded))
.def("add_account", &journal_t::add_account)
.def("remove_account", &journal_t::remove_account)
.def("find_account", py_find_account_1,
- return_internal_reference<1,
- with_custodian_and_ward_postcall<0, 1> >())
+ return_internal_reference<1,
+ with_custodian_and_ward_postcall<0, 1> >())
.def("find_account", py_find_account_2,
- return_internal_reference<1,
- with_custodian_and_ward_postcall<0, 1> >())
+ return_internal_reference<1,
+ with_custodian_and_ward_postcall<0, 1> >())
.def("find_account_re", &journal_t::find_account_re,
- return_internal_reference<1,
- with_custodian_and_ward_postcall<0, 1> >())
+ return_internal_reference<1,
+ with_custodian_and_ward_postcall<0, 1> >())
.def("add_xact", &journal_t::add_xact)
.def("remove_xact", &journal_t::remove_xact)
@@ -293,20 +293,20 @@ void export_journal()
.def("__len__", xacts_len)
#if 0
.def("__getitem__", xacts_getitem,
- return_internal_reference<1,
- with_custodian_and_ward_postcall<0, 1> >())
+ return_internal_reference<1,
+ with_custodian_and_ward_postcall<0, 1> >())
#endif
.def("__iter__", python::range<return_internal_reference<> >
- (&journal_t::xacts_begin, &journal_t::xacts_end))
+ (&journal_t::xacts_begin, &journal_t::xacts_end))
.def("xacts", python::range<return_internal_reference<> >
- (&journal_t::xacts_begin, &journal_t::xacts_end))
+ (&journal_t::xacts_begin, &journal_t::xacts_end))
.def("auto_xacts", python::range<return_internal_reference<> >
- (&journal_t::auto_xacts_begin, &journal_t::auto_xacts_end))
+ (&journal_t::auto_xacts_begin, &journal_t::auto_xacts_end))
.def("period_xacts", python::range<return_internal_reference<> >
- (&journal_t::period_xacts_begin, &journal_t::period_xacts_end))
+ (&journal_t::period_xacts_begin, &journal_t::period_xacts_end))
.def("sources", python::range<return_internal_reference<> >
- (&journal_t::sources_begin, &journal_t::sources_end))
+ (&journal_t::sources_begin, &journal_t::sources_end))
.def("read", py_read)
diff --git a/src/py_post.cc b/src/py_post.cc
index e4a50980..930a46c9 100644
--- a/src/py_post.cc
+++ b/src/py_post.cc
@@ -48,7 +48,7 @@ namespace {
return post.has_tag(tag_mask);
}
bool py_has_tag_2m(post_t& post, const mask_t& tag_mask,
- const boost::optional<mask_t>& value_mask) {
+ const boost::optional<mask_t>& value_mask) {
return post.has_tag(tag_mask, value_mask);
}
@@ -59,7 +59,7 @@ namespace {
return post.get_tag(tag_mask);
}
boost::optional<string> py_get_tag_2m(post_t& post, const mask_t& tag_mask,
- const boost::optional<mask_t>& value_mask) {
+ const boost::optional<mask_t>& value_mask) {
return post.get_tag(tag_mask, value_mask);
}
@@ -88,8 +88,8 @@ void export_post()
class_< post_t::xdata_t > ("PostingXData")
#if 1
.add_property("flags",
- &supports_flags<uint_least16_t>::flags,
- &supports_flags<uint_least16_t>::set_flags)
+ &supports_flags<uint_least16_t>::flags,
+ &supports_flags<uint_least16_t>::set_flags)
.def("has_flags", &supports_flags<uint_least16_t>::has_flags)
.def("clear_flags", &supports_flags<uint_least16_t>::clear_flags)
.def("add_flags", &supports_flags<uint_least16_t>::add_flags)
@@ -97,34 +97,34 @@ void export_post()
#endif
.add_property("visited_value",
- make_getter(&post_t::xdata_t::visited_value),
- make_setter(&post_t::xdata_t::visited_value))
+ make_getter(&post_t::xdata_t::visited_value),
+ make_setter(&post_t::xdata_t::visited_value))
.add_property("compound_value",
- make_getter(&post_t::xdata_t::compound_value),
- make_setter(&post_t::xdata_t::compound_value))
+ make_getter(&post_t::xdata_t::compound_value),
+ make_setter(&post_t::xdata_t::compound_value))
.add_property("total",
- make_getter(&post_t::xdata_t::total),
- make_setter(&post_t::xdata_t::total))
+ make_getter(&post_t::xdata_t::total),
+ make_setter(&post_t::xdata_t::total))
.add_property("count",
- make_getter(&post_t::xdata_t::count),
- make_setter(&post_t::xdata_t::count))
+ make_getter(&post_t::xdata_t::count),
+ make_setter(&post_t::xdata_t::count))
.add_property("date",
- make_getter(&post_t::xdata_t::date),
- make_setter(&post_t::xdata_t::date))
+ make_getter(&post_t::xdata_t::date),
+ make_setter(&post_t::xdata_t::date))
.add_property("datetime",
- make_getter(&post_t::xdata_t::datetime),
- make_setter(&post_t::xdata_t::datetime))
+ make_getter(&post_t::xdata_t::datetime),
+ make_setter(&post_t::xdata_t::datetime))
.add_property("account",
- make_getter(&post_t::xdata_t::account,
- return_value_policy<reference_existing_object>()),
- make_setter(&post_t::xdata_t::account,
- with_custodian_and_ward<1, 2>()))
+ make_getter(&post_t::xdata_t::account,
+ return_value_policy<reference_existing_object>()),
+ make_setter(&post_t::xdata_t::account,
+ with_custodian_and_ward<1, 2>()))
.add_property("sort_values",
- make_getter(&post_t::xdata_t::sort_values),
- make_setter(&post_t::xdata_t::sort_values))
+ make_getter(&post_t::xdata_t::sort_values),
+ make_setter(&post_t::xdata_t::sort_values))
;
- scope().attr("POST_VIRTUAL") = POST_VIRTUAL;
+ scope().attr("POST_VIRTUAL") = POST_VIRTUAL;
scope().attr("POST_MUST_BALANCE") = POST_MUST_BALANCE;
scope().attr("POST_CALCULATED") = POST_CALCULATED;
scope().attr("POST_COST_CALCULATED") = POST_COST_CALCULATED;
@@ -133,24 +133,24 @@ void export_post()
//.def(init<account_t *>())
.add_property("xact",
- make_getter(&post_t::xact,
- return_internal_reference<>()),
- make_setter(&post_t::xact,
- with_custodian_and_ward<1, 2>()))
+ make_getter(&post_t::xact,
+ return_internal_reference<>()),
+ make_setter(&post_t::xact,
+ with_custodian_and_ward<1, 2>()))
.add_property("account",
- make_getter(&post_t::account,
- return_internal_reference<>()),
- make_setter(&post_t::account,
- with_custodian_and_ward<1, 2>()))
+ make_getter(&post_t::account,
+ return_internal_reference<>()),
+ make_setter(&post_t::account,
+ with_custodian_and_ward<1, 2>()))
.add_property("amount",
- make_getter(&post_t::amount),
- make_setter(&post_t::amount))
+ make_getter(&post_t::amount),
+ make_setter(&post_t::amount))
.add_property("cost",
- make_getter(&post_t::cost),
- make_setter(&post_t::cost))
+ make_getter(&post_t::cost),
+ make_setter(&post_t::cost))
.add_property("assigned_amount",
- make_getter(&post_t::assigned_amount),
- make_setter(&post_t::assigned_amount))
+ make_getter(&post_t::assigned_amount),
+ make_setter(&post_t::assigned_amount))
.def("has_tag", py_has_tag_1s)
.def("has_tag", py_has_tag_1m)
@@ -171,13 +171,13 @@ void export_post()
.def("has_xdata", &post_t::has_xdata)
.def("clear_xdata", &post_t::clear_xdata)
.def("xdata", py_xdata,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("add_to_value", &post_t::add_to_value)
.def("set_reported_account", &post_t::set_reported_account)
.def("reported_account", py_reported_account,
- return_internal_reference<>())
+ return_internal_reference<>())
;
}
diff --git a/src/py_times.cc b/src/py_times.cc
index 39b0df7a..c2e0b8f8 100644
--- a/src/py_times.cc
+++ b/src/py_times.cc
@@ -41,10 +41,10 @@ namespace ledger {
using namespace boost::python;
-#define MY_PyDateTime_IMPORT \
- PyDateTimeAPI = (PyDateTime_CAPI*) \
- PyCObject_Import(const_cast<char *>("datetime"), \
- const_cast<char *>("datetime_CAPI"))
+#define MY_PyDateTime_IMPORT \
+ PyDateTimeAPI = (PyDateTime_CAPI*) \
+ PyCObject_Import(const_cast<char *>("datetime"), \
+ const_cast<char *>("datetime_CAPI"))
struct date_to_python
{
@@ -65,7 +65,7 @@ struct date_from_python
}
static void construct(PyObject * obj_ptr,
- converter::rvalue_from_python_stage1_data * data)
+ converter::rvalue_from_python_stage1_data * data)
{
MY_PyDateTime_IMPORT;
@@ -113,7 +113,7 @@ struct datetime_from_python
}
static void construct(PyObject * obj_ptr,
- converter::rvalue_from_python_stage1_data * data)
+ converter::rvalue_from_python_stage1_data * data)
{
MY_PyDateTime_IMPORT;
@@ -139,14 +139,14 @@ struct datetime_from_python
datetime_t * moment
= new datetime_t(date_t(y, m, d),
- datetime_t::time_duration_type(h, min, s, ms));
+ datetime_t::time_duration_type(h, min, s, ms));
data->convertible = (void *) moment;
}
};
typedef register_python_conversion<datetime_t,
- datetime_to_python, datetime_from_python>
+ datetime_to_python, datetime_from_python>
datetime_python_conversion;
@@ -189,7 +189,7 @@ struct duration_from_python
}
static void construct(PyObject* obj_ptr,
- python::converter::rvalue_from_python_stage1_data * data)
+ python::converter::rvalue_from_python_stage1_data * data)
{
PyDateTime_Delta const* pydelta
= reinterpret_cast<PyDateTime_Delta*>(obj_ptr);
@@ -202,8 +202,8 @@ struct duration_from_python
// Create time duration object
posix_time::time_duration
duration = (posix_time::hours(24) * days +
- posix_time::seconds(pydelta->seconds) +
- posix_time::microseconds(pydelta->microseconds));
+ posix_time::seconds(pydelta->seconds) +
+ posix_time::microseconds(pydelta->microseconds));
if (is_negative)
duration = duration.invert_sign();
@@ -218,7 +218,7 @@ struct duration_from_python
};
typedef register_python_conversion<time_duration_t,
- duration_to_python, duration_from_python>
+ duration_to_python, duration_from_python>
duration_python_conversion;
@@ -240,7 +240,7 @@ void export_times()
register_optional_to_python<date_t>();
scope().attr("parse_datetime") = &py_parse_datetime;
- scope().attr("parse_date") = &py_parse_date;
+ scope().attr("parse_date") = &py_parse_date;
scope().attr("times_initialize") = &times_initialize;
scope().attr("times_shutdown") = &times_shutdown;
diff --git a/src/py_utils.cc b/src/py_utils.cc
index 952416cc..c513def4 100644
--- a/src/py_utils.cc
+++ b/src/py_utils.cc
@@ -59,7 +59,7 @@ struct bool_from_python
}
static void construct(PyObject* obj_ptr,
- converter::rvalue_from_python_stage1_data* data)
+ converter::rvalue_from_python_stage1_data* data)
{
void * storage =
((converter::rvalue_from_python_storage<bool>*) data)->storage.bytes;
@@ -89,19 +89,19 @@ struct string_from_python
static void* convertible(PyObject* obj_ptr)
{
if (!PyUnicode_Check(obj_ptr) &&
- !PyString_Check(obj_ptr)) return 0;
+ !PyString_Check(obj_ptr)) return 0;
return obj_ptr;
}
static void construct(PyObject* obj_ptr,
- converter::rvalue_from_python_stage1_data* data)
+ converter::rvalue_from_python_stage1_data* data)
{
if (PyString_Check(obj_ptr)) {
const char* value = PyString_AsString(obj_ptr);
if (value == 0) throw_error_already_set();
void* storage =
- reinterpret_cast<converter::rvalue_from_python_storage<string> *>
- (data)->storage.bytes;
+ reinterpret_cast<converter::rvalue_from_python_storage<string> *>
+ (data)->storage.bytes;
new (storage) string(value);
data->convertible = storage;
} else {
@@ -112,18 +112,18 @@ struct string_from_python
string str;
if (sizeof(Py_UNICODE) == 2) // UTF-16
- utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str));
+ utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str));
else if (sizeof(Py_UNICODE) == 4) // UTF-32
- utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str));
+ utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str));
#if !defined(NO_ASSERTS)
else
- assert(! "Py_UNICODE has an unexpected size");
+ assert(! "Py_UNICODE has an unexpected size");
#endif
if (value == 0) throw_error_already_set();
void* storage =
- reinterpret_cast<converter::rvalue_from_python_storage<string> *>
- (data)->storage.bytes;
+ reinterpret_cast<converter::rvalue_from_python_storage<string> *>
+ (data)->storage.bytes;
new (storage) string(str);
data->convertible = storage;
}
@@ -151,7 +151,7 @@ struct istream_from_python
}
static void construct(PyObject* obj_ptr,
- converter::rvalue_from_python_stage1_data* data)
+ converter::rvalue_from_python_stage1_data* data)
{
void* storage =
reinterpret_cast<converter::rvalue_from_python_storage<pyifstream> *>
@@ -162,7 +162,7 @@ struct istream_from_python
};
typedef register_python_conversion<std::istream,
- istream_to_python, istream_from_python>
+ istream_to_python, istream_from_python>
istream_python_conversion;
@@ -183,7 +183,7 @@ struct ostream_from_python
}
static void construct(PyObject* obj_ptr,
- converter::rvalue_from_python_stage1_data* data)
+ converter::rvalue_from_python_stage1_data* data)
{
void* storage =
reinterpret_cast<converter::rvalue_from_python_storage<pyofstream> *>
@@ -194,7 +194,7 @@ struct ostream_from_python
};
typedef register_python_conversion<std::ostream,
- ostream_to_python, ostream_from_python>
+ ostream_to_python, ostream_from_python>
ostream_python_conversion;
@@ -205,8 +205,8 @@ void export_utils()
.def(init<uint_least8_t>())
.add_property("flags",
- &supports_flags<uint_least8_t>::flags,
- &supports_flags<uint_least8_t>::set_flags)
+ &supports_flags<uint_least8_t>::flags,
+ &supports_flags<uint_least8_t>::set_flags)
.def("has_flags", &supports_flags<uint_least8_t>::has_flags)
.def("clear_flags", &supports_flags<uint_least8_t>::clear_flags)
.def("add_flags", &supports_flags<uint_least8_t>::add_flags)
@@ -218,8 +218,8 @@ void export_utils()
.def(init<uint_least16_t>())
.add_property("flags",
- &supports_flags<uint_least16_t>::flags,
- &supports_flags<uint_least16_t>::set_flags)
+ &supports_flags<uint_least16_t>::flags,
+ &supports_flags<uint_least16_t>::set_flags)
.def("has_flags", &supports_flags<uint_least16_t>::has_flags)
.def("clear_flags", &supports_flags<uint_least16_t>::clear_flags)
.def("add_flags", &supports_flags<uint_least16_t>::add_flags)
@@ -237,10 +237,10 @@ void export_utils()
#endif
class_< delegates_flags<uint_least16_t>,
- boost::noncopyable > ("DelegatesFlags16", no_init)
+ boost::noncopyable > ("DelegatesFlags16", no_init)
.add_property("flags",
- &delegates_flags<uint_least16_t>::flags,
- &delegates_flags<uint_least16_t>::set_flags)
+ &delegates_flags<uint_least16_t>::flags,
+ &delegates_flags<uint_least16_t>::set_flags)
.def("has_flags", &delegates_flags<uint_least16_t>::has_flags)
.def("clear_flags", &delegates_flags<uint_least16_t>::clear_flags)
.def("add_flags", &delegates_flags<uint_least16_t>::add_flags)
diff --git a/src/py_value.cc b/src/py_value.cc
index dabda427..f8f36453 100644
--- a/src/py_value.cc
+++ b/src/py_value.cc
@@ -42,7 +42,7 @@ using namespace boost::python;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(value_overloads, value, 0, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(exchange_commodities_overloads,
- exchange_commodities, 1, 2)
+ exchange_commodities, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_string_overloads, set_string, 0, 2)
namespace {
@@ -51,12 +51,12 @@ namespace {
return value.value(CURRENT_TIME());
}
boost::optional<value_t> py_value_1(const value_t& value,
- commodity_t& in_terms_of) {
+ commodity_t& in_terms_of) {
return value.value(CURRENT_TIME(), in_terms_of);
}
boost::optional<value_t> py_value_2(const value_t& value,
- commodity_t& in_terms_of,
- datetime_t& moment) {
+ commodity_t& in_terms_of,
+ datetime_t& moment) {
return value.value(moment, in_terms_of);
}
@@ -110,9 +110,9 @@ namespace {
} // unnamed namespace
-#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_ArithmeticError, err.what()); \
+#define EXC_TRANSLATOR(type) \
+ void exc_translate_ ## type(const type& err) { \
+ PyErr_SetString(PyExc_ArithmeticError, err.what()); \
}
EXC_TRANSLATOR(value_error)
@@ -120,16 +120,16 @@ EXC_TRANSLATOR(value_error)
void export_value()
{
enum_< value_t::type_t >("ValueType")
- .value("Void", value_t::VOID)
- .value("Boolean", value_t::BOOLEAN)
- .value("DateTime", value_t::DATETIME)
- .value("Date", value_t::DATE)
- .value("Integer", value_t::INTEGER)
- .value("Amount", value_t::AMOUNT)
- .value("Balance", value_t::BALANCE)
- .value("String", value_t::STRING)
- .value("Sequence", value_t::SEQUENCE)
- .value("Scope", value_t::SCOPE)
+ .value("Void", value_t::VOID)
+ .value("Boolean", value_t::BOOLEAN)
+ .value("DateTime", value_t::DATETIME)
+ .value("Date", value_t::DATE)
+ .value("Integer", value_t::INTEGER)
+ .value("Amount", value_t::AMOUNT)
+ .value("Balance", value_t::BALANCE)
+ .value("String", value_t::STRING)
+ .value("Sequence", value_t::SEQUENCE)
+ .value("Scope", value_t::SCOPE)
;
class_< value_t > ("Value")
@@ -214,9 +214,9 @@ void export_value()
.def(self -= other<amount_t>())
.def(self -= other<balance_t>())
- .def(self - self)
- .def(self - long())
- .def(long() - self)
+ .def(self - self)
+ .def(self - long())
+ .def(long() - self)
.def(self - other<amount_t>())
.def(other<amount_t>() - self)
.def(self - other<balance_t>())
@@ -225,8 +225,8 @@ void export_value()
.def(self *= long())
.def(self *= other<amount_t>())
- .def(self * self)
- .def(self * long())
+ .def(self * self)
+ .def(self * long())
.def(long() * self)
.def(self * other<amount_t>())
.def(other<amount_t>() * self)
@@ -235,9 +235,9 @@ void export_value()
.def(self /= long())
.def(self /= other<amount_t>())
- .def(self / self)
- .def(self / long())
- .def(long() / self)
+ .def(self / self)
+ .def(self / long())
+ .def(long() / self)
.def(self / other<amount_t>())
.def(other<amount_t>() / self)
@@ -269,7 +269,7 @@ void export_value()
.def("value", &value_t::value, value_overloads())
.def("price", &value_t::price)
.def("exchange_commodities", &value_t::exchange_commodities,
- exchange_commodities_overloads())
+ exchange_commodities_overloads())
.def("__nonzero__", &value_t::is_nonzero)
.def("is_nonzero", &value_t::is_nonzero)
@@ -333,8 +333,8 @@ void export_value()
.def("annotate", &value_t::annotate)
.def("has_annotation", &value_t::has_annotation)
.add_property("annotation",
- make_function(py_value_annotation,
- return_internal_reference<>()))
+ make_function(py_value_annotation,
+ return_internal_reference<>()))
.def("strip_annotations", py_strip_annotations_0)
.def("strip_annotations", py_strip_annotations_1)
@@ -362,7 +362,7 @@ void export_value()
scope().attr("NULL_VALUE") = NULL_VALUE;
scope().attr("string_value") = &string_value;
- scope().attr("mask_value") = &mask_value;
+ scope().attr("mask_value") = &mask_value;
scope().attr("value_context") = &value_context;
register_optional_to_python<value_t>();
diff --git a/src/py_xact.cc b/src/py_xact.cc
index 6553a67f..5ab0d90d 100644
--- a/src/py_xact.cc
+++ b/src/py_xact.cc
@@ -84,14 +84,14 @@ void export_xact()
{
class_< xact_base_t, bases<item_t> > ("TransactionBase")
.add_property("journal",
- make_getter(&xact_base_t::journal,
- return_internal_reference<>()),
- make_setter(&xact_base_t::journal,
- with_custodian_and_ward<1, 2>()))
+ make_getter(&xact_base_t::journal,
+ return_internal_reference<>()),
+ make_setter(&xact_base_t::journal,
+ with_custodian_and_ward<1, 2>()))
.def("__len__", posts_len)
.def("__getitem__", posts_getitem,
- return_internal_reference<>())
+ return_internal_reference<>())
.def("add_post", &xact_base_t::add_post, with_custodian_and_ward<1, 2>())
.def("remove_post", &xact_base_t::add_post)
@@ -99,20 +99,20 @@ void export_xact()
.def("finalize", &xact_base_t::finalize)
.def("__iter__", python::range<return_internal_reference<> >
- (&xact_t::posts_begin, &xact_t::posts_end))
+ (&xact_t::posts_begin, &xact_t::posts_end))
.def("posts", python::range<return_internal_reference<> >
- (&xact_t::posts_begin, &xact_t::posts_end))
+ (&xact_t::posts_begin, &xact_t::posts_end))
.def("valid", &xact_base_t::valid)
;
class_< xact_t, bases<xact_base_t> > ("Transaction")
.add_property("code",
- make_getter(&xact_t::code),
- make_setter(&xact_t::code))
+ make_getter(&xact_t::code),
+ make_setter(&xact_t::code))
.add_property("payee",
- make_getter(&xact_t::payee),
- make_setter(&xact_t::payee))
+ make_getter(&xact_t::payee),
+ make_setter(&xact_t::payee))
.def("add_post", &xact_t::add_post, with_custodian_and_ward<1, 2>())
@@ -132,8 +132,8 @@ void export_xact()
.def(init<predicate_t>())
.add_property("predicate",
- make_getter(&auto_xact_t::predicate),
- make_setter(&auto_xact_t::predicate))
+ make_getter(&auto_xact_t::predicate),
+ make_setter(&auto_xact_t::predicate))
.def("extend_xact", &auto_xact_t::extend_xact)
;
@@ -142,11 +142,11 @@ void export_xact()
.def(init<string>())
.add_property("period",
- make_getter(&period_xact_t::period),
- make_setter(&period_xact_t::period))
+ make_getter(&period_xact_t::period),
+ make_setter(&period_xact_t::period))
.add_property("period_string",
- make_getter(&period_xact_t::period_string),
- make_setter(&period_xact_t::period_string))
+ make_getter(&period_xact_t::period_string),
+ make_setter(&period_xact_t::period_string))
;
}
diff --git a/src/pyfstream.h b/src/pyfstream.h
index 02e4d240..37978ff4 100644
--- a/src/pyfstream.h
+++ b/src/pyfstream.h
@@ -59,7 +59,7 @@ protected:
z[0] = static_cast<char>(c);
z[1] = '\0';
if (PyFile_WriteString(z, reinterpret_cast<PyObject *>(fo)) < 0) {
- return EOF;
+ return EOF;
}
}
return c;
@@ -124,8 +124,8 @@ public:
TRACE_CTOR(pyinbuf, "PyFileObject *");
setg (buffer+pbSize, // beginning of putback area
- buffer+pbSize, // read position
- buffer+pbSize); // end position
+ buffer+pbSize, // read position
+ buffer+pbSize); // end position
}
~pyinbuf() throw() {
TRACE_DTOR(pyinbuf);
@@ -157,7 +157,7 @@ protected:
* the putback area
*/
memmove (buffer+(pbSize-numPutback), gptr()-numPutback,
- numPutback);
+ numPutback);
// read at most bufSize new characters
PyObject *line = PyFile_GetLine(reinterpret_cast<PyObject *>(fo), bufSize);
@@ -174,8 +174,8 @@ protected:
// reset buffer pointers
setg (buffer+(pbSize-numPutback), // beginning of putback area
- buffer+pbSize, // read position
- buffer+pbSize+num); // end of buffer
+ buffer+pbSize, // read position
+ buffer+pbSize+num); // end of buffer
// return next character
return traits_type::to_int_type(*gptr());
diff --git a/src/pyinterp.cc b/src/pyinterp.cc
index 1330fc5c..76fc0561 100644
--- a/src/pyinterp.cc
+++ b/src/pyinterp.cc
@@ -80,10 +80,10 @@ struct python_run
object result;
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,
- intepreter->main_nspace.ptr(),
- intepreter->main_nspace.ptr())))) {}
+ intepreter->main_nspace.ptr(),
+ intepreter->main_nspace.ptr())))) {}
operator object() {
return result;
}
@@ -104,12 +104,12 @@ void python_interpreter_t::initialize()
object main_module = python::import("__main__");
if (! main_module)
throw_(std::runtime_error,
- _("Python failed to initialize (couldn't find __main__)"));
+ _("Python failed to initialize (couldn't find __main__)"));
main_nspace = extract<dict>(main_module.attr("__dict__"));
if (! main_nspace)
throw_(std::runtime_error,
- _("Python failed to initialize (couldn't find __dict__)"));
+ _("Python failed to initialize (couldn't find __dict__)"));
python::detail::init_module("ledger", &initialize_for_python);
@@ -142,17 +142,17 @@ void python_interpreter_t::hack_system_paths()
if (exists(pathname / "ledger" / "__init__.py")) {
if (python::object module_ledger = python::import("ledger")) {
- DEBUG("python.interp",
- "Setting ledger.__path__ = " << (pathname / "ledger"));
+ DEBUG("python.interp",
+ "Setting ledger.__path__ = " << (pathname / "ledger"));
- python::object ledger_dict = module_ledger.attr("__dict__");
- python::list temp_list;
- temp_list.append((pathname / "ledger").string());
+ python::object ledger_dict = module_ledger.attr("__dict__");
+ python::list temp_list;
+ temp_list.append((pathname / "ledger").string());
- ledger_dict["__path__"] = temp_list;
+ ledger_dict["__path__"] = temp_list;
} else {
- throw_(std::runtime_error,
- _("Python failed to initialize (couldn't find ledger)"));
+ throw_(std::runtime_error,
+ _("Python failed to initialize (couldn't find ledger)"));
}
#if defined(DEBUG_ON)
path_initialized = true;
@@ -163,7 +163,7 @@ void python_interpreter_t::hack_system_paths()
#if defined(DEBUG_ON)
if (! path_initialized)
DEBUG("python.init",
- "Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH");
+ "Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH");
#endif
}
@@ -176,7 +176,7 @@ object python_interpreter_t::import_into_main(const string& str)
object mod = python::import(str.c_str());
if (! mod)
throw_(std::runtime_error,
- _("Failed to import Python module %1") << str);
+ _("Failed to import Python module %1") << str);
// Import all top-level entries directly into the main namespace
main_nspace.update(mod.attr("__dict__"));
@@ -217,7 +217,7 @@ object python_interpreter_t::import_option(const string& str)
object python_interpreter_t::eval(std::istream& in, py_eval_mode_t mode)
{
- bool first = true;
+ bool first = true;
string buffer;
buffer.reserve(4096);
@@ -328,12 +328,12 @@ value_t python_interpreter_t::server_command(call_scope_t& args)
server_module = python::import("ledger.server");
if (! server_module)
throw_(std::runtime_error,
- _("Could not import ledger.server; please check your PYTHONPATH"));
+ _("Could not import ledger.server; please check your PYTHONPATH"));
}
catch (const error_already_set&) {
PyErr_Print();
throw_(std::runtime_error,
- _("Could not import ledger.server; please check your PYTHONPATH"));
+ _("Could not import ledger.server; please check your PYTHONPATH"));
}
if (python::object main_function = server_module.attr("main")) {
@@ -344,12 +344,12 @@ value_t python_interpreter_t::server_command(call_scope_t& args)
catch (const error_already_set&) {
PyErr_Print();
throw_(std::runtime_error,
- _("Error while invoking ledger.server's main() function"));
+ _("Error while invoking ledger.server's main() function"));
}
return true;
} else {
throw_(std::runtime_error,
- _("The ledger.server module is missing its main() function!"));
+ _("The ledger.server module is missing its main() function!"));
}
return false;
@@ -367,7 +367,7 @@ python_interpreter_t::lookup_option(const char * p)
}
expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
// Give our superclass first dibs on symbol definitions
if (expr_t::ptr_op_t op = session_t::lookup(kind, name))
@@ -382,7 +382,7 @@ expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
DEBUG("python.interp", "Python lookup: " << name);
if (python::object obj = main_nspace.get(name.c_str()))
- return WRAP_FUNCTOR(functor_t(obj, name));
+ return WRAP_FUNCTOR(functor_t(obj, name));
}
break;
@@ -396,12 +396,12 @@ expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
switch (*p) {
case 'p':
if (is_eq(p, "python"))
- return MAKE_FUNCTOR(python_interpreter_t::python_command);
+ return MAKE_FUNCTOR(python_interpreter_t::python_command);
break;
case 's':
if (is_eq(p, "server"))
- return MAKE_FUNCTOR(python_interpreter_t::server_command);
+ return MAKE_FUNCTOR(python_interpreter_t::server_command);
break;
}
}
@@ -419,21 +419,21 @@ namespace {
if (value.is_scope()) {
const scope_t * scope = value.as_scope();
if (const post_t * post = dynamic_cast<const post_t *>(scope))
- lst.append(ptr(post));
+ lst.append(ptr(post));
else if (const xact_t * xact = dynamic_cast<const xact_t *>(scope))
- lst.append(ptr(xact));
+ lst.append(ptr(xact));
else if (const account_t * account =
- dynamic_cast<const account_t *>(scope))
- lst.append(ptr(account));
+ dynamic_cast<const account_t *>(scope))
+ lst.append(ptr(account));
else if (const period_xact_t * period_xact =
- dynamic_cast<const period_xact_t *>(scope))
- lst.append(ptr(period_xact));
+ dynamic_cast<const period_xact_t *>(scope))
+ lst.append(ptr(period_xact));
else if (const auto_xact_t * auto_xact =
- dynamic_cast<const auto_xact_t *>(scope))
- lst.append(ptr(auto_xact));
+ dynamic_cast<const auto_xact_t *>(scope))
+ lst.append(ptr(auto_xact));
else
- throw_(std::logic_error,
- _("Cannot downcast scoped object to specific type"));
+ throw_(std::logic_error,
+ _("Cannot downcast scoped object to specific type"));
} else {
lst.append(value);
}
@@ -449,7 +449,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
extract<value_t> val(func);
std::signal(SIGINT, sigint_handler);
if (val.check())
- return val();
+ return val();
return NULL_VALUE;
}
else if (args.size() > 0) {
@@ -457,31 +457,31 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
// jww (2009-11-05): What about a single argument which is a sequence,
// rather than a sequence of arguments?
if (args.value().is_sequence())
- foreach (const value_t& value, args.value().as_sequence())
- append_value(arglist, value);
+ foreach (const value_t& value, args.value().as_sequence())
+ append_value(arglist, value);
else
- append_value(arglist, args.value());
+ append_value(arglist, args.value());
if (PyObject * val =
- PyObject_CallObject(func.ptr(), python::tuple(arglist).ptr())) {
- extract<value_t> xval(val);
- value_t result;
- if (xval.check()) {
- result = xval();
- Py_DECREF(val);
- } else {
- Py_DECREF(val);
- throw_(calc_error,
- _("Could not evaluate Python variable '%1'") << name);
- }
- std::signal(SIGINT, sigint_handler);
- return result;
+ PyObject_CallObject(func.ptr(), python::tuple(arglist).ptr())) {
+ extract<value_t> xval(val);
+ value_t result;
+ if (xval.check()) {
+ result = xval();
+ Py_DECREF(val);
+ } else {
+ Py_DECREF(val);
+ throw_(calc_error,
+ _("Could not evaluate Python variable '%1'") << name);
+ }
+ std::signal(SIGINT, sigint_handler);
+ return result;
}
else if (PyErr_Occurred()) {
- PyErr_Print();
- throw_(calc_error, _("Failed call to Python function '%1'") << name);
+ PyErr_Print();
+ throw_(calc_error, _("Failed call to Python function '%1'") << name);
} else {
- assert(false);
+ assert(false);
}
}
else {
diff --git a/src/pyinterp.h b/src/pyinterp.h
index e3a091ad..3d747d5c 100644
--- a/src/pyinterp.h
+++ b/src/pyinterp.h
@@ -69,11 +69,11 @@ public:
};
python::object eval(std::istream& in,
- py_eval_mode_t mode = PY_EVAL_EXPR);
+ py_eval_mode_t mode = PY_EVAL_EXPR);
python::object eval(const string& str,
- py_eval_mode_t mode = PY_EVAL_EXPR);
+ py_eval_mode_t mode = PY_EVAL_EXPR);
python::object eval(const char * c_str,
- py_eval_mode_t mode = PY_EVAL_EXPR) {
+ py_eval_mode_t mode = PY_EVAL_EXPR) {
string str(c_str);
return eval(str, mode);
}
@@ -107,7 +107,7 @@ public:
option_t<python_interpreter_t> * lookup_option(const char * p);
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
OPTION_(python_interpreter_t, import_, DO_(scope) {
interactive_t args(scope, "ss");
diff --git a/src/pyutils.h b/src/pyutils.h
index e0f77003..efb1b858 100644
--- a/src/pyutils.h
+++ b/src/pyutils.h
@@ -59,8 +59,8 @@ struct register_optional_to_python : public boost::noncopyable
static PyObject * convert(const boost::optional<T>& value)
{
return boost::python::incref
- (value ? boost::python::to_python_value<T>()(*value) :
- boost::python::detail::none());
+ (value ? boost::python::to_python_value<T>()(*value) :
+ boost::python::detail::none());
}
};
@@ -71,30 +71,30 @@ struct register_optional_to_python : public boost::noncopyable
using namespace boost::python::converter;
if (source == Py_None)
- return source;
+ return source;
const registration& converters(registered<T>::converters);
if (implicit_rvalue_convertible_from_python(source, converters)) {
- rvalue_from_python_stage1_data data =
- rvalue_from_python_stage1(source, converters);
- return rvalue_from_python_stage2(source, data, converters);
+ rvalue_from_python_stage1_data data =
+ rvalue_from_python_stage1(source, converters);
+ return rvalue_from_python_stage2(source, data, converters);
}
return NULL;
}
static void construct(PyObject * source,
- boost::python::converter::rvalue_from_python_stage1_data * data)
+ boost::python::converter::rvalue_from_python_stage1_data * data)
{
using namespace boost::python::converter;
void * const storage =
- reinterpret_cast<rvalue_from_python_storage<T> *>(data)->storage.bytes;
+ reinterpret_cast<rvalue_from_python_storage<T> *>(data)->storage.bytes;
- if (data->convertible == source) // == None
- new (storage) boost::optional<T>(); // A Boost uninitialized value
+ if (data->convertible == source) // == None
+ new (storage) boost::optional<T>(); // A Boost uninitialized value
else
- new (storage) boost::optional<T>(*reinterpret_cast<T *>(data->convertible));
+ new (storage) boost::optional<T>(*reinterpret_cast<T *>(data->convertible));
data->convertible = storage;
}
diff --git a/src/query.cc b/src/query.cc
index 363c6f73..404c101f 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -58,17 +58,17 @@ query_t::lexer_t::token_t query_t::lexer_t::next_token()
case '"':
case '/': {
string pat;
- char closing = *arg_i;
+ char closing = *arg_i;
bool found_closing = false;
for (++arg_i; arg_i != arg_end; ++arg_i) {
if (*arg_i == '\\') {
- if (++arg_i == arg_end)
- throw_(parse_error, _("Unexpected '\\' at end of pattern"));
+ if (++arg_i == arg_end)
+ throw_(parse_error, _("Unexpected '\\' at end of pattern"));
}
else if (*arg_i == closing) {
- ++arg_i;
- found_closing = true;
- break;
+ ++arg_i;
+ found_closing = true;
+ break;
}
pat.push_back(*arg_i);
}
@@ -125,11 +125,11 @@ query_t::lexer_t::token_t query_t::lexer_t::next_token()
case '\t':
case '\n':
case '\r':
- if (! consume_whitespace)
- goto test_ident;
- else
- ident.push_back(*arg_i);
- break;
+ if (! consume_whitespace)
+ goto test_ident;
+ else
+ ident.push_back(*arg_i);
+ break;
case '(':
case ')':
case '&':
@@ -139,12 +139,12 @@ query_t::lexer_t::token_t query_t::lexer_t::next_token()
case '#':
case '%':
case '=':
- if (! consume_next)
- goto test_ident;
+ if (! consume_next)
+ goto test_ident;
// fall through...
default:
- ident.push_back(*arg_i);
- break;
+ ident.push_back(*arg_i);
+ break;
}
}
consume_whitespace = false;
@@ -251,7 +251,7 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex
node = parse_query_term(tok.kind);
if (! node)
throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol());
+ _("%1 operator not followed by argument") << tok.symbol());
break;
case lexer_t::token_t::TERM:
@@ -264,30 +264,30 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex
date_interval_t interval(*tok.value);
if (interval.start) {
- node = new expr_t::op_t(expr_t::op_t::O_GTE);
- node->set_left(ident);
+ node = new expr_t::op_t(expr_t::op_t::O_GTE);
+ node->set_left(ident);
- expr_t::ptr_op_t arg1 = new expr_t::op_t(expr_t::op_t::VALUE);
- arg1->set_value(*interval.start);
- node->set_right(arg1);
+ expr_t::ptr_op_t arg1 = new expr_t::op_t(expr_t::op_t::VALUE);
+ arg1->set_value(*interval.start);
+ node->set_right(arg1);
}
if (interval.finish) {
- expr_t::ptr_op_t lt = new expr_t::op_t(expr_t::op_t::O_LT);
- lt->set_left(ident);
-
- expr_t::ptr_op_t arg1 = new expr_t::op_t(expr_t::op_t::VALUE);
- arg1->set_value(*interval.finish);
- lt->set_right(arg1);
-
- if (node) {
- expr_t::ptr_op_t prev(node);
- node = new expr_t::op_t(expr_t::op_t::O_AND);
- node->set_left(prev);
- node->set_right(lt);
- } else {
- node = lt;
- }
+ expr_t::ptr_op_t lt = new expr_t::op_t(expr_t::op_t::O_LT);
+ lt->set_left(ident);
+
+ expr_t::ptr_op_t arg1 = new expr_t::op_t(expr_t::op_t::VALUE);
+ arg1->set_value(*interval.finish);
+ lt->set_right(arg1);
+
+ if (node) {
+ expr_t::ptr_op_t prev(node);
+ node = new expr_t::op_t(expr_t::op_t::O_AND);
+ node->set_left(prev);
+ node->set_right(lt);
+ } else {
+ node = lt;
+ }
}
break;
}
@@ -308,22 +308,22 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex
tok = lexer.peek_token();
if (tok.kind == lexer_t::token_t::TOK_EQ) {
- tok = lexer.next_token();
- tok = lexer.next_token();
- if (tok.kind != lexer_t::token_t::TERM)
- throw_(parse_error,
- _("Metadata equality operator not followed by term"));
-
- expr_t::ptr_op_t arg2 = new expr_t::op_t(expr_t::op_t::VALUE);
- assert(tok.value);
- arg2->set_value(mask_t(*tok.value));
-
- node->set_right(expr_t::op_t::new_node
- (expr_t::op_t::O_SEQ,
- expr_t::op_t::new_node
- (expr_t::op_t::O_CONS, arg1, arg2)));
+ tok = lexer.next_token();
+ tok = lexer.next_token();
+ if (tok.kind != lexer_t::token_t::TERM)
+ throw_(parse_error,
+ _("Metadata equality operator not followed by term"));
+
+ expr_t::ptr_op_t arg2 = new expr_t::op_t(expr_t::op_t::VALUE);
+ assert(tok.value);
+ arg2->set_value(mask_t(*tok.value));
+
+ node->set_right(expr_t::op_t::new_node
+ (expr_t::op_t::O_SEQ,
+ expr_t::op_t::new_node
+ (expr_t::op_t::O_CONS, arg1, arg2)));
} else {
- node->set_right(arg1);
+ node->set_right(arg1);
}
break;
}
@@ -334,15 +334,15 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex
expr_t::ptr_op_t ident = new expr_t::op_t(expr_t::op_t::IDENT);
switch (tok_context) {
case lexer_t::token_t::TOK_ACCOUNT:
- ident->set_ident("account"); break;
+ ident->set_ident("account"); break;
case lexer_t::token_t::TOK_PAYEE:
- ident->set_ident("payee"); break;
+ ident->set_ident("payee"); break;
case lexer_t::token_t::TOK_CODE:
- ident->set_ident("code"); break;
+ ident->set_ident("code"); break;
case lexer_t::token_t::TOK_NOTE:
- ident->set_ident("note"); break;
+ ident->set_ident("note"); break;
default:
- assert(false); break;
+ assert(false); break;
}
expr_t::ptr_op_t mask = new expr_t::op_t(expr_t::op_t::VALUE);
@@ -382,7 +382,7 @@ query_t::parser_t::parse_unary_expr(lexer_t::token_t::kind_t tok_context)
expr_t::ptr_op_t term(parse_query_term(tok_context));
if (! term)
throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol());
+ _("%1 operator not followed by argument") << tok.symbol());
node = new expr_t::op_t(expr_t::op_t::O_NOT);
node->set_left(term);
@@ -405,16 +405,16 @@ query_t::parser_t::parse_and_expr(lexer_t::token_t::kind_t tok_context)
while (true) {
lexer_t::token_t tok = lexer.next_token();
if (tok.kind == lexer_t::token_t::TOK_AND) {
- expr_t::ptr_op_t prev(node);
- node = new expr_t::op_t(expr_t::op_t::O_AND);
- node->set_left(prev);
- node->set_right(parse_unary_expr(tok_context));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol());
+ expr_t::ptr_op_t prev(node);
+ node = new expr_t::op_t(expr_t::op_t::O_AND);
+ node->set_left(prev);
+ node->set_right(parse_unary_expr(tok_context));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol());
} else {
- lexer.push_token(tok);
- break;
+ lexer.push_token(tok);
+ break;
}
}
return node;
@@ -429,16 +429,16 @@ query_t::parser_t::parse_or_expr(lexer_t::token_t::kind_t tok_context)
while (true) {
lexer_t::token_t tok = lexer.next_token();
if (tok.kind == lexer_t::token_t::TOK_OR) {
- expr_t::ptr_op_t prev(node);
- node = new expr_t::op_t(expr_t::op_t::O_OR);
- node->set_left(prev);
- node->set_right(parse_and_expr(tok_context));
- if (! node->right())
- throw_(parse_error,
- _("%1 operator not followed by argument") << tok.symbol());
+ expr_t::ptr_op_t prev(node);
+ node = new expr_t::op_t(expr_t::op_t::O_OR);
+ node->set_left(prev);
+ node->set_right(parse_and_expr(tok_context));
+ if (! node->right())
+ throw_(parse_error,
+ _("%1 operator not followed by argument") << tok.symbol());
} else {
- lexer.push_token(tok);
- break;
+ lexer.push_token(tok);
+ break;
}
}
return node;
diff --git a/src/query.h b/src/query.h
index 59adfd72..e3821f19 100644
--- a/src/query.h
+++ b/src/query.h
@@ -68,107 +68,107 @@ public:
struct token_t
{
enum kind_t {
- UNKNOWN,
+ UNKNOWN,
- LPAREN,
- RPAREN,
+ LPAREN,
+ RPAREN,
- TOK_NOT,
- TOK_AND,
- TOK_OR,
- TOK_EQ,
+ TOK_NOT,
+ TOK_AND,
+ TOK_OR,
+ TOK_EQ,
- TOK_DATE,
- TOK_CODE,
- TOK_PAYEE,
- TOK_NOTE,
- TOK_ACCOUNT,
- TOK_META,
- TOK_EXPR,
+ TOK_DATE,
+ TOK_CODE,
+ TOK_PAYEE,
+ TOK_NOTE,
+ TOK_ACCOUNT,
+ TOK_META,
+ TOK_EXPR,
- TERM,
+ TERM,
- END_REACHED
+ END_REACHED
} kind;
optional<string> value;
explicit token_t(kind_t _kind = UNKNOWN,
- const optional<string>& _value = none)
- : kind(_kind), value(_value) {
- TRACE_CTOR(query_t::lexer_t::token_t, "");
+ const optional<string>& _value = none)
+ : kind(_kind), value(_value) {
+ TRACE_CTOR(query_t::lexer_t::token_t, "");
}
token_t(const token_t& tok)
- : kind(tok.kind), value(tok.value) {
- TRACE_CTOR(query_t::lexer_t::token_t, "copy");
+ : kind(tok.kind), value(tok.value) {
+ TRACE_CTOR(query_t::lexer_t::token_t, "copy");
}
~token_t() throw() {
- TRACE_DTOR(query_t::lexer_t::token_t);
+ TRACE_DTOR(query_t::lexer_t::token_t);
}
token_t& operator=(const token_t& tok) {
- if (this != &tok) {
- kind = tok.kind;
- value = tok.value;
- }
- return *this;
+ if (this != &tok) {
+ kind = tok.kind;
+ value = tok.value;
+ }
+ return *this;
}
operator bool() const {
- return kind != END_REACHED;
+ return kind != END_REACHED;
}
string to_string() const {
- switch (kind) {
- case UNKNOWN: return "UNKNOWN";
- case LPAREN: return "LPAREN";
- case RPAREN: return "RPAREN";
- case TOK_NOT: return "TOK_NOT";
- case TOK_AND: return "TOK_AND";
- case TOK_OR: return "TOK_OR";
- case TOK_EQ: return "TOK_EQ";
- case TOK_DATE: return "TOK_DATE";
- case TOK_CODE: return "TOK_CODE";
- case TOK_PAYEE: return "TOK_PAYEE";
- case TOK_NOTE: return "TOK_NOTE";
- case TOK_ACCOUNT: return "TOK_ACCOUNT";
- case TOK_META: return "TOK_META";
- case TOK_EXPR: return "TOK_EXPR";
- case TERM: return string("TERM(") + *value + ")";
- case END_REACHED: return "END_REACHED";
- }
- assert(false);
- return empty_string;
+ switch (kind) {
+ case UNKNOWN: return "UNKNOWN";
+ case LPAREN: return "LPAREN";
+ case RPAREN: return "RPAREN";
+ case TOK_NOT: return "TOK_NOT";
+ case TOK_AND: return "TOK_AND";
+ case TOK_OR: return "TOK_OR";
+ case TOK_EQ: return "TOK_EQ";
+ case TOK_DATE: return "TOK_DATE";
+ case TOK_CODE: return "TOK_CODE";
+ case TOK_PAYEE: return "TOK_PAYEE";
+ case TOK_NOTE: return "TOK_NOTE";
+ case TOK_ACCOUNT: return "TOK_ACCOUNT";
+ case TOK_META: return "TOK_META";
+ case TOK_EXPR: return "TOK_EXPR";
+ case TERM: return string("TERM(") + *value + ")";
+ case END_REACHED: return "END_REACHED";
+ }
+ assert(false);
+ return empty_string;
}
string symbol() const {
- switch (kind) {
- case LPAREN: return "(";
- case RPAREN: return ")";
- case TOK_NOT: return "not";
- case TOK_AND: return "and";
- case TOK_OR: return "or";
- case TOK_EQ: return "=";
- case TOK_DATE: return "date";
- case TOK_CODE: return "code";
- case TOK_PAYEE: return "payee";
- case TOK_NOTE: return "note";
- case TOK_ACCOUNT: return "account";
- case TOK_META: return "meta";
- case TOK_EXPR: return "expr";
-
- case END_REACHED: return "<EOF>";
-
- case TERM:
- assert(false);
- return "<TERM>";
-
- case UNKNOWN:
- default:
- assert(false);
- return "<UNKNOWN>";
- }
+ switch (kind) {
+ case LPAREN: return "(";
+ case RPAREN: return ")";
+ case TOK_NOT: return "not";
+ case TOK_AND: return "and";
+ case TOK_OR: return "or";
+ case TOK_EQ: return "=";
+ case TOK_DATE: return "date";
+ case TOK_CODE: return "code";
+ case TOK_PAYEE: return "payee";
+ case TOK_NOTE: return "note";
+ case TOK_ACCOUNT: return "account";
+ case TOK_META: return "meta";
+ case TOK_EXPR: return "expr";
+
+ case END_REACHED: return "<EOF>";
+
+ case TERM:
+ assert(false);
+ return "<TERM>";
+
+ case UNKNOWN:
+ default:
+ assert(false);
+ return "<UNKNOWN>";
+ }
}
void unexpected();
@@ -178,11 +178,11 @@ public:
token_t token_cache;
lexer_t(value_t::sequence_t::const_iterator _begin,
- value_t::sequence_t::const_iterator _end,
- bool _multiple_args = true)
+ value_t::sequence_t::const_iterator _end,
+ bool _multiple_args = true)
: begin(_begin), end(_end),
- consume_whitespace(false), consume_next_arg(false),
- multiple_args(_multiple_args)
+ consume_whitespace(false), consume_next_arg(false),
+ multiple_args(_multiple_args)
{
TRACE_CTOR(query_t::lexer_t, "");
assert(begin != end);
@@ -191,11 +191,11 @@ public:
}
lexer_t(const lexer_t& lexer)
: begin(lexer.begin), end(lexer.end),
- arg_i(lexer.arg_i), arg_end(lexer.arg_end),
- consume_whitespace(lexer.consume_whitespace),
- consume_next_arg(lexer.consume_next_arg),
- multiple_args(lexer.multiple_args),
- token_cache(lexer.token_cache)
+ arg_i(lexer.arg_i), arg_end(lexer.arg_end),
+ consume_whitespace(lexer.consume_whitespace),
+ consume_next_arg(lexer.consume_next_arg),
+ multiple_args(lexer.multiple_args),
+ token_cache(lexer.token_cache)
{
TRACE_CTOR(query_t::lexer_t, "copy");
}
@@ -210,7 +210,7 @@ public:
}
token_t peek_token() {
if (token_cache.kind == token_t::UNKNOWN)
- token_cache = next_token();
+ token_cache = next_token();
return token_cache;
}
};
@@ -264,8 +264,8 @@ public:
TRACE_CTOR(query_t, "copy");
}
query_t(const string& arg,
- const keep_details_t& _what_to_keep = keep_details_t(),
- bool multiple_args = true)
+ const keep_details_t& _what_to_keep = keep_details_t(),
+ bool multiple_args = true)
: predicate_t(_what_to_keep) {
TRACE_CTOR(query_t, "string, keep_details_t");
if (! arg.empty()) {
@@ -274,8 +274,8 @@ public:
}
}
query_t(const value_t& args,
- const keep_details_t& _what_to_keep = keep_details_t(),
- bool multiple_args = true)
+ const keep_details_t& _what_to_keep = keep_details_t(),
+ bool multiple_args = true)
: predicate_t(_what_to_keep) {
TRACE_CTOR(query_t, "value_t, keep_details_t");
if (! args.empty())
@@ -288,12 +288,12 @@ public:
void parse_args(const value_t& args, bool multiple_args = true) {
if (! parser)
parser = parser_t(args, multiple_args);
- ptr = parser->parse(); // expr_t::ptr
+ ptr = parser->parse(); // expr_t::ptr
}
void parse_again() {
assert(parser);
- ptr = parser->parse(); // expr_t::ptr
+ ptr = parser->parse(); // expr_t::ptr
}
bool tokens_remaining() {
diff --git a/src/quotes.cc b/src/quotes.cc
index 4e3ec33e..90c1f3eb 100644
--- a/src/quotes.cc
+++ b/src/quotes.cc
@@ -40,13 +40,13 @@ namespace ledger {
optional<price_point_t>
commodity_quote_from_script(commodity_t& commodity,
- const optional<commodity_t&>& exchange_commodity)
+ const optional<commodity_t&>& exchange_commodity)
{
DEBUG("commodity.download", "downloading quote for symbol " << commodity.symbol());
#if defined(DEBUG_ON)
if (exchange_commodity)
DEBUG("commodity.download",
- " in terms of commodity " << exchange_commodity->symbol());
+ " in terms of commodity " << exchange_commodity->symbol());
#endif
char buf[256];
@@ -76,29 +76,29 @@ commodity_quote_from_script(commodity_t& commodity,
DEBUG("commodity.download", "downloaded quote: " << buf);
if (optional<std::pair<commodity_t *, price_point_t> > point =
- commodity_pool_t::current_pool->parse_price_directive(buf)) {
+ commodity_pool_t::current_pool->parse_price_directive(buf)) {
if (commodity_pool_t::current_pool->price_db) {
#if defined(__GNUG__) && __GNUG__ < 3
- ofstream database(*commodity_pool_t::current_pool->price_db,
- ios::out | ios::app);
+ ofstream database(*commodity_pool_t::current_pool->price_db,
+ ios::out | ios::app);
#else
- ofstream database(*commodity_pool_t::current_pool->price_db,
- std::ios_base::out | std::ios_base::app);
+ ofstream database(*commodity_pool_t::current_pool->price_db,
+ std::ios_base::out | std::ios_base::app);
#endif
- database << "P "
- << format_datetime(point->second.when, FMT_WRITTEN)
- << " " << commodity.symbol()
- << " " << point->second.price
- << std::endl;
+ database << "P "
+ << format_datetime(point->second.when, FMT_WRITTEN)
+ << " " << commodity.symbol()
+ << " " << point->second.price
+ << std::endl;
}
return point->second;
}
} else {
DEBUG("commodity.download",
- "Failed to download price for '" << commodity.symbol() <<
- "' (command: \"getquote " << commodity.symbol() <<
- " " << (exchange_commodity ?
- exchange_commodity->symbol() : "''") << "\")");
+ "Failed to download price for '" << commodity.symbol() <<
+ "' (command: \"getquote " << commodity.symbol() <<
+ " " << (exchange_commodity ?
+ exchange_commodity->symbol() : "''") << "\")");
// Don't try to download this commodity again.
commodity.add_flags(COMMODITY_NOMARKET);
diff --git a/src/quotes.h b/src/quotes.h
index e981fdad..376d8918 100644
--- a/src/quotes.h
+++ b/src/quotes.h
@@ -46,7 +46,7 @@ namespace ledger {
optional<price_point_t>
commodity_quote_from_script(commodity_t& commodity,
- const optional<commodity_t&>& exchange_commodity);
+ const optional<commodity_t&>& exchange_commodity);
} // namespace ledger
diff --git a/src/report.cc b/src/report.cc
index 1e1827f9..c5cdb843 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -76,7 +76,7 @@ void report_t::normalize_options(const string& verb)
}
item_t::use_effective_date = (HANDLED(effective) &&
- ! HANDLED(actual_dates));
+ ! HANDLED(actual_dates));
commodity_pool_t::current_pool->keep_base = HANDLED(base);
commodity_pool_t::current_pool->get_quotes = session.HANDLED(download);
@@ -96,7 +96,7 @@ void report_t::normalize_options(const string& verb)
set_datetime_format(HANDLER(datetime_format_).str().c_str());
if (HANDLED(start_of_week_)) {
if (optional<date_time::weekdays> weekday =
- string_to_day_of_week(HANDLER(start_of_week_).str()))
+ string_to_day_of_week(HANDLER(start_of_week_).str()))
start_of_week = *weekday;
}
@@ -106,24 +106,24 @@ void report_t::normalize_options(const string& verb)
if (! HANDLED(meta_width_)) {
string::size_type i = HANDLER(meta_).str().find(':');
if (i != string::npos) {
- HANDLED(meta_width_).on_with
- (string("?normalize"),
- lexical_cast<long>(string(HANDLER(meta_).str(), i + 1)));
- HANDLED(meta_).on(string("?normalize"),
- string(HANDLER(meta_).str(), 0, i));
+ HANDLED(meta_width_).on_with
+ (string("?normalize"),
+ lexical_cast<long>(string(HANDLER(meta_).str(), i + 1)));
+ HANDLED(meta_).on(string("?normalize"),
+ string(HANDLER(meta_).str(), 0, i));
}
}
if (HANDLED(meta_width_)) {
HANDLER(prepend_format_).on
- (string("?normalize"),
- string("%(justify(truncated(tag(\"") +
- HANDLER(meta_).str() + "\"), " +
- HANDLED(meta_width_).value.to_string() + " - 1), " +
- HANDLED(meta_width_).value.to_string() + "))");
+ (string("?normalize"),
+ string("%(justify(truncated(tag(\"") +
+ HANDLER(meta_).str() + "\"), " +
+ HANDLED(meta_width_).value.to_string() + " - 1), " +
+ HANDLED(meta_width_).value.to_string() + "))");
meta_width = HANDLED(meta_width_).value.to_long();
} else {
HANDLER(prepend_format_).on(string("?normalize"), string("%(tag(\"") +
- HANDLER(meta_).str() + "\"))");
+ HANDLER(meta_).str() + "\"))");
}
}
if (! HANDLED(prepend_width_))
@@ -183,7 +183,7 @@ void report_t::normalize_options(const string& verb)
if (HANDLED(exchange_) &&
HANDLER(exchange_).str().find('=') != string::npos) {
value_t(0L).exchange_commodities(HANDLER(exchange_).str(), true,
- terminus);
+ terminus);
}
long cols = 0;
@@ -202,22 +202,22 @@ void report_t::normalize_options(const string& verb)
if (! HANDLER(date_width_).specified)
HANDLER(date_width_)
- .on_with(none, static_cast<long>(format_date(CURRENT_DATE(),
- FMT_PRINTED).length()));
+ .on_with(none, static_cast<long>(format_date(CURRENT_DATE(),
+ FMT_PRINTED).length()));
long date_width = HANDLER(date_width_).value.to_long();
long payee_width = (HANDLER(payee_width_).specified ?
- HANDLER(payee_width_).value.to_long() :
- int(double(cols) * 0.263157));
+ HANDLER(payee_width_).value.to_long() :
+ int(double(cols) * 0.263157));
long account_width = (HANDLER(account_width_).specified ?
- HANDLER(account_width_).value.to_long() :
- int(double(cols) * 0.302631));
+ HANDLER(account_width_).value.to_long() :
+ int(double(cols) * 0.302631));
long amount_width = (HANDLER(amount_width_).specified ?
- HANDLER(amount_width_).value.to_long() :
- int(double(cols) * 0.157894));
+ HANDLER(amount_width_).value.to_long() :
+ int(double(cols) * 0.157894));
long total_width = (HANDLER(total_width_).specified ?
- HANDLER(total_width_).value.to_long() :
- amount_width);
+ HANDLER(total_width_).value.to_long() :
+ amount_width);
DEBUG("auto.columns", "date_width = " << date_width);
DEBUG("auto.columns", "payee_width = " << payee_width);
@@ -226,16 +226,16 @@ void report_t::normalize_options(const string& verb)
DEBUG("auto.columns", "total_width = " << total_width);
if (! HANDLER(date_width_).specified &&
- ! HANDLER(payee_width_).specified &&
- ! HANDLER(account_width_).specified &&
- ! HANDLER(amount_width_).specified &&
- ! HANDLER(total_width_).specified) {
+ ! HANDLER(payee_width_).specified &&
+ ! HANDLER(account_width_).specified &&
+ ! HANDLER(amount_width_).specified &&
+ ! HANDLER(total_width_).specified) {
long total = (4 /* the spaces between */ + date_width + payee_width +
- account_width + amount_width + total_width);
+ account_width + amount_width + total_width);
if (total > cols) {
- DEBUG("auto.columns", "adjusting account down");
- account_width -= total - cols;
- DEBUG("auto.columns", "account_width now = " << account_width);
+ DEBUG("auto.columns", "adjusting account down");
+ account_width -= total - cols;
+ DEBUG("auto.columns", "account_width now = " << account_width);
}
}
@@ -261,7 +261,7 @@ void report_t::parse_query_args(const value_t& args, const string& whence)
HANDLER(limit_).on(whence, query.text());
DEBUG("report.predicate",
- "Predicate = " << HANDLER(limit_).str());
+ "Predicate = " << HANDLER(limit_).str());
}
if (query.tokens_remaining()) {
@@ -270,7 +270,7 @@ void report_t::parse_query_args(const value_t& args, const string& whence)
HANDLER(display_).on(whence, query.text());
DEBUG("report.predicate",
- "Display predicate = " << HANDLER(display_).str());
+ "Display predicate = " << HANDLER(display_).str());
}
}
}
@@ -279,7 +279,7 @@ namespace {
struct posts_flusher
{
post_handler_ptr handler;
- report_t& report;
+ report_t& report;
posts_flusher(post_handler_ptr _handler, report_t& _report)
: handler(_handler), report(_report) {}
@@ -335,7 +335,7 @@ namespace {
struct accounts_title_printer
{
acct_handler_ptr handler;
- report_t& report;
+ report_t& report;
accounts_title_printer(acct_handler_ptr _handler, report_t& _report)
: handler(_handler), report(_report) {}
@@ -343,9 +343,9 @@ namespace {
void operator()(const value_t& val)
{
if (! report.HANDLED(no_titles)) {
- std::ostringstream buf;
- val.print(buf);
- handler->title(buf.str());
+ std::ostringstream buf;
+ val.print(buf);
+ handler->title(buf.str());
}
}
};
@@ -353,7 +353,7 @@ namespace {
struct accounts_flusher
{
acct_handler_ptr handler;
- report_t& report;
+ report_t& report;
accounts_flusher(acct_handler_ptr _handler, report_t& _report)
: handler(_handler), report(_report) {}
@@ -368,23 +368,23 @@ namespace {
scoped_ptr<accounts_iterator> iter;
if (! report.HANDLED(sort_)) {
- iter.reset(new basic_accounts_iterator(*report.session.journal->master));
+ iter.reset(new basic_accounts_iterator(*report.session.journal->master));
} else {
- expr_t sort_expr(report.HANDLER(sort_).str());
- sort_expr.set_context(&report);
- iter.reset(new sorted_accounts_iterator(*report.session.journal->master,
- sort_expr, report.HANDLED(flat)));
+ expr_t sort_expr(report.HANDLER(sort_).str());
+ sort_expr.set_context(&report);
+ iter.reset(new sorted_accounts_iterator(*report.session.journal->master,
+ sort_expr, report.HANDLED(flat)));
}
if (report.HANDLED(display_)) {
- DEBUG("report.predicate",
- "Display predicate = " << report.HANDLER(display_).str());
- pass_down_accounts(handler, *iter.get(),
- predicate_t(report.HANDLER(display_).str(),
- report.what_to_keep()),
- report);
+ DEBUG("report.predicate",
+ "Display predicate = " << report.HANDLER(display_).str());
+ pass_down_accounts(handler, *iter.get(),
+ predicate_t(report.HANDLER(display_).str(),
+ report.what_to_keep()),
+ report);
} else {
- pass_down_accounts(handler, *iter.get());
+ pass_down_accounts(handler, *iter.get());
}
report.session.journal->clear_xdata();
@@ -396,7 +396,7 @@ void report_t::accounts_report(acct_handler_ptr handler)
{
post_handler_ptr chain =
chain_post_handlers(post_handler_ptr(new ignore_posts), *this,
- /* for_accounts_report= */ true);
+ /* for_accounts_report= */ true);
if (HANDLED(group_by_)) {
std::auto_ptr<post_splitter>
splitter(new post_splitter(chain, *this, HANDLER(group_by_).expr));
@@ -454,12 +454,12 @@ value_t report_t::fn_market(call_scope_t& scope)
value_t result;
optional<datetime_t> moment = (args.has(1) ?
- args.get<datetime_t>(1) :
- optional<datetime_t>());
+ args.get<datetime_t>(1) :
+ optional<datetime_t>());
if (args.has(2))
result = args.value_at(0).exchange_commodities(args.get<string>(2),
- /* add_prices= */ false,
- moment);
+ /* add_prices= */ false,
+ moment);
else
result = args.value_at(0).value(moment);
@@ -482,8 +482,8 @@ value_t report_t::fn_get_at(call_scope_t& scope)
} else {
if (! args.value_at(0).is_sequence())
throw_(std::runtime_error,
- _("Attempting to get argument at index %1 from %2")
- << args.get<long>(1) << args.value_at(0).label());
+ _("Attempting to get argument at index %1 from %2")
+ << args.get<long>(1) << args.value_at(0).label());
}
return args.get<const value_t::sequence_t&>(0)[args.get<long>(1)];
}
@@ -584,9 +584,9 @@ value_t report_t::fn_truncated(call_scope_t& scope)
{
interactive_t args(scope, "v&ll");
return string_value(format_t::truncate
- (args.get<string>(0),
- args.has(1) && args.get<int>(1) > 0 ? args.get<int>(1) : 0,
- args.has(2) ? args.get<int>(2) : 0));
+ (args.get<string>(0),
+ args.has(1) && args.get<int>(1) > 0 ? args.get<int>(1) : 0,
+ args.has(2) ? args.get<int>(2) : 0));
}
value_t report_t::fn_justify(call_scope_t& scope)
@@ -608,7 +608,7 @@ value_t report_t::fn_justify(call_scope_t& scope)
value_t report_t::fn_quoted(call_scope_t& scope)
{
- interactive_t args(scope, "v");
+ interactive_t args(scope, "v");
std::ostringstream out;
out << '"';
@@ -625,7 +625,7 @@ value_t report_t::fn_quoted(call_scope_t& scope)
value_t report_t::fn_join(call_scope_t& scope)
{
- interactive_t args(scope, "s");
+ interactive_t args(scope, "s");
std::ostringstream out;
foreach (const char ch, args.get<string>(0)) {
@@ -642,7 +642,7 @@ value_t report_t::fn_format_date(call_scope_t& scope)
interactive_t args(scope, "d&s");
if (args.has(1))
return string_value(format_date(args.get<date_t>(0), FMT_CUSTOM,
- args.get<string>(1).c_str()));
+ args.get<string>(1).c_str()));
else
return string_value(format_date(args.get<date_t>(0), FMT_PRINTED));
}
@@ -654,17 +654,17 @@ value_t report_t::fn_ansify_if(call_scope_t& scope)
if (args.has(1)) {
string color = args.get<string>(1);
std::ostringstream buf;
- if (color == "black") buf << "\033[30m";
- else if (color == "red") buf << "\033[31m";
- else if (color == "green") buf << "\033[32m";
- else if (color == "yellow") buf << "\033[33m";
- else if (color == "blue") buf << "\033[34m";
+ if (color == "black") buf << "\033[30m";
+ else if (color == "red") buf << "\033[31m";
+ else if (color == "green") buf << "\033[32m";
+ else if (color == "yellow") buf << "\033[33m";
+ else if (color == "blue") buf << "\033[34m";
else if (color == "magenta") buf << "\033[35m";
- else if (color == "cyan") buf << "\033[36m";
- else if (color == "white") buf << "\033[37m";
- else if (color == "bold") buf << "\033[1m";
+ else if (color == "cyan") buf << "\033[36m";
+ else if (color == "white") buf << "\033[37m";
+ else if (color == "bold") buf << "\033[1m";
else if (color == "underline") buf << "\033[4m";
- else if (color == "blink") buf << "\033[5m";
+ else if (color == "blink") buf << "\033[5m";
buf << args.value_at(0);
buf << "\033[0m";
return string_value(buf.str());
@@ -677,7 +677,7 @@ value_t report_t::fn_percent(call_scope_t& scope)
{
interactive_t args(scope, "aa");
return (amount_t("100.00%") *
- (args.get<amount_t>(0) / args.get<amount_t>(1)).number());
+ (args.get<amount_t>(0) / args.get<amount_t>(1)).number());
}
value_t report_t::fn_price(call_scope_t& scope)
@@ -1094,13 +1094,13 @@ option_t<report_t> * report_t::lookup_option(const char * p)
}
void report_t::define(const symbol_t::kind_t kind, const string& name,
- expr_t::ptr_op_t def)
+ expr_t::ptr_op_t def)
{
session.define(kind, name, def);
}
expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (expr_t::ptr_op_t def = session.lookup(kind, name))
return def;
@@ -1114,208 +1114,208 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
switch (*p) {
case 'd':
case 'm':
- return MAKE_FUNCTOR(report_t::fn_now);
+ return MAKE_FUNCTOR(report_t::fn_now);
case 'P':
- return MAKE_FUNCTOR(report_t::fn_market);
+ return MAKE_FUNCTOR(report_t::fn_market);
case 't':
- return MAKE_FUNCTOR(report_t::fn_display_amount);
+ return MAKE_FUNCTOR(report_t::fn_display_amount);
case 'T':
- return MAKE_FUNCTOR(report_t::fn_display_total);
+ return MAKE_FUNCTOR(report_t::fn_display_total);
case 'U':
- return MAKE_FUNCTOR(report_t::fn_abs);
+ return MAKE_FUNCTOR(report_t::fn_abs);
case 'S':
- return MAKE_FUNCTOR(report_t::fn_strip);
+ return MAKE_FUNCTOR(report_t::fn_strip);
case 'i':
- throw_(std::runtime_error,
- _("The i value expression variable is no longer supported"));
+ throw_(std::runtime_error,
+ _("The i value expression variable is no longer supported"));
case 'A':
- throw_(std::runtime_error,
- _("The A value expression variable is no longer supported"));
+ throw_(std::runtime_error,
+ _("The A value expression variable is no longer supported"));
case 'v':
case 'V':
- throw_(std::runtime_error,
- _("The V and v value expression variables are no longer supported"));
+ throw_(std::runtime_error,
+ _("The V and v value expression variables are no longer supported"));
case 'I':
case 'B':
- throw_(std::runtime_error,
- _("The I and B value expression variables are no longer supported"));
+ throw_(std::runtime_error,
+ _("The I and B value expression variables are no longer supported"));
case 'g':
case 'G':
- throw_(std::runtime_error,
- _("The G and g value expression variables are no longer supported"));
+ throw_(std::runtime_error,
+ _("The G and g value expression variables are no longer supported"));
default:
- return NULL;
+ return NULL;
}
}
switch (*p) {
case 'a':
if (is_eq(p, "amount_expr"))
- return MAKE_FUNCTOR(report_t::fn_amount_expr);
+ return MAKE_FUNCTOR(report_t::fn_amount_expr);
else if (is_eq(p, "ansify_if"))
- return MAKE_FUNCTOR(report_t::fn_ansify_if);
+ return MAKE_FUNCTOR(report_t::fn_ansify_if);
else if (is_eq(p, "abs"))
- return MAKE_FUNCTOR(report_t::fn_abs);
+ return MAKE_FUNCTOR(report_t::fn_abs);
break;
case 'b':
if (is_eq(p, "black"))
- return WRAP_FUNCTOR(fn_black);
+ return WRAP_FUNCTOR(fn_black);
else if (is_eq(p, "blink"))
- return WRAP_FUNCTOR(fn_blink);
+ return WRAP_FUNCTOR(fn_blink);
else if (is_eq(p, "blue"))
- return WRAP_FUNCTOR(fn_blue);
+ return WRAP_FUNCTOR(fn_blue);
else if (is_eq(p, "bold"))
- return WRAP_FUNCTOR(fn_bold);
+ return WRAP_FUNCTOR(fn_bold);
break;
case 'c':
if (is_eq(p, "cyan"))
- return WRAP_FUNCTOR(fn_cyan);
+ return WRAP_FUNCTOR(fn_cyan);
break;
case 'd':
if (is_eq(p, "display_amount"))
- return MAKE_FUNCTOR(report_t::fn_display_amount);
+ return MAKE_FUNCTOR(report_t::fn_display_amount);
else if (is_eq(p, "display_total"))
- return MAKE_FUNCTOR(report_t::fn_display_total);
+ return MAKE_FUNCTOR(report_t::fn_display_total);
else if (is_eq(p, "date"))
- return MAKE_FUNCTOR(report_t::fn_now);
+ return MAKE_FUNCTOR(report_t::fn_now);
break;
case 'f':
if (is_eq(p, "format_date"))
- return MAKE_FUNCTOR(report_t::fn_format_date);
+ return MAKE_FUNCTOR(report_t::fn_format_date);
else if (is_eq(p, "floor"))
- return MAKE_FUNCTOR(report_t::fn_floor);
+ return MAKE_FUNCTOR(report_t::fn_floor);
break;
case 'g':
if (is_eq(p, "get_at"))
- return MAKE_FUNCTOR(report_t::fn_get_at);
+ return MAKE_FUNCTOR(report_t::fn_get_at);
else if (is_eq(p, "green"))
- return WRAP_FUNCTOR(fn_green);
+ return WRAP_FUNCTOR(fn_green);
break;
case 'i':
if (is_eq(p, "is_seq"))
- return MAKE_FUNCTOR(report_t::fn_is_seq);
+ return MAKE_FUNCTOR(report_t::fn_is_seq);
break;
case 'j':
if (is_eq(p, "justify"))
- return MAKE_FUNCTOR(report_t::fn_justify);
+ return MAKE_FUNCTOR(report_t::fn_justify);
else if (is_eq(p, "join"))
- return MAKE_FUNCTOR(report_t::fn_join);
+ return MAKE_FUNCTOR(report_t::fn_join);
break;
case 'm':
if (is_eq(p, "market"))
- return MAKE_FUNCTOR(report_t::fn_market);
+ return MAKE_FUNCTOR(report_t::fn_market);
else if (is_eq(p, "magenta"))
- return WRAP_FUNCTOR(fn_magenta);
+ return WRAP_FUNCTOR(fn_magenta);
break;
case 'n':
if (is_eq(p, "null"))
- return WRAP_FUNCTOR(fn_null);
+ return WRAP_FUNCTOR(fn_null);
else if (is_eq(p, "now"))
- return MAKE_FUNCTOR(report_t::fn_now);
+ return MAKE_FUNCTOR(report_t::fn_now);
break;
case 'o':
if (is_eq(p, "options"))
- return MAKE_FUNCTOR(report_t::fn_options);
+ return MAKE_FUNCTOR(report_t::fn_options);
break;
case 'p':
if (is_eq(p, "post"))
- return WRAP_FUNCTOR(fn_false);
+ return WRAP_FUNCTOR(fn_false);
else if (is_eq(p, "percent"))
- return MAKE_FUNCTOR(report_t::fn_percent);
+ return MAKE_FUNCTOR(report_t::fn_percent);
else if (is_eq(p, "price"))
- return MAKE_FUNCTOR(report_t::fn_price);
+ return MAKE_FUNCTOR(report_t::fn_price);
else if (is_eq(p, "print"))
- return MAKE_FUNCTOR(report_t::fn_print);
+ return MAKE_FUNCTOR(report_t::fn_print);
break;
case 'q':
if (is_eq(p, "quoted"))
- return MAKE_FUNCTOR(report_t::fn_quoted);
+ return MAKE_FUNCTOR(report_t::fn_quoted);
else if (is_eq(p, "quantity"))
- return MAKE_FUNCTOR(report_t::fn_quantity);
+ return MAKE_FUNCTOR(report_t::fn_quantity);
break;
case 'r':
if (is_eq(p, "rounded"))
- return MAKE_FUNCTOR(report_t::fn_rounded);
+ return MAKE_FUNCTOR(report_t::fn_rounded);
else if (is_eq(p, "red"))
- return WRAP_FUNCTOR(fn_red);
+ return WRAP_FUNCTOR(fn_red);
break;
case 's':
if (is_eq(p, "scrub"))
- return MAKE_FUNCTOR(report_t::fn_scrub);
+ return MAKE_FUNCTOR(report_t::fn_scrub);
else if (is_eq(p, "strip"))
- return MAKE_FUNCTOR(report_t::fn_strip);
+ return MAKE_FUNCTOR(report_t::fn_strip);
break;
case 't':
if (is_eq(p, "truncated"))
- return MAKE_FUNCTOR(report_t::fn_truncated);
+ return MAKE_FUNCTOR(report_t::fn_truncated);
else if (is_eq(p, "total_expr"))
- return MAKE_FUNCTOR(report_t::fn_total_expr);
+ return MAKE_FUNCTOR(report_t::fn_total_expr);
else if (is_eq(p, "today"))
- return MAKE_FUNCTOR(report_t::fn_today);
+ return MAKE_FUNCTOR(report_t::fn_today);
else if (is_eq(p, "t"))
- return MAKE_FUNCTOR(report_t::fn_display_amount);
+ return MAKE_FUNCTOR(report_t::fn_display_amount);
else if (is_eq(p, "trim"))
- return MAKE_FUNCTOR(report_t::fn_trim);
+ return MAKE_FUNCTOR(report_t::fn_trim);
else if (is_eq(p, "to_boolean"))
- return MAKE_FUNCTOR(report_t::fn_to_boolean);
+ return MAKE_FUNCTOR(report_t::fn_to_boolean);
else if (is_eq(p, "to_int"))
- return MAKE_FUNCTOR(report_t::fn_to_int);
+ return MAKE_FUNCTOR(report_t::fn_to_int);
else if (is_eq(p, "to_datetime"))
- return MAKE_FUNCTOR(report_t::fn_to_datetime);
+ return MAKE_FUNCTOR(report_t::fn_to_datetime);
else if (is_eq(p, "to_date"))
- return MAKE_FUNCTOR(report_t::fn_to_date);
+ return MAKE_FUNCTOR(report_t::fn_to_date);
else if (is_eq(p, "to_amount"))
- return MAKE_FUNCTOR(report_t::fn_to_amount);
+ return MAKE_FUNCTOR(report_t::fn_to_amount);
else if (is_eq(p, "to_balance"))
- return MAKE_FUNCTOR(report_t::fn_to_balance);
+ return MAKE_FUNCTOR(report_t::fn_to_balance);
else if (is_eq(p, "to_string"))
- return MAKE_FUNCTOR(report_t::fn_to_string);
+ return MAKE_FUNCTOR(report_t::fn_to_string);
else if (is_eq(p, "to_mask"))
- return MAKE_FUNCTOR(report_t::fn_to_mask);
+ return MAKE_FUNCTOR(report_t::fn_to_mask);
else if (is_eq(p, "to_sequence"))
- return MAKE_FUNCTOR(report_t::fn_to_sequence);
+ return MAKE_FUNCTOR(report_t::fn_to_sequence);
break;
case 'T':
if (is_eq(p, "T"))
- return MAKE_FUNCTOR(report_t::fn_display_total);
+ return MAKE_FUNCTOR(report_t::fn_display_total);
break;
case 'u':
if (is_eq(p, "underline"))
- return WRAP_FUNCTOR(fn_underline);
+ return WRAP_FUNCTOR(fn_underline);
else if (is_eq(p, "unrounded"))
- return MAKE_FUNCTOR(report_t::fn_unrounded);
+ return MAKE_FUNCTOR(report_t::fn_unrounded);
break;
case 'v':
if (is_eq(p, "value_date"))
- return MAKE_FUNCTOR(report_t::fn_now);
+ return MAKE_FUNCTOR(report_t::fn_now);
break;
case 'w':
if (is_eq(p, "white"))
- return WRAP_FUNCTOR(fn_white);
+ return WRAP_FUNCTOR(fn_white);
break;
case 'y':
if (is_eq(p, "yellow"))
- return WRAP_FUNCTOR(fn_yellow);
+ return WRAP_FUNCTOR(fn_yellow);
break;
}
@@ -1333,135 +1333,135 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
switch (*p) {
case 'a':
if (is_eq(p, "accounts")) {
- return WRAP_FUNCTOR(reporter<>(new report_accounts(*this), *this,
- "#accounts"));
+ return WRAP_FUNCTOR(reporter<>(new report_accounts(*this), *this,
+ "#accounts"));
}
break;
case 'b':
if (*(p + 1) == '\0' || is_eq(p, "bal") || is_eq(p, "balance")) {
- return expr_t::op_t::wrap_functor
- (reporter<account_t, acct_handler_ptr, &report_t::accounts_report>
- (new format_accounts(*this, report_format(HANDLER(balance_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#balance"));
+ return expr_t::op_t::wrap_functor
+ (reporter<account_t, acct_handler_ptr, &report_t::accounts_report>
+ (new format_accounts(*this, report_format(HANDLER(balance_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#balance"));
}
else if (is_eq(p, "budget")) {
- HANDLER(amount_).set_expr(string("#budget"), "(amount, 0)");
-
- budget_flags |= BUDGET_WRAP_VALUES;
- if (! (budget_flags & ~BUDGET_WRAP_VALUES))
- budget_flags |= BUDGET_BUDGETED;
-
- return expr_t::op_t::wrap_functor
- (reporter<account_t, acct_handler_ptr, &report_t::accounts_report>
- (new format_accounts(*this, report_format(HANDLER(budget_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#budget"));
+ HANDLER(amount_).set_expr(string("#budget"), "(amount, 0)");
+
+ budget_flags |= BUDGET_WRAP_VALUES;
+ if (! (budget_flags & ~BUDGET_WRAP_VALUES))
+ budget_flags |= BUDGET_BUDGETED;
+
+ return expr_t::op_t::wrap_functor
+ (reporter<account_t, acct_handler_ptr, &report_t::accounts_report>
+ (new format_accounts(*this, report_format(HANDLER(budget_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#budget"));
}
break;
case 'c':
if (is_eq(p, "csv")) {
- return WRAP_FUNCTOR
- (reporter<>
- (new format_posts(*this, report_format(HANDLER(csv_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#csv"));
+ return WRAP_FUNCTOR
+ (reporter<>
+ (new format_posts(*this, report_format(HANDLER(csv_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#csv"));
}
else if (is_eq(p, "cleared")) {
- HANDLER(amount_).set_expr(string("#cleared"),
- "(amount, cleared ? amount : 0)");
- return expr_t::op_t::wrap_functor
- (reporter<account_t, acct_handler_ptr, &report_t::accounts_report>
- (new format_accounts(*this, report_format(HANDLER(cleared_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#cleared"));
+ HANDLER(amount_).set_expr(string("#cleared"),
+ "(amount, cleared ? amount : 0)");
+ return expr_t::op_t::wrap_functor
+ (reporter<account_t, acct_handler_ptr, &report_t::accounts_report>
+ (new format_accounts(*this, report_format(HANDLER(cleared_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#cleared"));
}
else if (is_eq(p, "convert")) {
- return WRAP_FUNCTOR(convert_command);
+ return WRAP_FUNCTOR(convert_command);
}
else if (is_eq(p, "commodities")) {
- return WRAP_FUNCTOR(reporter<>(new report_commodities(*this), *this,
- "#commodities"));
+ return WRAP_FUNCTOR(reporter<>(new report_commodities(*this), *this,
+ "#commodities"));
}
break;
case 'e':
if (is_eq(p, "equity")) {
- HANDLER(generated).on_only(string("#equity"));
- return WRAP_FUNCTOR(reporter<>(new print_xacts(*this), *this, "#equity"));
+ HANDLER(generated).on_only(string("#equity"));
+ return WRAP_FUNCTOR(reporter<>(new print_xacts(*this), *this, "#equity"));
}
else if (is_eq(p, "entry")) {
- return WRAP_FUNCTOR(xact_command);
+ return WRAP_FUNCTOR(xact_command);
}
else if (is_eq(p, "emacs")) {
- return WRAP_FUNCTOR
- (reporter<>(new format_emacs_posts(output_stream), *this, "#emacs"));
+ return WRAP_FUNCTOR
+ (reporter<>(new format_emacs_posts(output_stream), *this, "#emacs"));
}
else if (is_eq(p, "echo")) {
- return MAKE_FUNCTOR(report_t::echo_command);
+ return MAKE_FUNCTOR(report_t::echo_command);
}
break;
case 'p':
if (*(p + 1) == '\0' || is_eq(p, "print")) {
- return WRAP_FUNCTOR
- (reporter<>(new print_xacts(*this, HANDLED(raw)), *this, "#print"));
+ return WRAP_FUNCTOR
+ (reporter<>(new print_xacts(*this, HANDLED(raw)), *this, "#print"));
}
else if (is_eq(p, "prices")) {
- return expr_t::op_t::wrap_functor
- (reporter<post_t, post_handler_ptr, &report_t::commodities_report>
- (new format_posts(*this, report_format(HANDLER(prices_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#prices"));
+ return expr_t::op_t::wrap_functor
+ (reporter<post_t, post_handler_ptr, &report_t::commodities_report>
+ (new format_posts(*this, report_format(HANDLER(prices_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#prices"));
}
else if (is_eq(p, "pricedb")) {
- return expr_t::op_t::wrap_functor
- (reporter<post_t, post_handler_ptr, &report_t::commodities_report>
- (new format_posts(*this, report_format(HANDLER(pricedb_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#pricedb"));
+ return expr_t::op_t::wrap_functor
+ (reporter<post_t, post_handler_ptr, &report_t::commodities_report>
+ (new format_posts(*this, report_format(HANDLER(pricedb_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#pricedb"));
}
else if (is_eq(p, "pricemap")) {
- return MAKE_FUNCTOR(report_t::pricemap_command);
+ return MAKE_FUNCTOR(report_t::pricemap_command);
}
else if (is_eq(p, "payees")) {
- return WRAP_FUNCTOR(reporter<>(new report_payees(*this), *this,
- "#payees"));
+ return WRAP_FUNCTOR(reporter<>(new report_payees(*this), *this,
+ "#payees"));
}
break;
case 'r':
if (*(p + 1) == '\0' || is_eq(p, "reg") || is_eq(p, "register")) {
- return WRAP_FUNCTOR
- (reporter<>
- (new format_posts(*this, report_format(HANDLER(register_format_)),
- maybe_format(HANDLER(prepend_format_)),
- HANDLER(prepend_width_).value.to_long()),
- *this, "#register"));
+ return WRAP_FUNCTOR
+ (reporter<>
+ (new format_posts(*this, report_format(HANDLER(register_format_)),
+ maybe_format(HANDLER(prepend_format_)),
+ HANDLER(prepend_width_).value.to_long()),
+ *this, "#register"));
}
else if (is_eq(p, "reload")) {
- return MAKE_FUNCTOR(report_t::reload_command);
+ return MAKE_FUNCTOR(report_t::reload_command);
}
break;
case 's':
if (is_eq(p, "stats") || is_eq(p, "stat"))
- return WRAP_FUNCTOR(report_statistics);
+ return WRAP_FUNCTOR(report_statistics);
break;
case 'x':
if (is_eq(p, "xact"))
- return WRAP_FUNCTOR(xact_command);
+ return WRAP_FUNCTOR(xact_command);
else if (is_eq(p, "xml"))
- return WRAP_FUNCTOR(reporter<>(new format_xml(*this), *this, "#xml"));
+ return WRAP_FUNCTOR(reporter<>(new format_xml(*this), *this, "#xml"));
break;
}
break;
@@ -1470,38 +1470,38 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
switch (*p) {
case 'a':
if (is_eq(p, "args"))
- return WRAP_FUNCTOR(query_command);
+ return WRAP_FUNCTOR(query_command);
break;
case 'e':
if (is_eq(p, "eval"))
- return WRAP_FUNCTOR(eval_command);
+ return WRAP_FUNCTOR(eval_command);
else if (is_eq(p, "expr"))
- return WRAP_FUNCTOR(parse_command);
+ return WRAP_FUNCTOR(parse_command);
break;
case 'f':
if (is_eq(p, "format"))
- return WRAP_FUNCTOR(format_command);
+ return WRAP_FUNCTOR(format_command);
break;
case 'g':
if (is_eq(p, "generate")) {
- return expr_t::op_t::wrap_functor
- (reporter<post_t, post_handler_ptr, &report_t::generate_report>
- (new print_xacts(*this), *this, "#generate"));
+ return expr_t::op_t::wrap_functor
+ (reporter<post_t, post_handler_ptr, &report_t::generate_report>
+ (new print_xacts(*this), *this, "#generate"));
}
break;
case 'p':
if (is_eq(p, "parse"))
- return WRAP_FUNCTOR(parse_command);
+ return WRAP_FUNCTOR(parse_command);
else if (is_eq(p, "period"))
- return WRAP_FUNCTOR(period_command);
+ return WRAP_FUNCTOR(period_command);
break;
case 'q':
if (is_eq(p, "query"))
- return WRAP_FUNCTOR(query_command);
+ return WRAP_FUNCTOR(query_command);
break;
case 't':
if (is_eq(p, "template"))
- return WRAP_FUNCTOR(template_command);
+ return WRAP_FUNCTOR(template_command);
break;
}
break;
diff --git a/src/report.h b/src/report.h
index 9e70551f..f1a213c1 100644
--- a/src/report.h
+++ b/src/report.h
@@ -107,11 +107,11 @@ class report_t : public scope_t
report_t();
public:
- session_t& session;
+ session_t& session;
output_stream_t output_stream;
#define BUDGET_NO_BUDGET 0x00
-#define BUDGET_BUDGETED 0x01
+#define BUDGET_BUDGETED 0x01
#define BUDGET_UNBUDGETED 0x02
#define BUDGET_WRAP_VALUES 0x04
@@ -203,9 +203,9 @@ public:
keep_details_t what_to_keep() {
bool lots = HANDLED(lots) || HANDLED(lots_actual);
return keep_details_t(lots || HANDLED(lot_prices),
- lots || HANDLED(lot_dates),
- lots || HANDLED(lot_tags),
- HANDLED(lots_actual));
+ lots || HANDLED(lot_dates),
+ lots || HANDLED(lot_tags),
+ HANDLED(lots_actual));
}
void report_options(std::ostream& out)
@@ -331,17 +331,17 @@ public:
option_t<report_t> * lookup_option(const char * p);
virtual void define(const symbol_t::kind_t kind, const string& name,
- expr_t::ptr_op_t def);
+ expr_t::ptr_op_t def);
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
/**
* Option handlers
*/
OPTION__(report_t, abbrev_len_,
- CTOR(report_t, abbrev_len_) { on_with(none, 2L); });
+ CTOR(report_t, abbrev_len_) { on_with(none, 2L); });
OPTION(report_t, account_);
OPTION_(report_t, actual, DO() { // -L
@@ -373,16 +373,16 @@ public:
OPTION_(report_t, average, DO() { // -A
parent->HANDLER(display_total_)
- .set_expr(string("--average"), "count>0?(total_expr/count):0");
+ .set_expr(string("--average"), "count>0?(total_expr/count):0");
});
OPTION__(report_t, balance_format_, CTOR(report_t, balance_format_) {
on(none,
- "%(justify(scrub(display_total), 20, 20 + prepend_width, true, color))"
- " %(!options.flat ? depth_spacer : \"\")"
- "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
- "%$1\n%/"
- "--------------------\n");
+ "%(justify(scrub(display_total), 20, 20 + prepend_width, true, color))"
+ " %(!options.flat ? depth_spacer : \"\")"
+ "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
+ "%$1\n%/"
+ "--------------------\n");
});
OPTION(report_t, base);
@@ -396,9 +396,9 @@ public:
date_interval_t interval(args[1].to_string());
optional<date_t> begin = interval.begin(parent->session.current_year);
if (! begin)
- throw_(std::invalid_argument,
- _("Could not determine beginning of period '%1'")
- << args[1].to_string());
+ throw_(std::invalid_argument,
+ _("Could not determine beginning of period '%1'")
+ << args[1].to_string());
string predicate = "date>=[" + to_iso_extended_string(*begin) + "]";
parent->HANDLER(limit_).on(string("--begin"), predicate);
@@ -410,24 +410,24 @@ public:
OPTION__(report_t, budget_format_, CTOR(report_t, budget_format_) {
on(none,
- "%(justify(scrub(get_at(total_expr, 0)), 12, -1, true, color))"
- " %(justify(-scrub(get_at(total_expr, 1)), 12, "
- " 12 + 1 + 12, true, color))"
- " %(justify(scrub(get_at(total_expr, 1) + "
- " get_at(total_expr, 0)), 12, "
- " 12 + 1 + 12 + 1 + 12, true, color))"
- " %(ansify_if("
- " justify((get_at(total_expr, 1) ? "
- " (100% * scrub(get_at(total_expr, 0))) / "
- " -scrub(get_at(total_expr, 1)) : 0), "
- " 5, -1, true, false),"
- " magenta if (color and get_at(total_expr, 1) and "
- " (abs(quantity(scrub(get_at(total_expr, 0))) / "
- " quantity(scrub(get_at(total_expr, 1)))) >= 1))))"
- " %(!options.flat ? depth_spacer : \"\")"
- "%-(ansify_if(partial_account(options.flat), blue if color))\n"
- "%/%$1 %$2 %$3 %$4\n%/"
- "------------ ------------ ------------ -----\n");
+ "%(justify(scrub(get_at(total_expr, 0)), 12, -1, true, color))"
+ " %(justify(-scrub(get_at(total_expr, 1)), 12, "
+ " 12 + 1 + 12, true, color))"
+ " %(justify(scrub(get_at(total_expr, 1) + "
+ " get_at(total_expr, 0)), 12, "
+ " 12 + 1 + 12 + 1 + 12, true, color))"
+ " %(ansify_if("
+ " justify((get_at(total_expr, 1) ? "
+ " (100% * scrub(get_at(total_expr, 0))) / "
+ " -scrub(get_at(total_expr, 1)) : 0), "
+ " 5, -1, true, false),"
+ " magenta if (color and get_at(total_expr, 1) and "
+ " (abs(quantity(scrub(get_at(total_expr, 0))) / "
+ " quantity(scrub(get_at(total_expr, 1)))) >= 1))))"
+ " %(!options.flat ? depth_spacer : \"\")"
+ "%-(ansify_if(partial_account(options.flat), blue if color))\n"
+ "%/%$1 %$2 %$3 %$4\n%/"
+ "------------ ------------ ------------ -----\n");
});
OPTION(report_t, by_payee); // -P
@@ -438,14 +438,14 @@ public:
OPTION__(report_t, cleared_format_, CTOR(report_t, cleared_format_) {
on(none,
- "%(justify(scrub(get_at(total_expr, 0)), 16, 16 + prepend_width, "
- " true, color)) %(justify(scrub(get_at(total_expr, 1)), 18, "
- " 36 + prepend_width, true, color))"
- " %(latest_cleared ? format_date(latest_cleared) : \" \")"
- " %(!options.flat ? depth_spacer : \"\")"
- "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
- "%$1 %$2 %$3\n%/"
- "---------------- ---------------- ---------\n");
+ "%(justify(scrub(get_at(total_expr, 0)), 16, 16 + prepend_width, "
+ " true, color)) %(justify(scrub(get_at(total_expr, 1)), 18, "
+ " 36 + prepend_width, true, color))"
+ " %(latest_cleared ? format_date(latest_cleared) : \" \")"
+ " %(!options.flat ? depth_spacer : \"\")"
+ "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
+ "%$1 %$2 %$3\n%/"
+ "---------------- ---------------- ---------\n");
});
OPTION(report_t, color);
@@ -465,14 +465,14 @@ public:
OPTION__(report_t, csv_format_, CTOR(report_t, csv_format_) {
on(none,
- "%(quoted(date)),"
- "%(quoted(code)),"
- "%(quoted(payee)),"
- "%(quoted(display_account)),"
- "%(quoted(commodity)),"
- "%(quoted(quantity(scrub(display_amount)))),"
- "%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))),"
- "%(quoted(join(note | xact.note)))\n");
+ "%(quoted(date)),"
+ "%(quoted(code)),"
+ "%(quoted(payee)),"
+ "%(quoted(display_account)),"
+ "%(quoted(commodity)),"
+ "%(quoted(quantity(scrub(display_amount)))),"
+ "%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))),"
+ "%(quoted(join(note | xact.note)))\n");
});
OPTION_(report_t, current, DO() { // -c
@@ -490,12 +490,12 @@ public:
OPTION_(report_t, depth_, DO_(scope) {
interactive_t args(scope, "sl");
parent->HANDLER(display_).on(string("--depth"),
- string("depth<=") + args.get<string>(1));
+ string("depth<=") + args.get<string>(1));
});
OPTION_(report_t, deviation, DO() {
parent->HANDLER(display_total_)
- .set_expr(string("--deviation"), "amount_expr-total_expr/count");
+ .set_expr(string("--deviation"), "amount_expr-total_expr/count");
});
OPTION__
@@ -506,8 +506,8 @@ public:
option_t<report_t>::on_with(whence, text);
else
option_t<report_t>::on_with(whence,
- string_value(string("(") + str() + ")&(" +
- text.as_string() + ")"));
+ string_value(string("(") + str() + ")&(" +
+ text.as_string() + ")"));
});
OPTION__
@@ -548,9 +548,9 @@ public:
// 2008/01/01 instead of 2009/01/01 (which is what end() would return).
optional<date_t> end = interval.begin(parent->session.current_year);
if (! end)
- throw_(std::invalid_argument,
- _("Could not determine end of period '%1'")
- << args[1].to_string());
+ throw_(std::invalid_argument,
+ _("Could not determine end of period '%1'")
+ << args[1].to_string());
string predicate = "date<[" + to_iso_extended_string(*end) + "]";
parent->HANDLER(limit_).on(string("--end"), predicate);
@@ -582,21 +582,21 @@ public:
// Since we are displaying the amounts of revalued postings, they
// will end up being composite totals, and hence a pair of pairs.
parent->HANDLER(display_amount_)
- .set_expr(string("--gain"),
- "use_direct_amount ? amount :"
- " (is_seq(get_at(amount_expr, 0)) ?"
- " get_at(get_at(amount_expr, 0), 0) :"
- " market(get_at(amount_expr, 0), value_date, exchange)"
- " - get_at(amount_expr, 1))");
+ .set_expr(string("--gain"),
+ "use_direct_amount ? amount :"
+ " (is_seq(get_at(amount_expr, 0)) ?"
+ " get_at(get_at(amount_expr, 0), 0) :"
+ " market(get_at(amount_expr, 0), value_date, exchange)"
+ " - get_at(amount_expr, 1))");
parent->HANDLER(revalued_total_)
- .set_expr(string("--gain"),
- "(market(get_at(total_expr, 0), value_date, exchange), "
- "get_at(total_expr, 1))");
+ .set_expr(string("--gain"),
+ "(market(get_at(total_expr, 0), value_date, exchange), "
+ "get_at(total_expr, 1))");
parent->HANDLER(display_total_)
- .set_expr(string("--gain"),
- "use_direct_amount ? total_expr :"
- " market(get_at(total_expr, 0), value_date, exchange)"
- " - get_at(total_expr, 1)");
+ .set_expr(string("--gain"),
+ "use_direct_amount ? total_expr :"
+ " market(get_at(total_expr, 0), value_date, exchange)"
+ " - get_at(total_expr, 1)");
});
OPTION(report_t, generated);
@@ -631,8 +631,8 @@ public:
option_t<report_t>::on_with(whence, text);
else
option_t<report_t>::on_with(whence,
- string_value(string("(") + str() + ")&(" +
- text.as_string() + ")"));
+ string_value(string("(") + str() + ")&(" +
+ text.as_string() + ")"));
});
OPTION(report_t, lot_dates);
@@ -644,11 +644,11 @@ public:
OPTION_(report_t, market, DO() { // -V
parent->HANDLER(revalued).on_only(string("--market"));
parent->HANDLER(display_amount_)
- .set_expr(string("--market"),
- "market(amount_expr, value_date, exchange)");
+ .set_expr(string("--market"),
+ "market(amount_expr, value_date, exchange)");
parent->HANDLER(display_total_)
- .set_expr(string("--market"),
- "market(total_expr, value_date, exchange)");
+ .set_expr(string("--market"),
+ "market(total_expr, value_date, exchange)");
});
OPTION(report_t, meta_);
@@ -669,9 +669,9 @@ public:
date_interval_t interval(args[1].to_string());
optional<date_t> begin = interval.begin(parent->session.current_year);
if (! begin)
- throw_(std::invalid_argument,
- _("Could not determine beginning of period '%1'")
- << args[1].to_string());
+ throw_(std::invalid_argument,
+ _("Could not determine beginning of period '%1'")
+ << args[1].to_string());
ledger::epoch = parent->terminus = datetime_t(*begin);
parent->session.current_year = ledger::epoch->date().year();
});
@@ -684,8 +684,8 @@ public:
option_t<report_t>::on_with(whence, text);
else
option_t<report_t>::on_with(whence,
- string_value(string("(") + str() + ")&(" +
- text.as_string() + ")"));
+ string_value(string("(") + str() + ")&(" +
+ text.as_string() + ")"));
});
OPTION(report_t, output_); // -o
@@ -697,20 +697,20 @@ public:
if (! std::getenv("PAGER") && isatty(STDOUT_FILENO)) {
bool have_less = false;
if (exists(path("/opt/local/bin/less")) ||
- exists(path("/usr/local/bin/less")) ||
- exists(path("/usr/bin/less")))
- have_less = true;
+ exists(path("/usr/local/bin/less")) ||
+ exists(path("/usr/bin/less")))
+ have_less = true;
if (have_less) {
- on(none, "less");
- setenv("LESS", "-FRSX", 0); // don't overwrite
+ on(none, "less");
+ setenv("LESS", "-FRSX", 0); // don't overwrite
}
}
}
virtual void on_with(const optional<string>& whence, const value_t& text) {
string cmd(text.to_string());
if (cmd == "" || cmd == "false" || cmd == "off" ||
- cmd == "none" || cmd == "no" || cmd == "disable")
+ cmd == "none" || cmd == "no" || cmd == "disable")
option_t<report_t>::off();
else
option_t<report_t>::on_with(whence, text);
@@ -723,7 +723,7 @@ public:
virtual void on_with(const optional<string>& whence, const value_t& text) {
string cmd(text.to_string());
if (cmd == "" || cmd == "false" || cmd == "off" ||
- cmd == "none" || cmd == "no" || cmd == "disable")
+ cmd == "none" || cmd == "no" || cmd == "disable")
option_t<report_t>::off();
else
option_t<report_t>::on_with(whence, text);
@@ -738,9 +738,9 @@ public:
OPTION_(report_t, percent, DO() { // -%
parent->HANDLER(total_)
- .set_expr(string("--percent"),
- "((is_account&parent&parent.total)?"
- " percent(scrub(total), scrub(parent.total)):0");
+ .set_expr(string("--percent"),
+ "((is_account&parent&parent.total)?"
+ " percent(scrub(total), scrub(parent.total)):0");
});
OPTION__
@@ -751,19 +751,19 @@ public:
option_t<report_t>::on_with(whence, text);
else
option_t<report_t>::on_with(whence,
- string_value(text.as_string() + " " + str()));
+ string_value(text.as_string() + " " + str()));
});
OPTION(report_t, pivot_);
OPTION__(report_t, plot_amount_format_, CTOR(report_t, plot_amount_format_) {
on(none,
- "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_amount)))\n");
+ "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_amount)))\n");
});
OPTION__(report_t, plot_total_format_, CTOR(report_t, plot_total_format_) {
on(none,
- "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_total)))\n");
+ "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_total)))\n");
});
OPTION(report_t, prepend_format_);
@@ -773,20 +773,20 @@ public:
OPTION_(report_t, price, DO() { // -I
parent->HANDLER(display_amount_)
- .set_expr(string("--price"), "price(amount_expr)");
+ .set_expr(string("--price"), "price(amount_expr)");
parent->HANDLER(display_total_)
- .set_expr(string("--price"), "price(total_expr)");
+ .set_expr(string("--price"), "price(total_expr)");
});
OPTION__(report_t, prices_format_, CTOR(report_t, prices_format_) {
on(none,
- "%(date) %-8(display_account) %(justify(scrub(display_amount), 12, "
- " 2 + 9 + 8 + 12, true, color))\n");
+ "%(date) %-8(display_account) %(justify(scrub(display_amount), 12, "
+ " 2 + 9 + 8 + 12, true, color))\n");
});
OPTION__(report_t, pricedb_format_, CTOR(report_t, pricedb_format_) {
on(none,
- "P %(datetime) %(display_account) %(scrub(display_amount))\n");
+ "P %(datetime) %(display_account) %(scrub(display_amount))\n");
});
OPTION_(report_t, quantity, DO() { // -O
@@ -807,20 +807,20 @@ public:
OPTION__(report_t, register_format_, CTOR(report_t, register_format_) {
on(none,
- "%(ansify_if(justify(format_date(date), date_width), green "
- " if color & date > today))"
- " %(ansify_if(justify(truncated(payee, payee_width), payee_width), "
- " bold if color & !cleared & actual))"
- " %(ansify_if(justify(truncated(display_account, account_width, "
- " abbrev_len), account_width), blue if color))"
- " %(justify(scrub(display_amount), amount_width, "
- " 3 + meta_width + date_width + payee_width + account_width"
- " + amount_width + prepend_width, true, color))"
- " %(justify(scrub(display_total), total_width, "
- " 4 + meta_width + date_width + payee_width + account_width"
- " + amount_width + total_width + prepend_width, true, color))\n%/"
- "%(justify(\" \", 2 + date_width + payee_width))"
- "%$3 %$4 %$5\n");
+ "%(ansify_if(justify(format_date(date), date_width), green "
+ " if color & date > today))"
+ " %(ansify_if(justify(truncated(payee, payee_width), payee_width), "
+ " bold if color & !cleared & actual))"
+ " %(ansify_if(justify(truncated(display_account, account_width, "
+ " abbrev_len), account_width), blue if color))"
+ " %(justify(scrub(display_amount), amount_width, "
+ " 3 + meta_width + date_width + payee_width + account_width"
+ " + amount_width + prepend_width, true, color))"
+ " %(justify(scrub(display_total), total_width, "
+ " 4 + meta_width + date_width + payee_width + account_width"
+ " + amount_width + total_width + prepend_width, true, color))\n%/"
+ "%(justify(\" \", 2 + date_width + payee_width))"
+ "%$3 %$4 %$5\n");
});
OPTION(report_t, related); // -r
@@ -885,14 +885,14 @@ public:
OPTION_(report_t, truncate_, DO_(args) {
string style(args[1].to_string());
if (style == "leading")
- format_t::default_style = format_t::TRUNCATE_LEADING;
+ format_t::default_style = format_t::TRUNCATE_LEADING;
else if (style == "middle")
- format_t::default_style = format_t::TRUNCATE_MIDDLE;
+ format_t::default_style = format_t::TRUNCATE_MIDDLE;
else if (style == "trailing")
- format_t::default_style = format_t::TRUNCATE_TRAILING;
+ format_t::default_style = format_t::TRUNCATE_TRAILING;
else
- throw_(std::invalid_argument,
- _("Unrecognized truncation style: '%1'") << style);
+ throw_(std::invalid_argument,
+ _("Unrecognized truncation style: '%1'") << style);
format_t::default_style_changed = true;
});
@@ -911,9 +911,9 @@ public:
OPTION_(report_t, unround, DO() {
parent->HANDLER(display_amount_)
- .set_expr(string("--unround"), "unrounded(amount_expr)");
+ .set_expr(string("--unround"), "unrounded(amount_expr)");
parent->HANDLER(display_total_)
- .set_expr(string("--unround"), "unrounded(total_expr)");
+ .set_expr(string("--unround"), "unrounded(total_expr)");
});
OPTION(report_t, unsorted);
@@ -931,36 +931,36 @@ public:
});
OPTION__(report_t, meta_width_,
- bool specified;
- CTOR(report_t, meta_width_) { specified = false; }
- DO_(args) { value = args[1].to_long(); specified = true; });
+ bool specified;
+ CTOR(report_t, meta_width_) { specified = false; }
+ DO_(args) { value = args[1].to_long(); specified = true; });
OPTION__(report_t, date_width_,
- bool specified;
- CTOR(report_t, date_width_) { specified = false; }
- DO_(args) { value = args[1].to_long(); specified = true; });
+ bool specified;
+ CTOR(report_t, date_width_) { specified = false; }
+ DO_(args) { value = args[1].to_long(); specified = true; });
OPTION__(report_t, payee_width_,
- bool specified;
- CTOR(report_t, payee_width_) { specified = false; }
- DO_(args) { value = args[1].to_long(); specified = true; });
+ bool specified;
+ CTOR(report_t, payee_width_) { specified = false; }
+ DO_(args) { value = args[1].to_long(); specified = true; });
OPTION__(report_t, account_width_,
- bool specified;
- CTOR(report_t, account_width_) { specified = false; }
- DO_(args) { value = args[1].to_long(); specified = true; });
+ bool specified;
+ CTOR(report_t, account_width_) { specified = false; }
+ DO_(args) { value = args[1].to_long(); specified = true; });
OPTION__(report_t, amount_width_,
- bool specified;
- CTOR(report_t, amount_width_) { specified = false; }
- DO_(args) { value = args[1].to_long(); specified = true; });
+ bool specified;
+ CTOR(report_t, amount_width_) { specified = false; }
+ DO_(args) { value = args[1].to_long(); specified = true; });
OPTION__(report_t, total_width_,
- bool specified;
- CTOR(report_t, total_width_) { specified = false; }
- DO_(args) { value = args[1].to_long(); specified = true; });
+ bool specified;
+ CTOR(report_t, total_width_) { specified = false; }
+ DO_(args) { value = args[1].to_long(); specified = true; });
};
template <class Type = post_t,
- class handler_ptr = post_handler_ptr,
- void (report_t::*report_method)(handler_ptr) =
- &report_t::posts_report>
+ class handler_ptr = post_handler_ptr,
+ void (report_t::*report_method)(handler_ptr) =
+ &report_t::posts_report>
class reporter
{
shared_ptr<item_handler<Type> > handler;
@@ -970,7 +970,7 @@ class reporter
public:
reporter(item_handler<Type> * _handler,
- report_t& _report, const string& _whence)
+ report_t& _report, const string& _whence)
: handler(_handler), report(_report), whence(_whence) {}
value_t operator()(call_scope_t& args)
diff --git a/src/scope.cc b/src/scope.cc
index 72cf4ad3..faad352a 100644
--- a/src/scope.cc
+++ b/src/scope.cc
@@ -38,7 +38,7 @@ namespace ledger {
scope_t * scope_t::default_scope = NULL;
void symbol_scope_t::define(const symbol_t::kind_t kind,
- const string& name, expr_t::ptr_op_t def)
+ const string& name, expr_t::ptr_op_t def)
{
DEBUG("scope.symbols", "Defining '" << name << "' = " << def);
@@ -53,15 +53,15 @@ void symbol_scope_t::define(const symbol_t::kind_t kind,
symbols->erase(i);
result = symbols->insert(symbol_map::value_type(symbol_t(kind, name, def),
- def));
+ def));
if (! result.second)
throw_(compile_error,
- _("Redefinition of '%1' in the same scope") << name);
+ _("Redefinition of '%1' in the same scope") << name);
}
}
expr_t::ptr_op_t symbol_scope_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (symbols) {
symbol_map::const_iterator i = symbols->find(symbol_t(kind, name));
diff --git a/src/scope.h b/src/scope.h
index 1e6f24a1..e3dd3e3f 100644
--- a/src/scope.h
+++ b/src/scope.h
@@ -58,8 +58,8 @@ struct symbol_t
FORMAT
};
- kind_t kind;
- string name;
+ kind_t kind;
+ string name;
expr_t::ptr_op_t definition;
symbol_t() : kind(UNKNOWN), name(""), definition(NULL) {
@@ -110,9 +110,9 @@ public:
}
virtual void define(const symbol_t::kind_t, const string&,
- expr_t::ptr_op_t) {}
+ expr_t::ptr_op_t) {}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name) = 0;
+ const string& name) = 0;
#if defined(HAVE_BOOST_SERIALIZATION)
private:
@@ -142,13 +142,13 @@ public:
}
virtual void define(const symbol_t::kind_t kind,
- const string& name, expr_t::ptr_op_t def) {
+ const string& name, expr_t::ptr_op_t def) {
if (parent)
parent->define(kind, name, def);
}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name) {
+ const string& name) {
if (parent)
return parent->lookup(kind, name);
return NULL;
@@ -186,10 +186,10 @@ public:
}
virtual void define(const symbol_t::kind_t kind, const string& name,
- expr_t::ptr_op_t def);
+ expr_t::ptr_op_t def);
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
#if defined(HAVE_BOOST_SERIALIZATION)
private:
@@ -292,7 +292,7 @@ public:
scope_t& grandchild;
explicit bind_scope_t(scope_t& _parent,
- scope_t& _grandchild)
+ scope_t& _grandchild)
: child_scope_t(_parent), grandchild(_grandchild) {
TRACE_CTOR(bind_scope_t, "scope_t&, scope_t&");
}
@@ -301,13 +301,13 @@ public:
}
virtual void define(const symbol_t::kind_t kind, const string& name,
- expr_t::ptr_op_t def) {
+ expr_t::ptr_op_t def) {
parent->define(kind, name, def);
grandchild.define(kind, name, def);
}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name) {
+ const string& name) {
if (expr_t::ptr_op_t def = grandchild.lookup(kind, name))
return def;
return child_scope_t::lookup(kind, name);
@@ -366,7 +366,7 @@ public:
value_scope_t(const value_t& _value) : value(_value) {}
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (kind != symbol_t::FUNCTION)
return NULL;
diff --git a/src/session.cc b/src/session.cc
index f8befde4..8adfef38 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -105,37 +105,37 @@ std::size_t session_t::read_data(const string& master_account)
cache = archive_t(HANDLED(cache_).str());
if (! (cache &&
- cache->should_load(HANDLER(file_).data_files) &&
- cache->load(*journal.get()))) {
+ cache->should_load(HANDLER(file_).data_files) &&
+ cache->load(*journal.get()))) {
#endif // HAVE_BOOST_SERIALIZATION
if (price_db_path) {
if (exists(*price_db_path)) {
- if (journal->read(*price_db_path) > 0)
- throw_(parse_error, _("Transactions not allowed in price history file"));
+ if (journal->read(*price_db_path) > 0)
+ throw_(parse_error, _("Transactions not allowed in price history file"));
}
}
foreach (const path& pathname, HANDLER(file_).data_files) {
if (pathname == "-") {
- // To avoid problems with stdin and pipes, etc., we read the entire
- // file in beforehand into a memory buffer, and then parcel it out
- // from there.
- std::ostringstream buffer;
-
- while (std::cin.good() && ! std::cin.eof()) {
- char line[8192];
- std::cin.read(line, 8192);
- std::streamsize count = std::cin.gcount();
- buffer.write(line, count);
- }
- buffer.flush();
-
- std::istringstream buf_in(buffer.str());
-
- xact_count += journal->read(buf_in, "/dev/stdin", acct);
- journal->sources.push_back(journal_t::fileinfo_t());
+ // To avoid problems with stdin and pipes, etc., we read the entire
+ // file in beforehand into a memory buffer, and then parcel it out
+ // from there.
+ std::ostringstream buffer;
+
+ while (std::cin.good() && ! std::cin.eof()) {
+ char line[8192];
+ std::cin.read(line, 8192);
+ std::streamsize count = std::cin.gcount();
+ buffer.write(line, count);
+ }
+ buffer.flush();
+
+ std::istringstream buf_in(buffer.str());
+
+ xact_count += journal->read(buf_in, "/dev/stdin", acct);
+ journal->sources.push_back(journal_t::fileinfo_t());
} else {
- xact_count += journal->read(pathname, acct);
+ xact_count += journal->read(pathname, acct);
}
}
@@ -166,7 +166,7 @@ void session_t::read_journal_files()
std::size_t count = read_data(master_account);
if (count == 0)
throw_(parse_error,
- _("Failed to locate any transactions; did you specify a valid file with -f?"));
+ _("Failed to locate any transactions; did you specify a valid file with -f?"));
INFO_FINISH(journal);
@@ -222,7 +222,7 @@ option_t<session_t> * session_t::lookup_option(const char * p)
}
expr_t::ptr_op_t session_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
switch (kind) {
case symbol_t::FUNCTION:
diff --git a/src/session.h b/src/session.h
index 3916b964..4968f1b8 100644
--- a/src/session.h
+++ b/src/session.h
@@ -57,8 +57,8 @@ class session_t : public symbol_scope_t
friend void set_session_context(session_t * session);
public:
- bool flush_on_next_data_file;
- date_t::year_type current_year;
+ bool flush_on_next_data_file;
+ date_t::year_type current_year;
std::auto_ptr<journal_t> journal;
explicit session_t();
@@ -91,7 +91,7 @@ public:
option_t<session_t> * lookup_option(const char * p);
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
/**
* Option handlers
diff --git a/src/stats.cc b/src/stats.cc
index 86a8338d..172971aa 100644
--- a/src/stats.cc
+++ b/src/stats.cc
@@ -58,11 +58,11 @@ value_t report_statistics(call_scope_t& args)
{
straccstream accum;
out << ACCUM(accum << _("Time period: %1 to %2 (%3 days)")
- << format_date(statistics.earliest_post)
- << format_date(statistics.latest_post)
- << (statistics.latest_post -
- statistics.earliest_post).days())
- << std::endl << std::endl;
+ << format_date(statistics.earliest_post)
+ << format_date(statistics.latest_post)
+ << (statistics.latest_post -
+ statistics.earliest_post).days())
+ << std::endl << std::endl;
}
out << _(" Files these postings came from:") << std::endl;
@@ -89,12 +89,12 @@ value_t report_statistics(call_scope_t& args)
out << " (";
out.precision(2);
out << (double((statistics.latest_post - statistics.earliest_post).days()) /
- double(statistics.posts_count)) << _(" per day)") << std::endl;
+ double(statistics.posts_count)) << _(" per day)") << std::endl;
out << _(" Uncleared postings: ");
out.width(6);
out << (statistics.posts_count -
- statistics.posts_cleared_count) << std::endl;
+ statistics.posts_cleared_count) << std::endl;
out << std::endl;
diff --git a/src/stream.cc b/src/stream.cc
index 272d4f1c..79faa05a 100644
--- a/src/stream.cc
+++ b/src/stream.cc
@@ -73,11 +73,11 @@ namespace {
if (status < 0) {
throw std::logic_error(_("Failed to fork child process"));
}
- else if (status == 0) { // child
+ else if (status == 0) { // child
// Duplicate pipe's reading end into stdin
status = dup2(pfd[0], STDIN_FILENO);
if (status == -1)
- perror("dup2");
+ perror("dup2");
// Close unuseful file descriptors: the pipe's writing and reading
// ends (the latter is not needed anymore, after the duplication).
@@ -98,7 +98,7 @@ namespace {
perror((std::string("execlp: ") + pager_path.string()).c_str());
exit(1);
}
- else { // parent
+ else { // parent
close(pfd[0]);
typedef iostreams::stream<iostreams::file_descriptor_sink> fdstream;
*os = new fdstream(pfd[1]);
@@ -108,7 +108,7 @@ namespace {
}
void output_stream_t::initialize(const optional<path>& output_file,
- const optional<path>& pager_path)
+ const optional<path>& pager_path)
{
if (output_file && *output_file != "-")
os = new ofstream(*output_file);
diff --git a/src/stream.h b/src/stream.h
index 356df08c..42c85534 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -114,7 +114,7 @@ public:
* empty.
*/
void initialize(const optional<path>& output_file = none,
- const optional<path>& pager_path = none);
+ const optional<path>& pager_path = none);
/**
* Convertor to a standard ostream. This is used so that we can
diff --git a/src/temps.cc b/src/temps.cc
index 7a630176..365c33c5 100644
--- a/src/temps.cc
+++ b/src/temps.cc
@@ -63,7 +63,7 @@ xact_t& temporaries_t::create_xact()
}
post_t& temporaries_t::copy_post(post_t& origin, xact_t& xact,
- account_t * account)
+ account_t * account)
{
if (! post_temps)
post_temps = std::list<post_t>();
@@ -99,7 +99,7 @@ post_t& temporaries_t::create_post(xact_t& xact, account_t * account)
}
account_t& temporaries_t::create_account(const string& name,
- account_t * parent)
+ account_t * parent)
{
if (! acct_temps)
acct_temps = std::list<account_t>();
@@ -119,10 +119,10 @@ void temporaries_t::clear()
if (post_temps) {
foreach (post_t& post, *post_temps) {
if (! post.xact->has_flags(ITEM_TEMP))
- post.xact->remove_post(&post);
+ post.xact->remove_post(&post);
if (post.account && ! post.account->has_flags(ACCOUNT_TEMP))
- post.account->remove_post(&post);
+ post.account->remove_post(&post);
}
post_temps->clear();
}
@@ -133,7 +133,7 @@ void temporaries_t::clear()
if (acct_temps) {
foreach (account_t& acct, *acct_temps) {
if (acct.parent && ! acct.parent->has_flags(ACCOUNT_TEMP))
- acct.parent->remove_account(&acct);
+ acct.parent->remove_account(&acct);
}
acct_temps->clear();
}
diff --git a/src/temps.h b/src/temps.h
index 210bbf63..1e7eb69f 100644
--- a/src/temps.h
+++ b/src/temps.h
@@ -61,13 +61,13 @@ public:
return xact_temps->back();
}
post_t& copy_post(post_t& origin, xact_t& xact,
- account_t * account = NULL);
+ account_t * account = NULL);
post_t& create_post(xact_t& xact, account_t * account);
post_t& last_post() {
return post_temps->back();
}
account_t& create_account(const string& name = "",
- account_t * parent = NULL);
+ account_t * parent = NULL);
account_t& last_account() {
return acct_temps->back();
}
diff --git a/src/textual.cc b/src/textual.cc
index dba31323..5308fa18 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -49,26 +49,26 @@
namespace ledger {
namespace {
- typedef std::pair<commodity_t *, amount_t> fixed_rate_t;
+ typedef std::pair<commodity_t *, amount_t> fixed_rate_t;
typedef variant<account_t *, string, fixed_rate_t> state_t;
class parse_context_t : public noncopyable
{
public:
- journal_t& journal;
- scope_t& scope;
+ journal_t& journal;
+ scope_t& scope;
std::list<state_t> state_stack;
#if defined(TIMELOG_SUPPORT)
- time_log_t timelog;
+ time_log_t timelog;
#endif
- bool strict;
- std::size_t count;
- std::size_t errors;
- std::size_t sequence;
+ bool strict;
+ std::size_t count;
+ std::size_t errors;
+ std::size_t sequence;
parse_context_t(journal_t& _journal, scope_t& _scope)
: journal(_journal), scope(_scope), timelog(journal),
- strict(false), count(0), errors(0), sequence(1) {}
+ strict(false), count(0), errors(0), sequence(1) {}
bool front_is_account() {
return state_stack.front().type() == typeid(account_t *);
@@ -82,8 +82,8 @@ namespace {
account_t * top_account() {
foreach (state_t& state, state_stack)
- if (state.type() == typeid(account_t *))
- return boost::get<account_t *>(state);
+ if (state.type() == typeid(account_t *))
+ return boost::get<account_t *>(state);
return NULL;
}
};
@@ -97,9 +97,9 @@ namespace {
instance_t * parent;
accounts_map account_aliases;
const path * original_file;
- path pathname;
+ path pathname;
std::istream& in;
- char linebuf[MAX_LINE + 1];
+ char linebuf[MAX_LINE + 1];
std::size_t linenum;
istream_pos_type line_beg_pos;
istream_pos_type curr_pos;
@@ -107,9 +107,9 @@ namespace {
optional<date_t::year_type> current_year;
instance_t(parse_context_t& _context,
- std::istream& _in,
- const path * _original_file = NULL,
- instance_t * _parent = NULL);
+ std::istream& _in,
+ const path * _original_file = NULL,
+ instance_t * _parent = NULL);
~instance_t();
@@ -117,7 +117,7 @@ namespace {
std::streamsize read_line(char *& line);
bool peek_whitespace_line() {
return (in.good() && ! in.eof() &&
- (in.peek() == ' ' || in.peek() == '\t'));
+ (in.peek() == ' ' || in.peek() == '\t'));
}
void read_next_directive();
@@ -148,31 +148,31 @@ namespace {
void define_directive(char * line);
bool general_directive(char * line);
- post_t * parse_post(char * line,
- std::streamsize len,
- account_t * account,
- xact_t * xact,
- bool defer_expr = false);
+ post_t * parse_post(char * line,
+ std::streamsize len,
+ account_t * account,
+ xact_t * xact,
+ bool defer_expr = false);
bool parse_posts(account_t * account,
- xact_base_t& xact,
- const bool defer_expr = false);
+ xact_base_t& xact,
+ const bool defer_expr = false);
- xact_t * parse_xact(char * line,
- std::streamsize len,
- account_t * account);
+ xact_t * parse_xact(char * line,
+ std::streamsize len,
+ account_t * account);
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
};
- void parse_amount_expr(std::istream& in,
- scope_t& scope,
- post_t& post,
- amount_t& amount,
- const parse_flags_t& flags = PARSE_DEFAULT,
- const bool defer_expr = false,
- optional<expr_t> * amount_expr = NULL)
+ void parse_amount_expr(std::istream& in,
+ scope_t& scope,
+ post_t& post,
+ amount_t& amount,
+ const parse_flags_t& flags = PARSE_DEFAULT,
+ const bool defer_expr = false,
+ optional<expr_t> * amount_expr = NULL)
{
expr_t expr(in, flags.plus_flags(PARSE_PARTIAL));
@@ -181,25 +181,25 @@ namespace {
#if defined(DEBUG_ENABLED)
DEBUG_IF("textual.parse") {
if (_debug_stream) {
- ledger::dump_value_expr(*_debug_stream, expr);
- *_debug_stream << std::endl;
+ ledger::dump_value_expr(*_debug_stream, expr);
+ *_debug_stream << std::endl;
}
}
#endif
if (expr) {
if (amount_expr)
- *amount_expr = expr;
+ *amount_expr = expr;
if (! defer_expr)
- amount = post.resolve_expr(scope, expr);
+ amount = post.resolve_expr(scope, expr);
}
}
}
instance_t::instance_t(parse_context_t& _context,
- std::istream& _in,
- const path * _original_file,
- instance_t * _parent)
+ std::istream& _in,
+ const path * _original_file,
+ instance_t * _parent)
: context(_context), parent(_parent), original_file(_original_file),
pathname(original_file ? *original_file : "/dev/stdin"), in(_in)
{
@@ -216,7 +216,7 @@ void instance_t::parse()
INFO("Parsing file '" << pathname.string() << "'");
TRACE_START(instance_parse, 1,
- "Done parsing file '" << pathname.string() << "'");
+ "Done parsing file '" << pathname.string() << "'");
if (! in.good() || in.eof())
return;
@@ -232,30 +232,30 @@ void instance_t::parse()
string current_context = error_context();
if (parent) {
- std::list<instance_t *> instances;
+ std::list<instance_t *> instances;
- for (instance_t * instance = parent;
- instance;
- instance = instance->parent)
- instances.push_front(instance);
+ for (instance_t * instance = parent;
+ instance;
+ instance = instance->parent)
+ instances.push_front(instance);
- foreach (instance_t * instance, instances)
- add_error_context(_("In file included from %1")
- << file_context(instance->pathname,
- instance->linenum));
+ foreach (instance_t * instance, instances)
+ add_error_context(_("In file included from %1")
+ << file_context(instance->pathname,
+ instance->linenum));
}
add_error_context(_("While parsing file %1")
- << file_context(pathname, linenum));
+ << file_context(pathname, linenum));
if (caught_signal != NONE_CAUGHT)
- throw;
+ throw;
string err_context = error_context();
if (! err_context.empty())
- std::cerr << err_context << std::endl;
+ std::cerr << err_context << std::endl;
if (! current_context.empty())
- std::cerr << current_context << std::endl;
+ std::cerr << current_context << std::endl;
std::cerr << _("Error: ") << err.what() << std::endl;
context.errors++;
@@ -268,7 +268,7 @@ void instance_t::parse()
std::streamsize instance_t::read_line(char *& line)
{
assert(in.good());
- assert(! in.eof()); // no one should call us in that case
+ assert(! in.eof()); // no one should call us in that case
line_beg_pos = curr_pos;
@@ -283,7 +283,7 @@ std::streamsize instance_t::read_line(char *& line)
else
line = linebuf;
- if (line[len - 1] == '\r') // strip Windows CRLF down to LF
+ if (line[len - 1] == '\r') // strip Windows CRLF down to LF
line[--len] = '\0';
linenum++;
@@ -291,7 +291,7 @@ std::streamsize instance_t::read_line(char *& line)
curr_pos = line_beg_pos;
curr_pos += len;
- return len - 1; // LF is being silently dropped
+ return len - 1; // LF is being silently dropped
}
return 0;
}
@@ -306,7 +306,7 @@ void instance_t::read_next_directive()
switch (line[0]) {
case '\0':
- assert(false); // shouldn't ever reach here
+ assert(false); // shouldn't ever reach here
break;
case ' ':
@@ -314,13 +314,13 @@ void instance_t::read_next_directive()
break;
}
- case ';': // comments
+ case ';': // comments
case '#':
case '*':
case '|':
break;
- case '-': // option setting
+ case '-': // option setting
option_directive(line);
break;
@@ -336,10 +336,10 @@ void instance_t::read_next_directive()
case '9':
xact_directive(line, len);
break;
- case '=': // automated xact
+ case '=': // automated xact
automated_xact_directive(line);
break;
- case '~': // period xact
+ case '~': // period xact
period_xact_directive(line);
break;
@@ -347,47 +347,47 @@ void instance_t::read_next_directive()
case '!':
line++;
// fall through...
- default: // some other directive
+ default: // some other directive
if (! general_directive(line)) {
switch (line[0]) {
#if defined(TIMELOG_SUPPORT)
case 'i':
- clock_in_directive(line, false);
- break;
+ clock_in_directive(line, false);
+ break;
case 'I':
- clock_in_directive(line, true);
- break;
+ clock_in_directive(line, true);
+ break;
case 'o':
- clock_out_directive(line, false);
- break;
+ clock_out_directive(line, false);
+ break;
case 'O':
- clock_out_directive(line, true);
- break;
+ clock_out_directive(line, true);
+ break;
case 'h':
case 'b':
- break;
+ break;
#endif // TIMELOG_SUPPORT
- case 'A': // a default account for unbalanced posts
- default_account_directive(line);
- break;
- case 'C': // a set of conversions
- price_conversion_directive(line);
- break;
- case 'D': // a default commodity for "xact"
- default_commodity_directive(line);
- break;
- case 'N': // don't download prices
- nomarket_directive(line);
- break;
- case 'P': // a pricing xact
- price_xact_directive(line);
- break;
- case 'Y': // set the current year
- year_directive(line);
- break;
+ case 'A': // a default account for unbalanced posts
+ default_account_directive(line);
+ break;
+ case 'C': // a set of conversions
+ price_conversion_directive(line);
+ break;
+ case 'D': // a default commodity for "xact"
+ default_commodity_directive(line);
+ break;
+ case 'N': // don't download prices
+ nomarket_directive(line);
+ break;
+ case 'P': // a pricing xact
+ price_xact_directive(line);
+ break;
+ case 'Y': // set the current year
+ year_directive(line);
+ break;
}
}
break;
@@ -418,9 +418,9 @@ void instance_t::clock_in_directive(char * line, bool /*capitalized*/)
position.sequence = context.sequence++;
time_xact_t event(position, parse_datetime(datetime, current_year),
- p ? context.top_account()->find_account(p) : NULL,
- n ? n : "",
- end ? end : "");
+ p ? context.top_account()->find_account(p) : NULL,
+ n ? n : "",
+ end ? end : "");
context.timelog.clock_in(event);
}
@@ -447,9 +447,9 @@ void instance_t::clock_out_directive(char * line, bool /*capitalized*/)
position.sequence = context.sequence++;
time_xact_t event(position, parse_datetime(datetime, current_year),
- p ? context.top_account()->find_account(p) : NULL,
- n ? n : "",
- end ? end : "");
+ p ? context.top_account()->find_account(p) : NULL,
+ n ? n : "",
+ end ? end : "");
context.timelog.clock_out(event);
context.count++;
@@ -526,8 +526,8 @@ void instance_t::automated_xact_directive(char * line)
std::auto_ptr<auto_xact_t> ae
(new auto_xact_t(query_t(string(skip_ws(line + 1)),
- keep_details_t(true, true, true), false)));
- ae->pos = position_t();
+ keep_details_t(true, true, true), false)));
+ ae->pos = position_t();
ae->pos->pathname = pathname;
ae->pos->beg_pos = line_beg_pos;
ae->pos->beg_line = linenum;
@@ -540,7 +540,7 @@ void instance_t::automated_xact_directive(char * line)
context.journal.auto_xacts.push_back(ae.get());
- ae->journal = &context.journal;
+ ae->journal = &context.journal;
ae->pos->end_pos = curr_pos;
ae->pos->end_line = linenum;
@@ -610,7 +610,7 @@ void instance_t::xact_directive(char * line, std::streamsize len)
std::auto_ptr<xact_t> manager(xact);
if (context.journal.add_xact(xact)) {
- manager.release(); // it's owned by the journal now
+ manager.release(); // it's owned by the journal now
context.count++;
}
// It's perfectly valid for the journal to reject the xact, which it will
@@ -650,10 +650,10 @@ void instance_t::include_directive(char * line)
mask_t glob;
#if BOOST_VERSION >= 103700
- path parent_path = filename.parent_path();
+ path parent_path = filename.parent_path();
glob.assign_glob(filename.filename());
#else // BOOST_VERSION >= 103700
- path parent_path = filename.branch_path();
+ path parent_path = filename.branch_path();
glob.assign_glob(filename.leaf());
#endif // BOOST_VERSION >= 103700
@@ -661,33 +661,33 @@ void instance_t::include_directive(char * line)
if (exists(parent_path)) {
filesystem::directory_iterator end;
for (filesystem::directory_iterator iter(parent_path);
- iter != end;
- ++iter) {
+ iter != end;
+ ++iter) {
#if BOOST_VERSION <= 103500
if (is_regular(*iter))
#else
if (is_regular_file(*iter))
#endif
- {
+ {
#if BOOST_VERSION >= 103700
- string base = (*iter).filename();
+ string base = (*iter).filename();
#else // BOOST_VERSION >= 103700
- string base = (*iter).leaf();
+ string base = (*iter).leaf();
#endif // BOOST_VERSION >= 103700
- if (glob.match(base)) {
- path inner_file(*iter);
- ifstream stream(inner_file);
- instance_t instance(context, stream, &inner_file, this);
- instance.parse();
- files_found = true;
- }
+ if (glob.match(base)) {
+ path inner_file(*iter);
+ ifstream stream(inner_file);
+ instance_t instance(context, stream, &inner_file, this);
+ instance.parse();
+ files_found = true;
+ }
}
}
}
if (! files_found)
throw_(std::runtime_error,
- _("File to include was not found: '%1'") << filename);
+ _("File to include was not found: '%1'") << filename);
}
@@ -707,17 +707,17 @@ void instance_t::end_directive(char * kind)
if ((name.empty() || name == "account") && ! context.front_is_account())
throw_(std::runtime_error,
- _("'end account' directive does not match open directive"));
+ _("'end account' directive does not match open directive"));
else if (name == "tag" && ! context.front_is_string())
throw_(std::runtime_error,
- _("'end tag' directive does not match open directive"));
+ _("'end tag' directive does not match open directive"));
else if (name == "fixed" && ! context.front_is_fixed_rate())
throw_(std::runtime_error,
- _("'end fixed' directive does not match open directive"));
+ _("'end fixed' directive does not match open directive"));
if (context.state_stack.size() <= 1)
throw_(std::runtime_error,
- _("'end' found, but no enclosing tag or account directive"));
+ _("'end' found, but no enclosing tag or account directive"));
else
context.state_stack.pop_front();
}
@@ -747,9 +747,9 @@ void instance_t::fixed_directive(char * line)
{
if (optional<std::pair<commodity_t *, price_point_t> > price_point =
commodity_pool_t::current_pool->parse_price_directive(trim_ws(line),
- true)) {
+ true)) {
context.state_stack.push_front(fixed_rate_t(price_point->first,
- price_point->second.price));
+ price_point->second.price));
} else {
throw_(std::runtime_error, _("Error in fixed directive"));
}
@@ -789,7 +789,7 @@ void instance_t::account_mapping_directive(char * line)
if (payee_regex)
context.journal.account_mappings.push_back
(account_mapping_t(mask_t(payee_regex),
- context.top_account()->find_account(account_name)));
+ context.top_account()->find_account(account_name)));
while (peek_whitespace_line()) {
#if defined(NO_ASSERTS)
@@ -805,7 +805,7 @@ void instance_t::account_mapping_directive(char * line)
context.journal.account_mappings.push_back
(account_mapping_t(mask_t(payee_regex),
- context.top_account()->find_account(account_name)));
+ context.top_account()->find_account(account_name)));
}
}
@@ -822,7 +822,7 @@ void instance_t::tag_directive(char * line)
void instance_t::define_directive(char * line)
{
expr_t def(skip_ws(line));
- def.compile(context.scope); // causes definitions to be established
+ def.compile(context.scope); // causes definitions to be established
}
bool instance_t::general_directive(char * line)
@@ -923,18 +923,18 @@ bool instance_t::general_directive(char * line)
return false;
}
-post_t * instance_t::parse_post(char * line,
- std::streamsize len,
- account_t * account,
- xact_t * xact,
- bool defer_expr)
+post_t * instance_t::parse_post(char * line,
+ std::streamsize len,
+ account_t * account,
+ xact_t * xact,
+ bool defer_expr)
{
TRACE_START(post_details, 1, "Time spent parsing postings:");
std::auto_ptr<post_t> post(new post_t);
- post->xact = xact; // this could be NULL
- post->pos = position_t();
+ post->xact = xact; // this could be NULL
+ post->pos = position_t();
post->pos->pathname = pathname;
post->pos->beg_pos = line_beg_pos;
post->pos->beg_line = linenum;
@@ -958,14 +958,14 @@ post_t * instance_t::parse_post(char * line,
post->set_state(item_t::CLEARED);
p = skip_ws(p + 1);
DEBUG("textual.parse", "line " << linenum << ": "
- << "Parsed the CLEARED flag");
+ << "Parsed the CLEARED flag");
break;
case '!':
post->set_state(item_t::PENDING);
p = skip_ws(p + 1);
DEBUG("textual.parse", "line " << linenum << ": "
- << "Parsed the PENDING flag");
+ << "Parsed the PENDING flag");
break;
}
@@ -988,19 +988,19 @@ post_t * instance_t::parse_post(char * line,
if ((*p == '[' && *(e - 1) == ']') || (*p == '(' && *(e - 1) == ')')) {
post->add_flags(POST_VIRTUAL);
DEBUG("textual.parse", "line " << linenum << ": "
- << "Parsed a virtual account name");
+ << "Parsed a virtual account name");
if (*p == '[') {
post->add_flags(POST_MUST_BALANCE);
DEBUG("textual.parse", "line " << linenum << ": "
- << "Posting must balance");
+ << "Posting must balance");
}
p++; e--;
}
string name(p, e - p);
DEBUG("textual.parse", "line " << linenum << ": "
- << "Parsed account name " << name);
+ << "Parsed account name " << name);
if (account_aliases.size() > 0) {
accounts_map::const_iterator i = account_aliases.find(name);
@@ -1013,15 +1013,15 @@ post_t * instance_t::parse_post(char * line,
if (context.strict && ! post->account->has_flags(ACCOUNT_KNOWN)) {
if (post->_state == item_t::UNCLEARED)
warning_(_("\"%1\", line %2: Unknown account '%3'")
- << pathname << linenum << post->account->fullname());
+ << pathname << linenum << post->account->fullname());
post->account->add_flags(ACCOUNT_KNOWN);
}
if (post->account->name == _("Unknown")) {
foreach (account_mapping_t& value, context.journal.account_mappings) {
if (value.first.match(xact->payee)) {
- post->account = value.second;
- break;
+ post->account = value.second;
+ break;
}
}
}
@@ -1036,39 +1036,39 @@ post_t * instance_t::parse_post(char * line,
beg = next - line;
ptristream stream(next, len - beg);
- if (*next != '(') // indicates a value expression
+ if (*next != '(') // indicates a value expression
post->amount.parse(stream, PARSE_NO_REDUCE);
else
parse_amount_expr(stream, context.scope, *post.get(), post->amount,
- PARSE_NO_REDUCE | PARSE_SINGLE | PARSE_NO_ASSIGN,
- defer_expr, &post->amount_expr);
+ PARSE_NO_REDUCE | PARSE_SINGLE | PARSE_NO_ASSIGN,
+ defer_expr, &post->amount_expr);
if (! post->amount.is_null() && post->amount.has_commodity()) {
if (context.strict &&
- ! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
- if (post->_state == item_t::UNCLEARED)
- warning_(_("\"%1\", line %2: Unknown commodity '%3'")
- << pathname << linenum << post->amount.commodity());
- post->amount.commodity().add_flags(COMMODITY_KNOWN);
+ ! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
+ if (post->_state == item_t::UNCLEARED)
+ warning_(_("\"%1\", line %2: Unknown commodity '%3'")
+ << pathname << linenum << post->amount.commodity());
+ post->amount.commodity().add_flags(COMMODITY_KNOWN);
}
if (! post->amount.has_annotation()) {
- foreach (state_t& state, context.state_stack) {
- if (state.type() == typeid(fixed_rate_t)) {
- fixed_rate_t& rate(boost::get<fixed_rate_t>(state));
- if (*rate.first == post->amount.commodity()) {
- annotation_t details(rate.second);
- details.add_flags(ANNOTATION_PRICE_FIXATED);
- post->amount.annotate(details);
- break;
- }
- }
- }
+ foreach (state_t& state, context.state_stack) {
+ if (state.type() == typeid(fixed_rate_t)) {
+ fixed_rate_t& rate(boost::get<fixed_rate_t>(state));
+ if (*rate.first == post->amount.commodity()) {
+ annotation_t details(rate.second);
+ details.add_flags(ANNOTATION_PRICE_FIXATED);
+ post->amount.annotate(details);
+ break;
+ }
+ }
+ }
}
}
DEBUG("textual.parse", "line " << linenum << ": "
- << "post amount = " << post->amount);
+ << "post amount = " << post->amount);
if (stream.eof()) {
next = NULL;
@@ -1078,73 +1078,73 @@ post_t * instance_t::parse_post(char * line,
// Parse the optional cost (@ PER-UNIT-COST, @@ TOTAL-COST)
if (*next == '@') {
- DEBUG("textual.parse", "line " << linenum << ": "
- << "Found a price indicator");
-
- bool per_unit = true;
-
- if (*++next == '@') {
- per_unit = false;
- post->add_flags(POST_COST_IN_FULL);
- DEBUG("textual.parse", "line " << linenum << ": "
- << "And it's for a total price");
- }
-
- beg = ++next - line;
-
- p = skip_ws(next);
- if (*p) {
- post->cost = amount_t();
-
- bool fixed_cost = false;
- if (*p == '=') {
- p++;
- fixed_cost = true;
- if (*p == '\0')
- throw parse_error(_("Posting is missing a cost amount"));
- }
-
- beg = p - line;
- ptristream cstream(p, len - beg);
-
- if (*p != '(') // indicates a value expression
- post->cost->parse(cstream, PARSE_NO_MIGRATE);
- else
- parse_amount_expr(cstream, context.scope, *post.get(), *post->cost,
- PARSE_NO_MIGRATE | PARSE_SINGLE | PARSE_NO_ASSIGN);
-
- if (post->cost->sign() < 0)
- throw parse_error(_("A posting's cost may not be negative"));
-
- post->cost->in_place_unround();
-
- if (per_unit) {
- // For the sole case where the cost might be uncommoditized,
- // guarantee that the commodity of the cost after multiplication
- // is the same as it was before.
- commodity_t& cost_commodity(post->cost->commodity());
- *post->cost *= post->amount;
- post->cost->set_commodity(cost_commodity);
- }
- else if (post->amount.sign() < 0) {
- post->cost->in_place_negate();
- }
-
- if (fixed_cost)
- post->add_flags(POST_COST_FIXATED);
-
- DEBUG("textual.parse", "line " << linenum << ": "
- << "Total cost is " << *post->cost);
- DEBUG("textual.parse", "line " << linenum << ": "
- << "Annotated amount is " << post->amount);
-
- if (cstream.eof())
- next = NULL;
- else
- next = skip_ws(p + static_cast<std::ptrdiff_t>(cstream.tellg()));
- } else {
- throw parse_error(_("Expected a cost amount"));
- }
+ DEBUG("textual.parse", "line " << linenum << ": "
+ << "Found a price indicator");
+
+ bool per_unit = true;
+
+ if (*++next == '@') {
+ per_unit = false;
+ post->add_flags(POST_COST_IN_FULL);
+ DEBUG("textual.parse", "line " << linenum << ": "
+ << "And it's for a total price");
+ }
+
+ beg = ++next - line;
+
+ p = skip_ws(next);
+ if (*p) {
+ post->cost = amount_t();
+
+ bool fixed_cost = false;
+ if (*p == '=') {
+ p++;
+ fixed_cost = true;
+ if (*p == '\0')
+ throw parse_error(_("Posting is missing a cost amount"));
+ }
+
+ beg = p - line;
+ ptristream cstream(p, len - beg);
+
+ if (*p != '(') // indicates a value expression
+ post->cost->parse(cstream, PARSE_NO_MIGRATE);
+ else
+ parse_amount_expr(cstream, context.scope, *post.get(), *post->cost,
+ PARSE_NO_MIGRATE | PARSE_SINGLE | PARSE_NO_ASSIGN);
+
+ if (post->cost->sign() < 0)
+ throw parse_error(_("A posting's cost may not be negative"));
+
+ post->cost->in_place_unround();
+
+ if (per_unit) {
+ // For the sole case where the cost might be uncommoditized,
+ // guarantee that the commodity of the cost after multiplication
+ // is the same as it was before.
+ commodity_t& cost_commodity(post->cost->commodity());
+ *post->cost *= post->amount;
+ post->cost->set_commodity(cost_commodity);
+ }
+ else if (post->amount.sign() < 0) {
+ post->cost->in_place_negate();
+ }
+
+ if (fixed_cost)
+ post->add_flags(POST_COST_FIXATED);
+
+ DEBUG("textual.parse", "line " << linenum << ": "
+ << "Total cost is " << *post->cost);
+ DEBUG("textual.parse", "line " << linenum << ": "
+ << "Annotated amount is " << post->amount);
+
+ if (cstream.eof())
+ next = NULL;
+ else
+ next = skip_ws(p + static_cast<std::ptrdiff_t>(cstream.tellg()));
+ } else {
+ throw parse_error(_("Expected a cost amount"));
+ }
}
}
}
@@ -1153,7 +1153,7 @@ post_t * instance_t::parse_post(char * line,
if (xact && next && *next == '=') {
DEBUG("textual.parse", "line " << linenum << ": "
- << "Found a balance assignment indicator");
+ << "Found a balance assignment indicator");
beg = ++next - line;
@@ -1164,70 +1164,70 @@ post_t * instance_t::parse_post(char * line,
beg = p - line;
ptristream stream(p, len - beg);
- if (*p != '(') // indicates a value expression
- post->assigned_amount->parse(stream, PARSE_NO_MIGRATE);
+ if (*p != '(') // indicates a value expression
+ post->assigned_amount->parse(stream, PARSE_NO_MIGRATE);
else
- parse_amount_expr(stream, context.scope, *post.get(),
- *post->assigned_amount,
- PARSE_SINGLE | PARSE_NO_MIGRATE);
+ parse_amount_expr(stream, context.scope, *post.get(),
+ *post->assigned_amount,
+ PARSE_SINGLE | PARSE_NO_MIGRATE);
if (post->assigned_amount->is_null()) {
- if (post->amount.is_null())
- throw parse_error(_("Balance assignment must evaluate to a constant"));
- else
- throw parse_error(_("Balance assertion must evaluate to a constant"));
+ if (post->amount.is_null())
+ throw parse_error(_("Balance assignment must evaluate to a constant"));
+ else
+ throw parse_error(_("Balance assertion must evaluate to a constant"));
}
DEBUG("textual.parse", "line " << linenum << ": "
- << "POST assign: parsed amt = " << *post->assigned_amount);
+ << "POST assign: parsed amt = " << *post->assigned_amount);
- amount_t& amt(*post->assigned_amount);
+ amount_t& amt(*post->assigned_amount);
value_t account_total
- (post->account->amount(false).strip_annotations(keep_details_t()));
+ (post->account->amount(false).strip_annotations(keep_details_t()));
DEBUG("post.assign",
- "line " << linenum << ": " "account balance = " << account_total);
+ "line " << linenum << ": " "account balance = " << account_total);
DEBUG("post.assign",
- "line " << linenum << ": " "post amount = " << amt);
+ "line " << linenum << ": " "post amount = " << amt);
amount_t diff = amt;
switch (account_total.type()) {
case value_t::AMOUNT:
- diff -= account_total.as_amount();
- break;
+ diff -= account_total.as_amount();
+ break;
case value_t::BALANCE:
- if (optional<amount_t> comm_bal =
- account_total.as_balance().commodity_amount(amt.commodity()))
- diff -= *comm_bal;
- break;
+ if (optional<amount_t> comm_bal =
+ account_total.as_balance().commodity_amount(amt.commodity()))
+ diff -= *comm_bal;
+ break;
default:
- break;
+ break;
}
DEBUG("post.assign",
- "line " << linenum << ": " << "diff = " << diff);
+ "line " << linenum << ": " << "diff = " << diff);
DEBUG("textual.parse",
- "line " << linenum << ": " << "POST assign: diff = " << diff);
+ "line " << linenum << ": " << "POST assign: diff = " << diff);
if (! diff.is_zero()) {
- if (! post->amount.is_null()) {
- diff -= post->amount;
- if (! diff.is_zero())
- throw_(parse_error, _("Balance assertion off by %1") << diff);
- } else {
- post->amount = diff;
- DEBUG("textual.parse", "line " << linenum << ": "
- << "Overwrite null posting");
- }
+ if (! post->amount.is_null()) {
+ diff -= post->amount;
+ if (! diff.is_zero())
+ throw_(parse_error, _("Balance assertion off by %1") << diff);
+ } else {
+ post->amount = diff;
+ DEBUG("textual.parse", "line " << linenum << ": "
+ << "Overwrite null posting");
+ }
}
if (stream.eof())
- next = NULL;
+ next = NULL;
else
- next = skip_ws(p + static_cast<std::ptrdiff_t>(stream.tellg()));
+ next = skip_ws(p + static_cast<std::ptrdiff_t>(stream.tellg()));
} else {
throw parse_error(_("Expected an balance assignment/assertion amount"));
}
@@ -1239,15 +1239,15 @@ post_t * instance_t::parse_post(char * line,
post->append_note(++next, true, current_year);
next = line + len;
DEBUG("textual.parse", "line " << linenum << ": "
- << "Parsed a posting note");
+ << "Parsed a posting note");
}
// There should be nothing more to read
if (next && *next)
throw_(parse_error,
- _("Unexpected char '%1' (Note: inline math requires parentheses)")
- << *next);
+ _("Unexpected char '%1' (Note: inline math requires parentheses)")
+ << *next);
post->pos->end_pos = curr_pos;
post->pos->end_line = linenum;
@@ -1255,7 +1255,7 @@ post_t * instance_t::parse_post(char * line,
if (! context.state_stack.empty()) {
foreach (const state_t& state, context.state_stack)
if (state.type() == typeid(string))
- post->parse_tags(boost::get<string>(state).c_str(), true);
+ post->parse_tags(boost::get<string>(state).c_str(), true);
}
TRACE_STOP(post_details, 1);
@@ -1271,8 +1271,8 @@ post_t * instance_t::parse_post(char * line,
}
bool instance_t::parse_posts(account_t * account,
- xact_base_t& xact,
- const bool defer_expr)
+ xact_base_t& xact,
+ const bool defer_expr)
{
TRACE_START(xact_posts, 1, "Time spent parsing postings:");
@@ -1294,15 +1294,15 @@ bool instance_t::parse_posts(account_t * account,
return added;
}
-xact_t * instance_t::parse_xact(char * line,
- std::streamsize len,
- account_t * account)
+xact_t * instance_t::parse_xact(char * line,
+ std::streamsize len,
+ account_t * account)
{
TRACE_START(xact_text, 1, "Time spent parsing transaction text:");
std::auto_ptr<xact_t> xact(new xact_t);
- xact->pos = position_t();
+ xact->pos = position_t();
xact->pos->pathname = pathname;
xact->pos->beg_pos = line_beg_pos;
xact->pos->beg_line = linenum;
@@ -1353,8 +1353,8 @@ xact_t * instance_t::parse_xact(char * line,
char * p = next_element(next, true);
foreach (payee_mapping_t& value, context.journal.payee_mappings) {
if (value.first.match(next)) {
- xact->payee = value.second;
- break;
+ xact->payee = value.second;
+ break;
}
}
if (xact->payee.empty())
@@ -1387,9 +1387,9 @@ xact_t * instance_t::parse_xact(char * line,
if (*p == ';') {
item_t * item;
if (last_post)
- item = last_post;
+ item = last_post;
else
- item = xact.get();
+ item = xact.get();
// This is a trailing note, and possibly a metadata info tag
item->append_note(p + 1, true, current_year);
@@ -1399,9 +1399,9 @@ xact_t * instance_t::parse_xact(char * line,
reveal_context = false;
if (post_t * post =
- parse_post(p, len - (p - line), account, xact.get())) {
- xact->add_post(post);
- last_post = post;
+ parse_post(p, len - (p - line), account, xact.get())) {
+ xact->add_post(post);
+ last_post = post;
}
}
}
@@ -1411,11 +1411,11 @@ xact_t * instance_t::parse_xact(char * line,
foreach (post_t * post, xact->posts) {
if (post->_state == item_t::UNCLEARED) {
- result = item_t::UNCLEARED;
- break;
+ result = item_t::UNCLEARED;
+ break;
}
else if (post->_state == item_t::PENDING) {
- result = item_t::PENDING;
+ result = item_t::PENDING;
}
}
}
@@ -1426,7 +1426,7 @@ xact_t * instance_t::parse_xact(char * line,
if (! context.state_stack.empty()) {
foreach (const state_t& state, context.state_stack)
if (state.type() == typeid(string))
- xact->parse_tags(boost::get<string>(state).c_str(), false);
+ xact->parse_tags(boost::get<string>(state).c_str(), false);
}
TRACE_STOP(xact_details, 1);
@@ -1438,23 +1438,23 @@ xact_t * instance_t::parse_xact(char * line,
if (reveal_context) {
add_error_context(_("While parsing transaction:"));
add_error_context(source_context(xact->pos->pathname,
- xact->pos->beg_pos, curr_pos, "> "));
+ xact->pos->beg_pos, curr_pos, "> "));
}
throw;
}
}
expr_t::ptr_op_t instance_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
return context.scope.lookup(kind, name);
}
std::size_t journal_t::parse(std::istream& in,
- scope_t& scope,
- account_t * master,
- const path * original_file,
- bool strict)
+ scope_t& scope,
+ account_t * master,
+ const path * original_file,
+ bool strict)
{
TRACE_START(parsing_total, 1, "Total time spent parsing text:");
diff --git a/src/timelog.cc b/src/timelog.cc
index 217aa581..241824cd 100644
--- a/src/timelog.cc
+++ b/src/timelog.cc
@@ -41,8 +41,8 @@ namespace ledger {
namespace {
void clock_out_from_timelog(std::list<time_xact_t>& time_xacts,
- time_xact_t out_event,
- journal_t& journal)
+ time_xact_t out_event,
+ journal_t& journal)
{
time_xact_t event;
@@ -55,29 +55,29 @@ namespace {
}
else if (! out_event.account) {
throw parse_error
- (_("When multiple check-ins are active, checking out requires an account"));
+ (_("When multiple check-ins are active, checking out requires an account"));
}
else {
bool found = false;
for (std::list<time_xact_t>::iterator i = time_xacts.begin();
- i != time_xacts.end();
- i++)
- if (out_event.account == (*i).account) {
- event = *i;
- found = true;
- time_xacts.erase(i);
- break;
- }
+ i != time_xacts.end();
+ i++)
+ if (out_event.account == (*i).account) {
+ event = *i;
+ found = true;
+ time_xacts.erase(i);
+ break;
+ }
if (! found)
- throw parse_error
- (_("Timelog check-out event does not match any current check-ins"));
+ throw parse_error
+ (_("Timelog check-out event does not match any current check-ins"));
}
if (out_event.checkin < event.checkin)
throw parse_error
- (_("Timelog check-out date less than corresponding check-in"));
+ (_("Timelog check-out date less than corresponding check-in"));
if (! out_event.desc.empty() && event.desc.empty()) {
event.desc = out_event.desc;
@@ -98,7 +98,7 @@ namespace {
char buf[32];
std::sprintf(buf, "%lds", long((out_event.checkin - event.checkin)
- .total_seconds()));
+ .total_seconds()));
amount_t amt;
amt.parse(buf);
VERIFY(amt.valid());
@@ -128,8 +128,8 @@ time_log_t::~time_log_t()
foreach (account_t * account, accounts)
clock_out_from_timelog(time_xacts,
- time_xact_t(none, CURRENT_TIME(), account),
- journal);
+ time_xact_t(none, CURRENT_TIME(), account),
+ journal);
assert(time_xacts.empty());
}
@@ -140,7 +140,7 @@ void time_log_t::clock_in(time_xact_t event)
if (! time_xacts.empty()) {
foreach (time_xact_t& time_xact, time_xacts) {
if (event.account == time_xact.account)
- throw parse_error(_("Cannot double check-in to the same account"));
+ throw parse_error(_("Cannot double check-in to the same account"));
}
}
diff --git a/src/timelog.h b/src/timelog.h
index caa23ec0..79629408 100644
--- a/src/timelog.h
+++ b/src/timelog.h
@@ -64,14 +64,14 @@ public:
TRACE_CTOR(time_xact_t, "");
}
time_xact_t(const optional<position_t>& _position,
- const datetime_t& _checkin,
- account_t * _account = NULL,
- const string& _desc = "",
- const string& _note = "")
+ const datetime_t& _checkin,
+ account_t * _account = NULL,
+ const string& _desc = "",
+ const string& _note = "")
: checkin(_checkin), account(_account), desc(_desc), note(_note),
position(_position ? *_position : position_t()) {
TRACE_CTOR(time_xact_t,
- "position_t, datetime_t, account_t *, string, string");
+ "position_t, datetime_t, account_t *, string, string");
}
time_xact_t(const time_xact_t& xact)
: checkin(xact.checkin), account(xact.account),
@@ -86,7 +86,7 @@ public:
class time_log_t
{
std::list<time_xact_t> time_xacts;
- journal_t& journal;
+ journal_t& journal;
public:
time_log_t(journal_t& _journal) : journal(_journal) {
diff --git a/src/times.cc b/src/times.cc
index 60e8e7cc..26e1dc21 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -60,17 +60,17 @@ namespace {
temporal_io_t(const char * _fmt_str, bool _input)
: fmt_str(_fmt_str),
- traits(icontains(fmt_str, "%y"),
- icontains(fmt_str, "%m") || icontains(fmt_str, "%b"),
- icontains(fmt_str, "%d")),
- input(_input) {
+ traits(icontains(fmt_str, "%y"),
+ icontains(fmt_str, "%m") || icontains(fmt_str, "%b"),
+ icontains(fmt_str, "%d")),
+ input(_input) {
#if defined(USE_BOOST_FACETS)
if (input) {
- input_facet = new InputFacetType(fmt_str);
- input_stream.imbue(std::locale(std::locale::classic(), input_facet));
+ input_facet = new InputFacetType(fmt_str);
+ input_stream.imbue(std::locale(std::locale::classic(), input_facet));
} else {
- output_facet = new OutputFacetType(fmt_str);
- output_stream.imbue(std::locale(std::locale::classic(), output_facet));
+ output_facet = new OutputFacetType(fmt_str);
+ output_stream.imbue(std::locale(std::locale::classic(), output_facet));
}
#endif // USE_BOOST_FACETS
}
@@ -78,14 +78,14 @@ namespace {
void set_format(const char * fmt) {
fmt_str = fmt;
traits = date_traits_t(icontains(fmt_str, "%y"),
- icontains(fmt_str, "%m") ||
- icontains(fmt_str, "%b"),
- icontains(fmt_str, "%d"));
+ icontains(fmt_str, "%m") ||
+ icontains(fmt_str, "%b"),
+ icontains(fmt_str, "%d"));
#if defined(USE_BOOST_FACETS)
if (input)
- input_facet->format(fmt_str);
+ input_facet->format(fmt_str);
else
- output_facet->format(fmt_str);
+ output_facet->format(fmt_str);
#endif // USE_BOOST_FACETS
}
@@ -110,7 +110,7 @@ namespace {
template <>
datetime_t temporal_io_t<datetime_t, posix_time::time_input_facet,
- posix_time::time_facet>
+ posix_time::time_facet>
::parse(const char * str)
{
#if defined(USE_BOOST_FACETS)
@@ -122,15 +122,15 @@ namespace {
input_stream >> when;
#if defined(DEBUG_ON)
if (when.is_not_a_date_time())
- DEBUG("times.parse", "Failed to parse date/time '" << str
- << "' using pattern '" << fmt_str << "'");
+ DEBUG("times.parse", "Failed to parse date/time '" << str
+ << "' using pattern '" << fmt_str << "'");
#endif
if (! when.is_not_a_date_time() &&
- input_stream.good() && ! input_stream.eof() &&
- input_stream.peek() != EOF) {
- DEBUG("times.parse", "This string has leftovers: '" << str << "'");
- return datetime_t();
+ input_stream.good() && ! input_stream.eof() &&
+ input_stream.peek() != EOF) {
+ DEBUG("times.parse", "This string has leftovers: '" << str << "'");
+ return datetime_t();
}
return when;
#else // USE_BOOST_FACETS
@@ -145,7 +145,7 @@ namespace {
template <>
date_t temporal_io_t<date_t, gregorian::date_input_facet,
- gregorian::date_facet>
+ gregorian::date_facet>
::parse(const char * str)
{
#if defined(USE_BOOST_FACETS)
@@ -157,21 +157,21 @@ namespace {
input_stream >> when;
#if defined(DEBUG_ON)
if (when.is_not_a_date())
- DEBUG("times.parse", "Failed to parse date '" << str
- << "' using pattern '" << fmt_str << "'");
+ DEBUG("times.parse", "Failed to parse date '" << str
+ << "' using pattern '" << fmt_str << "'");
#endif
if (! when.is_not_a_date() &&
- input_stream.good() && ! input_stream.eof() &&
- input_stream.peek() != EOF) {
- DEBUG("times.parse", "This string has leftovers: '" << str << "'");
- return date_t();
+ input_stream.good() && ! input_stream.eof() &&
+ input_stream.peek() != EOF) {
+ DEBUG("times.parse", "This string has leftovers: '" << str << "'");
+ return date_t();
}
return when;
#else // USE_BOOST_FACETS
std::tm data;
std::memset(&data, 0, sizeof(std::tm));
- data.tm_mday = 1; // some formats have no day
+ data.tm_mday = 1; // some formats have no day
if (strptime(str, fmt_str, &data))
return gregorian::date_from_tm(data);
else
@@ -180,9 +180,9 @@ namespace {
}
typedef temporal_io_t<datetime_t, posix_time::time_input_facet,
- posix_time::time_facet> datetime_io_t;
+ posix_time::time_facet> datetime_io_t;
typedef temporal_io_t<date_t, gregorian::date_input_facet,
- gregorian::date_facet> date_io_t;
+ gregorian::date_facet> date_io_t;
shared_ptr<datetime_io_t> input_datetime_io;
shared_ptr<date_io_t> input_date_io;
@@ -194,8 +194,8 @@ namespace {
std::vector<shared_ptr<date_io_t> > readers;
date_t parse_date_mask_routine(const char * date_str, date_io_t& io,
- optional_year year,
- date_traits_t * traits = NULL)
+ optional_year year,
+ date_traits_t * traits = NULL)
{
VERIFY(std::strlen(date_str) < 127);
@@ -204,7 +204,7 @@ namespace {
for (char * p = buf; *p; p++)
if (*p == '.' || *p == '-')
- *p = '/';
+ *p = '/';
date_t when = io.parse(buf);
@@ -219,41 +219,41 @@ namespace {
const char * p = when_str.c_str();
const char * q = buf;
for (; *p && *q; p++, q++) {
- if (*p != *q && *p == '0') p++;
- if (! *p || *p != *q) break;
+ if (*p != *q && *p == '0') p++;
+ if (! *p || *p != *q) break;
}
if (*p != '\0' || *q != '\0')
- throw_(date_error, _("Invalid date: %1") << date_str);
+ throw_(date_error, _("Invalid date: %1") << date_str);
if (traits)
- *traits = io.traits;
+ *traits = io.traits;
if (! io.traits.has_year) {
- when = date_t(year ? *year : CURRENT_DATE().year(),
- when.month(), when.day());
+ when = date_t(year ? *year : CURRENT_DATE().year(),
+ when.month(), when.day());
- if (! year && when.month() > CURRENT_DATE().month())
- when -= gregorian::years(1);
+ if (! year && when.month() > CURRENT_DATE().month())
+ when -= gregorian::years(1);
}
}
return when;
}
date_t parse_date_mask(const char * date_str, optional_year year,
- date_traits_t * traits = NULL)
+ date_traits_t * traits = NULL)
{
if (input_date_io.get()) {
date_t when = parse_date_mask_routine(date_str, *input_date_io.get(),
- year, traits);
+ year, traits);
if (! when.is_not_a_date())
- return when;
+ return when;
}
foreach (shared_ptr<date_io_t>& reader, readers) {
date_t when = parse_date_mask_routine(date_str, *reader.get(),
- year, traits);
+ year, traits);
if (! when.is_not_a_date())
- return when;
+ return when;
}
throw_(date_error, _("Invalid date: %1") << date_str);
@@ -344,8 +344,8 @@ date_t date_specifier_t::begin(const optional_year& current_year) const
// wday in that month; if the year is set, then in that year.
return gregorian::date(static_cast<date_t::year_type>(the_year),
- static_cast<date_t::month_type>(the_month),
- static_cast<date_t::day_type>(the_day));
+ static_cast<date_t::month_type>(the_month),
+ static_cast<date_t::day_type>(the_day));
}
date_t date_specifier_t::end(const optional_year& current_year) const
@@ -363,7 +363,7 @@ date_t date_specifier_t::end(const optional_year& current_year) const
}
std::ostream& operator<<(std::ostream& out,
- const date_duration_t& duration)
+ const date_duration_t& duration)
{
if (duration.quantum == date_duration_t::DAYS)
out << duration.length << " day(s)";
@@ -395,194 +395,194 @@ class date_parser_t
struct token_t
{
enum kind_t {
- UNKNOWN,
-
- TOK_DATE,
- TOK_INT,
- TOK_SLASH,
- TOK_DASH,
- TOK_DOT,
-
- TOK_A_YEAR,
- TOK_A_MONTH,
- TOK_A_WDAY,
-
- TOK_SINCE,
- TOK_UNTIL,
- TOK_IN,
- TOK_THIS,
- TOK_NEXT,
- TOK_LAST,
- TOK_EVERY,
-
- TOK_TODAY,
- TOK_TOMORROW,
- TOK_YESTERDAY,
-
- TOK_YEAR,
- TOK_QUARTER,
- TOK_MONTH,
- TOK_WEEK,
- TOK_DAY,
-
- TOK_YEARLY,
- TOK_QUARTERLY,
- TOK_BIMONTHLY,
- TOK_MONTHLY,
- TOK_BIWEEKLY,
- TOK_WEEKLY,
- TOK_DAILY,
-
- TOK_YEARS,
- TOK_QUARTERS,
- TOK_MONTHS,
- TOK_WEEKS,
- TOK_DAYS,
-
- END_REACHED
+ UNKNOWN,
+
+ TOK_DATE,
+ TOK_INT,
+ TOK_SLASH,
+ TOK_DASH,
+ TOK_DOT,
+
+ TOK_A_YEAR,
+ TOK_A_MONTH,
+ TOK_A_WDAY,
+
+ TOK_SINCE,
+ TOK_UNTIL,
+ TOK_IN,
+ TOK_THIS,
+ TOK_NEXT,
+ TOK_LAST,
+ TOK_EVERY,
+
+ TOK_TODAY,
+ TOK_TOMORROW,
+ TOK_YESTERDAY,
+
+ TOK_YEAR,
+ TOK_QUARTER,
+ TOK_MONTH,
+ TOK_WEEK,
+ TOK_DAY,
+
+ TOK_YEARLY,
+ TOK_QUARTERLY,
+ TOK_BIMONTHLY,
+ TOK_MONTHLY,
+ TOK_BIWEEKLY,
+ TOK_WEEKLY,
+ TOK_DAILY,
+
+ TOK_YEARS,
+ TOK_QUARTERS,
+ TOK_MONTHS,
+ TOK_WEEKS,
+ TOK_DAYS,
+
+ END_REACHED
} kind;
typedef variant<unsigned short,
- string,
- date_specifier_t::year_type,
- date_time::months_of_year,
- date_time::weekdays,
- date_specifier_t> content_t;
+ string,
+ date_specifier_t::year_type,
+ date_time::months_of_year,
+ date_time::weekdays,
+ date_specifier_t> content_t;
optional<content_t> value;
explicit token_t(kind_t _kind = UNKNOWN,
- const optional<content_t>& _value =
- content_t(empty_string))
- : kind(_kind), value(_value) {
- TRACE_CTOR(date_parser_t::lexer_t::token_t, "");
+ const optional<content_t>& _value =
+ content_t(empty_string))
+ : kind(_kind), value(_value) {
+ TRACE_CTOR(date_parser_t::lexer_t::token_t, "");
}
token_t(const token_t& tok)
- : kind(tok.kind), value(tok.value) {
- TRACE_CTOR(date_parser_t::lexer_t::token_t, "copy");
+ : kind(tok.kind), value(tok.value) {
+ TRACE_CTOR(date_parser_t::lexer_t::token_t, "copy");
}
~token_t() throw() {
- TRACE_DTOR(date_parser_t::lexer_t::token_t);
+ TRACE_DTOR(date_parser_t::lexer_t::token_t);
}
token_t& operator=(const token_t& tok) {
- if (this != &tok) {
- kind = tok.kind;
- value = tok.value;
- }
- return *this;
+ if (this != &tok) {
+ kind = tok.kind;
+ value = tok.value;
+ }
+ return *this;
}
operator bool() const {
- return kind != END_REACHED;
+ return kind != END_REACHED;
}
string to_string() const {
- std::ostringstream out;
-
- switch (kind) {
- case UNKNOWN:
- out << boost::get<string>(*value);
- break;
- case TOK_DATE:
- return boost::get<date_specifier_t>(*value).to_string();
- case TOK_INT:
- out << boost::get<unsigned short>(*value);
- break;
- case TOK_SLASH: return "/";
- case TOK_DASH: return "-";
- case TOK_DOT: return ".";
- case TOK_A_YEAR:
- out << boost::get<date_specifier_t::year_type>(*value);
- break;
- case TOK_A_MONTH:
- out << date_specifier_t::month_type
- (boost::get<date_time::months_of_year>(*value));
- break;
- case TOK_A_WDAY:
- out << date_specifier_t::day_of_week_type
- (boost::get<date_time::weekdays>(*value));
- break;
- case TOK_SINCE: return "since";
- case TOK_UNTIL: return "until";
- case TOK_IN: return "in";
- case TOK_THIS: return "this";
- case TOK_NEXT: return "next";
- case TOK_LAST: return "last";
- case TOK_EVERY: return "every";
- case TOK_TODAY: return "today";
- case TOK_TOMORROW: return "tomorrow";
- case TOK_YESTERDAY: return "yesterday";
- case TOK_YEAR: return "year";
- case TOK_QUARTER: return "quarter";
- case TOK_MONTH: return "month";
- case TOK_WEEK: return "week";
- case TOK_DAY: return "day";
- case TOK_YEARLY: return "yearly";
- case TOK_QUARTERLY: return "quarterly";
- case TOK_BIMONTHLY: return "bimonthly";
- case TOK_MONTHLY: return "monthly";
- case TOK_BIWEEKLY: return "biweekly";
- case TOK_WEEKLY: return "weekly";
- case TOK_DAILY: return "daily";
- case TOK_YEARS: return "years";
- case TOK_QUARTERS: return "quarters";
- case TOK_MONTHS: return "months";
- case TOK_WEEKS: return "weeks";
- case TOK_DAYS: return "days";
- case END_REACHED: return "<EOF>";
- default:
- assert(false);
- return empty_string;
- }
-
- return out.str();
+ std::ostringstream out;
+
+ switch (kind) {
+ case UNKNOWN:
+ out << boost::get<string>(*value);
+ break;
+ case TOK_DATE:
+ return boost::get<date_specifier_t>(*value).to_string();
+ case TOK_INT:
+ out << boost::get<unsigned short>(*value);
+ break;
+ case TOK_SLASH: return "/";
+ case TOK_DASH: return "-";
+ case TOK_DOT: return ".";
+ case TOK_A_YEAR:
+ out << boost::get<date_specifier_t::year_type>(*value);
+ break;
+ case TOK_A_MONTH:
+ out << date_specifier_t::month_type
+ (boost::get<date_time::months_of_year>(*value));
+ break;
+ case TOK_A_WDAY:
+ out << date_specifier_t::day_of_week_type
+ (boost::get<date_time::weekdays>(*value));
+ break;
+ case TOK_SINCE: return "since";
+ case TOK_UNTIL: return "until";
+ case TOK_IN: return "in";
+ case TOK_THIS: return "this";
+ case TOK_NEXT: return "next";
+ case TOK_LAST: return "last";
+ case TOK_EVERY: return "every";
+ case TOK_TODAY: return "today";
+ case TOK_TOMORROW: return "tomorrow";
+ case TOK_YESTERDAY: return "yesterday";
+ case TOK_YEAR: return "year";
+ case TOK_QUARTER: return "quarter";
+ case TOK_MONTH: return "month";
+ case TOK_WEEK: return "week";
+ case TOK_DAY: return "day";
+ case TOK_YEARLY: return "yearly";
+ case TOK_QUARTERLY: return "quarterly";
+ case TOK_BIMONTHLY: return "bimonthly";
+ case TOK_MONTHLY: return "monthly";
+ case TOK_BIWEEKLY: return "biweekly";
+ case TOK_WEEKLY: return "weekly";
+ case TOK_DAILY: return "daily";
+ case TOK_YEARS: return "years";
+ case TOK_QUARTERS: return "quarters";
+ case TOK_MONTHS: return "months";
+ case TOK_WEEKS: return "weeks";
+ case TOK_DAYS: return "days";
+ case END_REACHED: return "<EOF>";
+ default:
+ assert(false);
+ return empty_string;
+ }
+
+ return out.str();
}
void dump(std::ostream& out) const {
- switch (kind) {
- case UNKNOWN: out << "UNKNOWN"; break;
- case TOK_DATE: out << "TOK_DATE"; break;
- case TOK_INT: out << "TOK_INT"; break;
- case TOK_SLASH: out << "TOK_SLASH"; break;
- case TOK_DASH: out << "TOK_DASH"; break;
- case TOK_DOT: out << "TOK_DOT"; break;
- case TOK_A_YEAR: out << "TOK_A_YEAR"; break;
- case TOK_A_MONTH: out << "TOK_A_MONTH"; break;
- case TOK_A_WDAY: out << "TOK_A_WDAY"; break;
- case TOK_SINCE: out << "TOK_SINCE"; break;
- case TOK_UNTIL: out << "TOK_UNTIL"; break;
- case TOK_IN: out << "TOK_IN"; break;
- case TOK_THIS: out << "TOK_THIS"; break;
- case TOK_NEXT: out << "TOK_NEXT"; break;
- case TOK_LAST: out << "TOK_LAST"; break;
- case TOK_EVERY: out << "TOK_EVERY"; break;
- case TOK_TODAY: out << "TOK_TODAY"; break;
- case TOK_TOMORROW: out << "TOK_TOMORROW"; break;
- case TOK_YESTERDAY: out << "TOK_YESTERDAY"; break;
- case TOK_YEAR: out << "TOK_YEAR"; break;
- case TOK_QUARTER: out << "TOK_QUARTER"; break;
- case TOK_MONTH: out << "TOK_MONTH"; break;
- case TOK_WEEK: out << "TOK_WEEK"; break;
- case TOK_DAY: out << "TOK_DAY"; break;
- case TOK_YEARLY: out << "TOK_YEARLY"; break;
- case TOK_QUARTERLY: out << "TOK_QUARTERLY"; break;
- case TOK_BIMONTHLY: out << "TOK_BIMONTHLY"; break;
- case TOK_MONTHLY: out << "TOK_MONTHLY"; break;
- case TOK_BIWEEKLY: out << "TOK_BIWEEKLY"; break;
- case TOK_WEEKLY: out << "TOK_WEEKLY"; break;
- case TOK_DAILY: out << "TOK_DAILY"; break;
- case TOK_YEARS: out << "TOK_YEARS"; break;
- case TOK_QUARTERS: out << "TOK_QUARTERS"; break;
- case TOK_MONTHS: out << "TOK_MONTHS"; break;
- case TOK_WEEKS: out << "TOK_WEEKS"; break;
- case TOK_DAYS: out << "TOK_DAYS"; break;
- case END_REACHED: out << "END_REACHED"; break;
- default:
- assert(false);
- break;
- }
+ switch (kind) {
+ case UNKNOWN: out << "UNKNOWN"; break;
+ case TOK_DATE: out << "TOK_DATE"; break;
+ case TOK_INT: out << "TOK_INT"; break;
+ case TOK_SLASH: out << "TOK_SLASH"; break;
+ case TOK_DASH: out << "TOK_DASH"; break;
+ case TOK_DOT: out << "TOK_DOT"; break;
+ case TOK_A_YEAR: out << "TOK_A_YEAR"; break;
+ case TOK_A_MONTH: out << "TOK_A_MONTH"; break;
+ case TOK_A_WDAY: out << "TOK_A_WDAY"; break;
+ case TOK_SINCE: out << "TOK_SINCE"; break;
+ case TOK_UNTIL: out << "TOK_UNTIL"; break;
+ case TOK_IN: out << "TOK_IN"; break;
+ case TOK_THIS: out << "TOK_THIS"; break;
+ case TOK_NEXT: out << "TOK_NEXT"; break;
+ case TOK_LAST: out << "TOK_LAST"; break;
+ case TOK_EVERY: out << "TOK_EVERY"; break;
+ case TOK_TODAY: out << "TOK_TODAY"; break;
+ case TOK_TOMORROW: out << "TOK_TOMORROW"; break;
+ case TOK_YESTERDAY: out << "TOK_YESTERDAY"; break;
+ case TOK_YEAR: out << "TOK_YEAR"; break;
+ case TOK_QUARTER: out << "TOK_QUARTER"; break;
+ case TOK_MONTH: out << "TOK_MONTH"; break;
+ case TOK_WEEK: out << "TOK_WEEK"; break;
+ case TOK_DAY: out << "TOK_DAY"; break;
+ case TOK_YEARLY: out << "TOK_YEARLY"; break;
+ case TOK_QUARTERLY: out << "TOK_QUARTERLY"; break;
+ case TOK_BIMONTHLY: out << "TOK_BIMONTHLY"; break;
+ case TOK_MONTHLY: out << "TOK_MONTHLY"; break;
+ case TOK_BIWEEKLY: out << "TOK_BIWEEKLY"; break;
+ case TOK_WEEKLY: out << "TOK_WEEKLY"; break;
+ case TOK_DAILY: out << "TOK_DAILY"; break;
+ case TOK_YEARS: out << "TOK_YEARS"; break;
+ case TOK_QUARTERS: out << "TOK_QUARTERS"; break;
+ case TOK_MONTHS: out << "TOK_MONTHS"; break;
+ case TOK_WEEKS: out << "TOK_WEEKS"; break;
+ case TOK_DAYS: out << "TOK_DAYS"; break;
+ case END_REACHED: out << "END_REACHED"; break;
+ default:
+ assert(false);
+ break;
+ }
}
void unexpected();
@@ -592,14 +592,14 @@ class date_parser_t
token_t token_cache;
lexer_t(string::const_iterator _begin,
- string::const_iterator _end)
+ string::const_iterator _end)
: begin(_begin), end(_end)
{
TRACE_CTOR(date_parser_t::lexer_t, "");
}
lexer_t(const lexer_t& lexer)
: begin(lexer.begin), end(lexer.end),
- token_cache(lexer.token_cache)
+ token_cache(lexer.token_cache)
{
TRACE_CTOR(date_parser_t::lexer_t, "copy");
}
@@ -614,7 +614,7 @@ class date_parser_t
}
token_t peek_token() {
if (token_cache.kind == token_t::UNKNOWN)
- token_cache = next_token();
+ token_cache = next_token();
return token_cache;
}
};
@@ -642,7 +642,7 @@ private:
};
void date_parser_t::determine_when(date_parser_t::lexer_t::token_t& tok,
- date_specifier_t& specifier)
+ date_specifier_t& specifier)
{
switch (tok.kind) {
case lexer_t::token_t::TOK_DATE:
@@ -680,8 +680,8 @@ date_interval_t date_parser_t::parse()
optional<date_specifier_t> inclusion_specifier;
date_interval_t period;
- date_t today = CURRENT_DATE();
- bool end_inclusive = false;
+ date_t today = CURRENT_DATE();
+ bool end_inclusive = false;
for (lexer_t::token_t tok = lexer.next_token();
tok.kind != lexer_t::token_t::END_REACHED;
@@ -697,77 +697,77 @@ date_interval_t date_parser_t::parse()
case lexer_t::token_t::TOK_DATE:
if (! inclusion_specifier)
- inclusion_specifier = date_specifier_t();
+ inclusion_specifier = date_specifier_t();
determine_when(tok, *inclusion_specifier);
break;
case lexer_t::token_t::TOK_INT:
if (! inclusion_specifier)
- inclusion_specifier = date_specifier_t();
+ inclusion_specifier = date_specifier_t();
determine_when(tok, *inclusion_specifier);
break;
case lexer_t::token_t::TOK_A_YEAR:
if (! inclusion_specifier)
- inclusion_specifier = date_specifier_t();
+ inclusion_specifier = date_specifier_t();
determine_when(tok, *inclusion_specifier);
break;
case lexer_t::token_t::TOK_A_MONTH:
if (! inclusion_specifier)
- inclusion_specifier = date_specifier_t();
+ inclusion_specifier = date_specifier_t();
determine_when(tok, *inclusion_specifier);
break;
case lexer_t::token_t::TOK_A_WDAY:
if (! inclusion_specifier)
- inclusion_specifier = date_specifier_t();
+ inclusion_specifier = date_specifier_t();
determine_when(tok, *inclusion_specifier);
break;
case lexer_t::token_t::TOK_DASH:
if (inclusion_specifier) {
- since_specifier = inclusion_specifier;
- until_specifier = date_specifier_t();
- inclusion_specifier = none;
+ since_specifier = inclusion_specifier;
+ until_specifier = date_specifier_t();
+ inclusion_specifier = none;
- tok = lexer.next_token();
- determine_when(tok, *until_specifier);
+ tok = lexer.next_token();
+ determine_when(tok, *until_specifier);
- // The dash operator is special: it has an _inclusive_ end.
- end_inclusive = true;
+ // The dash operator is special: it has an _inclusive_ end.
+ end_inclusive = true;
} else {
- tok.unexpected();
+ tok.unexpected();
}
break;
case lexer_t::token_t::TOK_SINCE:
if (since_specifier) {
- tok.unexpected();
+ tok.unexpected();
} else {
- since_specifier = date_specifier_t();
- tok = lexer.next_token();
- determine_when(tok, *since_specifier);
+ since_specifier = date_specifier_t();
+ tok = lexer.next_token();
+ determine_when(tok, *since_specifier);
}
break;
case lexer_t::token_t::TOK_UNTIL:
if (until_specifier) {
- tok.unexpected();
+ tok.unexpected();
} else {
- until_specifier = date_specifier_t();
- tok = lexer.next_token();
- determine_when(tok, *until_specifier);
+ until_specifier = date_specifier_t();
+ tok = lexer.next_token();
+ determine_when(tok, *until_specifier);
}
break;
case lexer_t::token_t::TOK_IN:
if (inclusion_specifier) {
- tok.unexpected();
+ tok.unexpected();
} else {
- inclusion_specifier = date_specifier_t();
- tok = lexer.next_token();
- determine_when(tok, *inclusion_specifier);
+ inclusion_specifier = date_specifier_t();
+ tok = lexer.next_token();
+ determine_when(tok, *inclusion_specifier);
}
break;
@@ -776,90 +776,90 @@ date_interval_t date_parser_t::parse()
case lexer_t::token_t::TOK_LAST: {
int8_t adjust = 0;
if (tok.kind == lexer_t::token_t::TOK_NEXT)
- adjust = 1;
+ adjust = 1;
else if (tok.kind == lexer_t::token_t::TOK_LAST)
- adjust = -1;
+ adjust = -1;
tok = lexer.next_token();
switch (tok.kind) {
case lexer_t::token_t::TOK_INT:
- // jww (2009-11-18): Allow things like "last 5 weeks"
- assert(! "Need to allow for expressions like \"last 5 weeks\"");
- tok.unexpected();
- break;
+ // jww (2009-11-18): Allow things like "last 5 weeks"
+ assert(! "Need to allow for expressions like \"last 5 weeks\"");
+ tok.unexpected();
+ break;
case lexer_t::token_t::TOK_A_MONTH: {
- inclusion_specifier = date_specifier_t();
- determine_when(tok, *inclusion_specifier);
-
- date_t temp(today.year(), *inclusion_specifier->month, 1);
- temp += gregorian::years(adjust);
- inclusion_specifier =
- date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
- temp.month());
- break;
+ inclusion_specifier = date_specifier_t();
+ determine_when(tok, *inclusion_specifier);
+
+ date_t temp(today.year(), *inclusion_specifier->month, 1);
+ temp += gregorian::years(adjust);
+ inclusion_specifier =
+ date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
+ temp.month());
+ break;
}
case lexer_t::token_t::TOK_A_WDAY: {
- inclusion_specifier = date_specifier_t();
- determine_when(tok, *inclusion_specifier);
-
- date_t temp =
- date_duration_t::find_nearest(today, date_duration_t::WEEKS);
- while (temp.day_of_week() != inclusion_specifier->wday)
- temp += gregorian::days(1);
- temp += gregorian::days(7 * adjust);
- inclusion_specifier = date_specifier_t(temp);
- break;
+ inclusion_specifier = date_specifier_t();
+ determine_when(tok, *inclusion_specifier);
+
+ date_t temp =
+ date_duration_t::find_nearest(today, date_duration_t::WEEKS);
+ while (temp.day_of_week() != inclusion_specifier->wday)
+ temp += gregorian::days(1);
+ temp += gregorian::days(7 * adjust);
+ inclusion_specifier = date_specifier_t(temp);
+ break;
}
case lexer_t::token_t::TOK_YEAR: {
- date_t temp(today);
- temp += gregorian::years(adjust);
- inclusion_specifier =
- date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()));
- break;
+ date_t temp(today);
+ temp += gregorian::years(adjust);
+ inclusion_specifier =
+ date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()));
+ break;
}
case lexer_t::token_t::TOK_QUARTER: {
- date_t temp =
- date_duration_t::find_nearest(today, date_duration_t::QUARTERS);
- temp += gregorian::months(3 * adjust);
- inclusion_specifier =
- date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
- temp.month());
+ date_t temp =
+ date_duration_t::find_nearest(today, date_duration_t::QUARTERS);
+ temp += gregorian::months(3 * adjust);
+ inclusion_specifier =
+ date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
+ temp.month());
#if 0
- period.duration = date_duration_t(date_duration_t::QUARTERS, 1);
+ period.duration = date_duration_t(date_duration_t::QUARTERS, 1);
#endif
- break;
+ break;
}
case lexer_t::token_t::TOK_WEEK: {
- date_t temp =
- date_duration_t::find_nearest(today, date_duration_t::WEEKS);
- temp += gregorian::days(7 * adjust);
- inclusion_specifier = date_specifier_t(today);
+ date_t temp =
+ date_duration_t::find_nearest(today, date_duration_t::WEEKS);
+ temp += gregorian::days(7 * adjust);
+ inclusion_specifier = date_specifier_t(today);
#if 0
- period.duration = date_duration_t(date_duration_t::WEEKS, 1);
+ period.duration = date_duration_t(date_duration_t::WEEKS, 1);
#endif
- break;
+ break;
}
case lexer_t::token_t::TOK_DAY: {
- date_t temp(today);
- temp += gregorian::days(adjust);
- inclusion_specifier = date_specifier_t(temp);
- break;
+ date_t temp(today);
+ temp += gregorian::days(adjust);
+ inclusion_specifier = date_specifier_t(temp);
+ break;
}
default:
case lexer_t::token_t::TOK_MONTH: {
- date_t temp(today);
- temp += gregorian::months(adjust);
- inclusion_specifier =
- date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
- temp.month());
- break;
+ date_t temp(today);
+ temp += gregorian::months(adjust);
+ inclusion_specifier =
+ date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
+ temp.month());
+ break;
}
}
}
@@ -877,49 +877,49 @@ date_interval_t date_parser_t::parse()
case lexer_t::token_t::TOK_EVERY:
tok = lexer.next_token();
if (tok == lexer_t::token_t::TOK_INT) {
- int quantity = boost::get<unsigned short>(*tok.value);
- tok = lexer.next_token();
- switch (tok.kind) {
- case lexer_t::token_t::TOK_YEARS:
- period.duration = date_duration_t(date_duration_t::YEARS, quantity);
- break;
- case lexer_t::token_t::TOK_QUARTERS:
- period.duration = date_duration_t(date_duration_t::QUARTERS, quantity);
- break;
- case lexer_t::token_t::TOK_MONTHS:
- period.duration = date_duration_t(date_duration_t::MONTHS, quantity);
- break;
- case lexer_t::token_t::TOK_WEEKS:
- period.duration = date_duration_t(date_duration_t::WEEKS, quantity);
- break;
- case lexer_t::token_t::TOK_DAYS:
- period.duration = date_duration_t(date_duration_t::DAYS, quantity);
- break;
- default:
- tok.unexpected();
- break;
- }
+ int quantity = boost::get<unsigned short>(*tok.value);
+ tok = lexer.next_token();
+ switch (tok.kind) {
+ case lexer_t::token_t::TOK_YEARS:
+ period.duration = date_duration_t(date_duration_t::YEARS, quantity);
+ break;
+ case lexer_t::token_t::TOK_QUARTERS:
+ period.duration = date_duration_t(date_duration_t::QUARTERS, quantity);
+ break;
+ case lexer_t::token_t::TOK_MONTHS:
+ period.duration = date_duration_t(date_duration_t::MONTHS, quantity);
+ break;
+ case lexer_t::token_t::TOK_WEEKS:
+ period.duration = date_duration_t(date_duration_t::WEEKS, quantity);
+ break;
+ case lexer_t::token_t::TOK_DAYS:
+ period.duration = date_duration_t(date_duration_t::DAYS, quantity);
+ break;
+ default:
+ tok.unexpected();
+ break;
+ }
} else {
- switch (tok.kind) {
- case lexer_t::token_t::TOK_YEAR:
- period.duration = date_duration_t(date_duration_t::YEARS, 1);
- break;
- case lexer_t::token_t::TOK_QUARTER:
- period.duration = date_duration_t(date_duration_t::QUARTERS, 1);
- break;
- case lexer_t::token_t::TOK_MONTH:
- period.duration = date_duration_t(date_duration_t::MONTHS, 1);
- break;
- case lexer_t::token_t::TOK_WEEK:
- period.duration = date_duration_t(date_duration_t::WEEKS, 1);
- break;
- case lexer_t::token_t::TOK_DAY:
- period.duration = date_duration_t(date_duration_t::DAYS, 1);
- break;
- default:
- tok.unexpected();
- break;
- }
+ switch (tok.kind) {
+ case lexer_t::token_t::TOK_YEAR:
+ period.duration = date_duration_t(date_duration_t::YEARS, 1);
+ break;
+ case lexer_t::token_t::TOK_QUARTER:
+ period.duration = date_duration_t(date_duration_t::QUARTERS, 1);
+ break;
+ case lexer_t::token_t::TOK_MONTH:
+ period.duration = date_duration_t(date_duration_t::MONTHS, 1);
+ break;
+ case lexer_t::token_t::TOK_WEEK:
+ period.duration = date_duration_t(date_duration_t::WEEKS, 1);
+ break;
+ case lexer_t::token_t::TOK_DAY:
+ period.duration = date_duration_t(date_duration_t::DAYS, 1);
+ break;
+ default:
+ tok.unexpected();
+ break;
+ }
}
break;
@@ -983,13 +983,13 @@ void date_interval_t::resolve_end()
if (start && ! end_of_duration) {
end_of_duration = duration->add(*start);
DEBUG("times.interval",
- "stabilize: end_of_duration = " << *end_of_duration);
+ "stabilize: end_of_duration = " << *end_of_duration);
}
if (finish && *end_of_duration > *finish) {
end_of_duration = finish;
DEBUG("times.interval",
- "stabilize: end_of_duration reset to end: " << *end_of_duration);
+ "stabilize: end_of_duration reset to end: " << *end_of_duration);
}
if (start && ! next) {
@@ -1009,9 +1009,9 @@ date_t date_duration_t::find_nearest(const date_t& date, skip_quantum_t skip)
case date_duration_t::QUARTERS:
result = date_t(date.year(), date.month(), 1);
while (result.month() != gregorian::Jan &&
- result.month() != gregorian::Apr &&
- result.month() != gregorian::Jul &&
- result.month() != gregorian::Oct)
+ result.month() != gregorian::Apr &&
+ result.month() != gregorian::Jul &&
+ result.month() != gregorian::Oct)
result -= gregorian::months(1);
break;
case date_duration_t::MONTHS:
@@ -1043,7 +1043,7 @@ void date_interval_t::stabilize(const optional<date_t>& date)
DEBUG("times.interval", "stabilize: date passed, but not aligned");
if (duration) {
DEBUG("times.interval",
- "stabilize: aligning with a duration: " << *duration);
+ "stabilize: aligning with a duration: " << *duration);
// The interval object has not been seeded with a start date yet, so
// find the nearest period before on on date which fits, if possible.
@@ -1057,71 +1057,71 @@ void date_interval_t::stabilize(const optional<date_t>& date)
#if defined(DEBUG_ON)
if (initial_start)
- DEBUG("times.interval",
- "stabilize: initial_start = " << *initial_start);
+ DEBUG("times.interval",
+ "stabilize: initial_start = " << *initial_start);
if (initial_finish)
- DEBUG("times.interval",
- "stabilize: initial_finish = " << *initial_finish);
+ DEBUG("times.interval",
+ "stabilize: initial_finish = " << *initial_finish);
#endif
date_t when = start ? *start : *date;
if (duration->quantum == date_duration_t::MONTHS ||
- duration->quantum == date_duration_t::QUARTERS ||
- duration->quantum == date_duration_t::YEARS) {
- DEBUG("times.interval",
- "stabilize: monthly, quarterly or yearly duration");
- start = date_duration_t::find_nearest(when, duration->quantum);
+ duration->quantum == date_duration_t::QUARTERS ||
+ duration->quantum == date_duration_t::YEARS) {
+ DEBUG("times.interval",
+ "stabilize: monthly, quarterly or yearly duration");
+ start = date_duration_t::find_nearest(when, duration->quantum);
} else {
- DEBUG("times.interval", "stabilize: daily or weekly duration");
- start = date_duration_t::find_nearest(when - gregorian::days(400),
- duration->quantum);
+ DEBUG("times.interval", "stabilize: daily or weekly duration");
+ start = date_duration_t::find_nearest(when - gregorian::days(400),
+ duration->quantum);
}
DEBUG("times.interval",
- "stabilize: beginning start date = " << *start);
+ "stabilize: beginning start date = " << *start);
while (*start < *date) {
- date_interval_t next_interval(*this);
- ++next_interval;
-
- if (next_interval.start && *next_interval.start < *date) {
- *this = next_interval;
- } else {
- end_of_duration = none;
- next = none;
- break;
- }
+ date_interval_t next_interval(*this);
+ ++next_interval;
+
+ if (next_interval.start && *next_interval.start < *date) {
+ *this = next_interval;
+ } else {
+ end_of_duration = none;
+ next = none;
+ break;
+ }
}
DEBUG("times.interval", "stabilize: proposed start date = " << *start);
if (initial_start && (! start || *start < *initial_start)) {
- // Using the discovered start, find the end of the period
- resolve_end();
+ // Using the discovered start, find the end of the period
+ resolve_end();
- start = initial_start;
- DEBUG("times.interval", "stabilize: start reset to initial start");
+ start = initial_start;
+ DEBUG("times.interval", "stabilize: start reset to initial start");
}
if (initial_finish && (! finish || *finish > *initial_finish)) {
- finish = initial_finish;
- DEBUG("times.interval", "stabilize: finish reset to initial finish");
+ finish = initial_finish;
+ DEBUG("times.interval", "stabilize: finish reset to initial finish");
}
#if defined(DEBUG_ON)
if (start)
- DEBUG("times.interval", "stabilize: final start = " << *start);
+ DEBUG("times.interval", "stabilize: final start = " << *start);
if (finish)
- DEBUG("times.interval", "stabilize: final finish = " << *finish);
+ DEBUG("times.interval", "stabilize: final finish = " << *finish);
#endif
}
else if (range) {
if (date) {
- start = range->begin(date->year());
- finish = range->end(date->year());
+ start = range->begin(date->year());
+ finish = range->end(date->year());
} else {
- start = range->begin();
- finish = range->end();
+ start = range->begin();
+ finish = range->end();
}
}
aligned = true;
@@ -1134,7 +1134,7 @@ void date_interval_t::stabilize(const optional<date_t>& date)
if (! start && ! finish)
throw_(date_error,
- _("Invalid date interval: neither start, nor finish, nor duration"));
+ _("Invalid date interval: neither start, nor finish, nor duration"));
} else {
resolve_end();
}
@@ -1146,7 +1146,7 @@ bool date_interval_t::find_period(const date_t& date)
if (finish && date > *finish) {
DEBUG("times.interval",
- "false: date [" << date << "] > finish [" << *finish << "]");
+ "false: date [" << date << "] > finish [" << *finish << "]");
return false;
}
@@ -1155,15 +1155,15 @@ bool date_interval_t::find_period(const date_t& date)
}
else if (date < *start) {
DEBUG("times.interval",
- "false: date [" << date << "] < start [" << *start << "]");
+ "false: date [" << date << "] < start [" << *start << "]");
return false;
}
if (end_of_duration) {
if (date < *end_of_duration) {
DEBUG("times.interval",
- "true: date [" << date << "] < end_of_duration ["
- << *end_of_duration << "]");
+ "true: date [" << date << "] < end_of_duration ["
+ << *end_of_duration << "]");
return true;
}
} else {
@@ -1185,17 +1185,17 @@ bool date_interval_t::find_period(const date_t& date)
while (date >= scan && (! finish || scan < *finish)) {
if (date < end_of_scan) {
- start = scan;
+ start = scan;
end_of_duration = end_of_scan;
- next = none;
+ next = none;
- DEBUG("times.interval", "true: start = " << *start);
+ DEBUG("times.interval", "true: start = " << *start);
DEBUG("times.interval", "true: end_of_duration = " << *end_of_duration);
return true;
}
- scan = duration->add(scan);
+ scan = duration->add(scan);
end_of_scan = duration->add(scan);
}
@@ -1211,7 +1211,7 @@ date_interval_t& date_interval_t::operator++()
if (! duration)
throw_(date_error,
- _("Cannot increment a date interval without a duration"));
+ _("Cannot increment a date interval without a duration"));
assert(next);
@@ -1319,16 +1319,16 @@ date_parser_t::lexer_t::token_t date_parser_t::lexer_t::next_token()
date_traits_t traits;
date_t when = parse_date_mask(possible_date.c_str(), none, &traits);
if (! when.is_not_a_date()) {
- begin = i;
- return token_t(token_t::TOK_DATE,
- token_t::content_t(date_specifier_t(when, traits)));
+ begin = i;
+ return token_t(token_t::TOK_DATE,
+ token_t::content_t(date_specifier_t(when, traits)));
}
}
catch (date_error&) {
if (contains(possible_date, "/") ||
- contains(possible_date, "-") ||
- contains(possible_date, "."))
- throw;
+ contains(possible_date, "-") ||
+ contains(possible_date, "."))
+ throw;
}
}
@@ -1337,85 +1337,85 @@ date_parser_t::lexer_t::token_t date_parser_t::lexer_t::next_token()
string term;
bool alnum = std::isalnum(*begin);
for (; (begin != end && ! std::isspace(*begin) &&
- ((alnum && static_cast<bool>(std::isalnum(*begin))) ||
- (! alnum && ! static_cast<bool>(std::isalnum(*begin))))); begin++)
+ ((alnum && static_cast<bool>(std::isalnum(*begin))) ||
+ (! alnum && ! static_cast<bool>(std::isalnum(*begin))))); begin++)
term.push_back(*begin);
if (! term.empty()) {
if (std::isdigit(term[0])) {
if (term.length() == 4)
- return token_t(token_t::TOK_A_YEAR,
- token_t::content_t
- (lexical_cast<date_specifier_t::year_type>(term)));
+ return token_t(token_t::TOK_A_YEAR,
+ token_t::content_t
+ (lexical_cast<date_specifier_t::year_type>(term)));
else
- return token_t(token_t::TOK_INT,
- token_t::content_t(lexical_cast<unsigned short>(term)));
+ return token_t(token_t::TOK_INT,
+ token_t::content_t(lexical_cast<unsigned short>(term)));
}
else if (std::isalpha(term[0])) {
to_lower(term);
if (optional<date_time::months_of_year> month =
- string_to_month_of_year(term)) {
- return token_t(token_t::TOK_A_MONTH, token_t::content_t(*month));
+ string_to_month_of_year(term)) {
+ return token_t(token_t::TOK_A_MONTH, token_t::content_t(*month));
}
else if (optional<date_time::weekdays> wday =
- string_to_day_of_week(term)) {
- return token_t(token_t::TOK_A_WDAY, token_t::content_t(*wday));
+ string_to_day_of_week(term)) {
+ return token_t(token_t::TOK_A_WDAY, token_t::content_t(*wday));
}
else if (term == _("from") || term == _("since"))
- return token_t(token_t::TOK_SINCE);
+ return token_t(token_t::TOK_SINCE);
else if (term == _("to") || term == _("until"))
- return token_t(token_t::TOK_UNTIL);
+ return token_t(token_t::TOK_UNTIL);
else if (term == _("in"))
- return token_t(token_t::TOK_IN);
+ return token_t(token_t::TOK_IN);
else if (term == _("this"))
- return token_t(token_t::TOK_THIS);
+ return token_t(token_t::TOK_THIS);
else if (term == _("next"))
- return token_t(token_t::TOK_NEXT);
+ return token_t(token_t::TOK_NEXT);
else if (term == _("last"))
- return token_t(token_t::TOK_LAST);
+ return token_t(token_t::TOK_LAST);
else if (term == _("every"))
- return token_t(token_t::TOK_EVERY);
+ return token_t(token_t::TOK_EVERY);
else if (term == _("today"))
- return token_t(token_t::TOK_TODAY);
+ return token_t(token_t::TOK_TODAY);
else if (term == _("tomorrow"))
- return token_t(token_t::TOK_TOMORROW);
+ return token_t(token_t::TOK_TOMORROW);
else if (term == _("yesterday"))
- return token_t(token_t::TOK_YESTERDAY);
+ return token_t(token_t::TOK_YESTERDAY);
else if (term == _("year"))
- return token_t(token_t::TOK_YEAR);
+ return token_t(token_t::TOK_YEAR);
else if (term == _("quarter"))
- return token_t(token_t::TOK_QUARTER);
+ return token_t(token_t::TOK_QUARTER);
else if (term == _("month"))
- return token_t(token_t::TOK_MONTH);
+ return token_t(token_t::TOK_MONTH);
else if (term == _("week"))
- return token_t(token_t::TOK_WEEK);
+ return token_t(token_t::TOK_WEEK);
else if (term == _("day"))
- return token_t(token_t::TOK_DAY);
+ return token_t(token_t::TOK_DAY);
else if (term == _("yearly"))
- return token_t(token_t::TOK_YEARLY);
+ return token_t(token_t::TOK_YEARLY);
else if (term == _("quarterly"))
- return token_t(token_t::TOK_QUARTERLY);
+ return token_t(token_t::TOK_QUARTERLY);
else if (term == _("bimonthly"))
- return token_t(token_t::TOK_BIMONTHLY);
+ return token_t(token_t::TOK_BIMONTHLY);
else if (term == _("monthly"))
- return token_t(token_t::TOK_MONTHLY);
+ return token_t(token_t::TOK_MONTHLY);
else if (term == _("biweekly"))
- return token_t(token_t::TOK_BIWEEKLY);
+ return token_t(token_t::TOK_BIWEEKLY);
else if (term == _("weekly"))
- return token_t(token_t::TOK_WEEKLY);
+ return token_t(token_t::TOK_WEEKLY);
else if (term == _("daily"))
- return token_t(token_t::TOK_DAILY);
+ return token_t(token_t::TOK_DAILY);
else if (term == _("years"))
- return token_t(token_t::TOK_YEARS);
+ return token_t(token_t::TOK_YEARS);
else if (term == _("quarters"))
- return token_t(token_t::TOK_QUARTERS);
+ return token_t(token_t::TOK_QUARTERS);
else if (term == _("months"))
- return token_t(token_t::TOK_MONTHS);
+ return token_t(token_t::TOK_MONTHS);
else if (term == _("weeks"))
- return token_t(token_t::TOK_WEEKS);
+ return token_t(token_t::TOK_WEEKS);
else if (term == _("days"))
- return token_t(token_t::TOK_DAYS);
+ return token_t(token_t::TOK_DAYS);
}
else {
token_t::expected('\0', term[0]);
@@ -1462,12 +1462,12 @@ namespace {
typedef std::map<std::string, date_io_t *> date_io_map;
datetime_io_map temp_datetime_io;
- date_io_map temp_date_io;
+ date_io_map temp_date_io;
}
-std::string format_datetime(const datetime_t& when,
- const format_type_t format_type,
- const optional<const char *>& format)
+std::string format_datetime(const datetime_t& when,
+ const format_type_t format_type,
+ const optional<const char *>& format)
{
if (format_type == FMT_WRITTEN) {
return written_datetime_io->format(when);
@@ -1491,9 +1491,9 @@ std::string format_datetime(const datetime_t& when,
}
}
-std::string format_date(const date_t& when,
- const format_type_t format_type,
- const optional<const char *>& format)
+std::string format_date(const date_t& when,
+ const format_type_t format_type,
+ const optional<const char *>& format)
{
if (format_type == FMT_WRITTEN) {
return written_date_io->format(when);
diff --git a/src/times.h b/src/times.h
index 51cc8491..02b39ef7 100644
--- a/src/times.h
+++ b/src/times.h
@@ -51,8 +51,8 @@ namespace ledger {
DECLARE_EXCEPTION(datetime_error, std::runtime_error);
DECLARE_EXCEPTION(date_error, std::runtime_error);
-typedef boost::posix_time::ptime datetime_t;
-typedef datetime_t::time_duration_type time_duration_t;
+typedef boost::posix_time::ptime datetime_t;
+typedef datetime_t::time_duration_type time_duration_t;
inline bool is_valid(const datetime_t& moment) {
return ! moment.is_not_a_date_time();
@@ -89,14 +89,14 @@ typedef optional<date_t::year_type> optional_year;
datetime_t parse_datetime(const char * str, optional_year current_year = none);
inline datetime_t parse_datetime(const std::string& str,
- optional_year current_year = none) {
+ optional_year current_year = none) {
return parse_datetime(str.c_str(), current_year);
}
date_t parse_date(const char * str, optional_year current_year = none);
inline date_t parse_date(const std::string& str,
- optional_year current_year = none) {
+ optional_year current_year = none) {
return parse_date(str.c_str(), current_year);
}
@@ -105,18 +105,18 @@ enum format_type_t {
};
std::string format_datetime(const datetime_t& when,
- const format_type_t format_type = FMT_PRINTED,
- const optional<const char *>& format = none);
+ const format_type_t format_type = FMT_PRINTED,
+ const optional<const char *>& format = none);
void set_datetime_format(const char * format);
std::string format_date(const date_t& when,
- const format_type_t format_type = FMT_PRINTED,
- const optional<const char *>& format = none);
+ const format_type_t format_type = FMT_PRINTED,
+ const optional<const char *>& format = none);
void set_date_format(const char * format);
void set_input_date_format(const char * format);
inline void to_xml(std::ostream& out, const datetime_t& when,
- bool wrap = true)
+ bool wrap = true)
{
if (wrap) {
push_xml x(out, "datetime");
@@ -127,7 +127,7 @@ inline void to_xml(std::ostream& out, const datetime_t& when,
}
inline void to_xml(std::ostream& out, const date_t& when,
- bool wrap = true)
+ bool wrap = true)
{
if (wrap) {
push_xml x(out, "date");
@@ -144,8 +144,8 @@ struct date_traits_t
bool has_day;
date_traits_t(bool _has_year = false,
- bool _has_month = false,
- bool _has_day = false)
+ bool _has_month = false,
+ bool _has_day = false)
: has_year(_has_year), has_month(_has_month), has_day(_has_day) {
TRACE_CTOR(date_traits_t, "bool, bool, bool");
}
@@ -160,16 +160,16 @@ struct date_traits_t
}
date_traits_t& operator=(const date_traits_t& traits) {
- has_year = traits.has_year;
+ has_year = traits.has_year;
has_month = traits.has_month;
- has_day = traits.has_day;
+ has_day = traits.has_day;
return *this;
}
bool operator==(const date_traits_t& traits) const {
- return (has_year == traits.has_year &&
- has_month == traits.has_month &&
- has_day == traits.has_day);
+ return (has_year == traits.has_year &&
+ has_month == traits.has_month &&
+ has_day == traits.has_day);
}
#if defined(HAVE_BOOST_SERIALIZATION)
@@ -249,11 +249,11 @@ struct date_duration_t
out << length << ' ';
switch (quantum) {
- case DAYS: out << "day"; break;
- case WEEKS: out << "week"; break;
+ case DAYS: out << "day"; break;
+ case WEEKS: out << "week"; break;
case MONTHS: out << "month"; break;
case QUARTERS: out << "quarter"; break;
- case YEARS: out << "year"; break;
+ case YEARS: out << "year"; break;
default:
assert(false);
break;
@@ -287,31 +287,31 @@ class date_specifier_t
public:
#if 0
- typedef date_t::year_type year_type;
+ typedef date_t::year_type year_type;
#else
- typedef unsigned short year_type;
+ typedef unsigned short year_type;
#endif
- typedef date_t::month_type month_type;
- typedef date_t::day_type day_type;
+ typedef date_t::month_type month_type;
+ typedef date_t::day_type day_type;
typedef date_t::day_of_week_type day_of_week_type;
protected:
- optional<year_type> year;
- optional<month_type> month;
- optional<day_type> day;
+ optional<year_type> year;
+ optional<month_type> month;
+ optional<day_type> day;
optional<day_of_week_type> wday;
public:
date_specifier_t(const optional<year_type>& _year = none,
- const optional<month_type>& _month = none,
- const optional<day_type>& _day = none,
- const optional<day_of_week_type>& _wday = none)
+ const optional<month_type>& _month = none,
+ const optional<day_type>& _day = none,
+ const optional<day_of_week_type>& _wday = none)
: year(_year), month(_month), day(_day), wday(_wday) {
TRACE_CTOR(date_specifier_t,
- "year_type, month_type, day_type, day_of_week_type");
+ "year_type, month_type, day_type, day_of_week_type");
}
date_specifier_t(const date_t& date,
- const optional<date_traits_t>& traits = none) {
+ const optional<date_traits_t>& traits = none) {
TRACE_CTOR(date_specifier_t, "date_t, date_traits_t");
if (! traits || traits->has_year)
year = date.year();
@@ -333,7 +333,7 @@ public:
date_t end(const optional_year& current_year = none) const;
bool is_within(const date_t& date,
- const optional_year& current_year = none) const {
+ const optional_year& current_year = none) const {
return date >= begin(current_year) && date < end(current_year);
}
@@ -390,7 +390,7 @@ class date_range_t
public:
date_range_t(const optional<date_specifier_t>& _range_begin = none,
- const optional<date_specifier_t>& _range_end = none)
+ const optional<date_specifier_t>& _range_end = none)
: range_begin(_range_begin), range_end(_range_end),
end_inclusive(false) {
TRACE_CTOR(date_range_t, "date_specifier_t, date_specifier_t");
@@ -413,16 +413,16 @@ public:
optional<date_t> end(const optional_year& current_year = none) const {
if (range_end) {
if (end_inclusive)
- return range_end->end(current_year);
+ return range_end->end(current_year);
else
- return range_end->begin(current_year);
+ return range_end->begin(current_year);
} else {
return none;
}
}
bool is_within(const date_t& date,
- const optional_year& current_year = none) const {
+ const optional_year& current_year = none) const {
optional<date_t> b = begin(current_year);
optional<date_t> e = end(current_year);
bool after_begin = b ? date >= *b : true;
@@ -527,19 +527,19 @@ private:
class date_interval_t : public equality_comparable<date_interval_t>
{
public:
- static date_t add_duration(const date_t& date,
- const date_duration_t& duration);
- static date_t subtract_duration(const date_t& date,
- const date_duration_t& duration);
+ static date_t add_duration(const date_t& date,
+ const date_duration_t& duration);
+ static date_t subtract_duration(const date_t& date,
+ const date_duration_t& duration);
optional<date_specifier_or_range_t> range;
- optional<date_t> start; // the real start, after adjustment
- optional<date_t> finish; // the real end, likewise
- bool aligned;
- optional<date_t> next;
+ optional<date_t> start; // the real start, after adjustment
+ optional<date_t> finish; // the real end, likewise
+ bool aligned;
+ optional<date_t> next;
optional<date_duration_t> duration;
- optional<date_t> end_of_duration;
+ optional<date_t> end_of_duration;
explicit date_interval_t() : aligned(false) {
TRACE_CTOR(date_interval_t, "");
@@ -564,7 +564,7 @@ public:
bool operator==(const date_interval_t& other) const {
return (start == other.start &&
- (! start || *start == *other.start));
+ (! start || *start == *other.start));
}
operator bool() const {
@@ -580,8 +580,8 @@ public:
void parse(const string& str);
- void resolve_end();
- void stabilize(const optional<date_t>& date = none);
+ void resolve_end();
+ void stabilize(const optional<date_t>& date = none);
bool is_valid() const {
return start;
diff --git a/src/token.cc b/src/token.cc
index 905e13fe..9dfff065 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -50,74 +50,74 @@ int expr_t::token_t::parse_reserved_word(std::istream& in)
switch (buf[0]) {
case 'a':
if (std::strcmp(buf, "and") == 0) {
- symbol[0] = '&';
- symbol[1] = '\0';
- kind = KW_AND;
- return 1;
+ symbol[0] = '&';
+ symbol[1] = '\0';
+ kind = KW_AND;
+ return 1;
}
break;
case 'd':
if (std::strcmp(buf, "div") == 0) {
- symbol[0] = '/';
- symbol[1] = '/';
- symbol[2] = '\0';
- kind = KW_DIV;
- return 1;
+ symbol[0] = '/';
+ symbol[1] = '/';
+ symbol[2] = '\0';
+ kind = KW_DIV;
+ return 1;
}
break;
case 'e':
if (std::strcmp(buf, "else") == 0) {
- symbol[0] = 'L';
- symbol[1] = 'S';
- symbol[2] = '\0';
- kind = KW_ELSE;
- return 1;
+ symbol[0] = 'L';
+ symbol[1] = 'S';
+ symbol[2] = '\0';
+ kind = KW_ELSE;
+ return 1;
}
break;
case 'f':
if (std::strcmp(buf, "false") == 0) {
- kind = VALUE;
- value = false;
- return 1;
+ kind = VALUE;
+ value = false;
+ return 1;
}
break;
case 'i':
if (std::strcmp(buf, "if") == 0) {
- symbol[0] = 'i';
- symbol[1] = 'f';
- symbol[2] = '\0';
- kind = KW_IF;
- return 1;
+ symbol[0] = 'i';
+ symbol[1] = 'f';
+ symbol[2] = '\0';
+ kind = KW_IF;
+ return 1;
}
break;
case 'o':
if (std::strcmp(buf, "or") == 0) {
- symbol[0] = '|';
- symbol[1] = '\0';
- kind = KW_OR;
- return 1;
+ symbol[0] = '|';
+ symbol[1] = '\0';
+ kind = KW_OR;
+ return 1;
}
break;
case 'n':
if (std::strcmp(buf, "not") == 0) {
- symbol[0] = '!';
- symbol[1] = '\0';
- kind = EXCLAM;
- return 1;
+ symbol[0] = '!';
+ symbol[1] = '\0';
+ kind = EXCLAM;
+ return 1;
}
break;
case 't':
if (std::strcmp(buf, "true") == 0) {
- kind = VALUE;
- value = true;
- return 1;
+ kind = VALUE;
+ value = true;
+ return 1;
}
break;
}
@@ -129,7 +129,7 @@ int expr_t::token_t::parse_reserved_word(std::istream& in)
void expr_t::token_t::parse_ident(std::istream& in)
{
- kind = IDENT;
+ kind = IDENT;
length = 0;
char c, buf[256];
@@ -139,7 +139,7 @@ void expr_t::token_t::parse_ident(std::istream& in)
}
void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
- const char expecting)
+ const char expecting)
{
if (in.eof()) {
kind = TOK_EOF;
@@ -210,7 +210,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
optional<date_t> begin = timespan.begin();
if (! begin)
throw_(parse_error,
- _("Date specifier does not refer to a starting date"));
+ _("Date specifier does not refer to a starting date"));
kind = VALUE;
value = *begin;
break;
@@ -302,12 +302,12 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
in.get(c);
if (pflags.has_flags(PARSE_OP_CONTEXT)) { // operator context
kind = SLASH;
- } else { // terminal context
+ } else { // terminal context
// Read in the regexp
char buf[256];
READ_INTO_(in, buf, 255, c, length, c != '/');
if (c != '/')
- expected('/', c);
+ expected('/', c);
in.get(c);
length++;
@@ -395,7 +395,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
in.clear();
in.seekg(pos, std::ios::beg);
if (in.fail())
- throw_(parse_error, _("Failed to reset input stream"));
+ throw_(parse_error, _("Failed to reset input stream"));
}
// When in relaxed parsing mode, we want to migrate commodity flags
@@ -411,30 +411,30 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
try {
amount_t temp;
if (! temp.parse(in, parse_flags.plus_flags(PARSE_SOFT_FAIL))) {
- // If the amount had no commodity, it must be an unambiguous
- // variable reference
-
- in.clear();
- in.seekg(pos, std::ios::beg);
- if (in.fail())
- throw_(parse_error, _("Failed to reset input stream"));
-
- c = static_cast<char>(in.peek());
- if (std::isdigit(c) || c == '.')
- expected('\0', c);
-
- parse_ident(in);
-
- if (value.as_string().length() == 0) {
- kind = ERROR;
- symbol[0] = c;
- symbol[1] = '\0';
- unexpected(expecting);
- }
+ // If the amount had no commodity, it must be an unambiguous
+ // variable reference
+
+ in.clear();
+ in.seekg(pos, std::ios::beg);
+ if (in.fail())
+ throw_(parse_error, _("Failed to reset input stream"));
+
+ c = static_cast<char>(in.peek());
+ if (std::isdigit(c) || c == '.')
+ expected('\0', c);
+
+ parse_ident(in);
+
+ if (value.as_string().length() == 0) {
+ kind = ERROR;
+ symbol[0] = c;
+ symbol[1] = '\0';
+ unexpected(expecting);
+ }
} else {
- kind = VALUE;
- value = temp;
- length = static_cast<std::size_t>(in.tellg() - pos);
+ kind = VALUE;
+ value = temp;
+ length = static_cast<std::size_t>(in.tellg() - pos);
}
}
catch (const std::exception& err) {
@@ -476,16 +476,16 @@ void expr_t::token_t::unexpected(const char wanted)
switch (prev_kind) {
case TOK_EOF:
throw_(parse_error,
- _("Unexpected end of expression (wanted '%1')") << wanted);
+ _("Unexpected end of expression (wanted '%1')") << wanted);
case IDENT:
throw_(parse_error,
- _("Unexpected symbol '%1' (wanted '%2')") << value << wanted);
+ _("Unexpected symbol '%1' (wanted '%2')") << value << wanted);
case VALUE:
throw_(parse_error,
- _("Unexpected value '%1' (wanted '%2')") << value << wanted);
+ _("Unexpected value '%1' (wanted '%2')") << value << wanted);
default:
throw_(parse_error, _("Unexpected expression token '%1' (wanted '%2')")
- << symbol << wanted);
+ << symbol << wanted);
}
}
}
diff --git a/src/token.h b/src/token.h
index 582373cb..aae73837 100644
--- a/src/token.h
+++ b/src/token.h
@@ -49,52 +49,52 @@ namespace ledger {
struct expr_t::token_t : public noncopyable
{
enum kind_t {
- ERROR, // an error occurred while tokenizing
- VALUE, // any kind of literal value
- IDENT, // [A-Za-z_][-A-Za-z0-9_:]*
- MASK, // /regexp/
-
- LPAREN, // (
- RPAREN, // )
-
- EQUAL, // ==
- NEQUAL, // !=
- LESS, // <
- LESSEQ, // <=
- GREATER, // >
- GREATEREQ, // >=
-
- DEFINE, // :=
- ASSIGN, // =
- MATCH, // =~
- NMATCH, // !~
- MINUS, // -
- PLUS, // +
- STAR, // *
- SLASH, // /
- KW_DIV, // div
-
- EXCLAM, // !, not
- KW_AND, // &, &&, and
- KW_OR, // |, ||, or
- KW_MOD, // %
-
- KW_IF, // if
- KW_ELSE, // else
-
- QUERY, // ?
- COLON, // :
-
- DOT, // .
- COMMA, // ,
- SEMI, // ;
+ ERROR, // an error occurred while tokenizing
+ VALUE, // any kind of literal value
+ IDENT, // [A-Za-z_][-A-Za-z0-9_:]*
+ MASK, // /regexp/
+
+ LPAREN, // (
+ RPAREN, // )
+
+ EQUAL, // ==
+ NEQUAL, // !=
+ LESS, // <
+ LESSEQ, // <=
+ GREATER, // >
+ GREATEREQ, // >=
+
+ DEFINE, // :=
+ ASSIGN, // =
+ MATCH, // =~
+ NMATCH, // !~
+ MINUS, // -
+ PLUS, // +
+ STAR, // *
+ SLASH, // /
+ KW_DIV, // div
+
+ EXCLAM, // !, not
+ KW_AND, // &, &&, and
+ KW_OR, // |, ||, or
+ KW_MOD, // %
+
+ KW_IF, // if
+ KW_ELSE, // else
+
+ QUERY, // ?
+ COLON, // :
+
+ DOT, // .
+ COMMA, // ,
+ SEMI, // ;
TOK_EOF,
UNKNOWN
} kind;
- char symbol[3];
+ char symbol[3];
value_t value;
std::size_t length;
@@ -108,7 +108,7 @@ struct expr_t::token_t : public noncopyable
token_t& operator=(const token_t& other) {
if (&other == this)
return *this;
- assert(false); // only one token object is used at a time
+ assert(false); // only one token object is used at a time
return *this;
}
@@ -125,7 +125,7 @@ struct expr_t::token_t : public noncopyable
int parse_reserved_word(std::istream& in);
void parse_ident(std::istream& in);
void next(std::istream& in, const parse_flags_t& flags,
- const char expecting = '\0');
+ const char expecting = '\0');
void rewind(std::istream& in);
void unexpected(const char wanted = '\0');
void expected(const char wanted, char c = '\0');
diff --git a/src/unistring.h b/src/unistring.h
index d42f2b28..979ce08b 100644
--- a/src/unistring.h
+++ b/src/unistring.h
@@ -67,7 +67,7 @@ public:
TRACE_CTOR(unistring, "std::string");
const char * p = input.c_str();
- std::size_t len = input.length();
+ std::size_t len = input.length();
VERIFY(utf8::is_valid(p, p + len));
utf8::unchecked::utf8to32(p, p + len, std::back_inserter(utf32chars));
@@ -81,9 +81,9 @@ public:
}
std::string extract(const std::string::size_type begin = 0,
- const std::string::size_type len = 0) const
+ const std::string::size_type len = 0) const
{
- std::string utf8result;
+ std::string utf8result;
std::string::size_type this_len = length();
assert(begin <= this_len);
@@ -91,10 +91,10 @@ public:
if (this_len)
utf8::unchecked::utf32to8
- (utf32chars.begin() + begin,
- utf32chars.begin() + begin +
- (len ? (len > this_len ? this_len : len) : this_len),
- std::back_inserter(utf8result));
+ (utf32chars.begin() + begin,
+ utf32chars.begin() + begin +
+ (len ? (len > this_len ? this_len : len) : this_len),
+ std::back_inserter(utf8result));
return utf8result;
}
@@ -103,7 +103,7 @@ public:
std::size_t idx = 0;
foreach (const boost::uint32_t& ch, utf32chars) {
if (idx >= __pos && ch == __s)
- return idx;
+ return idx;
idx++;
}
return npos;
@@ -118,10 +118,10 @@ public:
};
inline void justify(std::ostream& out,
- const std::string& str,
- int width,
- bool right = false,
- bool redden = false)
+ const std::string& str,
+ int width,
+ bool right = false,
+ bool redden = false)
{
if (! right) {
if (redden) out << "\033[31m";
diff --git a/src/utils.cc b/src/utils.cc
index b8acb3db..dce804ff 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -45,9 +45,9 @@ namespace ledger {
DECLARE_EXCEPTION(assertion_failed, std::logic_error);
void debug_assert(const string& reason,
- const string& func,
- const string& file,
- std::size_t line)
+ const string& func,
+ const string& file,
+ std::size_t line)
{
std::ostringstream buf;
buf << "Assertion failed in \"" << file << "\", line " << line
@@ -80,11 +80,11 @@ typedef std::map<std::string, count_size_pair> object_count_map;
namespace {
bool memory_tracing_active = false;
- memory_map * live_memory = NULL;
- memory_map * freed_memory = NULL;
+ memory_map * live_memory = NULL;
+ memory_map * freed_memory = NULL;
object_count_map * live_memory_count = NULL;
object_count_map * total_memory_count = NULL;
- objects_map * live_objects = NULL;
+ objects_map * live_objects = NULL;
object_count_map * live_object_count = NULL;
object_count_map * total_object_count = NULL;
object_count_map * total_ctor_count = NULL;
@@ -94,11 +94,11 @@ void initialize_memory_tracing()
{
memory_tracing_active = false;
- live_memory = new memory_map;
- freed_memory = new memory_map;
+ live_memory = new memory_map;
+ freed_memory = new memory_map;
live_memory_count = new object_count_map;
total_memory_count = new object_count_map;
- live_objects = new objects_map;
+ live_objects = new objects_map;
live_object_count = new object_count_map;
total_object_count = new object_count_map;
total_ctor_count = new object_count_map;
@@ -119,18 +119,18 @@ void shutdown_memory_tracing()
report_memory(std::cerr);
}
- checked_delete(live_memory); live_memory = NULL;
- checked_delete(freed_memory); freed_memory = NULL;
- checked_delete(live_memory_count); live_memory_count = NULL;
+ checked_delete(live_memory); live_memory = NULL;
+ checked_delete(freed_memory); freed_memory = NULL;
+ checked_delete(live_memory_count); live_memory_count = NULL;
checked_delete(total_memory_count); total_memory_count = NULL;
- checked_delete(live_objects); live_objects = NULL;
- checked_delete(live_object_count); live_object_count = NULL;
+ checked_delete(live_objects); live_objects = NULL;
+ checked_delete(live_object_count); live_object_count = NULL;
checked_delete(total_object_count); total_object_count = NULL;
- checked_delete(total_ctor_count); total_ctor_count = NULL;
+ checked_delete(total_ctor_count); total_ctor_count = NULL;
}
inline void add_to_count_map(object_count_map& the_map,
- const char * name, std::size_t size)
+ const char * name, std::size_t size)
{
object_count_map::iterator k = the_map.find(name);
if (k != the_map.end()) {
@@ -274,9 +274,9 @@ inline void report_count_map(std::ostream& out, object_count_map& the_map)
{
foreach (object_count_map::value_type& pair, the_map)
out << " " << std::right << std::setw(12) << pair.second.first
- << " " << std::right << std::setw(7) << pair.second.second
- << " " << std::left << pair.first
- << std::endl;
+ << " " << std::right << std::setw(7) << pair.second.second
+ << " " << std::left << pair.first
+ << std::endl;
}
std::size_t current_objects_size()
@@ -290,7 +290,7 @@ std::size_t current_objects_size()
}
void trace_ctor_func(void * ptr, const char * cls_name, const char * args,
- std::size_t cls_size)
+ std::size_t cls_size)
{
if (! live_objects || ! memory_tracing_active) return;
@@ -358,7 +358,7 @@ void report_memory(std::ostream& out, bool report_all)
if (live_memory_count->size() > 0) {
out << "NOTE: There may be memory held by Boost "
- << "and libstdc++ after ledger::shutdown()" << std::endl;
+ << "and libstdc++ after ledger::shutdown()" << std::endl;
out << "Live memory count:" << std::endl;
report_count_map(out, *live_memory_count);
}
@@ -368,9 +368,9 @@ void report_memory(std::ostream& out, bool report_all)
foreach (const memory_map::value_type& pair, *live_memory)
out << " " << std::right << std::setw(12) << pair.first
- << " " << std::right << std::setw(7) << pair.second.second
- << " " << std::left << pair.second.first
- << std::endl;
+ << " " << std::right << std::setw(7) << pair.second.second
+ << " " << std::left << pair.second.first
+ << std::endl;
}
if (report_all && total_memory_count->size() > 0) {
@@ -388,9 +388,9 @@ void report_memory(std::ostream& out, bool report_all)
foreach (const objects_map::value_type& pair, *live_objects)
out << " " << std::right << std::setw(12) << pair.first
- << " " << std::right << std::setw(7) << pair.second.second
- << " " << std::left << pair.second.first
- << std::endl;
+ << " " << std::right << std::setw(7) << pair.second.second
+ << " " << std::left << pair.second.first
+ << std::endl;
}
if (report_all) {
@@ -470,28 +470,28 @@ strings_list split_arguments(const char * line)
for (const char * p = line; *p; p++) {
if (! in_quoted_string && std::isspace(*p)) {
if (q != buf) {
- *q = '\0';
- args.push_back(buf);
- q = buf;
+ *q = '\0';
+ args.push_back(buf);
+ q = buf;
}
}
else if (in_quoted_string != '\'' && *p == '\\') {
p++;
if (! *p)
- throw_(std::logic_error, _("Invalid use of backslash"));
+ throw_(std::logic_error, _("Invalid use of backslash"));
*q++ = *p;
}
else if (in_quoted_string != '"' && *p == '\'') {
if (in_quoted_string == '\'')
- in_quoted_string = '\0';
+ in_quoted_string = '\0';
else
- in_quoted_string = '\'';
+ in_quoted_string = '\'';
}
else if (in_quoted_string != '\'' && *p == '"') {
if (in_quoted_string == '"')
- in_quoted_string = '\0';
+ in_quoted_string = '\0';
else
- in_quoted_string = '"';
+ in_quoted_string = '"';
}
else {
*q++ = *p;
@@ -500,7 +500,7 @@ strings_list split_arguments(const char * line)
if (in_quoted_string)
throw_(std::logic_error,
- _("Unterminated string, expected '%1'") << in_quoted_string);
+ _("Unterminated string, expected '%1'") << in_quoted_string);
if (q != buf) {
*q = '\0';
@@ -521,12 +521,12 @@ strings_list split_arguments(const char * line)
namespace ledger {
-log_level_t _log_level = LOG_WARN;
-std::ostream * _log_stream = &std::cerr;
+log_level_t _log_level = LOG_WARN;
+std::ostream * _log_stream = &std::cerr;
std::ostringstream _log_buffer;
#if defined(TRACING_ON)
-uint8_t _trace_level;
+uint8_t _trace_level;
#endif
static inline void stream_memory_size(std::ostream& out, std::size_t size)
@@ -560,8 +560,8 @@ bool logger_func(log_level_t level)
}
*_log_stream << std::right << std::setw(5)
- << (TRUE_CURRENT_TIME() -
- logger_start).total_milliseconds() << "ms";
+ << (TRUE_CURRENT_TIME() -
+ logger_start).total_milliseconds() << "ms";
#if defined(VERIFY_ON)
IF_VERIFY() {
@@ -633,11 +633,11 @@ namespace ledger {
struct timer_t
{
- log_level_t level;
- ptime begin;
- time_duration spent;
- std::string description;
- bool active;
+ log_level_t level;
+ ptime begin;
+ time_duration spent;
+ std::string description;
+ bool active;
timer_t(log_level_t _level, std::string _description)
: level(_level), begin(TRUE_CURRENT_TIME()),
@@ -769,7 +769,7 @@ path expand_path(const path& pathname)
return pathname;
std::string path_string = pathname.string();
- const char * pfx = NULL;
+ const char * pfx = NULL;
string::size_type pos = path_string.find_first_of('/');
if (path_string.length() == 1 || pos == 1) {
@@ -779,14 +779,14 @@ path expand_path(const path& pathname)
// Punt. We're trying to expand ~/, but HOME isn't set
struct passwd * pw = getpwuid(getuid());
if (pw)
- pfx = pw->pw_dir;
+ pfx = pw->pw_dir;
}
#endif
}
#ifdef HAVE_GETPWNAM
else {
string user(path_string, 1, pos == string::npos ?
- string::npos : pos - 1);
+ string::npos : pos - 1);
struct passwd * pw = getpwnam(user.c_str());
if (pw)
pfx = pw->pw_dir;
diff --git a/src/utils.h b/src/utils.h
index 9135abde..40fa57cc 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -59,7 +59,7 @@
#define NO_ASSERTS 1
//#define NO_LOGGING 1
#else
-#define TRACING_ON 1 // use --trace X to enable
+#define TRACING_ON 1 // use --trace X to enable
#endif
/*@}*/
@@ -80,15 +80,15 @@ namespace ledger {
typedef std::list<string> strings_list;
- typedef posix_time::ptime ptime;
+ typedef posix_time::ptime ptime;
typedef ptime::time_duration_type time_duration;
- typedef gregorian::date date;
+ typedef gregorian::date date;
typedef gregorian::date_duration date_duration;
- typedef posix_time::seconds seconds;
+ typedef posix_time::seconds seconds;
- typedef boost::filesystem::path path;
- typedef boost::filesystem::ifstream ifstream;
- typedef boost::filesystem::ofstream ofstream;
+ typedef boost::filesystem::path path;
+ typedef boost::filesystem::ifstream ifstream;
+ typedef boost::filesystem::ofstream ofstream;
typedef boost::filesystem::filesystem_error filesystem_error;
}
@@ -110,12 +110,12 @@ namespace ledger {
namespace ledger {
void debug_assert(const string& reason, const string& func,
- const string& file, std::size_t line);
+ const string& file, std::size_t line);
}
-#define assert(x) \
- ((x) ? ((void)0) : debug_assert(#x, BOOST_CURRENT_FUNCTION, \
- __FILE__, __LINE__))
+#define assert(x) \
+ ((x) ? ((void)0) : debug_assert(#x, BOOST_CURRENT_FUNCTION, \
+ __FILE__, __LINE__))
#else // ! ASSERTS_ON
@@ -146,7 +146,7 @@ std::size_t current_memory_size();
std::size_t current_objects_size();
void trace_ctor_func(void * ptr, const char * cls_name, const char * args,
- std::size_t cls_size);
+ std::size_t cls_size);
void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size);
#define TRACE_CTOR(cls, args) \
@@ -239,8 +239,8 @@ inline string operator+(const string& __lhs, const char* __rhs)
inline string operator+(const string& __lhs, char __rhs)
{
- typedef string __string_type;
- typedef string::size_type __size_type;
+ typedef string __string_type;
+ typedef string::size_type __size_type;
__string_type __str(__lhs);
__str.append(__size_type(1), __rhs);
return __str;
@@ -301,8 +301,8 @@ enum log_level_t {
LOG_ALL
};
-extern log_level_t _log_level;
-extern std::ostream * _log_stream;
+extern log_level_t _log_level;
+extern std::ostream * _log_stream;
extern std::ostringstream _log_buffer;
bool logger_func(log_level_t level);
@@ -539,7 +539,7 @@ extern "C" char * realpath(const char *, char resolved_path[]);
#endif
inline const string& either_or(const string& first,
- const string& second) {
+ const string& second) {
return first.empty() ? second : first;
}
@@ -587,62 +587,62 @@ inline char peek_next_nonws(std::istream& in) {
return c;
}
-#define READ_INTO(str, targ, size, var, cond) { \
- char * _p = targ; \
- var = static_cast<char>(str.peek()); \
- while (str.good() && ! str.eof() && var != '\n' && \
- (cond) && _p - targ < size) { \
- str.get(var); \
- if (str.eof()) \
- break; \
- if (var == '\\') { \
- str.get(var); \
- if (in.eof()) \
- break; \
- switch (var) { \
- case 'b': var = '\b'; break; \
- case 'f': var = '\f'; break; \
- case 'n': var = '\n'; break; \
- case 'r': var = '\r'; break; \
- case 't': var = '\t'; break; \
- case 'v': var = '\v'; break; \
- default: break; \
- } \
- } \
- *_p++ = var; \
- var = static_cast<char>(str.peek()); \
- } \
- *_p = '\0'; \
+#define READ_INTO(str, targ, size, var, cond) { \
+ char * _p = targ; \
+ var = static_cast<char>(str.peek()); \
+ while (str.good() && ! str.eof() && var != '\n' && \
+ (cond) && _p - targ < size) { \
+ str.get(var); \
+ if (str.eof()) \
+ break; \
+ if (var == '\\') { \
+ str.get(var); \
+ if (in.eof()) \
+ break; \
+ switch (var) { \
+ case 'b': var = '\b'; break; \
+ case 'f': var = '\f'; break; \
+ case 'n': var = '\n'; break; \
+ case 'r': var = '\r'; break; \
+ case 't': var = '\t'; break; \
+ case 'v': var = '\v'; break; \
+ default: break; \
+ } \
+ } \
+ *_p++ = var; \
+ var = static_cast<char>(str.peek()); \
+ } \
+ *_p = '\0'; \
}
-#define READ_INTO_(str, targ, size, var, idx, cond) { \
- char * _p = targ; \
- var = static_cast<char>(str.peek()); \
- while (str.good() && ! str.eof() && var != '\n' && \
- (cond) && _p - targ < size) { \
- str.get(var); \
- if (str.eof()) \
- break; \
- idx++; \
- if (var == '\\') { \
- str.get(var); \
- if (in.eof()) \
- break; \
- switch (var) { \
- case 'b': var = '\b'; break; \
- case 'f': var = '\f'; break; \
- case 'n': var = '\n'; break; \
- case 'r': var = '\r'; break; \
- case 't': var = '\t'; break; \
- case 'v': var = '\v'; break; \
- default: break; \
- } \
- idx++; \
- } \
- *_p++ = var; \
- var = static_cast<char>(str.peek()); \
- } \
- *_p = '\0'; \
+#define READ_INTO_(str, targ, size, var, idx, cond) { \
+ char * _p = targ; \
+ var = static_cast<char>(str.peek()); \
+ while (str.good() && ! str.eof() && var != '\n' && \
+ (cond) && _p - targ < size) { \
+ str.get(var); \
+ if (str.eof()) \
+ break; \
+ idx++; \
+ if (var == '\\') { \
+ str.get(var); \
+ if (in.eof()) \
+ break; \
+ switch (var) { \
+ case 'b': var = '\b'; break; \
+ case 'f': var = '\f'; break; \
+ case 'n': var = '\n'; break; \
+ case 'r': var = '\r'; break; \
+ case 't': var = '\t'; break; \
+ case 'v': var = '\v'; break; \
+ default: break; \
+ } \
+ idx++; \
+ } \
+ *_p++ = var; \
+ var = static_cast<char>(str.peek()); \
+ } \
+ *_p = '\0'; \
}
inline string to_hex(uint_least32_t * message_digest, const int len = 1)
@@ -654,7 +654,7 @@ inline string to_hex(uint_least32_t * message_digest, const int len = 1)
buf.fill('0');
buf << std::hex << message_digest[i];
if (i + 1 >= len)
- break; // only output the first LEN dwords
+ break; // only output the first LEN dwords
}
return buf.str();
}
@@ -672,12 +672,12 @@ inline string sha1sum(const string& str)
class push_xml
{
std::ostream& out;
- string tag;
- bool leave_open;
+ string tag;
+ bool leave_open;
public:
push_xml(std::ostream& _out, const string& _tag, bool has_attrs = false,
- bool _leave_open = false)
+ bool _leave_open = false)
: out(_out), tag(_tag), leave_open(_leave_open) {
out << '<' << tag;
if (! has_attrs)
@@ -697,17 +697,17 @@ public:
foreach (const char& ch, str) {
switch (ch) {
case '<':
- buf << "&lt;";
- break;
+ buf << "&lt;";
+ break;
case '>':
- buf << "&gt;";
- break;
+ buf << "&gt;";
+ break;
case '&':
- buf << "&amp;";
- break;
+ buf << "&amp;";
+ break;
default:
- buf << ch;
- break;
+ buf << ch;
+ break;
}
}
return buf.str();
diff --git a/src/value.cc b/src/value.cc
index 74dd843d..63e48333 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -35,7 +35,7 @@
#include "commodity.h"
#include "annotate.h"
#include "pool.h"
-#include "unistring.h" // for justify()
+#include "unistring.h" // for justify()
#include "op.h"
namespace ledger {
@@ -65,11 +65,11 @@ value_t::storage_t& value_t::storage_t::operator=(const value_t::storage_t& rhs)
void value_t::initialize()
{
- true_value = new storage_t;
+ true_value = new storage_t;
true_value->type = BOOLEAN;
true_value->data = true;
- false_value = new storage_t;
+ false_value = new storage_t;
false_value->type = BOOLEAN;
false_value->data = false;
}
@@ -103,14 +103,14 @@ value_t::operator bool() const
std::ostringstream out;
out << *this;
throw_(value_error,
- _("Cannot determine truth of %1 (did you mean 'account =~ %2'?)")
- << label() << out.str());
+ _("Cannot determine truth of %1 (did you mean 'account =~ %2'?)")
+ << label() << out.str());
}
case SEQUENCE:
if (! as_sequence().empty()) {
foreach (const value_t& value, as_sequence()) {
- if (value)
- return true;
+ if (value)
+ return true;
}
}
return false;
@@ -281,7 +281,7 @@ void value_t::in_place_simplify()
DEBUG_("as an amount it looks like: " << *this);
}
-#ifdef REDUCE_TO_INTEGER // this is off by default
+#ifdef REDUCE_TO_INTEGER // this is off by default
if (is_amount() && ! as_amount().has_commodity() &&
as_amount().fits_in_long()) {
DEBUG_("Reducing amount to integer");
@@ -307,7 +307,7 @@ value_t value_t::number() const
if (! as_sequence().empty()) {
value_t temp;
foreach (const value_t& value, as_sequence())
- temp += value.number();
+ temp += value.number();
return temp;
}
break;
@@ -333,14 +333,14 @@ value_t& value_t::operator+=(const value_t& val)
else if (is_sequence()) {
if (val.is_sequence()) {
if (size() == val.size()) {
- sequence_t::iterator i = begin();
- sequence_t::const_iterator j = val.begin();
+ sequence_t::iterator i = begin();
+ sequence_t::const_iterator j = val.begin();
- for (; i != end(); i++, j++)
- *i += *j;
+ for (; i != end(); i++, j++)
+ *i += *j;
} else {
- add_error_context(_("While adding %1 to %2:") << *this << val);
- throw_(value_error, _("Cannot add sequences of different lengths"));
+ add_error_context(_("While adding %1 to %2:") << *this << val);
+ throw_(value_error, _("Cannot add sequences of different lengths"));
}
} else {
as_sequence_lval().push_back(new value_t(val));
@@ -353,12 +353,12 @@ value_t& value_t::operator+=(const value_t& val)
switch (val.type()) {
case INTEGER:
as_datetime_lval() +=
- time_duration_t(0, 0, static_cast<time_duration_t::sec_type>(val.as_long()));
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>(val.as_long()));
return *this;
case AMOUNT:
as_datetime_lval() +=
- time_duration_t(0, 0, static_cast<time_duration_t::sec_type>
- (val.as_amount().to_long()));
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>
+ (val.as_amount().to_long()));
return *this;
default:
break;
@@ -385,8 +385,8 @@ value_t& value_t::operator+=(const value_t& val)
return *this;
case AMOUNT:
if (val.as_amount().has_commodity()) {
- in_place_cast(BALANCE);
- return *this += val;
+ in_place_cast(BALANCE);
+ return *this += val;
}
in_place_cast(AMOUNT);
as_amount_lval() += val.as_amount();
@@ -404,21 +404,21 @@ value_t& value_t::operator+=(const value_t& val)
switch (val.type()) {
case INTEGER:
if (as_amount().has_commodity()) {
- in_place_cast(BALANCE);
- return *this += val;
+ in_place_cast(BALANCE);
+ return *this += val;
} else {
- as_amount_lval() += val.as_long();
- return *this;
+ as_amount_lval() += val.as_long();
+ return *this;
}
break;
case AMOUNT:
if (as_amount().commodity() != val.as_amount().commodity()) {
- in_place_cast(BALANCE);
- return *this += val;
+ in_place_cast(BALANCE);
+ return *this += val;
} else {
- as_amount_lval() += val.as_amount();
- return *this;
+ as_amount_lval() += val.as_amount();
+ return *this;
}
break;
@@ -465,19 +465,19 @@ value_t& value_t::operator-=(const value_t& val)
if (val.is_sequence()) {
if (size() == val.size()) {
- sequence_t::iterator i = begin();
- sequence_t::const_iterator j = val.begin();
+ sequence_t::iterator i = begin();
+ sequence_t::const_iterator j = val.begin();
- for (; i != end(); i++, j++)
- *i -= *j;
+ for (; i != end(); i++, j++)
+ *i -= *j;
} else {
- add_error_context(_("While subtracting %1 to %2:") << *this << val);
- throw_(value_error, _("Cannot subtract sequences of different lengths"));
+ add_error_context(_("While subtracting %1 to %2:") << *this << val);
+ throw_(value_error, _("Cannot subtract sequences of different lengths"));
}
} else {
sequence_t::iterator i = std::find(seq.begin(), seq.end(), val);
if (i != seq.end())
- seq.erase(i);
+ seq.erase(i);
}
return *this;
}
@@ -487,12 +487,12 @@ value_t& value_t::operator-=(const value_t& val)
switch (val.type()) {
case INTEGER:
as_datetime_lval() -=
- time_duration_t(0, 0, static_cast<time_duration_t::sec_type>(val.as_long()));
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>(val.as_long()));
return *this;
case AMOUNT:
as_datetime_lval() -=
- time_duration_t(0, 0, static_cast<time_duration_t::sec_type>
- (val.as_amount().to_long()));
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>
+ (val.as_amount().to_long()));
return *this;
default:
break;
@@ -536,27 +536,27 @@ value_t& value_t::operator-=(const value_t& val)
switch (val.type()) {
case INTEGER:
if (as_amount().has_commodity()) {
- in_place_cast(BALANCE);
- *this -= val;
- in_place_simplify();
- return *this;
+ in_place_cast(BALANCE);
+ *this -= val;
+ in_place_simplify();
+ return *this;
} else {
- as_amount_lval() -= val.as_long();
- in_place_simplify();
- return *this;
+ as_amount_lval() -= val.as_long();
+ in_place_simplify();
+ return *this;
}
break;
case AMOUNT:
if (as_amount().commodity() != val.as_amount().commodity()) {
- in_place_cast(BALANCE);
- *this -= val;
- in_place_simplify();
- return *this;
+ in_place_cast(BALANCE);
+ *this -= val;
+ in_place_simplify();
+ return *this;
} else {
- as_amount_lval() -= val.as_amount();
- in_place_simplify();
- return *this;
+ as_amount_lval() -= val.as_amount();
+ in_place_simplify();
+ return *this;
}
break;
@@ -642,8 +642,8 @@ value_t& value_t::operator*=(const value_t& val)
return *this;
case BALANCE:
if (val.as_balance().single_amount()) {
- as_amount_lval() *= val.simplified().as_amount();
- return *this;
+ as_amount_lval() *= val.simplified().as_amount();
+ return *this;
}
break;
default:
@@ -658,13 +658,13 @@ value_t& value_t::operator*=(const value_t& val)
return *this;
case AMOUNT:
if (as_balance().single_amount()) {
- in_place_simplify();
- as_amount_lval() *= val.as_amount();
- return *this;
+ in_place_simplify();
+ as_amount_lval() *= val.as_amount();
+ return *this;
}
else if (! val.as_amount().has_commodity()) {
- as_balance_lval() *= val.as_amount();
- return *this;
+ as_balance_lval() *= val.as_amount();
+ return *this;
}
break;
default:
@@ -709,19 +709,19 @@ value_t& value_t::operator/=(const value_t& val)
return *this;
case BALANCE:
if (val.as_balance().single_amount()) {
- value_t simpler(val.simplified());
- switch (simpler.type()) {
- case INTEGER:
- as_amount_lval() /= simpler.as_long();
- break;
- case AMOUNT:
- as_amount_lval() /= simpler.as_amount();
- break;
- default:
- assert(false);
- break;
- }
- return *this;
+ value_t simpler(val.simplified());
+ switch (simpler.type()) {
+ case INTEGER:
+ as_amount_lval() /= simpler.as_long();
+ break;
+ case AMOUNT:
+ as_amount_lval() /= simpler.as_amount();
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ return *this;
}
break;
default:
@@ -736,13 +736,13 @@ value_t& value_t::operator/=(const value_t& val)
return *this;
case AMOUNT:
if (as_balance().single_amount()) {
- in_place_simplify();
- as_amount_lval() /= val.as_amount();
- return *this;
+ in_place_simplify();
+ as_amount_lval() /= val.as_amount();
+ return *this;
}
else if (! val.as_amount().has_commodity()) {
- as_balance_lval() /= val.as_amount();
- return *this;
+ as_balance_lval() /= val.as_amount();
+ return *this;
}
break;
default:
@@ -852,16 +852,16 @@ bool value_t::is_less_than(const value_t& val) const
case BOOLEAN:
if (val.is_boolean()) {
if (as_boolean()) {
- if (! val.as_boolean())
- return false;
- else
- return false;
+ if (! val.as_boolean())
+ return false;
+ else
+ return false;
}
else if (! as_boolean()) {
- if (! val.as_boolean())
- return false;
- else
- return true;
+ if (! val.as_boolean())
+ return false;
+ else
+ return true;
}
}
break;
@@ -893,11 +893,11 @@ bool value_t::is_less_than(const value_t& val) const
return as_amount() < val.as_long();
case AMOUNT:
if (as_amount().commodity() == val.as_amount().commodity() ||
- ! as_amount().has_commodity() ||
- ! val.as_amount().has_commodity())
- return as_amount() < val.as_amount();
+ ! as_amount().has_commodity() ||
+ ! val.as_amount().has_commodity())
+ return as_amount() < val.as_amount();
else
- return commodity_t::compare_by_commodity()(&as_amount(), &val.as_amount());
+ return commodity_t::compare_by_commodity()(&as_amount(), &val.as_amount());
default:
break;
}
@@ -908,14 +908,14 @@ bool value_t::is_less_than(const value_t& val) const
case INTEGER:
case AMOUNT: {
if (val.is_nonzero())
- break;
+ break;
bool no_amounts = true;
foreach (const balance_t::amounts_map::value_type& pair,
- as_balance().amounts) {
- if (pair.second >= 0L)
- return false;
- no_amounts = false;
+ as_balance().amounts) {
+ if (pair.second >= 0L)
+ return false;
+ no_amounts = false;
}
return ! no_amounts;
}
@@ -934,13 +934,13 @@ bool value_t::is_less_than(const value_t& val) const
case INTEGER:
case AMOUNT: {
if (val.is_nonzero())
- break;
+ break;
bool no_amounts = true;
foreach (const value_t& value, as_sequence()) {
- if (value >= 0L)
- return false;
- no_amounts = false;
+ if (value >= 0L)
+ return false;
+ no_amounts = false;
}
return ! no_amounts;
}
@@ -948,14 +948,14 @@ bool value_t::is_less_than(const value_t& val) const
sequence_t::const_iterator i = as_sequence().begin();
sequence_t::const_iterator j = val.as_sequence().begin();
for (; (i != as_sequence().end() &&
- j != val.as_sequence().end()); i++, j++) {
- if (! ((*i) < (*j)))
- return false;
+ j != val.as_sequence().end()); i++, j++) {
+ if (! ((*i) < (*j)))
+ return false;
}
if (i == as_sequence().end())
- return true;
+ return true;
else
- return false;
+ return false;
break;
}
default:
@@ -968,7 +968,7 @@ bool value_t::is_less_than(const value_t& val) const
}
add_error_context(_("While comparing if %1 is less than %2:")
- << *this << val);
+ << *this << val);
throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
return *this;
@@ -979,16 +979,16 @@ bool value_t::is_greater_than(const value_t& val) const
switch (type()) {
if (val.is_boolean()) {
if (as_boolean()) {
- if (! val.as_boolean())
- return true;
- else
- return false;
+ if (! val.as_boolean())
+ return true;
+ else
+ return false;
}
else if (! as_boolean()) {
- if (! val.as_boolean())
- return false;
- else
- return false;
+ if (! val.as_boolean())
+ return false;
+ else
+ return false;
}
}
break;
@@ -1030,14 +1030,14 @@ bool value_t::is_greater_than(const value_t& val) const
case INTEGER:
case AMOUNT: {
if (val.is_nonzero())
- break;
+ break;
bool no_amounts = true;
foreach (const balance_t::amounts_map::value_type& pair,
- as_balance().amounts) {
- if (pair.second <= 0L)
- return false;
- no_amounts = false;
+ as_balance().amounts) {
+ if (pair.second <= 0L)
+ return false;
+ no_amounts = false;
}
return ! no_amounts;
}
@@ -1056,13 +1056,13 @@ bool value_t::is_greater_than(const value_t& val) const
case INTEGER:
case AMOUNT: {
if (val.is_nonzero())
- break;
+ break;
bool no_amounts = true;
foreach (const value_t& value, as_sequence()) {
- if (value <= 0L)
- return false;
- no_amounts = false;
+ if (value <= 0L)
+ return false;
+ no_amounts = false;
}
return ! no_amounts;
}
@@ -1070,14 +1070,14 @@ bool value_t::is_greater_than(const value_t& val) const
sequence_t::const_iterator i = as_sequence().begin();
sequence_t::const_iterator j = val.as_sequence().begin();
for (; (i != as_sequence().end() &&
- j != val.as_sequence().end()); i++, j++) {
- if (! ((*i) > (*j)))
- return false;
+ j != val.as_sequence().end()); i++, j++) {
+ if (! ((*i) > (*j)))
+ return false;
}
if (i == as_sequence().end())
- return false;
+ return false;
else
- return true;
+ return true;
break;
}
default:
@@ -1090,7 +1090,7 @@ bool value_t::is_greater_than(const value_t& val) const
}
add_error_context(_("While comparing if %1 is greater than %2:")
- << *this << val);
+ << *this << val);
throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
return *this;
@@ -1194,21 +1194,21 @@ void value_t::in_place_cast(type_t cast_type)
switch (cast_type) {
case INTEGER:
if (amt.is_null())
- set_long(0L);
+ set_long(0L);
else
- set_long(as_amount().to_long());
+ set_long(as_amount().to_long());
return;
case BALANCE:
if (amt.is_null())
- set_balance(balance_t());
+ set_balance(balance_t());
else
- set_balance(as_amount());
+ set_balance(as_amount());
return;
case STRING:
if (amt.is_null())
- set_string("");
+ set_string("");
else
- set_string(as_amount().to_string());
+ set_string(as_amount().to_string());
return;
default:
break;
@@ -1221,28 +1221,28 @@ void value_t::in_place_cast(type_t cast_type)
switch (cast_type) {
case AMOUNT: {
if (bal.amounts.size() == 1) {
- // Because we are changing the current balance value to an amount
- // value, and because set_amount takes a reference (and that memory is
- // about to be repurposed), we must pass in a copy.
- set_amount(amount_t((*bal.amounts.begin()).second));
- return;
+ // Because we are changing the current balance value to an amount
+ // value, and because set_amount takes a reference (and that memory is
+ // about to be repurposed), we must pass in a copy.
+ set_amount(amount_t((*bal.amounts.begin()).second));
+ return;
}
else if (bal.amounts.size() == 0) {
- set_amount(0L);
- return;
+ set_amount(0L);
+ return;
}
else {
- add_error_context(_("While converting %1 to an amount:") << *this);
- throw_(value_error, _("Cannot convert %1 with multiple commodities to %2")
- << label() << label(cast_type));
+ add_error_context(_("While converting %1 to an amount:") << *this);
+ throw_(value_error, _("Cannot convert %1 with multiple commodities to %2")
+ << label() << label(cast_type));
}
break;
}
case STRING:
if (bal.is_empty())
- set_string("");
+ set_string("");
else
- set_string(as_balance().to_string());
+ set_string(as_balance().to_string());
return;
default:
break;
@@ -1254,8 +1254,8 @@ void value_t::in_place_cast(type_t cast_type)
switch (cast_type) {
case INTEGER: {
if (all(as_string(), is_digit())) {
- set_long(lexical_cast<long>(as_string()));
- return;
+ set_long(lexical_cast<long>(as_string()));
+ return;
}
break;
}
@@ -1282,7 +1282,7 @@ void value_t::in_place_cast(type_t cast_type)
add_error_context(_("While converting %1:") << *this);
throw_(value_error,
- _("Cannot convert %1 to %2") << label() << label(cast_type));
+ _("Cannot convert %1 to %2") << label() << label(cast_type));
}
void value_t::in_place_negate()
@@ -1421,7 +1421,7 @@ bool value_t::is_zero() const
}
value_t value_t::value(const optional<datetime_t>& moment,
- const optional<commodity_t&>& in_terms_of) const
+ const optional<commodity_t&>& in_terms_of) const
{
switch (type()) {
case INTEGER:
@@ -1429,13 +1429,13 @@ value_t value_t::value(const optional<datetime_t>& moment,
case AMOUNT:
if (optional<amount_t> val =
- as_amount().value(moment, in_terms_of))
+ as_amount().value(moment, in_terms_of))
return *val;
return NULL_VALUE;
case BALANCE:
if (optional<balance_t> bal =
- as_balance().value(moment, in_terms_of))
+ as_balance().value(moment, in_terms_of))
return *bal;
return NULL_VALUE;
@@ -1460,9 +1460,9 @@ value_t value_t::price() const
}
}
-value_t value_t::exchange_commodities(const std::string& commodities,
- const bool add_prices,
- const optional<datetime_t>& moment)
+value_t value_t::exchange_commodities(const std::string& commodities,
+ const bool add_prices,
+ const optional<datetime_t>& moment)
{
scoped_array<char> buf(new char[commodities.length() + 1]);
@@ -1472,11 +1472,11 @@ value_t value_t::exchange_commodities(const std::string& commodities,
p;
p = std::strtok(NULL, ",")) {
if (commodity_t * commodity =
- commodity_pool_t::current_pool->parse_price_expression(p, add_prices,
- moment)) {
+ commodity_pool_t::current_pool->parse_price_expression(p, add_prices,
+ moment)) {
value_t result = value(moment, *commodity);
if (! result.is_null())
- return result;
+ return result;
}
}
return *this;
@@ -1657,7 +1657,7 @@ bool value_t::has_annotation() const
} else {
add_error_context(_("While checking if %1 has annotations:") << *this);
throw_(value_error,
- _("Cannot determine whether %1 is annotated") << label());
+ _("Cannot determine whether %1 is annotated") << label());
}
return false;
}
@@ -1711,9 +1711,9 @@ value_t value_t::strip_annotations(const keep_details_t& what_to_keep) const
}
void value_t::print(std::ostream& out,
- const int first_width,
- const int latter_width,
- const uint_least8_t flags) const
+ const int first_width,
+ const int latter_width,
+ const uint_least8_t flags) const
{
if (first_width > 0 &&
(! is_amount() || as_amount().is_zero()) &&
@@ -1746,7 +1746,7 @@ void value_t::print(std::ostream& out,
case INTEGER:
if (flags & AMOUNT_PRINT_COLORIZE && as_long() < 0)
justify(out, to_string(), first_width,
- flags & AMOUNT_PRINT_RIGHT_JUSTIFY, true);
+ flags & AMOUNT_PRINT_RIGHT_JUSTIFY, true);
else
out << as_long();
break;
@@ -1758,7 +1758,7 @@ void value_t::print(std::ostream& out,
std::ostringstream buf;
as_amount().print(buf, flags);
justify(out, buf.str(), first_width, flags & AMOUNT_PRINT_RIGHT_JUSTIFY,
- flags & AMOUNT_PRINT_COLORIZE && as_amount().sign() < 0);
+ flags & AMOUNT_PRINT_COLORIZE && as_amount().sign() < 0);
}
break;
}
@@ -1783,9 +1783,9 @@ void value_t::print(std::ostream& out,
bool first = true;
foreach (const value_t& value, as_sequence()) {
if (first)
- first = false;
+ first = false;
else
- out << ", ";
+ out << ", ";
value.print(out, first_width, latter_width, flags);
}
@@ -1853,14 +1853,14 @@ void value_t::dump(std::ostream& out, const bool relaxed) const
foreach (const char& ch, as_string()) {
switch (ch) {
case '"':
- out << "\\\"";
- break;
+ out << "\\\"";
+ break;
case '\\':
- out << "\\\\";
- break;
+ out << "\\\\";
+ break;
default:
- out << ch;
- break;
+ out << ch;
+ break;
}
}
out << '"';
@@ -1885,9 +1885,9 @@ void value_t::dump(std::ostream& out, const bool relaxed) const
bool first = true;
foreach (const value_t& value, as_sequence()) {
if (first)
- first = false;
+ first = false;
else
- out << ", ";
+ out << ", ";
value.dump(out, relaxed);
}
@@ -1915,7 +1915,7 @@ bool value_t::valid() const
}
bool sort_value_is_less_than(const std::list<sort_value_t>& left_values,
- const std::list<sort_value_t>& right_values)
+ const std::list<sort_value_t>& right_values)
{
std::list<sort_value_t>::const_iterator left_iter = left_values.begin();
std::list<sort_value_t>::const_iterator right_iter = right_values.begin();
@@ -1923,16 +1923,16 @@ bool sort_value_is_less_than(const std::list<sort_value_t>& left_values,
while (left_iter != left_values.end() && right_iter != right_values.end()) {
// Don't even try to sort balance values
if (! (*left_iter).value.is_balance() &&
- ! (*right_iter).value.is_balance()) {
+ ! (*right_iter).value.is_balance()) {
DEBUG("value.sort",
- " Comparing " << (*left_iter).value << " < " << (*right_iter).value);
+ " Comparing " << (*left_iter).value << " < " << (*right_iter).value);
if ((*left_iter).value < (*right_iter).value) {
- DEBUG("value.sort", " is less");
- return ! (*left_iter).inverted;
+ DEBUG("value.sort", " is less");
+ return ! (*left_iter).inverted;
}
else if ((*left_iter).value > (*right_iter).value) {
- DEBUG("value.sort", " is greater");
- return (*left_iter).inverted;
+ DEBUG("value.sort", " is greater");
+ return (*left_iter).inverted;
}
}
left_iter++; right_iter++;
diff --git a/src/value.h b/src/value.h
index ff8fe2b0..4dfd591c 100644
--- a/src/value.h
+++ b/src/value.h
@@ -49,7 +49,7 @@
#ifndef _VALUE_H
#define _VALUE_H
-#include "balance.h" // includes amount.h
+#include "balance.h" // includes amount.h
#include "mask.h"
namespace ledger {
@@ -75,21 +75,21 @@ class expr_t;
*/
class value_t
: public ordered_field_operators<value_t,
- equality_comparable<value_t, balance_t,
- additive<value_t, balance_t,
- multiplicative<value_t, balance_t,
- ordered_field_operators<value_t, amount_t,
- ordered_field_operators<value_t, double,
- ordered_field_operators<value_t, unsigned long,
- ordered_field_operators<value_t, long> > > > > > > >
+ equality_comparable<value_t, balance_t,
+ additive<value_t, balance_t,
+ multiplicative<value_t, balance_t,
+ ordered_field_operators<value_t, amount_t,
+ ordered_field_operators<value_t, double,
+ ordered_field_operators<value_t, unsigned long,
+ ordered_field_operators<value_t, long> > > > > > > >
{
public:
/**
* The sequence_t member type abstracts the type used to represent a
* resizable "array" of value_t objects.
*/
- typedef ptr_deque<value_t> sequence_t;
- typedef sequence_t::iterator iterator;
+ typedef ptr_deque<value_t> sequence_t;
+ typedef sequence_t::iterator iterator;
typedef sequence_t::const_iterator const_iterator;
typedef sequence_t::difference_type difference_type;
@@ -99,18 +99,18 @@ public:
* type_t.
*/
enum type_t {
- VOID, // a null value (i.e., uninitialized)
- BOOLEAN, // a boolean
- DATETIME, // a date and time (Boost posix_time)
- DATE, // a date (Boost gregorian::date)
- INTEGER, // a signed integer value
- AMOUNT, // a ledger::amount_t
- BALANCE, // a ledger::balance_t
- STRING, // a string object
- MASK, // a regular expression mask
- SEQUENCE, // a vector of value_t objects
- SCOPE, // a pointer to a scope
- EXPR // a pointer to a value expression
+ VOID, // a null value (i.e., uninitialized)
+ BOOLEAN, // a boolean
+ DATETIME, // a date and time (Boost posix_time)
+ DATE, // a date (Boost gregorian::date)
+ INTEGER, // a signed integer value
+ AMOUNT, // a ledger::amount_t
+ BALANCE, // a ledger::balance_t
+ STRING, // a string object
+ MASK, // a regular expression mask
+ SEQUENCE, // a vector of value_t objects
+ SCOPE, // a pointer to a scope
+ EXPR // a pointer to a value expression
};
private:
@@ -128,18 +128,18 @@ private:
* The `type' member holds the value_t::type_t value representing
* the type of the object stored.
*/
- variant<bool, // BOOLEAN
- datetime_t, // DATETIME
- date_t, // DATE
- long, // INTEGER
- amount_t, // AMOUNT
- balance_t *, // BALANCE
- string, // STRING
- mask_t, // MASK
- sequence_t *, // SEQUENCE
- scope_t *, // SCOPE
- expr_t * // EXPR
- > data;
+ variant<bool, // BOOLEAN
+ datetime_t, // DATETIME
+ date_t, // DATE
+ long, // INTEGER
+ amount_t, // AMOUNT
+ balance_t *, // BALANCE
+ string, // STRING
+ mask_t, // MASK
+ sequence_t *, // SEQUENCE
+ scope_t *, // SCOPE
+ expr_t * // EXPR
+ > data;
type_t type;
@@ -160,7 +160,7 @@ private:
TRACE_CTOR(value_t::storage_t, "");
}
- public: // so `checked_delete' can access it
+ public: // so `checked_delete' can access it
/**
* Destructor. Must only be called when the reference count has
* reached zero. The `destroy' method is used to do the actual
@@ -193,16 +193,16 @@ private:
*/
void acquire() const {
DEBUG("value.storage.refcount",
- "Acquiring " << this << ", refc now " << refc + 1);
+ "Acquiring " << this << ", refc now " << refc + 1);
VERIFY(refc >= 0);
refc++;
}
void release() const {
DEBUG("value.storage.refcount",
- "Releasing " << this << ", refc now " << refc - 1);
+ "Releasing " << this << ", refc now " << refc - 1);
VERIFY(refc > 0);
if (--refc == 0)
- checked_delete(this);
+ checked_delete(this);
}
friend inline void intrusive_ptr_add_ref(value_t::storage_t * storage) {
@@ -216,15 +216,15 @@ private:
DEBUG("value.storage.refcount", "Destroying " << this);
switch (type) {
case VOID:
- return;
+ return;
case BALANCE:
- checked_delete(boost::get<balance_t *>(data));
- break;
+ checked_delete(boost::get<balance_t *>(data));
+ break;
case SEQUENCE:
- checked_delete(boost::get<sequence_t *>(data));
- break;
+ checked_delete(boost::get<sequence_t *>(data));
+ break;
default:
- break;
+ break;
}
data = false;
type = VOID;
@@ -424,8 +424,8 @@ public:
temp.in_place_negate();
return temp;
}
- void in_place_negate(); // exists for efficiency's sake
- void in_place_not(); // exists for efficiency's sake
+ void in_place_negate(); // exists for efficiency's sake
+ void in_place_not(); // exists for efficiency's sake
value_t operator-() const {
return negated();
@@ -466,24 +466,24 @@ public:
temp.in_place_reduce();
return temp;
}
- void in_place_reduce(); // exists for efficiency's sake
+ void in_place_reduce(); // exists for efficiency's sake
value_t unreduced() const {
value_t temp(*this);
temp.in_place_unreduce();
return temp;
}
- void in_place_unreduce(); // exists for efficiency's sake
+ void in_place_unreduce(); // exists for efficiency's sake
// Return the "market value" of a given value at a specific time.
- value_t value(const optional<datetime_t>& moment = none,
- const optional<commodity_t&>& in_terms_of = none) const;
+ value_t value(const optional<datetime_t>& moment = none,
+ const optional<commodity_t&>& in_terms_of = none) const;
value_t price() const;
- value_t exchange_commodities(const std::string& commodities,
- const bool add_prices = false,
- const optional<datetime_t>& moment = none);
+ value_t exchange_commodities(const std::string& commodities,
+ const bool add_prices = false,
+ const optional<datetime_t>& moment = none);
/**
* Truth tests.
@@ -749,9 +749,9 @@ public:
* its underlying type, where possible. If not possible, an
* exception is thrown.
*/
- bool to_boolean() const;
- int to_int() const;
- long to_long() const;
+ bool to_boolean() const;
+ int to_int() const;
+ long to_long() const;
datetime_t to_datetime() const;
date_t to_date() const;
amount_t to_amount() const;
@@ -863,13 +863,13 @@ public:
std::size_t new_size = seq.size();
if (new_size == 0) {
#if BOOST_VERSION >= 103700
- storage.reset();
+ storage.reset();
#else
- storage = intrusive_ptr<storage_t>();
+ storage = intrusive_ptr<storage_t>();
#endif
}
else if (new_size == 1) {
- *this = seq.front();
+ *this = seq.front();
}
}
}
@@ -942,9 +942,9 @@ public:
* Printing methods.
*/
void print(std::ostream& out,
- const int first_width = -1,
- const int latter_width = -1,
- const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
+ const int first_width = -1,
+ const int latter_width = -1,
+ const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
void dump(std::ostream& out, const bool relaxed = true) const;
@@ -1011,7 +1011,7 @@ struct sort_value_t
};
bool sort_value_is_less_than(const std::list<sort_value_t>& left_values,
- const std::list<sort_value_t>& right_values);
+ const std::list<sort_value_t>& right_values);
void to_xml(std::ostream& out, const value_t& value);
diff --git a/src/xact.cc b/src/xact.cc
index d943e611..b4438b48 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -101,9 +101,9 @@ value_t xact_base_t::magnitude() const
foreach (const post_t * post, posts) {
if (post->amount.sign() > 0) {
if (post->cost)
- halfbal += *post->cost;
+ halfbal += *post->cost;
else
- halfbal += post->amount;
+ halfbal += post->amount;
}
}
return halfbal;
@@ -126,30 +126,30 @@ bool xact_base_t::finalize()
if (! p.is_null()) {
DEBUG("xact.finalize", "post must balance = " << p.reduced());
if (! post->cost && post->amount.has_annotation() &&
- post->amount.annotation().price) {
- // If the amount has no cost, but is annotated with a per-unit
- // price, use the price times the amount as the cost
- post->cost = (*post->amount.annotation().price *
- post->amount).unrounded();
- DEBUG("xact.finalize",
- "annotation price = " << *post->amount.annotation().price);
- DEBUG("xact.finalize", "amount = " << post->amount);
- DEBUG("xact.finalize", "priced cost = " << *post->cost);
- post->add_flags(POST_COST_CALCULATED);
- add_or_set_value(balance, post->cost->rounded().reduced());
+ post->amount.annotation().price) {
+ // If the amount has no cost, but is annotated with a per-unit
+ // price, use the price times the amount as the cost
+ post->cost = (*post->amount.annotation().price *
+ post->amount).unrounded();
+ DEBUG("xact.finalize",
+ "annotation price = " << *post->amount.annotation().price);
+ DEBUG("xact.finalize", "amount = " << post->amount);
+ DEBUG("xact.finalize", "priced cost = " << *post->cost);
+ post->add_flags(POST_COST_CALCULATED);
+ add_or_set_value(balance, post->cost->rounded().reduced());
} else {
- // If the amount was a cost, it very likely has the "keep_precision"
- // flag set, meaning commodity display precision is ignored when
- // displaying the amount. We never want this set for the balance,
- // so we must clear the flag in a temporary to avoid it propagating
- // into the balance.
- add_or_set_value(balance, p.keep_precision() ?
- p.rounded().reduced() : p.reduced());
+ // If the amount was a cost, it very likely has the "keep_precision"
+ // flag set, meaning commodity display precision is ignored when
+ // displaying the amount. We never want this set for the balance,
+ // so we must clear the flag in a temporary to avoid it propagating
+ // into the balance.
+ add_or_set_value(balance, p.keep_precision() ?
+ p.rounded().reduced() : p.reduced());
}
}
else if (null_post) {
throw_(std::logic_error,
- _("Only one posting with null amount allowed per transaction"));
+ _("Only one posting with null amount allowed per transaction"));
}
else {
null_post = post;
@@ -162,7 +162,7 @@ bool xact_base_t::finalize()
DEBUG("xact.finalize", "balance is " << balance.label());
if (balance.is_balance())
DEBUG("xact.finalize", "balance commodity count = "
- << balance.as_balance().amounts.size());
+ << balance.as_balance().amounts.size());
#endif
// If there is only one post, balance against the default account if one has
@@ -188,15 +188,15 @@ bool xact_base_t::finalize()
foreach (post_t * post, posts) {
if (! post->amount.is_null() && post->must_balance()) {
- if (post->amount.has_annotation())
- top_post = post;
- else if (! top_post)
- top_post = post;
+ if (post->amount.has_annotation())
+ top_post = post;
+ else if (! top_post)
+ top_post = post;
}
if (post->cost && ! post->has_flags(POST_COST_CALCULATED)) {
- saw_cost = true;
- break;
+ saw_cost = true;
+ break;
}
}
@@ -211,58 +211,58 @@ bool xact_base_t::finalize()
const amount_t * y = &(*a++).second;
if (x->commodity() != top_post->amount.commodity()) {
- const amount_t * t = x;
- x = y;
- y = t;
+ const amount_t * t = x;
+ x = y;
+ y = t;
}
if (*x && *y) {
- DEBUG("xact.finalize", "primary amount = " << *x);
- DEBUG("xact.finalize", "secondary amount = " << *y);
-
- commodity_t& comm(x->commodity());
- amount_t per_unit_cost;
- amount_t total_cost;
- const amount_t * prev_y = y;
-
- foreach (post_t * post, posts) {
- if (post != top_post && post->must_balance() &&
- ! post->amount.is_null() &&
- post->amount.has_annotation() &&
- post->amount.annotation().price) {
- amount_t temp = *post->amount.annotation().price * post->amount;
- if (total_cost.is_null()) {
- total_cost = temp;
- y = &total_cost;
- }
- else if (total_cost.commodity() == temp.commodity()) {
- total_cost += temp;
- }
- else {
- DEBUG("xact.finalize",
- "multiple price commodities, aborting price calc");
- y = prev_y;
- break;
- }
- DEBUG("xact.finalize", "total_cost = " << total_cost);
- }
- }
- per_unit_cost = (*y / *x).abs().unrounded();
-
- DEBUG("xact.finalize", "per_unit_cost = " << per_unit_cost);
-
- foreach (post_t * post, posts) {
- const amount_t& amt(post->amount);
-
- if (post->must_balance() && amt.commodity() == comm) {
- balance -= amt;
- post->cost = per_unit_cost * amt;
- post->add_flags(POST_COST_CALCULATED);
- balance += *post->cost;
-
- DEBUG("xact.finalize", "set post->cost to = " << *post->cost);
- }
- }
+ DEBUG("xact.finalize", "primary amount = " << *x);
+ DEBUG("xact.finalize", "secondary amount = " << *y);
+
+ commodity_t& comm(x->commodity());
+ amount_t per_unit_cost;
+ amount_t total_cost;
+ const amount_t * prev_y = y;
+
+ foreach (post_t * post, posts) {
+ if (post != top_post && post->must_balance() &&
+ ! post->amount.is_null() &&
+ post->amount.has_annotation() &&
+ post->amount.annotation().price) {
+ amount_t temp = *post->amount.annotation().price * post->amount;
+ if (total_cost.is_null()) {
+ total_cost = temp;
+ y = &total_cost;
+ }
+ else if (total_cost.commodity() == temp.commodity()) {
+ total_cost += temp;
+ }
+ else {
+ DEBUG("xact.finalize",
+ "multiple price commodities, aborting price calc");
+ y = prev_y;
+ break;
+ }
+ DEBUG("xact.finalize", "total_cost = " << total_cost);
+ }
+ }
+ per_unit_cost = (*y / *x).abs().unrounded();
+
+ DEBUG("xact.finalize", "per_unit_cost = " << per_unit_cost);
+
+ foreach (post_t * post, posts) {
+ const amount_t& amt(post->amount);
+
+ if (post->must_balance() && amt.commodity() == comm) {
+ balance -= amt;
+ post->cost = per_unit_cost * amt;
+ post->add_flags(POST_COST_CALCULATED);
+ balance += *post->cost;
+
+ DEBUG("xact.finalize", "set post->cost to = " << *post->cost);
+ }
+ }
}
}
}
@@ -275,39 +275,39 @@ bool xact_base_t::finalize()
if (post->amount.commodity() == post->cost->commodity())
throw_(balance_error,
- _("A posting's cost must be of a different commodity than its amount"));
+ _("A posting's cost must be of a different commodity than its amount"));
cost_breakdown_t breakdown =
commodity_pool_t::current_pool->exchange
(post->amount, *post->cost, false,
- datetime_t(date(), time_duration(0, 0, 0, 0)));
+ datetime_t(date(), time_duration(0, 0, 0, 0)));
if (post->amount.has_annotation() &&
- breakdown.basis_cost.commodity() == breakdown.final_cost.commodity()) {
+ breakdown.basis_cost.commodity() == breakdown.final_cost.commodity()) {
if (amount_t gain_loss = breakdown.basis_cost - breakdown.final_cost) {
- DEBUG("xact.finalize", "gain_loss = " << gain_loss);
- gain_loss.in_place_round();
- DEBUG("xact.finalize", "gain_loss rounds to = " << gain_loss);
-
- if (post->must_balance())
- add_or_set_value(balance, gain_loss.reduced());
-
- account_t * account;
- if (gain_loss.sign() > 0)
- account = journal->find_account(_("Equity:Capital Gains"));
- else
- account = journal->find_account(_("Equity:Capital Losses"));
-
- post_t * p = new post_t(account, gain_loss, ITEM_GENERATED);
- p->set_state(post->state());
- if (post->has_flags(POST_VIRTUAL)) {
- DEBUG("xact.finalize", "gain_loss came from a virtual post");
- p->add_flags(post->flags() & (POST_VIRTUAL | POST_MUST_BALANCE));
- }
- add_post(p);
- DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
+ DEBUG("xact.finalize", "gain_loss = " << gain_loss);
+ gain_loss.in_place_round();
+ DEBUG("xact.finalize", "gain_loss rounds to = " << gain_loss);
+
+ if (post->must_balance())
+ add_or_set_value(balance, gain_loss.reduced());
+
+ account_t * account;
+ if (gain_loss.sign() > 0)
+ account = journal->find_account(_("Equity:Capital Gains"));
+ else
+ account = journal->find_account(_("Equity:Capital Losses"));
+
+ post_t * p = new post_t(account, gain_loss, ITEM_GENERATED);
+ p->set_state(post->state());
+ if (post->has_flags(POST_VIRTUAL)) {
+ DEBUG("xact.finalize", "gain_loss came from a virtual post");
+ p->add_flags(post->flags() & (POST_VIRTUAL | POST_MUST_BALANCE));
+ }
+ add_post(p);
+ DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
} else {
- DEBUG("xact.finalize", "gain_loss would have display as zero");
+ DEBUG("xact.finalize", "gain_loss would have display as zero");
}
} else {
post->amount = breakdown.amount;
@@ -315,7 +315,7 @@ bool xact_base_t::finalize()
}
if (post->has_flags(POST_COST_FIXATED) &&
- post->amount.has_annotation() && post->amount.annotation().price) {
+ post->amount.has_annotation() && post->amount.annotation().price) {
DEBUG("xact.finalize", "fixating annotation price");
post->amount.annotation().add_flags(ANNOTATION_PRICE_FIXATED);
}
@@ -332,16 +332,16 @@ bool xact_base_t::finalize()
bool first = true;
const balance_t& bal(balance.as_balance());
foreach (const balance_t::amounts_map::value_type& pair, bal.amounts) {
- if (first) {
- null_post->amount = pair.second.negated();
- null_post->add_flags(POST_CALCULATED);
- first = false;
- } else {
- post_t * p = new post_t(null_post->account, pair.second.negated(),
- ITEM_GENERATED | POST_CALCULATED);
- p->set_state(null_post->state());
- add_post(p);
- }
+ if (first) {
+ null_post->amount = pair.second.negated();
+ null_post->add_flags(POST_CALCULATED);
+ first = false;
+ } else {
+ post_t * p = new post_t(null_post->account, pair.second.negated(),
+ ITEM_GENERATED | POST_CALCULATED);
+ p->set_state(null_post->state());
+ add_post(p);
+ }
}
}
else if (balance.is_amount()) {
@@ -377,10 +377,10 @@ bool xact_base_t::finalize()
foreach (post_t * post, posts) {
if (! post->amount.is_null()) {
- all_null = false;
- post->amount.in_place_reduce();
+ all_null = false;
+ post->amount.in_place_reduce();
} else {
- some_null = true;
+ some_null = true;
}
post->account->add_post(post);
@@ -390,10 +390,10 @@ bool xact_base_t::finalize()
}
if (all_null)
- return false; // ignore this xact completely
+ return false; // ignore this xact completely
else if (some_null)
throw_(balance_error,
- _("There cannot be null amounts after balancing a transaction"));
+ _("There cannot be null amounts after balancing a transaction"));
}
VERIFY(valid());
@@ -419,7 +419,7 @@ bool xact_base_t::verify()
// amount. We never want this set for the balance, so we must clear the
// flag in a temporary to avoid it propagating into the balance.
add_or_set_value(balance, p.keep_precision() ?
- p.rounded().reduced() : p.reduced());
+ p.rounded().reduced() : p.reduced());
}
VERIFY(balance.valid());
@@ -433,7 +433,7 @@ bool xact_base_t::verify()
if (post->amount.commodity() == post->cost->commodity())
throw_(amount_error,
- _("A posting's cost must be of a different commodity than its amount"));
+ _("A posting's cost must be of a different commodity than its amount"));
}
if (! balance.is_null() && ! balance.is_zero()) {
@@ -513,7 +513,7 @@ namespace {
foreach (post_t * p, post.xact->posts) {
bind_scope_t bound_scope(scope, *p);
if (expr.calc(bound_scope).to_boolean())
- return true;
+ return true;
}
return false;
}
@@ -528,14 +528,14 @@ namespace {
foreach (post_t * p, post.xact->posts) {
bind_scope_t bound_scope(scope, *p);
if (! expr.calc(bound_scope).to_boolean())
- return false;
+ return false;
}
return true;
}
}
expr_t::ptr_op_t xact_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
if (kind != symbol_t::FUNCTION)
return item_t::lookup(kind, name);
@@ -601,13 +601,13 @@ namespace {
case expr_t::op_t::O_MATCH:
if (op->left()->kind == expr_t::op_t::IDENT &&
- op->left()->as_ident() == "account" &&
- op->right()->kind == expr_t::op_t::VALUE &&
- op->right()->as_value().is_mask())
- return op->right()->as_value().as_mask()
- .match(post.reported_account()->fullname());
+ op->left()->as_ident() == "account" &&
+ op->right()->kind == expr_t::op_t::VALUE &&
+ op->right()->as_value().is_mask())
+ return op->right()->as_value().as_mask()
+ .match(post.reported_account()->fullname());
else
- break;
+ break;
case expr_t::op_t::O_NOT:
return ! post_pred(op->left(), post);
@@ -620,9 +620,9 @@ namespace {
case expr_t::op_t::O_QUERY:
if (post_pred(op->left(), post))
- return post_pred(op->right()->left(), post);
+ return post_pred(op->right()->left(), post);
else
- return post_pred(op->right()->right(), post);
+ return post_pred(op->right()->right(), post);
default:
break;
@@ -649,109 +649,109 @@ void auto_xact_t::extend_xact(xact_base_t& xact)
bool matches_predicate = false;
if (try_quick_match) {
try {
- bool found_memoized_result = false;
- if (! memoized_results.empty()) {
- std::map<string, bool>::iterator i =
- memoized_results.find(initial_post->account->fullname());
- if (i != memoized_results.end()) {
- found_memoized_result = true;
- matches_predicate = (*i).second;
- }
- }
-
- // Since the majority of people who use automated transactions simply
- // match against account names, try using a *much* faster version of
- // the predicate evaluator.
- if (! found_memoized_result) {
- matches_predicate = post_pred(predicate.get_op(), *initial_post);
- memoized_results.insert
- (std::pair<string, bool>(initial_post->account->fullname(),
- matches_predicate));
- }
+ bool found_memoized_result = false;
+ if (! memoized_results.empty()) {
+ std::map<string, bool>::iterator i =
+ memoized_results.find(initial_post->account->fullname());
+ if (i != memoized_results.end()) {
+ found_memoized_result = true;
+ matches_predicate = (*i).second;
+ }
+ }
+
+ // Since the majority of people who use automated transactions simply
+ // match against account names, try using a *much* faster version of
+ // the predicate evaluator.
+ if (! found_memoized_result) {
+ matches_predicate = post_pred(predicate.get_op(), *initial_post);
+ memoized_results.insert
+ (std::pair<string, bool>(initial_post->account->fullname(),
+ matches_predicate));
+ }
}
catch (...) {
- DEBUG("xact.extend.fail",
- "The quick matcher failed, going back to regular eval");
- try_quick_match = false;
- matches_predicate = predicate(*initial_post);
+ DEBUG("xact.extend.fail",
+ "The quick matcher failed, going back to regular eval");
+ try_quick_match = false;
+ matches_predicate = predicate(*initial_post);
}
} else {
matches_predicate = predicate(*initial_post);
}
if (matches_predicate) {
foreach (post_t * post, posts) {
- amount_t post_amount;
- if (post->amount.is_null()) {
- if (! post->amount_expr)
- throw_(amount_error,
- _("Automated transaction's posting has no amount"));
-
- bind_scope_t bound_scope(*scope_t::default_scope, *initial_post);
- value_t result(post->amount_expr->calc(bound_scope));
- if (result.is_long()) {
- post_amount = result.to_amount();
- } else {
- if (! result.is_amount())
- throw_(amount_error,
- _("Amount expressions must result in a simple amount"));
- post_amount = result.as_amount();
- }
- } else {
- post_amount = post->amount;
- }
-
- amount_t amt;
- if (! post_amount.commodity())
- amt = initial_post->amount * post_amount;
- else
- amt = post_amount;
+ amount_t post_amount;
+ if (post->amount.is_null()) {
+ if (! post->amount_expr)
+ throw_(amount_error,
+ _("Automated transaction's posting has no amount"));
+
+ bind_scope_t bound_scope(*scope_t::default_scope, *initial_post);
+ value_t result(post->amount_expr->calc(bound_scope));
+ if (result.is_long()) {
+ post_amount = result.to_amount();
+ } else {
+ if (! result.is_amount())
+ throw_(amount_error,
+ _("Amount expressions must result in a simple amount"));
+ post_amount = result.as_amount();
+ }
+ } else {
+ post_amount = post->amount;
+ }
+
+ amount_t amt;
+ if (! post_amount.commodity())
+ amt = initial_post->amount * post_amount;
+ else
+ amt = post_amount;
#if defined(DEBUG_ON)
- IF_DEBUG("xact.extend") {
- DEBUG("xact.extend",
- "Initial post on line " << initial_post->pos->beg_line << ": "
- << "amount " << initial_post->amount << " (precision "
- << initial_post->amount.precision() << ")");
-
- if (initial_post->amount.keep_precision())
- DEBUG("xact.extend", " precision is kept");
-
- DEBUG("xact.extend",
- "Posting on line " << post->pos->beg_line << ": "
- << "amount " << post_amount << ", amt " << amt
- << " (precision " << post_amount.precision()
- << " != " << amt.precision() << ")");
-
- if (post_amount.keep_precision())
- DEBUG("xact.extend", " precision is kept");
- if (amt.keep_precision())
- DEBUG("xact.extend", " amt precision is kept");
- }
+ IF_DEBUG("xact.extend") {
+ DEBUG("xact.extend",
+ "Initial post on line " << initial_post->pos->beg_line << ": "
+ << "amount " << initial_post->amount << " (precision "
+ << initial_post->amount.precision() << ")");
+
+ if (initial_post->amount.keep_precision())
+ DEBUG("xact.extend", " precision is kept");
+
+ DEBUG("xact.extend",
+ "Posting on line " << post->pos->beg_line << ": "
+ << "amount " << post_amount << ", amt " << amt
+ << " (precision " << post_amount.precision()
+ << " != " << amt.precision() << ")");
+
+ if (post_amount.keep_precision())
+ DEBUG("xact.extend", " precision is kept");
+ if (amt.keep_precision())
+ DEBUG("xact.extend", " amt precision is kept");
+ }
#endif // defined(DEBUG_ON)
- account_t * account = post->account;
- string fullname = account->fullname();
- assert(! fullname.empty());
-
- if (contains(fullname, "$account")) {
- fullname = regex_replace(fullname, regex("\\$account\\>"),
- initial_post->account->fullname());
- while (account->parent)
- account = account->parent;
- account = account->find_account(fullname);
- }
-
- // Copy over details so that the resulting post is a mirror of
- // the automated xact's one.
- post_t * new_post = new post_t(account, amt);
- new_post->copy_details(*post);
- new_post->add_flags(ITEM_GENERATED);
-
- xact.add_post(new_post);
- new_post->account->add_post(new_post);
-
- if (new_post->must_balance())
- needs_further_verification = true;
+ account_t * account = post->account;
+ string fullname = account->fullname();
+ assert(! fullname.empty());
+
+ if (contains(fullname, "$account")) {
+ fullname = regex_replace(fullname, regex("\\$account\\>"),
+ initial_post->account->fullname());
+ while (account->parent)
+ account = account->parent;
+ account = account->find_account(fullname);
+ }
+
+ // Copy over details so that the resulting post is a mirror of
+ // the automated xact's one.
+ post_t * new_post = new post_t(account, amt);
+ new_post->copy_details(*post);
+ new_post->add_flags(ITEM_GENERATED);
+
+ xact.add_post(new_post);
+ new_post->account->add_post(new_post);
+
+ if (new_post->must_balance())
+ needs_further_verification = true;
}
}
}
@@ -768,7 +768,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact)
}
void extend_xact_base(journal_t * journal,
- xact_base_t& base)
+ xact_base_t& base)
{
foreach (auto_xact_t * xact, journal->auto_xacts)
xact->extend_xact(base);
@@ -816,18 +816,18 @@ void to_xml(std::ostream& out, const xact_t& xact)
push_xml y(out, "metadata");
foreach (const item_t::string_map::value_type& pair, *xact.metadata) {
if (pair.second.first) {
- push_xml z(out, "variable");
- {
- push_xml w(out, "key");
- out << y.guard(pair.first);
- }
- {
- push_xml w(out, "value");
- out << y.guard(*pair.second.first);
- }
+ push_xml z(out, "variable");
+ {
+ push_xml w(out, "key");
+ out << y.guard(pair.first);
+ }
+ {
+ push_xml w(out, "value");
+ out << y.guard(*pair.second.first);
+ }
} else {
- push_xml z(out, "tag");
- out << y.guard(pair.first);
+ push_xml z(out, "tag");
+ out << y.guard(pair.first);
}
}
}
diff --git a/src/xact.h b/src/xact.h
index c6c61f95..2c3c7d05 100644
--- a/src/xact.h
+++ b/src/xact.h
@@ -106,7 +106,7 @@ class xact_t : public xact_base_t
{
public:
optional<string> code;
- string payee;
+ string payee;
xact_t() {
TRACE_CTOR(xact_t, "");
@@ -123,7 +123,7 @@ public:
string id() const;
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
- const string& name);
+ const string& name);
virtual bool valid() const;
@@ -188,7 +188,7 @@ class period_xact_t : public xact_base_t
{
public:
date_interval_t period;
- string period_string;
+ string period_string;
period_xact_t() {
TRACE_CTOR(period_xact_t, "");
@@ -221,7 +221,7 @@ private:
#endif // HAVE_BOOST_SERIALIZATION
};
-typedef std::list<xact_t *> xacts_list;
+typedef std::list<xact_t *> xacts_list;
typedef std::list<auto_xact_t *> auto_xacts_list;
typedef std::list<period_xact_t *> period_xacts_list;
diff --git a/src/xml.cc b/src/xml.cc
index 5dd10012..15710d44 100644
--- a/src/xml.cc
+++ b/src/xml.cc
@@ -43,8 +43,8 @@ namespace ledger {
namespace {
void xml_account(std::ostream& out, const account_t * acct) {
if ((acct->has_xdata() &&
- acct->xdata().has_flags(ACCOUNT_EXT_VISITED)) ||
- acct->children_with_flags(ACCOUNT_EXT_VISITED)) {
+ acct->xdata().has_flags(ACCOUNT_EXT_VISITED)) ||
+ acct->children_with_flags(ACCOUNT_EXT_VISITED)) {
out << "<account id=\"";
out.width(sizeof(unsigned long) * 2);
out.fill('0');
@@ -54,15 +54,15 @@ namespace {
out << "<name>" << acct->name << "</name>\n";
value_t total = acct->amount();
if (! total.is_null()) {
- out << "<amount>\n";
- to_xml(out, total);
- out << "</amount>\n";
+ out << "<amount>\n";
+ to_xml(out, total);
+ out << "</amount>\n";
}
total = acct->total();
if (! total.is_null()) {
- out << "<total>\n";
- to_xml(out, total);
- out << "</total>\n";
+ out << "<total>\n";
+ to_xml(out, total);
+ out << "</total>\n";
}
out << "</account>\n";
}
@@ -76,8 +76,8 @@ namespace {
foreach (const post_t * post, xact->posts)
if (post->has_xdata() &&
- post->xdata().has_flags(POST_EXT_VISITED))
- to_xml(out, *post);
+ post->xdata().has_flags(POST_EXT_VISITED))
+ to_xml(out, *post);
out << "</transaction>\n";
}
@@ -115,7 +115,7 @@ void format_xml::operator()(post_t& post)
assert(post.xdata().has_flags(POST_EXT_VISITED));
commodities.insert(commodities_pair(post.amount.commodity().symbol(),
- &post.amount.commodity()));
+ &post.amount.commodity()));
if (transactions_set.find(post.xact) == transactions_set.end())
transactions.push_back(post.xact);