ARSA Language  2.8
(Encryption, GPU and Web 3.0)
map Class Reference

#include <map.h>

Public Member Functions

int map ()
 Allocate new memory of map. More...
 
int map (const char *element,...)
 Allocate new memory of map with elements. More...
 
void set (int id, const char *name, const T &value)
 
const char * get (int id, const char *name)
 Direct const access operator. More...
 
const char * getkeybyid (int id, int num)
 Direct key access operator. More...
 
const char * getvaluebyid (int id, int num)
 Direct value access operator. More...
 
int size (int id)
 Get number of elements in the map. More...
 
int erase (int id, const char *name)
 Erases an element from the map.
. More...
 
void clear (int id)
 Clears the map and deletes all allocated memory. More...
 
bool close (int id)
 free memory of map More...
 
void log (int id)
 print all elements and value in log window More...
 
bool save (int id, const char *filename, const char *option="xml")
 save all elements and value to file as xml or json More...
 
const char * tostring (int id, const char *option="xml")
 save all elements and value to string buffer as xml or json More...
 

Detailed Description

Definition at line 7 of file map.h.

Constructor & Destructor Documentation

◆ map() [1/2]

int map::map ( )

Allocate new memory of map.

Returns
id >= 0 is successed, -1 is failed.
Must call map.close() for free memory.

◆ map() [2/2]

int map::map ( const char *  element,
  ... 
)

Allocate new memory of map with elements.

Parameters
elementdata member on this map
Returns
id >= 0 is successed, -1 is failed.
Must call map.close() for free memory.

Member Function Documentation

◆ clear()

void map::clear ( int  id)

Clears the map and deletes all allocated memory.

Parameters
idmap id.

◆ close()

bool map::close ( int  id)

free memory of map

Parameters
idmap id.
Returns
true is successed, false is failed.

◆ erase()

int map::erase ( int  id,
const char *  name 
)

Erases an element from the map.
.

Parameters
idmap id.
nameName of element to be operate.
Returns
new size of array is successed, 0 is empty, -1 is failed.

◆ get()

const char* map::get ( int  id,
const char *  name 
)

Direct const access operator.

Parameters
idmap id.
nameName of element to be operate.
Returns
Value from element name is successed, empty string is failed.

◆ getkeybyid()

const char* map::getkeybyid ( int  id,
int  num 
)

Direct key access operator.

Parameters
idmap id.
numid of element to be operate.
Returns
Key from element id is successed, empty string is failed.

◆ getvaluebyid()

const char* map::getvaluebyid ( int  id,
int  num 
)

Direct value access operator.

Parameters
idmap id.
numid of element to be operate.
Returns
Value from element id is successed, empty string is failed.

◆ log()

void map::log ( int  id)

print all elements and value in log window

Parameters
idmap id.

◆ save()

bool map::save ( int  id,
const char *  filename,
const char *  option = "xml" 
)

save all elements and value to file as xml or json

Parameters
idmap id.
filenamefilename want to save to disk.
optionfile type xml or json. default: xml
Returns
true is successed, false is failed.

◆ set()

void map::set ( int  id,
const char *  name,
const T &  value 
)

Adds new element or set new data to element by name in map.
If name exist is update otherwise is adding.

Parameters
idmap id.
nameelement name
valuedata to add at map.

◆ size()

int map::size ( int  id)

Get number of elements in the map.

Parameters
idmap id.
Returns
Size of elements in the map which are actually occupied. empty is 0.

◆ tostring()

const char* map::tostring ( int  id,
const char *  option = "xml" 
)

save all elements and value to string buffer as xml or json

Parameters
idmap id.
optionfile type xml or json. default: xml
Returns
successed return map buffer in string format, otherwise is empty string.

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