INGOR
|
key-value pairs. More...
#include <ytKeyValues.h>
Public Member Functions | |
ytKeyValues * | ytKeyValues_new () |
Creates a new ytKeyValues instance. | |
void | ytKeyValues_delete (ytKeyValues *this) |
Deletes the ytKeyValues instance. | |
void | ytKeyValues_deleteAll (ytKeyValues *this) |
Deletes the ytKeyValues instance and stored values. | |
ytKeyValues * | ytKeyValues_clone (const ytKeyValues *this) |
Generates a clone of this ytKeyValue instance. | |
ytObject * | ytKeyValues_obj (ytKeyValues *kv) |
Returns the pointer of ytObject. | |
ytKeyValues * | ytKeyValues_from (ytObject *this) |
Converts an ytObject instance to ytKeyValues. | |
void | ytKeyValues_add (ytKeyValues *this, const char *key, ytObject *value) |
Adds a value to the ytKeyValues instance. | |
void | ytKeyValues_set (ytKeyValues *this, const char *key, ytObject *value) |
Sets a key and its value to the ytKeyValues instance. | |
void | ytKeyValues_setDelete (ytKeyValues *this, const char *key, ytObject *value) |
Sets a key and its value to the ytKeyValues instance. | |
void | ytKeyValues_addInt (ytKeyValues *this, const char *key, int value) |
Adds an integer value to the ytKeyValues instance. | |
void | ytKeyValues_addString (ytKeyValues *this, const char *key, const char *value) |
Adds a string value to the ytKeyValues instance. | |
void | ytKeyValues_addIntArray (ytKeyValues *this, const char *key, ytIntArray *value) |
Adds an integer array to the ytKeyValues instance. | |
void | ytKeyValues_addDoubleArray (ytKeyValues *this, const char *key, ytDoubleArray *value) |
Adds a double-precision float array to the ytKeyValues instance. | |
ytObject * | ytKeyValues_get (const ytKeyValues *this, const char *key) |
Returns the value associated with the given key. | |
ytObject * | ytKeyValues_remove (ytKeyValues *this, const char *key) |
Removes a key value pair. | |
int | ytKeyValues_getInt (const ytKeyValues *this, const char *key, int def) |
Returns the value associated with the given key as an integer value. | |
double | ytKeyValues_getDouble (const ytKeyValues *this, const char *key, double def) |
Returns the value associated with the given key as a double value. | |
char * | ytKeyValues_getString (const ytKeyValues *this, const char *key) |
Returns the value associated with the given key as a string value. | |
ytIntArray * | ytKeyValues_getIntArray (const ytKeyValues *this, const char *key) |
Returns the value associated with the given key as a ytIntArray instance. | |
ytStrArray * | ytKeyValues_getStrArray (const ytKeyValues *this, const char *key) |
Returns the value associated with the given key as a ytStrArray instance. | |
size_t | ytKeyValues_size (const ytKeyValues *this) |
Returns the number of key-value pairs. | |
const char * | ytKeyValues_getKey (const ytKeyValues *this, size_t index) |
Returns the key at the specified index. | |
int | ytKeyValues_getKeyIndex (const ytKeyValues *this, const char *key) |
ytObject * | ytKeyValues_getValue (const ytKeyValues *this, size_t index) |
Returns the value at the specified position. | |
ytKeyValues * | ytKeyValues_parse (const char *str) |
Parses a ytKeyValue format string and store keys and values in the generated ytKeyValues instance. | |
ytStrArray * | ytKeyValues_getKeys (const ytKeyValues *this, ytStrArray *ar) |
Returns the added keys. | |
void | ytKeyValues_print (const ytKeyValues *this, FILE *fp) |
Prints the contents of the ytKeyValues instance. | |
ytByte * | ytKeyValues_serialize (const ytKeyValues *this, ytByte **pptr) |
Serializes the objects onto the memory. | |
ytKeyValues * | ytKeyValues_deserialize (ytByte **const pptr) |
Deserializes the object from the serialized binary sequence. | |
#define | ytKeyValues_ERROR_VALUE |
Error value. | |
key-value pairs.
void ytKeyValues_add | ( | ytKeyValues * | this, |
const char * | key, | ||
ytObject * | value | ||
) |
Adds a value to the ytKeyValues instance.
this | pointer to the ytKeyValues instance. |
key | key of the value to add. |
value | pointer to the value. |
void ytKeyValues_addDoubleArray | ( | ytKeyValues * | this, |
const char * | key, | ||
ytDoubleArray * | value | ||
) |
Adds a double-precision float array to the ytKeyValues instance.
this | pointer to the ytKeyValues instance. |
key | key of the value to add. |
value | pointer to the ytDoubleArray instance to add. Note that the instance is not copied. Therfore, the user must not delete the added instance by yourself. |
void ytKeyValues_addIntArray | ( | ytKeyValues * | this, |
const char * | key, | ||
ytIntArray * | value | ||
) |
Adds an integer array to the ytKeyValues instance.
this | pointer to the ytKeyValues instance. |
key | key of the value to add. |
value | pointer to the ytIntArray instance to add. Note that the instance is not copied. Therfore, the user must not delete the added instance by yourself. |
void ytKeyValues_addString | ( | ytKeyValues * | this, |
const char * | key, | ||
const char * | value | ||
) |
Adds a string value to the ytKeyValues instance.
this | pointer to the ytKeyValues instance. |
key | key of the value to add. |
value | pointer to the string to add. The memory is newly allocated and the string is copied to it. |
ytKeyValues * ytKeyValues_clone | ( | const ytKeyValues * | this | ) |
void ytKeyValues_delete | ( | ytKeyValues * | this | ) |
Deletes the ytKeyValues instance.
This does not releases memory allocated for values.
void ytKeyValues_deleteAll | ( | ytKeyValues * | this | ) |
Deletes the ytKeyValues instance and stored values.
this | pointer to the ytKeyValues instance to delete. NULL acceptable. |
ytKeyValues * ytKeyValues_deserialize | ( | ytByte **const | pptr | ) |
Deserializes the object from the serialized binary sequence.
[in,out] | pptr | pointer to the pointer to the memory address where the serialized binary sequence of the ytKeyValues instance is stored. The dereferenced pointer, i.e. *pptr progresses to point to the next address to read if it is available. |
ytKeyValues * ytKeyValues_from | ( | ytObject * | this | ) |
Converts an ytObject instance to ytKeyValues.
this | NULL acceptable. If so, this also returns NULL. |
ytObject * ytKeyValues_get | ( | const ytKeyValues * | this, |
const char * | key | ||
) |
Returns the value associated with the given key.
this | ytKeyValues instance. NULL acceptable. If so, this returns NULL. |
key | key string to get. |
double ytKeyValues_getDouble | ( | const ytKeyValues * | this, |
const char * | key, | ||
double | def | ||
) |
Returns the value associated with the given key as a double value.
If the key is not found or the type of the value of the given key is not double, this returns the default value specified as def.
this | ytKeyValues instance. Null acceptable. |
key | key. |
def | default value. |
int ytKeyValues_getInt | ( | const ytKeyValues * | this, |
const char * | key, | ||
int | def | ||
) |
Returns the value associated with the given key as an integer value.
If the key is not found or the type of the value of the given key is not integer, this returns the default value specified as def.
this | ytKeyValues instance. NULL acceptable. |
key | key. |
def | default value. |
const char * ytKeyValues_getKey | ( | const ytKeyValues * | this, |
size_t | index | ||
) |
Returns the key at the specified index.
this | |
index |
ytStrArray * ytKeyValues_getKeys | ( | const ytKeyValues * | this, |
ytStrArray * | ar | ||
) |
Returns the added keys.
All the sttring values are newly allocated. Therefore users must release them by yourself.
ar | if NULL, a new instance will be generated and return. |
ytKeyValues * ytKeyValues_parse | ( | const char * | str | ) |
Parses a ytKeyValue format string and store keys and values in the generated ytKeyValues instance.
str | pointer to the string to be parsed. NULL acceptable. If so, this returns the empty ytKeyValues instance. |
ytObject * ytKeyValues_remove | ( | ytKeyValues * | this, |
const char * | key | ||
) |
Removes a key value pair.
this | |
key |
ytByte * ytKeyValues_serialize | ( | const ytKeyValues * | this, |
ytByte ** | pptr | ||
) |
Serializes the objects onto the memory.
The serialized binary sequence of the object can be deserialized (recovered) by ytKeyValues_deserialize().
this | instance to serialize. NULL is acceptable. If so, the serialized binary represents the ytType_NULL type empty instance. | |
[in,out] | pptr | pointer to the pointer to store the binary sequence of the object. The pointed address of the pointer, i.e., *pptr , will progress and point to the next position to write if available. NULL can be specified. If so, new memory is allocated and returned. |
void ytKeyValues_set | ( | ytKeyValues * | this, |
const char * | key, | ||
ytObject * | value | ||
) |
Sets a key and its value to the ytKeyValues instance.
If the same key is already added, value will be replaced. In such a case, the previous object is not freed.
void ytKeyValues_setDelete | ( | ytKeyValues * | this, |
const char * | key, | ||
ytObject * | value | ||
) |
Sets a key and its value to the ytKeyValues instance.
If the same key is already added, the value will be deleted and replaced.
size_t ytKeyValues_size | ( | const ytKeyValues * | this | ) |
Returns the number of key-value pairs.
this |