My Project
Public Types | Public Member Functions | List of all members
NPLInterface::NPLTable Class Reference

this is a pure c++ implementation of lua table. More...

#include <NPLInterface.hpp>

Inheritance diagram for NPLInterface::NPLTable:
NPLInterface::NPLObjectBase NPLInterface::intrusive_ptr_single_thread_base

Public Types

typedef std::map< std::string, NPLObjectProxyTableFieldMap_Type
 
typedef std::map< int, NPLObjectProxyTableIntFieldMap_Type
 
typedef TableFieldMap_Type::iterator Iterator_Type
 
typedef TableIntFieldMap_Type::iterator IndexIterator_Type
 
- Public Types inherited from NPLInterface::NPLObjectBase
enum  NPLObjectType {
  NPLObjectType_Nil, NPLObjectType_Table, NPLObjectType_Number, NPLObjectType_String,
  NPLObjectType_Bool
}
 

Public Member Functions

 NPLTable ()
 this is an empty table
 
void ToString (std::string &str)
 
void Clear ()
 
void SetField (const string &sName, const NPLObjectProxy &pObject)
 
void SetField (int nIndex, const NPLObjectProxy &pObject)
 
NPLObjectProxy GetField (int nIndex)
 
NPLObjectProxy GetField (const string &sName)
 
NPLObjectProxyCreateGetField (int nIndex)
 
NPLObjectProxyCreateGetField (const string &sName)
 
Iterator_Type begin ()
 
Iterator_Type end ()
 
IndexIterator_Type index_begin ()
 
IndexIterator_Type index_end ()
 
NPLObjectProxyoperator[] (const string &sName)
 this will create get field. More...
 
NPLObjectProxyoperator[] (const char *sName)
 
NPLObjectProxyoperator[] (int nIndex)
 
- Public Member Functions inherited from NPLInterface::NPLObjectBase
NPLObjectType GetType ()
 

Additional Inherited Members

- Public Attributes inherited from NPLInterface::intrusive_ptr_single_thread_base
long m_ref_count
 
- Protected Attributes inherited from NPLInterface::NPLObjectBase
NPLObjectType m_type
 

Detailed Description

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.

Remarks
: Use NPLObjectProxy instead of this class. Example: Example 1: Create NPLTable and serialize to string NPLObjectProxy msg; msg["nid"] = (double)10; msg["name"] = "value"; msg["tab"]["name1"] = "value1"; NPLHelper::SerializeNPLTableToString(NULL, msg, strOutput);

Example 2: deserialize NPLTable from string.

NPLObjectProxy tabMsg = NPLHelper::StringToNPLTable("{nid=10, name=\"value\", tab={name1=\"value1\"}}");
assert((double)tabMsg["nid"] == 10);
assert((tabMsg["name"]) == "value");
assert((tabMsg["tab"]["name1"]) == "value1");

  @note: no cyclic link is allowed.

Member Function Documentation

§ operator[]()

NPLObjectProxy& NPLInterface::NPLTable::operator[] ( const string &  sName)
inline

this will create get field.


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