cwObject.h/cpp : Added list_ele().

This commit is contained in:
kpl 2020-01-27 17:48:17 -05:00
parent 59507913e0
commit 72b959690f
2 changed files with 19 additions and 8 deletions

View File

@ -372,10 +372,22 @@ const struct cw::object_str* cw::object_t::find( const char* label ) const
return ch; return ch;
} }
} }
return nullptr; return nullptr;
} }
const struct cw::object_str* cw::object_t::list_ele( unsigned idx ) const
{
if( is_list() )
{
unsigned i = 0;
for(object_t* o=u.children; o!=nullptr; o=o->sibling,++i)
if( i == idx )
return o;
}
return nullptr;
}
void cw::object_t::print(const print_ctx_t* c) const void cw::object_t::print(const print_ctx_t* c) const
{ {

View File

@ -36,8 +36,6 @@ namespace cw
typedef unsigned objTypeId_t; typedef unsigned objTypeId_t;
enum enum
{ {
kValueContainerFl = 0x01, // root,pair, or list are the only legal value containers kValueContainerFl = 0x01, // root,pair, or list are the only legal value containers
@ -124,6 +122,7 @@ namespace cw
const char* pair_label() const; const char* pair_label() const;
const struct object_str* pair_value() const; const struct object_str* pair_value() const;
const struct object_str* find( const char* label ) const; const struct object_str* find( const char* label ) const;
const struct object_str* list_ele( unsigned idx ) const;
template< typename T > template< typename T >
rc_t get( const char* label, T& v ) const rc_t get( const char* label, T& v ) const