My Project
|
this is a pure c++ implementation of lua table. More...
#include <NPLTable.h>
Public Member Functions | |
NPLTable () | |
this is an empty table | |
void | ToString (std::string &str) |
output table to serialized string. More... | |
void | Clear () |
clear the table object | |
void | SetField (const string &sName, const NPLObjectProxy &pObject) |
Set the field. More... | |
void | SetField (int nIndex, const NPLObjectProxy &pObject) |
NPLObjectProxy | GetField (const string &sName) |
get a field. More... | |
NPLObjectProxy | GetField (int nIndex) |
NPLObjectProxy & | CreateGetField (const string &sName) |
create or get a field. More... | |
NPLObjectProxy & | CreateGetField (int nIndex) |
Iterator_Type | begin () |
Iterator_Type | end () |
IndexIterator_Type | index_begin () |
IndexIterator_Type | index_end () |
NPLObjectProxy & | operator[] (const string &sName) |
this will create get field. More... | |
NPLObjectProxy & | operator[] (const char *sName) |
NPLObjectProxy & | operator[] (int nIndex) |
![]() | |
NPLObjectType | GetType () |
bool | isTable () |
bool | isNumber () |
bool | isString () |
bool | isNil () |
bool | isBool () |
Additional Inherited Members | |
![]() | |
enum | NPLObjectType { NPLObjectType_Nil, NPLObjectType_Table, NPLObjectType_Number, NPLObjectType_String, NPLObjectType_Bool } |
typedef std::map< std::string, NPLObjectProxy > | TableFieldMap_Type |
typedef std::map< int, NPLObjectProxy > | TableIntFieldMap_Type |
typedef TableFieldMap_Type::iterator | Iterator_Type |
typedef TableIntFieldMap_Type::iterator | IndexIterator_Type |
![]() | |
long | m_ref_count |
![]() | |
intrusive_ptr_single_thread_base (const intrusive_ptr_single_thread_base &) | |
intrusive_ptr_single_thread_base & | operator= (const intrusive_ptr_single_thread_base &) |
![]() | |
NPLObjectType | m_type |
this is a pure c++ implementation of lua table.
it can convert back and force from string. only data members are supported. This class is mostly used by C++ plugin modules.
Example 2: deserialize NPLTable from string.
NPL::NPLObjectProxy tabMsg = NPL::NPLHelper::StringToNPLTable("{nid=10, name=\"value\", tab={name1=\"value1\"}}"); PE_ASSERT((double)tabMsg["nid"] == 10); PE_ASSERT((tabMsg["name"]) == "value"); PE_ASSERT((tabMsg["tab"]["name1"]) == "value1"); @note: no cyclic link is allowed.
NPLObjectProxy & NPLTable::CreateGetField | ( | const string & | sName | ) |
create or get a field.
It may return null proxy
NPLObjectProxy NPLTable::GetField | ( | const string & | sName | ) |
get a field.
It may return null if not found.
|
inline |
this will create get field.
void NPLTable::SetField | ( | const string & | sName, |
const NPLObjectProxy & | pObject | ||
) |
Set the field.
sName | the field name |
pObject | if NULL, it will remove the field, as if nil in lua. |
void NPLTable::ToString | ( | std::string & | str | ) |
output table to serialized string.