diff options
author | Craig Earls <enderw88@gmail.com> | 2013-01-29 10:34:12 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-01-29 10:34:12 -0700 |
commit | c18d0663a536f3291c70ca82a520b477325968e9 (patch) | |
tree | 5d6a82d20c02abd0706a7300f0b9dd9ea26f691c /src/output.cc | |
parent | 0bbff75f43a096823c2838ae3b7330cf86a54b78 (diff) | |
parent | 3e72a51dc3d296c9f647efaf4cbfbbdcf4bf6df1 (diff) | |
download | fork-ledger-c18d0663a536f3291c70ca82a520b477325968e9.tar.gz fork-ledger-c18d0663a536f3291c70ca82a520b477325968e9.tar.bz2 fork-ledger-c18d0663a536f3291c70ca82a520b477325968e9.zip |
Merge branch 'add-tags-command' into kitchen-sink
Diffstat (limited to 'src/output.cc')
-rw-r--r-- | src/output.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/output.cc b/src/output.cc index f433f8d1..6ed7f861 100644 --- a/src/output.cc +++ b/src/output.cc @@ -318,6 +318,34 @@ void report_payees::operator()(post_t& post) (*i).second++; } +void report_tags::flush() +{ + std::ostream& out(report.output_stream); + + foreach (tags_pair& entry, tags) { + if (report.HANDLED(count)) + out << entry.second << ' '; + out << entry.first << '\n'; + } +} + +void report_tags::operator()(post_t& post) +{ + if(post.metadata){ + foreach (const item_t::string_map::value_type& data, *post.metadata){ + string tag=data.first; + if(report.HANDLED(values) && (data.second).first){ + tag+=": "+ (data.second).first.get().to_string(); + } + std::map<string, std::size_t>::iterator i = tags.find(tag); + if (i == tags.end()) + tags.insert(tags_pair(tag, 1)); + else + (*i).second++; + } + } +} + void report_commodities::flush() { std::ostream& out(report.output_stream); |