Added a collect_posts handler

This commit is contained in:
John Wiegley 2009-11-12 05:10:07 -05:00
parent cd0a040778
commit 86daa41a90

View file

@ -61,6 +61,35 @@ public:
virtual void operator()(post_t&) {}
};
class collect_posts : public item_handler<post_t>
{
public:
std::vector<post_t *> posts;
collect_posts() : item_handler<post_t>() {
TRACE_CTOR(collect_posts, "");
}
virtual ~collect_posts() {
TRACE_DTOR(collect_posts);
}
std::size_t length() const {
return posts.size();
}
std::vector<post_t *>::iterator begin() {
return posts.begin();
}
std::vector<post_t *>::iterator end() {
return posts.end();
}
virtual void flush() {}
virtual void operator()(post_t& post) {
posts.push_back(&post);
}
};
class posts_iterator;
class pass_down_posts : public item_handler<post_t>