diff options
-rw-r--r-- | amount.cc | 8 | ||||
-rw-r--r-- | amount.h | 7 | ||||
-rw-r--r-- | format.h | 2 | ||||
-rw-r--r-- | main.cc | 46 |
4 files changed, 38 insertions, 25 deletions
@@ -144,6 +144,14 @@ amount_t& amount_t::operator=(const std::string& value) return *this; } +amount_t& amount_t::operator=(const char * value) +{ + std::string valstr(value); + std::istringstream str(valstr); + parse(str); + return *this; +} + // assignment operator amount_t& amount_t::operator=(const amount_t& amt) { @@ -45,6 +45,12 @@ class amount_t std::istringstream str(value); str >> *this; } + amount_t(const char * value) { + _init(); + std::string valstr(value); + std::istringstream str(valstr); + str >> *this; + } amount_t(const bool value); amount_t(const int value); amount_t(const unsigned int value); @@ -59,6 +65,7 @@ class amount_t // assignment operator amount_t& operator=(const amount_t& amt); amount_t& operator=(const std::string& value); + amount_t& operator=(const char * value); amount_t& operator=(const bool value); amount_t& operator=(const int value); amount_t& operator=(const unsigned int value); @@ -105,7 +105,7 @@ class format_transaction format_transaction(std::ostream& _output_stream, const format_t& _first_line_format, const format_t& _next_lines_format, - const node_t * display_predicate, + const node_t * display_predicate = NULL, #ifdef COLLAPSED_REGISTER const bool _collapsed = false, #endif @@ -491,7 +491,7 @@ int main(int argc, char * argv[]) // Process the remaining command-line arguments std::auto_ptr<entry_t> new_entry; - if (command == "entry") { + if (command == "e") { new_entry.reset(journal->derive_entry(argc - index, &argv[index])); } else { // Treat the remaining command-line arguments as regular @@ -636,8 +636,18 @@ int main(int argc, char * argv[]) else f = print_fmt.c_str(); + std::string first_line_format; + std::string next_lines_format; + + if (const char * p = std::strstr(f, "%/")) { + first_line_format = std::string(f, 0, p - f); + next_lines_format = std::string(p + 2); + } else { + first_line_format = next_lines_format = f; + } + if (command == "b") { - format_t format(f); + format_t format(first_line_format); format_account formatter(std::cout, format, display_predicate.get()); walk_accounts(journal->master, formatter, predicate.get(), xact_display_flags, show_subtotals, show_expanded ? 0 : 1, @@ -652,38 +662,26 @@ int main(int argc, char * argv[]) } } else if (command == "E") { - std::string first_line_format; - std::string next_lines_format; - - if (const char * p = std::strstr(f, "%/")) { - first_line_format = std::string(f, 0, p - f); - next_lines_format = std::string(p + 2); - } else { - first_line_format = next_lines_format = f; - } - format_t format(first_line_format); format_t nformat(next_lines_format); - format_equity formatter(std::cout, format, nformat, display_predicate.get()); walk_accounts(journal->master, formatter, predicate.get(), xact_display_flags, true, 0, sort_order.get()); } - else { - std::string first_line_format; - std::string next_lines_format; - - if (const char * p = std::strstr(f, "%/")) { - first_line_format = std::string(f, 0, p - f); - next_lines_format = std::string(p + 2); - } else { - first_line_format = next_lines_format = f; - } - + else if (command == "e") { format_t format(first_line_format); format_t nformat(next_lines_format); + format_transaction formatter(std::cout, format, nformat); + for (transactions_list::iterator i = new_entry->transactions.begin(); + i != new_entry->transactions.end(); + i++) + handle_transaction(*i, formatter, xact_display_flags); + } + else { + format_t format(first_line_format); + format_t nformat(next_lines_format); format_transaction formatter(std::cout, format, nformat, display_predicate.get(), #ifdef COLLAPSED_REGISTER |