diff options
author | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:00 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:00 -0400 |
commit | 42f43b7686038e4cbca16d8d2118b139544e6de3 (patch) | |
tree | 52c5473401c57282242d66b8dd75f4c07bf41d07 /csv.cc | |
parent | c7b4370ff9c8ab5c96f15b1e712e6db6bdab6324 (diff) | |
download | fork-ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.tar.gz fork-ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.tar.bz2 fork-ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.zip |
Check in all changes made so far toward 3.0.
Diffstat (limited to 'csv.cc')
-rw-r--r-- | csv.cc | 105 |
1 files changed, 0 insertions, 105 deletions
@@ -1,105 +0,0 @@ -#include "csv.h" - -namespace ledger { - -namespace { - inline void write_escaped_string(std::ostream& out, const std::string& xact) - { - out << "\""; - for (std::string::const_iterator i = xact.begin(); i != xact.end(); i++) - if (*i == '"') { - out << "\\"; - out << "\""; - } else { - out << *i; - } - out << "\""; - } -} - -void format_csv_transactions::operator()(transaction_t& xact) -{ - if (! transaction_has_xdata(xact) || - ! (transaction_xdata_(xact).dflags & TRANSACTION_DISPLAYED)) { - - { - format_t fmt("%D"); - std::ostringstream str; - fmt.format(str, details_t(xact)); - write_escaped_string(out, str.str()); - } - out << ','; - - { - format_t fmt("%P"); - std::ostringstream str; - fmt.format(str, details_t(xact)); - write_escaped_string(out, str.str()); - } - out << ','; - - { - format_t fmt("%A"); - std::ostringstream str; - fmt.format(str, details_t(xact)); - write_escaped_string(out, str.str()); - } - out << ','; - - { - format_t fmt("%t"); - std::ostringstream str; - fmt.format(str, details_t(xact)); - write_escaped_string(out, str.str()); - } - out << ','; - - { - format_t fmt("%T"); - std::ostringstream str; - fmt.format(str, details_t(xact)); - write_escaped_string(out, str.str()); - } - out << ','; - - switch (xact.state) { - case transaction_t::CLEARED: - write_escaped_string(out, "*"); - break; - case transaction_t::PENDING: - write_escaped_string(out, "!"); - break; - default: { - transaction_t::state_t state; - if (xact.entry->get_state(&state)) - switch (state) { - case transaction_t::CLEARED: - write_escaped_string(out, "*"); - break; - case transaction_t::PENDING: - write_escaped_string(out, "!"); - break; - default: - write_escaped_string(out, ""); - break; - } - } - } - out << ','; - - write_escaped_string(out, xact.entry->code); - out << ','; - - { - format_t fmt("%N"); - std::ostringstream str; - fmt.format(str, details_t(xact)); - write_escaped_string(out, str.str()); - } - out << '\n'; - - transaction_xdata(xact).dflags |= TRANSACTION_DISPLAYED; - } -} - -} // namespace ledger |