KVIrc  4.9.2
DeveloperAPIs
Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions | List of all members
KviKvsArray Class Reference

This class defines a new data type which contains array data. More...

#include <KviKvsArray.h>

+ Inheritance diagram for KviKvsArray:

Public Member Functions

void append (KviKvsVariant *pVal)
 
void appendAsString (QString &szBuffer)
 Appends data to the array converting it into a string. More...
 
KviKvsVariantat (kvs_uint_t uIdx) const
 Returns the element at the given index. More...
 
KviKvsVariantgetAt (kvs_uint_t uIdx)
 Returns the element at the given index. More...
 
bool isEmpty ()
 Returns true if the array is empty. More...
 
 KviKvsArray ()
 Constructs the array data. More...
 
 KviKvsArray (const KviKvsArray &array)
 Constructs the array data. More...
 
void rsort ()
 Sorts the array in reverse order. More...
 
void serialize (QString &szResult)
 Serializes the array to a given buffer. More...
 
void set (kvs_uint_t uIdx, KviKvsVariant *pVal)
 Sets an element into the array at the given index. More...
 
kvs_uint_t size ()
 Returns the size of the array. More...
 
void sort ()
 Sorts the array. More...
 
void unset (kvs_uint_t uIdx)
 Unsets an element from the array. More...
 
 ~KviKvsArray ()
 Destroys the array data. More...
 

Protected Member Functions

void findNewSize ()
 Finds the new size of the array. More...
 

Protected Attributes

KviKvsVariant ** m_pData
 
kvs_uint_t m_uAllocSize
 
kvs_uint_t m_uSize
 

Static Private Member Functions

static int compare (const void *pV1, const void *pV2)
 Compares two elements of the array. More...
 
static int compareReverse (const void *pV1, const void *pV2)
 Compares two elements of the array in reverse order. More...
 

Detailed Description

This class defines a new data type which contains array data.

Warning
This class must not have virtual functions nor destructor. Otherwise it will happily crash on windows when it is allocated in modules and destroyed anywhere else around

Constructor & Destructor Documentation

KviKvsArray::KviKvsArray ( )

Constructs the array data.

Returns
KviKvsArray

References m_pData, m_uAllocSize, and m_uSize.

KviKvsArray::KviKvsArray ( const KviKvsArray array)

Constructs the array data.

This is a carbon copy

Parameters
arrayThe array to copy from
Returns
KviKvsArray

References KviMemory::allocate(), m_pData, m_uAllocSize, m_uSize, and u.

KviKvsArray::~KviKvsArray ( )

Destroys the array data.

References KviMemory::free(), m_pData, m_uSize, and u.

Member Function Documentation

void KviKvsArray::append ( KviKvsVariant pVal)

Appends a variant to this array.

References m_uSize, and set().

Referenced by package_kvs_fnc_info(), and spellchecker_kvs_suggestions().

void KviKvsArray::appendAsString ( QString &  szBuffer)

Appends data to the array converting it into a string.

Parameters
szBufferThe string to append
Returns
void

References KviKvsVariant::appendAsString(), m_pData, m_uSize, and u.

Referenced by KviKvsVariant::appendAsString(), and KviKvsVariant::asString().

KviKvsVariant* KviKvsArray::at ( kvs_uint_t  uIdx) const
inline
int KviKvsArray::compare ( const void *  pV1,
const void *  pV2 
)
staticprivate

Compares two elements of the array.

Parameters
pV1The first element to compare
pV2The second element to compare
Returns
int

Referenced by compareReverse(), and sort().

int KviKvsArray::compareReverse ( const void *  pV1,
const void *  pV2 
)
staticprivate

Compares two elements of the array in reverse order.

Parameters
pV1The first element to compare
pV2The second element to compare
Returns
int

References compare().

Referenced by rsort().

void KviKvsArray::findNewSize ( )
protected

Finds the new size of the array.

Returns
void

References KviMemory::free(), KVI_KVS_ARRAY_ALLOC_CHUNK, m_pData, m_uAllocSize, m_uSize, KviMemory::reallocate(), and u.

Referenced by rsort(), sort(), and unset().

KviKvsVariant * KviKvsArray::getAt ( kvs_uint_t  uIdx)

Returns the element at the given index.

If the element doesn't exists, it returns an empty element. If the index is out of array bounds, it increases the array size, fillin the array in with zeros.

Parameters
uIdxThe index of the element to retrieve
Returns
KviKvsVariant *

References KviMemory::allocate(), KVI_KVS_ARRAY_ALLOC_CHUNK, m_pData, m_uAllocSize, m_uSize, KviMemory::reallocate(), and u.

Referenced by KviKvsTreeNodeArrayElement::evaluateReadWriteInObjectScope().

bool KviKvsArray::isEmpty ( )
inline
void KviKvsArray::rsort ( )

Sorts the array in reverse order.

Returns
void

References compareReverse(), findNewSize(), m_pData, and m_uSize.

Referenced by KviKvsCoreFunctions::KVSCF().

void KviKvsArray::serialize ( QString &  szResult)

Serializes the array to a given buffer.

Parameters
szResultThe buffer to store
Returns
void

References m_pData, m_uSize, KviKvsVariant::serialize(), szBuffer, and u.

Referenced by KviKvsVariant::serialize().

void KviKvsArray::set ( kvs_uint_t  uIdx,
KviKvsVariant pVal 
)
kvs_uint_t KviKvsArray::size ( )
inline
void KviKvsArray::sort ( )

Sorts the array.

Returns
void

References compare(), findNewSize(), m_pData, and m_uSize.

Referenced by KviKvsCoreFunctions::KVSCF().

void KviKvsArray::unset ( kvs_uint_t  uIdx)

Unsets an element from the array.

Parameters
uIdxThe index of the element to unset
Returns
void

References findNewSize(), m_pData, and m_uSize.

Referenced by KviKvsArrayElement::~KviKvsArrayElement().

Member Data Documentation

KviKvsVariant** KviKvsArray::m_pData
protected
kvs_uint_t KviKvsArray::m_uAllocSize
protected

Referenced by findNewSize(), getAt(), KviKvsArray(), and set().

kvs_uint_t KviKvsArray::m_uSize
protected

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