Skip to content

Commit

Permalink
Merge pull request #135 from ttti07/master
Browse files Browse the repository at this point in the history
C++ wrapper: add convenience method at() and lookup()
  • Loading branch information
vstakhov committed Mar 30, 2016
2 parents b51e368 + 88f5419 commit 6080a72
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions include/ucl++.h
Expand Up @@ -308,7 +308,7 @@ class Ucl final {
return default_val;
}

const Ucl operator[] (size_t i) const
const Ucl at (size_t i) const
{
if (type () == UCL_ARRAY) {
return Ucl (ucl_array_find_index (obj.get(), i));
Expand All @@ -317,7 +317,7 @@ class Ucl final {
return Ucl (nullptr);
}

const Ucl operator[](const std::string &key) const
const Ucl lookup (const std::string &key) const
{
if (type () == UCL_OBJECT) {
return Ucl (ucl_object_lookup_len (obj.get(),
Expand All @@ -326,6 +326,16 @@ class Ucl final {

return Ucl (nullptr);
}

inline const Ucl operator[] (size_t i) const
{
return at(i);
}

inline const Ucl operator[](const std::string &key) const
{
return lookup(key);
}
// Serialize.
void dump (std::string &out, ucl_emitter_t type = UCL_EMIT_JSON) const
{
Expand Down

0 comments on commit 6080a72

Please sign in to comment.