Skip to content

Commit

Permalink
kvp-frame.hpp: expose the iterator from underlying std::map (?)
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Apr 8, 2022
1 parent 9117615 commit ce9cfca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bindings/guile/gnc-kvp-guile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,14 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
break;
case KvpValue::Type::FRAME:
{
auto rv = SCM_EOL;
auto acc = [](const auto& k, const auto& v, auto& rv)
auto frame { val->get<KvpFrame*>() };
auto acc = [](const auto& rv, const auto& iter)
{
auto key_scm { scm_from_utf8_string (k) };
auto val_scm { gnc_kvp_value_ptr_to_scm (v) };
rv = scm_acons (key_scm, val_scm, rv);
auto key_scm { scm_from_utf8_string (iter.first) };
auto val_scm { gnc_kvp_value_ptr_to_scm (iter.second) };
return scm_acons (key_scm, val_scm, rv);
};
val->get<KvpFrame*>()->for_each_slot_temp (acc, rv);
return scm_reverse (rv);
return scm_reverse (std::accumulate (frame->begin(), frame->end(), SCM_EOL, acc));
}
break;
case KvpValue::Type::GLIST:
Expand Down
3 changes: 3 additions & 0 deletions libgnucash/engine/kvp-frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ struct KvpFrameImpl
bool empty() const noexcept { return m_valuemap.empty(); }
friend int compare(const KvpFrameImpl&, const KvpFrameImpl&) noexcept;

map_type::iterator begin() { return m_valuemap.begin(); }
map_type::iterator end() { return m_valuemap.end(); }

private:
map_type m_valuemap;

Expand Down

0 comments on commit ce9cfca

Please sign in to comment.