This commit is contained in:
John Wiegley 2016-11-12 18:51:11 -08:00
parent f1dc15a4c7
commit 960f4e809f
No known key found for this signature in database
GPG key ID: C144D8F4F19FE630
2 changed files with 18 additions and 10 deletions

View file

@ -34,6 +34,7 @@
#include "output.h"
#include "xact.h"
#include "post.h"
#include "item.h"
#include "account.h"
#include "session.h"
#include "report.h"
@ -329,21 +330,26 @@ void report_tags::flush()
}
}
void report_tags::operator()(post_t& post)
void report_tags::gather_metadata(item_t& item)
{
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();
}
if (item.metadata)
foreach (const item_t::string_map::value_type& data, *item.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));
tags.insert(tags_pair(tag, 1));
else
(*i).second++;
(*i).second++;
}
}
}
void report_tags::operator()(post_t& post)
{
gather_metadata(*post.xact);
gather_metadata(post);
}
void report_commodities::flush()

View file

@ -51,6 +51,7 @@ namespace ledger {
class xact_t;
class post_t;
class item_t;
class report_t;
class format_posts : public item_handler<post_t>
@ -208,6 +209,7 @@ public:
}
virtual void flush();
virtual void gather_metadata(item_t& item);
virtual void operator()(post_t& post);
virtual void clear() {