summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-08 23:28:30 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-08 23:28:30 -0400
commitf50def86c4a1203837a8f97066d9d4dfd268e0f1 (patch)
treec717ba4efb0ba09113111e1c45f45e770e5b17b9
parent57d98ac1207241c32ee19c71b4d621c313697bce (diff)
downloadfork-ledger-f50def86c4a1203837a8f97066d9d4dfd268e0f1.tar.gz
fork-ledger-f50def86c4a1203837a8f97066d9d4dfd268e0f1.tar.bz2
fork-ledger-f50def86c4a1203837a8f97066d9d4dfd268e0f1.zip
Moved get_partial_name from format.cc into account_t, where it belongs.
-rw-r--r--src/account.cc40
-rw-r--r--src/account.h5
-rw-r--r--src/format.cc24
-rw-r--r--src/format.h1
4 files changed, 28 insertions, 42 deletions
diff --git a/src/account.cc b/src/account.cc
index 109089fc..b6681c54 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -125,6 +125,26 @@ string account_t::fullname() const
}
}
+string account_t::partial_name() const
+{
+ string name;
+
+ for (const account_t * acct = this;
+ acct && acct->parent;
+ acct = acct->parent) {
+ if (acct->has_xdata() &&
+ acct->xdata().has_flags(ACCOUNT_EXT_DISPLAYED))
+ break;
+
+ if (name.empty())
+ name = acct->name;
+ else
+ name = acct->name + ":" + name;
+ }
+
+ return name;
+}
+
std::ostream& operator<<(std::ostream& out, const account_t& account)
{
out << account.fullname();
@@ -132,24 +152,8 @@ std::ostream& operator<<(std::ostream& out, const account_t& account)
}
namespace {
- value_t get_partial_name(account_t& account)
- {
- string name;
-
- for (account_t * acct = &account;
- acct && acct->parent;
- acct = acct->parent) {
- if (acct->has_xdata() &&
- acct->xdata().has_flags(ACCOUNT_EXT_DISPLAYED))
- break;
-
- if (name.empty())
- name = acct->name;
- else
- name = acct->name + ":" + name;
- }
-
- return string_value(name);
+ value_t get_partial_name(account_t& account) {
+ return string_value(account.partial_name());
}
value_t get_total(account_t& account) {
diff --git a/src/account.h b/src/account.h
index 2cf8192a..18792154 100644
--- a/src/account.h
+++ b/src/account.h
@@ -97,6 +97,7 @@ class account_t : public scope_t
return fullname();
}
string fullname() const;
+ string partial_name() const;
void add_account(account_t * acct) {
accounts.insert(accounts_map::value_type(acct->name, acct));
@@ -172,6 +173,10 @@ class account_t : public scope_t
xdata_ = xdata_t();
return *xdata_;
}
+ const xdata_t& xdata() const {
+ assert(xdata_);
+ return *xdata_;
+ }
void calculate_sums(expr_t& amount_expr, scope_t& scope);
};
diff --git a/src/format.cc b/src/format.cc
index c4683876..3bbb2b13 100644
--- a/src/format.cc
+++ b/src/format.cc
@@ -30,7 +30,7 @@
*/
#include "format.h"
-#include "account.h"
+#include "scope.h"
namespace ledger {
@@ -59,28 +59,6 @@ void format_t::element_t::dump(std::ostream& out) const
}
}
-namespace {
- string partial_account_name(account_t& account)
- {
- string name;
-
- for (account_t * acct = &account;
- acct && acct->parent;
- acct = acct->parent) {
- if (acct->has_xdata() &&
- acct->xdata().has_flags(ACCOUNT_EXT_DISPLAYED))
- break;
-
- if (name.empty())
- name = acct->name;
- else
- name = acct->name + ":" + name;
- }
-
- return name;
- }
-}
-
format_t::element_t * format_t::parse_elements(const string& fmt)
{
std::auto_ptr<element_t> result;
diff --git a/src/format.h b/src/format.h
index 5c0de527..49350104 100644
--- a/src/format.h
+++ b/src/format.h
@@ -46,7 +46,6 @@
#ifndef _FORMAT_H
#define _FORMAT_H
-#include "journal.h"
#include "expr.h"
namespace ledger {