KVIrc 5.2.6
Developer APIs
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.
 
KviKvsVariantat (kvs_uint_t uIdx) const
 Returns the element at the given index.
 
KviKvsVariantgetAt (kvs_uint_t uIdx)
 Returns the element at the given index.
 
bool isEmpty ()
 Returns true if the array is empty.
 
 KviKvsArray ()
 Constructs the array data.
 
 KviKvsArray (const KviKvsArray &array)
 Constructs the array data.
 
void rsort ()
 Sorts the array in reverse order.
 
void serialize (QString &szResult)
 Serializes the array to a given buffer.
 
void set (kvs_uint_t uIdx, KviKvsVariant *pVal)
 Sets an element into the array at the given index.
 
kvs_uint_t size ()
 Returns the size of the array.
 
void sort ()
 Sorts the array.
 
void unset (kvs_uint_t uIdx)
 Unsets an element from the array.
 
 ~KviKvsArray ()
 Destroys the array data.
 

Protected Member Functions

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

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.
 
static int compareReverse (const void *pV1, const void *pV2)
 Compares two elements of the array in reverse order.
 

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() [1/2]

KviKvsArray::KviKvsArray ( )

Constructs the array data.

Returns
KviKvsArray

References m_pData, m_uAllocSize, and m_uSize.

Referenced by KviKvsArray().

◆ KviKvsArray() [2/2]

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(), KviKvsArray(), m_pData, m_uAllocSize, m_uSize, and u.

◆ ~KviKvsArray()

KviKvsArray::~KviKvsArray ( )

Destroys the array data.

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

Member Function Documentation

◆ append()

void KviKvsArray::append ( KviKvsVariant * pVal)

Appends a variant to this array.

References m_uSize, and set().

Referenced by package_kvs_fnc_info().

◆ appendAsString()

void KviKvsArray::appendAsString ( QString & szBuffer)

Appends data to the array converting it into a string.

Parameters
szBufferThe string to append
Returns
void

References m_pData, m_uSize, szBuffer, and u.

◆ at()

◆ compare()

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 sort().

◆ compareReverse()

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

Referenced by rsort().

◆ findNewSize()

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().

◆ getAt()

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().

◆ isEmpty()

◆ rsort()

void KviKvsArray::rsort ( )

Sorts the array in reverse order.

Returns
void

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

Referenced by KviKvsCoreFunctions::KVSCF().

◆ serialize()

void KviKvsArray::serialize ( QString & szResult)

Serializes the array to a given buffer.

Parameters
szResultThe buffer to store
Returns
void

References m_pData, m_uSize, szBuffer, and u.

◆ set()

void KviKvsArray::set ( kvs_uint_t uIdx,
KviKvsVariant * pVal )

Sets an element into the array at the given index.

Parameters
uIdxThe index of the element to set
pValThe value to set
Returns
void

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

Referenced by append(), language_kvs_cmd_detect(), objects_kvs_fnc_instances(), and system_kvs_fnc_dbus().

◆ size()

◆ sort()

void KviKvsArray::sort ( )

Sorts the array.

Returns
void

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

Referenced by KviKvsCoreFunctions::KVSCF().

◆ unset()

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.

Member Data Documentation

◆ m_pData

◆ m_uAllocSize

kvs_uint_t KviKvsArray::m_uAllocSize
protected

◆ m_uSize


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