got entry working again

This commit is contained in:
John Wiegley 2004-08-07 22:25:12 -04:00
parent 84fe84bbd2
commit b7777eac68
4 changed files with 38 additions and 25 deletions

View file

@ -144,6 +144,14 @@ amount_t& amount_t::operator=(const std::string& value)
return *this; return *this;
} }
amount_t& amount_t::operator=(const char * value)
{
std::string valstr(value);
std::istringstream str(valstr);
parse(str);
return *this;
}
// assignment operator // assignment operator
amount_t& amount_t::operator=(const amount_t& amt) amount_t& amount_t::operator=(const amount_t& amt)
{ {

View file

@ -45,6 +45,12 @@ class amount_t
std::istringstream str(value); std::istringstream str(value);
str >> *this; 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 bool value);
amount_t(const int value); amount_t(const int value);
amount_t(const unsigned int value); amount_t(const unsigned int value);
@ -59,6 +65,7 @@ class amount_t
// assignment operator // assignment operator
amount_t& operator=(const amount_t& amt); amount_t& operator=(const amount_t& amt);
amount_t& operator=(const std::string& value); amount_t& operator=(const std::string& value);
amount_t& operator=(const char * value);
amount_t& operator=(const bool value); amount_t& operator=(const bool value);
amount_t& operator=(const int value); amount_t& operator=(const int value);
amount_t& operator=(const unsigned int value); amount_t& operator=(const unsigned int value);

View file

@ -105,7 +105,7 @@ class format_transaction
format_transaction(std::ostream& _output_stream, format_transaction(std::ostream& _output_stream,
const format_t& _first_line_format, const format_t& _first_line_format,
const format_t& _next_lines_format, const format_t& _next_lines_format,
const node_t * display_predicate, const node_t * display_predicate = NULL,
#ifdef COLLAPSED_REGISTER #ifdef COLLAPSED_REGISTER
const bool _collapsed = false, const bool _collapsed = false,
#endif #endif

46
main.cc
View file

@ -491,7 +491,7 @@ int main(int argc, char * argv[])
// Process the remaining command-line arguments // Process the remaining command-line arguments
std::auto_ptr<entry_t> new_entry; std::auto_ptr<entry_t> new_entry;
if (command == "entry") { if (command == "e") {
new_entry.reset(journal->derive_entry(argc - index, &argv[index])); new_entry.reset(journal->derive_entry(argc - index, &argv[index]));
} else { } else {
// Treat the remaining command-line arguments as regular // Treat the remaining command-line arguments as regular
@ -636,8 +636,18 @@ int main(int argc, char * argv[])
else else
f = print_fmt.c_str(); 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") { if (command == "b") {
format_t format(f); format_t format(first_line_format);
format_account formatter(std::cout, format, display_predicate.get()); format_account formatter(std::cout, format, display_predicate.get());
walk_accounts(journal->master, formatter, predicate.get(), walk_accounts(journal->master, formatter, predicate.get(),
xact_display_flags, show_subtotals, show_expanded ? 0 : 1, xact_display_flags, show_subtotals, show_expanded ? 0 : 1,
@ -652,38 +662,26 @@ int main(int argc, char * argv[])
} }
} }
else if (command == "E") { 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 format(first_line_format);
format_t nformat(next_lines_format); format_t nformat(next_lines_format);
format_equity formatter(std::cout, format, nformat, format_equity formatter(std::cout, format, nformat,
display_predicate.get()); display_predicate.get());
walk_accounts(journal->master, formatter, predicate.get(), walk_accounts(journal->master, formatter, predicate.get(),
xact_display_flags, true, 0, sort_order.get()); xact_display_flags, true, 0, sort_order.get());
} }
else { 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 format(first_line_format);
format_t nformat(next_lines_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, format_transaction formatter(std::cout, format, nformat,
display_predicate.get(), display_predicate.get(),
#ifdef COLLAPSED_REGISTER #ifdef COLLAPSED_REGISTER