cwObject.h/cpp : Added list_ele().
This commit is contained in:
parent
59507913e0
commit
72b959690f
16
cwObject.cpp
16
cwObject.cpp
@ -371,11 +371,23 @@ const struct cw::object_str* cw::object_t::find( const char* label ) const
|
|||||||
if((ch = o->find(label)) != nullptr )
|
if((ch = o->find(label)) != nullptr )
|
||||||
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
|
||||||
{
|
{
|
||||||
|
11
cwObject.h
11
cwObject.h
@ -35,8 +35,6 @@ namespace cw
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned objTypeId_t;
|
typedef unsigned objTypeId_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -102,10 +100,10 @@ namespace cw
|
|||||||
inline bool is_value_container() const { return type != nullptr && cwIsFlag(type->flags,kValueContainerFl); }
|
inline bool is_value_container() const { return type != nullptr && cwIsFlag(type->flags,kValueContainerFl); }
|
||||||
|
|
||||||
// Containers have children and use the object.u.children pointer.
|
// Containers have children and use the object.u.children pointer.
|
||||||
inline bool is_container() const { return type != nullptr && cwIsFlag(type->flags,kContainerFl); }
|
inline bool is_container() const { return type != nullptr && cwIsFlag(type->flags,kContainerFl); }
|
||||||
inline bool is_pair() const { return type != nullptr && type->id == kPairTId; }
|
inline bool is_pair() const { return type != nullptr && type->id == kPairTId; }
|
||||||
inline bool is_dict() const { return type != nullptr && type->id == kDictTId; }
|
inline bool is_dict() const { return type != nullptr && type->id == kDictTId; }
|
||||||
inline bool is_list() const { return type != nullptr && type->id == kListTId; }
|
inline bool is_list() const { return type != nullptr && type->id == kListTId; }
|
||||||
|
|
||||||
rc_t value( void* dst, unsigned dstTypeId );
|
rc_t value( void* dst, unsigned dstTypeId );
|
||||||
rc_t value( char& v ) const;
|
rc_t value( char& v ) const;
|
||||||
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user