Skip to content

Instantly share code, notes, and snippets.

@artemp
Created February 24, 2012 17:30
Show Gist options
  • Select an option

  • Save artemp/1902245 to your computer and use it in GitHub Desktop.

Select an option

Save artemp/1902245 to your computer and use it in GitHub Desktop.
class feature_kv_iterator :
public boost::iterator_facade<feature_kv_iterator,
boost::tuple<std::string , value> const,
boost::forward_traversal_tag>
{
public:
typedef boost::tuple<std::string,value> value_type;
feature_kv_iterator (feature_impl const& f, bool begin = false)
: f_(f),
itr_( begin ? f_.ctx_->begin() : f_.ctx_->end())
{}
private:
friend class boost::iterator_core_access;
inline void increment()
{
++itr_;
}
inline bool equal( feature_kv_iterator const& other) const
{
return ( itr_ == other.itr_);
}
inline value_type const& dereference() const
{
boost::get<0>(kv_) = itr_->first;
boost::optional<mapnik::value const&> val = f_.get_optional(itr_->second);
if (val) boost::get<1>(kv_) = *val;
else boost::get<1>(kv_) = value_null();
return kv_;
}
feature_impl const& f_;
std::map<std::string,std::size_t>::const_iterator itr_;
mutable value_type kv_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment