Opaque handle to a ktxHashList.
More...
#include <ktx.h>
|
void | ktxHashList_Construct (ktxHashList *pHead) |
| Construct an empty hash list for storing key-value pairs. More...
|
|
void | ktxHashList_Destruct (ktxHashList *pHead) |
| Destruct a hash list. More...
|
|
KTX_error_code | ktxHashList_Create (ktxHashList **ppHl) |
| Create an empty hash list for storing key-value pairs. More...
|
|
void | ktxHashList_Destroy (ktxHashList *pHead) |
| Destroy a hash list. More...
|
|
KTX_error_code | ktxHashList_AddKVPair (ktxHashList *pHead, const char *key, unsigned int valueLen, const void *value) |
| Add a key value pair to a hash list. More...
|
|
KTX_error_code | ktxHashList_FindValue (ktxHashList *pHead, const char *key, unsigned int *pValueLen, void **ppValue) |
| Looks up a key in a hash list and returns the value. More...
|
|
KTX_error_code | ktxHashList_Serialize (ktxHashList *pHead, unsigned int *pKvdLen, unsigned char **ppKvd) |
| Serialize a hash list to a block of data suitable for writing to a file. More...
|
|
KTX_error_code | ktxHashList_Deserialize (ktxHashList *pHead, unsigned int kvdLen, void *pKvd) |
| Construct a hash list from a block of serialized key-value data read from a file. More...
|
|
Opaque handle to a ktxHashList.
§ ktxHashList_AddKVPair()
Add a key value pair to a hash list.
- Parameters
-
[in] | pHead | pointer to the head of the target hash list. |
[in] | key | pointer to the UTF8 NUL-terminated string to be used as the key. |
[in] | valueLen | the number of bytes of data in value . |
[in] | value | pointer to the bytes of data constituting the value. |
- Returns
- KTX_SUCCESS or one of the following error codes.
- Exceptions
-
KTX_INVALID_VALUE | if This , key or value are NULL, key is an empty string or valueLen == 0. |
§ ktxHashList_Construct()
Construct an empty hash list for storing key-value pairs.
- Parameters
-
[in] | pHead | pointer to the location to write the list head. |
§ ktxHashList_Create()
Create an empty hash list for storing key-value pairs.
- Parameters
-
[in,out] | ppHl | address of a variable in which to set a pointer to the newly created hash list. |
- Returns
- KTX_SUCCESS or one of the following error codes.
- Exceptions
-
KTX_OUT_OF_MEMORY | if not enough memory. |
§ ktxHashList_Deserialize()
Construct a hash list from a block of serialized key-value data read from a file.
- Note
- The bytes of the 32-bit key-value lengths within the serialized data are expected to be in native endianness.
- Parameters
-
[in] | pHead | pointer to the head of the target hash list. |
[in] | kvdLen | the length of the serialized key-value data. |
[in] | pKvd | pointer to the serialized key-value data. table. |
- Returns
- KTX_SUCCESS or one of the following error codes.
- Exceptions
-
KTX_INVALID_OPERATION | if pHead does not point to an empty list. |
KTX_INVALID_VALUE | if pKvd or pHt is NULL or kvdLen == 0. |
KTX_OUT_OF_MEMORY | there was not enough memory to create the hash table. |
§ ktxHashList_Destroy()
Destroy a hash list.
All memory associated with the hash list's keys and values is freed. The hash list is also freed.
- Parameters
-
[in] | pHead | pointer to the hash list to be destroyed. |
§ ktxHashList_Destruct()
Destruct a hash list.
All memory associated with the hash list's keys and values is freed.
- Parameters
-
[in] | pHead | pointer to the hash list to be destroyed. |
§ ktxHashList_FindValue()
Looks up a key in a hash list and returns the value.
- Parameters
-
[in] | pHead | pointer to the head of the target hash list. |
[in] | key | pointer to a UTF8 NUL-terminated string to find. |
[in,out] | pValueLen | *pValueLen is set to the number of bytes of data in the returned value. |
[in,out] | ppValue | *ppValue is set to the point to the value for key . |
- Returns
- KTX_SUCCESS or one of the following error codes.
- Exceptions
-
KTX_INVALID_VALUE | if This , key or pValueLen or ppValue is NULL. |
KTX_NOT_FOUND | an entry matching key was not found. |
§ ktxHashList_Serialize()
Serialize a hash list to a block of data suitable for writing to a file.
The caller is responsible for freeing the data block returned by this function.
- Parameters
-
[in] | pHead | pointer to the head of the target hash list. |
[in,out] | pKvdLen | *pKvdLen is set to the number of bytes of data in the returned data block. |
[in,out] | ppKvd | *ppKvd is set to the point to the block of memory containing the serialized data. |
- Returns
- KTX_SUCCESS or one of the following error codes.
- Exceptions
-
KTX_INVALID_VALUE | if This , pKvdLen or ppKvd is NULL. |
KTX_OUT_OF_MEMORY | there was not enough memory to serialize the data. |