libngf
proplist.h File Reference
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef enum _NgfProplistType NgfProplistType
 
typedef struct _NgfProplist NgfProplist
 Internal property list instance.
 
typedef void(* NgfProplistCallback) (const char *key, const void *value, void *userdata)
 Property list callback for iterating over each entry.
 
typedef void(* NgfProplistExtendedCallback) (const char *key, const void *value, NgfProplistType type, void *userdata)
 Extended iteration callback with type information.
 

Enumerations

enum  _NgfProplistType {
  NGF_PROPLIST_VALUE_TYPE_STRING = 0 , NGF_PROPLIST_VALUE_TYPE_INTEGER , NGF_PROPLIST_VALUE_TYPE_UNSIGNED , NGF_PROPLIST_VALUE_TYPE_BOOLEAN ,
  NGF_PROPLIST_VALUE_TYPE_INVALID
}
 

Functions

NgfProplistngf_proplist_new (void)
 Create a new property list instance.
 
NgfProplistngf_proplist_copy (NgfProplist *orig)
 Create an identical copy of other proplist.
 
void ngf_proplist_free (NgfProplist *proplist)
 Free property list.
 
int ngf_proplist_sets (NgfProplist *proplist, const char *key, const char *value)
 Set a string value to property list.
 
const char * ngf_proplist_gets (NgfProplist *proplist, const char *key)
 Get a string value from property list.
 
int ngf_proplist_set_as_integer (NgfProplist *proplist, const char *key, int32_t value)
 Set a integer value to property list.
 
int ngf_proplist_get_as_integer (NgfProplist *proplist, const char *key, int32_t *integer_value)
 Get integer value from the property list.
 
int ngf_proplist_set_as_unsigned (NgfProplist *proplist, const char *key, uint32_t value)
 Set a unsigned integer value to property list.
 
int ngf_proplist_get_as_unsigned (NgfProplist *proplist, const char *key, uint32_t *unsigned_value)
 Get unsigned integer value from the property list.
 
int ngf_proplist_set_as_boolean (NgfProplist *proplist, const char *key, int value)
 Set a boolean value to property list.
 
int ngf_proplist_get_as_boolean (NgfProplist *proplist, const char *key, int *boolean_value)
 Get a boolean value from the property list.
 
NgfProplistType ngf_proplist_get_value_type (NgfProplist *proplist, const char *key)
 Get value type of the property.
 
int ngf_proplist_parse_integer (const char *value, int32_t *integer_value)
 Parse integer value.
 
int ngf_proplist_parse_unsigned (const char *value, uint32_t *unsigned_value)
 Parse unsigned integer value.
 
int ngf_proplist_parse_boolean (const char *value, int *boolean_value)
 Parse boolean value.
 
void ngf_proplist_foreach (NgfProplist *proplist, NgfProplistCallback callback, void *userdata)
 Iterate over each entry in the property list.
 
void ngf_proplist_foreach_extended (NgfProplist *proplist, NgfProplistExtendedCallback callback, void *userdata)
 Iterate over each entry in the property list and supply a value type.
 
const char ** ngf_proplist_get_keys (NgfProplist *proplist)
 Get a list of all keys in the property list.
 
void ngf_proplist_free_keys (const char **keys)
 Free a list of property keys.
 

Typedef Documentation

◆ NgfProplist

typedef struct _NgfProplist NgfProplist

Internal property list instance.

◆ NgfProplistCallback

typedef void(* NgfProplistCallback) (const char *key, const void *value, void *userdata)

Property list callback for iterating over each entry.

◆ NgfProplistExtendedCallback

typedef void(* NgfProplistExtendedCallback) (const char *key, const void *value, NgfProplistType type, void *userdata)

Extended iteration callback with type information.

◆ NgfProplistType

Enumeration Type Documentation

◆ _NgfProplistType

Enumerator
NGF_PROPLIST_VALUE_TYPE_STRING 
NGF_PROPLIST_VALUE_TYPE_INTEGER 
NGF_PROPLIST_VALUE_TYPE_UNSIGNED 
NGF_PROPLIST_VALUE_TYPE_BOOLEAN 
NGF_PROPLIST_VALUE_TYPE_INVALID 

Function Documentation

◆ ngf_proplist_copy()

NgfProplist * ngf_proplist_copy ( NgfProplist * orig)

Create an identical copy of other proplist.

Parameters
origOriginal NgfProplist a copy is made from.
Returns
Copy of orig NgfProplist or NULL if no memory.

◆ ngf_proplist_foreach()

void ngf_proplist_foreach ( NgfProplist * proplist,
NgfProplistCallback callback,
void * userdata )

Iterate over each entry in the property list.

Parameters
proplistNgfProplist
callbackCallback function type of NgfProplistCallback
userdataUser data

◆ ngf_proplist_foreach_extended()

void ngf_proplist_foreach_extended ( NgfProplist * proplist,
NgfProplistExtendedCallback callback,
void * userdata )

Iterate over each entry in the property list and supply a value type.

Parameters
proplistNgfProplist
callbackNgfProplistExtendedCallback
userdataUser data

◆ ngf_proplist_free()

void ngf_proplist_free ( NgfProplist * proplist)

Free property list.

Parameters
proplistNgfProplist, if NULL nothing done.

◆ ngf_proplist_free_keys()

void ngf_proplist_free_keys ( const char ** keys)

Free a list of property keys.

Parameters
keysArray of keys provided by ngf_proplist_get_keys

◆ ngf_proplist_get_as_boolean()

int ngf_proplist_get_as_boolean ( NgfProplist * proplist,
const char * key,
int * boolean_value )

Get a boolean value from the property list.

Parameters
proplistNgfProplist
keyKey name
boolean_value1 for TRUE, 0 for FALSE.
Returns
success Return 1 if getting value was successful, 0 if failed.

◆ ngf_proplist_get_as_integer()

int ngf_proplist_get_as_integer ( NgfProplist * proplist,
const char * key,
int32_t * integer_value )

Get integer value from the property list.

Parameters
proplistNgfProplist
keyKey name
integer_valueValue for the key if key exists in proplist
Returns
success Return 1 if getting value was successful, 0 if failed.

◆ ngf_proplist_get_as_unsigned()

int ngf_proplist_get_as_unsigned ( NgfProplist * proplist,
const char * key,
uint32_t * unsigned_value )

Get unsigned integer value from the property list.

Parameters
proplistNgfProplist
keyKey name
unsigned_valueValue for the key if key exists in proplist
Returns
success Return 1 if getting value was successful, 0 if failed.

◆ ngf_proplist_get_keys()

const char ** ngf_proplist_get_keys ( NgfProplist * proplist)

Get a list of all keys in the property list.

Parameters
proplistNgfProplist
Returns
NULL terminated list of keys in the property list or NULL if no keys.
const char **keys = NULL, **iter = NULL, *key = NULL;
keys = ngf_proplist_get_keys (proplist);
for (iter = keys; iter; iter++) {
key = keys[i];
...
}
const char ** ngf_proplist_get_keys(NgfProplist *proplist)
Get a list of all keys in the property list.

◆ ngf_proplist_get_value_type()

NgfProplistType ngf_proplist_get_value_type ( NgfProplist * proplist,
const char * key )

Get value type of the property.

Parameters
proplistNgfProplist
keyKey name
Returns
Value type or NULL if no such key.

◆ ngf_proplist_gets()

const char * ngf_proplist_gets ( NgfProplist * proplist,
const char * key )

Get a string value from property list.

Parameters
proplistNgfProplist
keyKey name
Returns
Key value or NULL if not found.

◆ ngf_proplist_new()

NgfProplist * ngf_proplist_new ( void )

Create a new property list instance.

Returns
NgfProplist or NULL if no memory.

◆ ngf_proplist_parse_boolean()

int ngf_proplist_parse_boolean ( const char * value,
int * boolean_value )

Parse boolean value.

Parameters
valueValue to parse.
boolean_valueParsed boolean value, 1 for TRUE 0 for FALSE.
Returns
1 on success, 0 if failed to parse.

◆ ngf_proplist_parse_integer()

int ngf_proplist_parse_integer ( const char * value,
int32_t * integer_value )

Parse integer value.

Parameters
valueValue to parse.
integer_valueParsed integer value.
Returns
1 on success, 0 if failed to parse.

◆ ngf_proplist_parse_unsigned()

int ngf_proplist_parse_unsigned ( const char * value,
uint32_t * unsigned_value )

Parse unsigned integer value.

Parameters
valueValue to parse.
integer_valueParsed integer value.
Returns
1 on success, 0 if failed to parse.

◆ ngf_proplist_set_as_boolean()

int ngf_proplist_set_as_boolean ( NgfProplist * proplist,
const char * key,
int value )

Set a boolean value to property list.

Parameters
proplistNgfProplist
keyKey name
valueValue for the key
Returns
1 on success, 0 out of memory or other error.

◆ ngf_proplist_set_as_integer()

int ngf_proplist_set_as_integer ( NgfProplist * proplist,
const char * key,
int32_t value )

Set a integer value to property list.

Parameters
proplistNgfProplist
keyKey name
valueValue for the key
Returns
1 on success, 0 out of memory or other error.

◆ ngf_proplist_set_as_unsigned()

int ngf_proplist_set_as_unsigned ( NgfProplist * proplist,
const char * key,
uint32_t value )

Set a unsigned integer value to property list.

Parameters
proplistNgfProplist
keyKey name
valueValue for the key
Returns
1 on success, 0 out of memory or other error.

◆ ngf_proplist_sets()

int ngf_proplist_sets ( NgfProplist * proplist,
const char * key,
const char * value )

Set a string value to property list.

Parameters
proplistNgfProplist
keyKey name
valueValue for the key
Returns
1 on success, 0 out of memory or other error.