libngf: libngf/proplist.h File Reference

libngf

Typedefs | Enumerations | Functions
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. More...
typedef void(* | NgfProplistCallback) (const char *key, const void *value, void *userdata)
| Property list callback for iterating over each entry. More...
typedef void(* | NgfProplistExtendedCallback) (const char *key, const void *value, NgfProplistType type, void *userdata)
| Extended iteration callback with type information. More...

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

## 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

typedef enum _NgfProplistType NgfProplistType

## Enumeration Type Documentation

## ◆ _NgfProplistType

enum _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

  orig | Original 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

  proplist | NgfProplist
  callback | Callback function type of NgfProplistCallback
  userdata | User 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

  proplist | NgfProplist
  callback | NgfProplistExtendedCallback
  userdata | User data

## ◆ ngf_proplist_free()

void ngf_proplist_free | ( | NgfProplist * | proplist | ) |

Free property list.

Parameters

  proplist | NgfProplist, if NULL nothing done.

## ◆ ngf_proplist_free_keys()

void ngf_proplist_free_keys | ( | const char ** | keys | ) |

Free a list of property keys.

Parameters

  keys | Array 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

  proplist | NgfProplist
  key | Key name
  boolean_value | 1 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

  proplist | NgfProplist
  key | Key name
  integer_value | Value 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

  proplist | NgfProplist
  key | Key name
  unsigned_value | Value 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

  proplist | NgfProplist

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];
  ...
  }
  ngf_proplist_get_keys
  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

  proplist | NgfProplist
  key | Key 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

  proplist | NgfProplist
  key | Key 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

  value | Value to parse.
  boolean_value | Parsed 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

  value | Value to parse.
  integer_value | Parsed 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

  value | Value to parse.
  integer_value | Parsed 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

  proplist | NgfProplist
  key | Key name
  value | Value 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

  proplist | NgfProplist
  key | Key name
  value | Value 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

  proplist | NgfProplist
  key | Key name
  value | Value 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

  proplist | NgfProplist
  key | Key name
  value | Value for the key

Returns
  1 on success, 0 out of memory or other error.