My Project
Public Member Functions | Public Attributes | List of all members
ParaScripting::ParaDataProvider Class Reference

Wrapper of internal ParaWorld data provider. More...

#include <ParaScriptingWorld.h>

Public Member Functions

bool IsValid ()
 check if the object is valid
 
 ParaDataProvider (void *pObj)
 
bool InsertPuzzleRecordFromString (const char *strRecord)
 Insert the new puzzle record to Puzzle_DB. More...
 
bool DeletePuzzleRecordByID (int ID)
 delete the existing puzzle record from Puzzle_DB More...
 
int GetNPCIDByName (const char *name)
 get NPC ID by name More...
 
int GetNPCCount ()
 the total number of NPC in the database. More...
 
bool DoesAttributeExists (const char *sName)
 whether a given attribute exists. More...
 
object GetAttribute (const char *sName, const object &sOut)
 get the attribute of the current attribute instance in the current table e.g. More...
 
bool UpdateAttribute (const char *sName, const object &sIn)
 update the attribute of the current attribute instance in the current table insert the attribute if it is not created before. More...
 
bool InsertAttribute (const char *sName, const object &sIn)
 insert by simple name value pair More...
 
bool DeleteAttribute (const char *sName)
 delete the attribute of the current attribute instance in the current table More...
 
bool ExecSQL (const char *sCmd)
 run a given sql command, commonly used commands are "BEGIN", "END", when we are batch saving attributes. More...
 
void SetTableName (const char *sName)
 set current attribute table name, the table will be created if not exists. More...
 
const char * GetTableName ()
 get the current attribute table name More...
 

Public Attributes

union {
   void *   m_pDataProvider
 
   AttributeProvider *   m_pAttributeProvider
 
}; 
 

Detailed Description

Wrapper of internal ParaWorld data provider.

Member Function Documentation

§ DeleteAttribute()

bool ParaDataProvider::DeleteAttribute ( const char *  sName)

delete the attribute of the current attribute instance in the current table

Parameters
sName: name of the attribute field
Returns
true if succeed.

§ DeletePuzzleRecordByID()

bool ParaDataProvider::DeletePuzzleRecordByID ( int  ID)

delete the existing puzzle record from Puzzle_DB

Parameters
IDID of target record
Returns
true if the record is deleted in database

§ DoesAttributeExists()

bool ParaDataProvider::DoesAttributeExists ( const char *  sName)

whether a given attribute exists.

This function is usually used internally. One common use of this function is to test if a field exists, so that we know if a object has been saved before or not.

Parameters
sName: name of the attribute field
Returns

§ ExecSQL()

bool ParaScripting::ParaDataProvider::ExecSQL ( const char *  sCmd)

run a given sql command, commonly used commands are "BEGIN", "END", when we are batch saving attributes.

§ GetAttribute()

object ParaDataProvider::GetAttribute ( const char *  sName,
const object sOut 
)

get the attribute of the current attribute instance in the current table e.g.

suppose db is a ParaDataProvider object. local x = db:GetAttribute("PlayerX", 0); local name = db:GetAttribute("PlayerName", "no_name");

Parameters
sName: name of the attribute field
sOut: [in|out] default value of the field. Currently it may be a string or a number
Returns
the object is returned. Currently it may be a string, boolean or a number.

§ GetNPCCount()

int ParaDataProvider::GetNPCCount ( )

the total number of NPC in the database.

There is no statement cached for this call.

Returns

§ GetNPCIDByName()

int ParaDataProvider::GetNPCIDByName ( const char *  name)

get NPC ID by name

Parameters
namename of character
Returns
id is returned if found in database; otherwise non-positive value(-1) is returned.

§ GetTableName()

const char * ParaDataProvider::GetTableName ( )

get the current attribute table name

Returns
current attribute table name

§ InsertAttribute()

bool ParaDataProvider::InsertAttribute ( const char *  sName,
const object sIn 
)

insert by simple name value pair

Parameters
sName: name of the attribute field
sInvalue of the attribute field. Currently it may be a string, boolean or a number.
Returns
true if succeed.

§ InsertPuzzleRecordFromString()

bool ParaDataProvider::InsertPuzzleRecordFromString ( const char *  strRecord)

Insert the new puzzle record to Puzzle_DB.

Parameters
recordID of record will be ignored and filled with actual ID if inserted successfully
Returns
true if the record is inserted in database

§ SetTableName()

void ParaDataProvider::SetTableName ( const char *  sName)

set current attribute table name, the table will be created if not exists.

Parameters
sNametable name

§ UpdateAttribute()

bool ParaDataProvider::UpdateAttribute ( const char *  sName,
const object sIn 
)

update the attribute of the current attribute instance in the current table insert the attribute if it is not created before.

Parameters
sName: name of the attribute field
sInvalue of the attribute field. Currently it may be a string, boolean or a number.
Returns
true if succeed.

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