My Project
Public Member Functions | List of all members
NPL::NPLObjectProxy Class Reference

NPL object proxy. More...

#include <NPLTable.h>

Inheritance diagram for NPL::NPLObjectProxy:

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)
 
NPLObjectProxyoperator[] (const string &sName)
 get field by name. More...
 
NPLObjectProxyoperator[] (const char *sName)
 
NPLObjectProxyoperator[] (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
 

Detailed Description

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");

Member Function Documentation

§ GetField() [1/2]

NPLObjectProxy NPLObjectProxy::GetField ( const string &  sName)

get a field.

It may return null if not found.

§ GetField() [2/2]

NPLObjectProxy NPLObjectProxy::GetField ( const char *  sName)

get a field.

It may return null if not found.

§ operator[]()

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.

§ SetField()

void NPL::NPLObjectProxy::SetField ( const string &  sName,
const NPLObjectProxy pObject 
)

Set the field.

Parameters
sNamethe field name
pObjectif NULL, it will remove the field, as if nil in lua.

The documentation for this class was generated from the following files: