|
My Project
|
#include <NPLTable.h>
Public Member Functions | |
| NPLObjectProxy (NPLObjectBase *pObject) | |
| operator double () | |
| void | operator= (double value) |
| operator bool () | |
| void | operator= (bool value) |
| operator const string & () | |
| const char * | c_str () |
| int | toInt () |
| bool | operator== (const string &value) |
| bool | operator== (const char *value) |
| void | operator= (const std::string &value) |
| void | operator= (const char *value) |
| NPLObjectProxy & | operator[] (const string &sName) |
| get field by name. More... | |
| NPLObjectProxy & | operator[] (const char *sName) |
| NPLObjectProxy & | operator[] (int nIndex) |
| NPLObjectProxy | GetField (const string &sName) |
| get a field. More... | |
| NPLObjectProxy | GetField (const char *sName) |
| get a field. More... | |
| void | SetField (const string &sName, const NPLObjectProxy &pObject) |
| Set the field. More... | |
| void | SetField (int nIndex, const NPLObjectProxy &pObject) |
| void | MakeNil () |
| make the object invalid | |
| NPLObjectBase::Iterator_Type | begin () |
| NPLObjectBase::Iterator_Type | end () |
| NPLObjectBase::IndexIterator_Type | index_begin () |
| NPLObjectBase::IndexIterator_Type | index_end () |
| NPLObjectBase::NPLObjectType | GetType () |
| get the type | |
NPL object proxy.
This is both a smart pointer and accessors Example 1: Create NPLTable and serialize to string NPL::NPLObjectProxy msg; msg["nid"] = (double)10; msg["name"] = "value"; msg["tab"]["name1"] = "value1"; NPL::NPLHelper::SerializeNPLTableToString(NULL, msg, strOutput);
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"); | NPLObjectProxy NPLObjectProxy::GetField | ( | const string & | sName | ) |
get a field.
It may return null if not found.
| NPLObjectProxy NPLObjectProxy::GetField | ( | const char * | sName | ) |
get a field.
It may return null if not found.
| NPLObjectProxy & NPLObjectProxy::operator[] | ( | const string & | sName | ) |
get field by name.
It will create an empty field if it does not exist. Use GetField() if you only want to find if a field exist of not.
| void NPL::NPLObjectProxy::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. |
1.8.12