jvar
JS inspired Variant and Json
jvar::PropArray< T > Class Template Reference

Detailed Description

template<class T>
class jvar::PropArray< T >

PropArray is similar to stl::map. It maintains a key value relationship. Keys are character strings. Value is the value provided in the template.

#include <arr.h>

Classes

struct  DataElem

Public Member Functions

T * addOrModify (const char *keyname, bool modifyfound=true)
T * add (const char *keyname)
bool remove (const char *keyname)
T * get (const char *keyname)
T * get (int pos)
const char * getKey (int pos)
int length ()
bool forEachSort (Iter< T > &iter)
bool forEach (Iter< T > &iter)
void clear ()

Member Function Documentation

template<class T>
T* jvar::PropArray< T >::add ( const char *  keyname) [inline]

Adds a new property

Parameters:
keynameProperty key name
Returns:
Pointer to the element or NULL if already exists
template<class T>
T* jvar::PropArray< T >::addOrModify ( const char *  keyname,
bool  modifyfound = true 
) [inline]

Adds or modifies a property and sets it value

Parameters:
keynameProperty key name
modifyfoundAllow modification if found
Returns:
Pointer to the value or NULL if not allowed to modify

Referenced by jvar::PropArray< Variant >::add().

template<class T>
void jvar::PropArray< T >::clear ( ) [inline]

Clears the property array

template<class T>
bool jvar::PropArray< T >::forEach ( Iter< T > &  iter) [inline]

Returns an iterator to property elements in original order

Parameters:
iterIterator
Returns:
Success
template<class T>
bool jvar::PropArray< T >::forEachSort ( Iter< T > &  iter) [inline]

Returns an iterator to property elements in sorted order

Parameters:
iterIterator
Returns:
Success
template<class T>
T* jvar::PropArray< T >::get ( const char *  keyname) [inline]

Returns a property element

Parameters:
keynameProperty key name
Returns:
Pointer to the element or NULL
template<class T>
T* jvar::PropArray< T >::get ( int  pos) [inline]

Returns the element from a given position

Parameters:
posPosition
Returns:
Pointer to the element or NULL
template<class T>
const char* jvar::PropArray< T >::getKey ( int  pos) [inline]

Returns the property key at position

Parameters:
posPosition
Returns:
Pointer to the property key name
template<class T>
int jvar::PropArray< T >::length ( ) [inline]

Returns the length of the property array

Returns:
Number of elements
template<class T>
bool jvar::PropArray< T >::remove ( const char *  keyname) [inline]

Removes a property

Parameters:
keynameProperty key name
Returns:
Success

The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerator