INGOR
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
ytKeyValues Class Reference

key-value pairs. More...

#include <ytKeyValues.h>

Public Member Functions

ytKeyValuesytKeyValues_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.
 
ytKeyValuesytKeyValues_clone (const ytKeyValues *this)
 Generates a clone of this ytKeyValue instance.
 
ytObjectytKeyValues_obj (ytKeyValues *kv)
 Returns the pointer of ytObject.
 
ytKeyValuesytKeyValues_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.
 
ytObjectytKeyValues_get (const ytKeyValues *this, const char *key)
 Returns the value associated with the given key.
 
ytObjectytKeyValues_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.
 
ytIntArrayytKeyValues_getIntArray (const ytKeyValues *this, const char *key)
 Returns the value associated with the given key as a ytIntArray instance.
 
ytStrArrayytKeyValues_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)
 
ytObjectytKeyValues_getValue (const ytKeyValues *this, size_t index)
 Returns the value at the specified position.
 
ytKeyValuesytKeyValues_parse (const char *str)
 Parses a ytKeyValue format string and store keys and values in the generated ytKeyValues instance.
 
ytStrArrayytKeyValues_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.
 
ytKeyValuesytKeyValues_deserialize (ytByte **const pptr)
 Deserializes the object from the serialized binary sequence.
 
#define ytKeyValues_ERROR_VALUE
 Error value.
 

Public Attributes

char * ytKeyValues_DEFAULT_VALUE
 Value used as a default value for no argument keys.
 
char * ytKeyValues_DEFAULT_KEY
 Value representing the default key, that is, the key used for values without keys.
 
char * ytKeyValues_ERROR_KEY
 Value representing error key.
 
int * ytKeyValues_DEFAULT_VALUE_ON
 Value representing ON.
 
int * ytKeyValues_DEFAULT_VALUE_OFF
 Value representing OFF.
 

Detailed Description

key-value pairs.

Member Function Documentation

◆ ytKeyValues_add()

void ytKeyValues_add ( ytKeyValues this,
const char *  key,
ytObject value 
)

Adds a value to the ytKeyValues instance.

Parameters
thispointer to the ytKeyValues instance.
keykey of the value to add.
valuepointer to the value.

◆ ytKeyValues_addDoubleArray()

void ytKeyValues_addDoubleArray ( ytKeyValues this,
const char *  key,
ytDoubleArray value 
)

Adds a double-precision float array to the ytKeyValues instance.

Parameters
thispointer to the ytKeyValues instance.
keykey of the value to add.
valuepointer to the ytDoubleArray instance to add. Note that the instance is not copied. Therfore, the user must not delete the added instance by yourself.

◆ ytKeyValues_addIntArray()

void ytKeyValues_addIntArray ( ytKeyValues this,
const char *  key,
ytIntArray value 
)

Adds an integer array to the ytKeyValues instance.

Parameters
thispointer to the ytKeyValues instance.
keykey of the value to add.
valuepointer to the ytIntArray instance to add. Note that the instance is not copied. Therfore, the user must not delete the added instance by yourself.

◆ ytKeyValues_addString()

void ytKeyValues_addString ( ytKeyValues this,
const char *  key,
const char *  value 
)

Adds a string value to the ytKeyValues instance.

Parameters
thispointer to the ytKeyValues instance.
keykey of the value to add.
valuepointer to the string to add. The memory is newly allocated and the string is copied to it.

◆ ytKeyValues_clone()

ytKeyValues * ytKeyValues_clone ( const ytKeyValues this)

Generates a clone of this ytKeyValue instance.

Parameters
this
Returns
ytKeyValues instance.

◆ ytKeyValues_delete()

void ytKeyValues_delete ( ytKeyValues this)

Deletes the ytKeyValues instance.

This does not releases memory allocated for values.

◆ ytKeyValues_deleteAll()

void ytKeyValues_deleteAll ( ytKeyValues this)

Deletes the ytKeyValues instance and stored values.

Parameters
thispointer to the ytKeyValues instance to delete. NULL acceptable.

◆ ytKeyValues_deserialize()

ytKeyValues * ytKeyValues_deserialize ( ytByte **const  pptr)

Deserializes the object from the serialized binary sequence.

Parameters
[in,out]pptrpointer 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.
Returns
pointer to the deserialized instance.

◆ ytKeyValues_from()

ytKeyValues * ytKeyValues_from ( ytObject this)

Converts an ytObject instance to ytKeyValues.

Parameters
thisNULL acceptable. If so, this also returns NULL.

◆ ytKeyValues_get()

ytObject * ytKeyValues_get ( const ytKeyValues this,
const char *  key 
)

Returns the value associated with the given key.

Parameters
thisytKeyValues instance. NULL acceptable. If so, this returns NULL.
keykey string to get.
Returns
ytObject instance or NULL if key does not exist.

◆ ytKeyValues_getDouble()

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.

Parameters
thisytKeyValues instance. Null acceptable.
keykey.
defdefault value.
Returns
integer value.

◆ ytKeyValues_getInt()

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.

Parameters
thisytKeyValues instance. NULL acceptable.
keykey.
defdefault value.
Returns
integer value.

◆ ytKeyValues_getKey()

const char * ytKeyValues_getKey ( const ytKeyValues this,
size_t  index 
)

Returns the key at the specified index.

Parameters
this
index
Returns
pointer to the key located at index.

◆ ytKeyValues_getKeys()

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.

Parameters
arif NULL, a new instance will be generated and return.
Returns
if ar is given, the same value returns. Or a newly generated \ytStrArray instance.

◆ ytKeyValues_parse()

ytKeyValues * ytKeyValues_parse ( const char *  str)

Parses a ytKeyValue format string and store keys and values in the generated ytKeyValues instance.

Parameters
strpointer to the string to be parsed. NULL acceptable. If so, this returns the empty ytKeyValues instance.
Returns
pointer to the ytKeyValues instance containing keys and values, or NULL if failed.
Go to Top

◆ ytKeyValues_remove()

ytObject * ytKeyValues_remove ( ytKeyValues this,
const char *  key 
)

Removes a key value pair.

Parameters
this
key
Returns
value associated with the specified key.

◆ ytKeyValues_serialize()

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

Parameters
thisinstance to serialize. NULL is acceptable. If so, the serialized binary represents the ytType_NULL type empty instance.
[in,out]pptrpointer 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.
Returns
memory address of the first position when you deserialize.

◆ ytKeyValues_set()

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.

◆ ytKeyValues_setDelete()

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.

◆ ytKeyValues_size()

size_t ytKeyValues_size ( const ytKeyValues this)

Returns the number of key-value pairs.

Parameters
this

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