From 30f79b07618872b7326742430e03795da5782860 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 14 Mar 2006 09:44:19 +0000 Subject: [PATCH] *** empty log message *** --- NEWS | 29 ++++++++++++++++++++++------- amount.cc | 3 ++- amount.h | 1 + config.cc | 5 +++++ config.h | 2 +- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 5feedcd8..0b0818d0 100644 --- a/NEWS +++ b/NEWS @@ -6,14 +6,29 @@ - Error reporting has been greatly improving, now showing full contextual information for most error messages. -- Added new --ansi reporting option, which shows negative values as - red using ANSI terminal codes; --ansi-invert makes non-negative - values red (which makes more sense for income and budget reports, - for example). +- Added --base reporting option, for reporting convertible commodities + in their most basic form. For example, if you read a timeclock file + with Ledger, the time values are reported as hour and minutes -- + whichever is the most compact form. But with --base, Ledger reports + only in seconds. -- Added a new --only predicate, which occurs during transaction - processing between --limit and --display. Here is a summary of how - the three supported predicates are used: + NOTE: Setting up convertible commodities is easy; here's how to use + Ledger for tracking quantities of data, where the most compact form + is reported (unless --base is specified): + + C 1.00 Kb = 1024 b + C 1.00 Mb = 1024 Kb + C 1.00 Gb = 1024 Mb + C 1.00 Tb = 1024 Gb + +- Added --ansi reporting option, which shows negative values as red + using ANSI terminal codes; --ansi-invert makes non-negative values + red (which makes more sense for income and budget reports, for + example). + +- Added --only predicate, which occurs during transaction processing + between --limit and --display. Here is a summary of how the three + supported predicates are used: --limit "a>100" diff --git a/amount.cc b/amount.cc index cad3e64d..b84bc535 100644 --- a/amount.cc +++ b/amount.cc @@ -15,6 +15,7 @@ bool do_cleanup = true; bool amount_t::keep_price = false; bool amount_t::keep_date = false; bool amount_t::keep_tag = false; +bool amount_t::keep_base = false; #define BIGINT_BULK_ALLOC 0x0001 #define BIGINT_KEEP_PREC 0x0002 @@ -723,7 +724,7 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt) } amount_t base(amt); - if (amt.commodity().larger()) { + if (! amount_t::keep_base && amt.commodity().larger()) { amount_t last(amt); while (last.commodity().larger()) { last /= *last.commodity().larger(); diff --git a/amount.h b/amount.h index 460047ae..4db7a5eb 100644 --- a/amount.h +++ b/amount.h @@ -28,6 +28,7 @@ class amount_t static bool keep_price; static bool keep_date; static bool keep_tag; + static bool keep_base; protected: void _init(); diff --git a/config.cc b/config.cc index 37198879..c33a9429 100644 --- a/config.cc +++ b/config.cc @@ -1129,6 +1129,10 @@ OPT_BEGIN(ansi_invert, "") { // // Commodity reporting +OPT_BEGIN(base, ":") { + amount_t::keep_base = true; +} OPT_END(base); + OPT_BEGIN(price_db, ":") { config->price_db = optarg; } OPT_END(price_db); @@ -1206,6 +1210,7 @@ option_t config_options[CONFIG_OPTIONS_SIZE] = { { "ansi-invert", '\0', false, opt_ansi_invert, false }, { "average", 'A', false, opt_average, false }, { "balance-format", '\0', true, opt_balance_format, false }, + { "base", '\0', false, opt_base, false }, { "basis", 'B', false, opt_basis, false }, { "begin", 'b', true, opt_begin, false }, { "budget", '\0', false, opt_budget, false }, diff --git a/config.h b/config.h index 6a057979..44a24976 100644 --- a/config.h +++ b/config.h @@ -107,7 +107,7 @@ class config_t std::list *>& ptrs); }; -#define CONFIG_OPTIONS_SIZE 88 +#define CONFIG_OPTIONS_SIZE 89 extern option_t config_options[CONFIG_OPTIONS_SIZE]; void option_help(std::ostream& out);