diff options
author | John Wiegley <johnw@newartisans.com> | 2004-07-26 23:33:51 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-07-26 23:33:51 -0400 |
commit | 161d6f79bd6f4ab45afa1cbae77548c8e508809a (patch) | |
tree | 55391f4997e20de173579d90b43316a968b27c9e /format.h | |
parent | fde56d0f1214b8fb9de5ba4d42d683ed494c45b0 (diff) | |
download | fork-ledger-161d6f79bd6f4ab45afa1cbae77548c8e508809a.tar.gz fork-ledger-161d6f79bd6f4ab45afa1cbae77548c8e508809a.tar.bz2 fork-ledger-161d6f79bd6f4ab45afa1cbae77548c8e508809a.zip |
initial rev of 2.0
Diffstat (limited to 'format.h')
-rw-r--r-- | format.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/format.h b/format.h new file mode 100644 index 00000000..3e66dc7b --- /dev/null +++ b/format.h @@ -0,0 +1,51 @@ +#ifndef _REPORT_H +#define _REPORT_H + +#include "ledger.h" +#include "constraint.h" +#include "balance.h" + +namespace ledger { + +std::string truncated(const std::string& str, unsigned int width); +std::string maximal_account_name(const item_t * item, const item_t * parent); + +struct format_t +{ + constraints_t constraints; + + std::string format_string; + node_t * value_style; + node_t * total_style; + + format_t() { + value_style = NULL; + total_style = NULL; + } + + ~format_t() { + if (value_style) delete value_style; + if (total_style) delete total_style; + } + + balance_t compute_value(const item_t * item) const { + if (value_style) + return value_style->compute(begin(), end(), item); + else + return balance_t(); + } + + balance_t compute_total(const item_t * item) const { + if (total_style) + return total_style->compute(begin(), end(), item); + else + return balance_t(); + } + + std::string report_line(const item_t * item, + const item_t * displayed_parent = NULL); +}; + +} // namespace ledger + +#endif // _REPORT_H |