ArrayObject

Engine/source/console/arrayObject.h

A data structure holding indexed sequences of key/value pairs for script use.

More...

Classes:

Data Query

bool

Returns true if string handling by the array is case-sensitive.

bool
isEqual(const String & valA, const String & valB)

Searches the array for the first matching value from the current array position.

Searches the array for the first matching key from the current array position.

Returns the key for a given index.

Returns the value for a given index.

Counts the number of elements in the array.

Counts the number of instances of a particular value in the array.

Counts the number of instances of a particular key in the array.

Data Alteration

push_back(const String & key, const String & value)

Adds a new array item to the end of the array.

Adds a new array item to the front of the array.

insert(const String & key, const String & value, S32 index)

Adds a new array item to a particular index of the array.

Removes an array item from the end of the array.

Removes an array item from the end of the array.

erase(S32 index)

Removes an array item from a particular index of the array.

Clears an array.

moveIndex(S32 prev, S32 index)

Moves a key and value from one index location to another.

Complex Data Alteration

Removes any duplicate values from the array (keeps the first instance only)

Removes any duplicate keys from the array (keeps the first instance only)

Makes this array an exact duplicate of another array.

Crops the keys that exists in the target array from our current array.

Appends the target array to our current array.

setKey(const String & key, S32 index)

Sets the key at the given index.

setValue(const String & value, S32 index)

Sets the key at the given index.

sort(bool valtest, bool asc, bool numeric)

This sorts the array.

sort(bool valtest, bool asc, const char * callbackFunctionName)

This sorts the array using a script callback.

Pointer Manipulation

Moves pointer to arrays first position.

Moves pointer to arrays last position.

Moves pointer to arrays next position If last position it returns -1 and no move occurs;.

Moves pointer to arrays prev position If first position it returns -1 and no move occurs;.

Returns current pointer index.

Data Listing

echo()

Echos the content of the array to the console.

Private Types

Parent 

Protected Attributes

The array of key/value pairs.

Protected Static Functions

bool
_addKeyFromField(void * object, const char * index, const char * data)

Public Functions

DECLARE_DESCRIPTION("An <a href="/coding/class/classsimobject/#classsimobject_1a1dfd4ae4b628f69df932347c4b1b078c">object</a> storing an indexed sequence of key/<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> pairs." )

Public Static Functions

Detailed Description

A data structure holding indexed sequences of key/value pairs for script use.

Sorting

_valueCompare(const void * a, const void * b)

_valueNumCompare(const void * a, const void * b)

_keyCompare(const void * a, const void * b)

_keyNumCompare(const void * a, const void * b)

_keyFunctionCompare(const void * a, const void * b)

_valueFunctionCompare(const void * a, const void * b)

bool smDecreasing 
bool smCaseSensitive 
const char * smCompareFunction 

Data Query

isCaseSensitive()

Returns true if string handling by the array is case-sensitive.

isEqual(const String & valA, const String & valB)

getIndexFromValue(const String & value)

Searches the array for the first matching value from the current array position.

It will return -1 if no matching index is found.

getIndexFromKey(const String & key)

Searches the array for the first matching key from the current array position.

It will return -1 if no matching index found.

getKeyFromIndex(S32 index)

Returns the key for a given index.

Will return a null value for an invalid index

getValueFromIndex(S32 index)

Returns the value for a given index.

Will return a null value for an invalid index

getIndexFromKeyValue(const String & key, const String & value)

count()

Counts the number of elements in the array.

countValue(const String & value)

Counts the number of instances of a particular value in the array.

countKey(const String & key)

Counts the number of instances of a particular key in the array.

Data Alteration

push_back(const String & key, const String & value)

Adds a new array item to the end of the array.

push_front(const String & key, const String & value)

Adds a new array item to the front of the array.

insert(const String & key, const String & value, S32 index)

Adds a new array item to a particular index of the array.

pop_back()

Removes an array item from the end of the array.

pop_front()

Removes an array item from the end of the array.

erase(S32 index)

Removes an array item from a particular index of the array.

empty()

Clears an array.

moveIndex(S32 prev, S32 index)

Moves a key and value from one index location to another.

Complex Data Alteration

uniqueValue()

Removes any duplicate values from the array (keeps the first instance only)

uniqueKey()

Removes any duplicate keys from the array (keeps the first instance only)

duplicate(ArrayObject * obj)

Makes this array an exact duplicate of another array.

crop(ArrayObject * obj)

Crops the keys that exists in the target array from our current array.

append(ArrayObject * obj)

Appends the target array to our current array.

setKey(const String & key, S32 index)

Sets the key at the given index.

setValue(const String & value, S32 index)

Sets the key at the given index.

sort(bool valtest, bool asc, bool numeric)

This sorts the array.

Parameters:

valtest

Determines whether sorting by value or key.

asc

Determines if sorting ascending or descending.

numeric

Determines if sorting alpha or numeric search.

sort(bool valtest, bool asc, const char * callbackFunctionName)

This sorts the array using a script callback.

Parameters:

valtest

Determines whether sorting by value or key.

asc

Determines if sorting ascending or descending.

callbackFunctionName

Name of the script function.

Pointer Manipulation

moveFirst()

Moves pointer to arrays first position.

moveLast()

Moves pointer to arrays last position.

moveNext()

Moves pointer to arrays next position If last position it returns -1 and no move occurs;.

movePrev()

Moves pointer to arrays prev position If first position it returns -1 and no move occurs;.

getCurrent()

Returns current pointer index.

setCurrent(S32 idx)

Data Listing

echo()

Echos the content of the array to the console.

Private Types

typedef SimObject Parent 

Protected Attributes

Vector< Element > mArray 

The array of key/value pairs.

bool mCaseSensitive 
S32 mCurrentIndex 

Protected Static Functions

_addKeyFromField(void * object, const char * index, const char * data)

Public Functions

ArrayObject()

DECLARE_CATEGORY("Core" )

DECLARE_CONOBJECT(ArrayObject )

DECLARE_DESCRIPTION("An <a href="/coding/class/classsimobject/#classsimobject_1a1dfd4ae4b628f69df932347c4b1b078c">object</a> storing an indexed sequence of key/<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> pairs." )

Public Static Functions

initPersistFields()