wlmaker
Loading...
Searching...
No Matches
Typedefs | Enumerations | Functions | Variables
model.h File Reference
#include <libbase/libbase.h>
Include dependency graph for model.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct _wlmcfg_object_t wlmcfg_object_t
 
typedef struct _wlmcfg_string_t wlmcfg_string_t
 
typedef struct _wlmcfg_dict_t wlmcfg_dict_t
 
typedef struct _wlmcfg_array_t wlmcfg_array_t
 

Enumerations

enum  wlmcfg_type_t { WLMCFG_STRING , WLMCFG_DICT , WLMCFG_ARRAY }
 

Functions

wlmcfg_object_twlmcfg_object_ref (wlmcfg_object_t *object_ptr)
 
void wlmcfg_object_unref (wlmcfg_object_t *object_ptr)
 
wlmcfg_string_twlmcfg_string_create (const char *value_ptr)
 
wlmcfg_object_twlmcfg_object_from_string (wlmcfg_string_t *string_ptr)
 
wlmcfg_string_twlmcfg_string_from_object (wlmcfg_object_t *object_ptr)
 
const char * wlmcfg_string_value (const wlmcfg_string_t *string_ptr)
 
wlmcfg_dict_twlmcfg_dict_create (void)
 
wlmcfg_object_twlmcfg_object_from_dict (wlmcfg_dict_t *dict_ptr)
 
wlmcfg_dict_twlmcfg_dict_from_object (wlmcfg_object_t *object_ptr)
 
bool wlmcfg_dict_add (wlmcfg_dict_t *dict_ptr, const char *key_ptr, wlmcfg_object_t *object_ptr)
 
wlmcfg_object_twlmcfg_dict_get (wlmcfg_dict_t *dict_ptr, const char *key_ptr)
 
bool wlmcfg_dict_foreach (wlmcfg_dict_t *dict_ptr, bool(*fn)(const char *key_ptr, wlmcfg_object_t *object_ptr, void *userdata_ptr), void *userdata_ptr)
 
wlmcfg_array_twlmcfg_array_create (void)
 
wlmcfg_object_twlmcfg_object_from_array (wlmcfg_array_t *array_ptr)
 
wlmcfg_array_twlmcfg_array_from_object (wlmcfg_object_t *object_ptr)
 
bool wlmcfg_array_push_back (wlmcfg_array_t *array_ptr, wlmcfg_object_t *object_ptr)
 
size_t wlmcfg_array_size (wlmcfg_array_t *array_ptr)
 
wlmcfg_object_twlmcfg_array_at (wlmcfg_array_t *array_ptr, size_t index)
 
static void wlmcfg_string_unref (wlmcfg_string_t *string_ptr)
 
static wlmcfg_dict_twlmcfg_dict_ref (wlmcfg_dict_t *dict_ptr)
 
static void wlmcfg_dict_unref (wlmcfg_dict_t *dict_ptr)
 
static wlmcfg_dict_twlmcfg_dict_get_dict (wlmcfg_dict_t *dict_ptr, const char *key_ptr)
 
static wlmcfg_array_twlmcfg_dict_get_array (wlmcfg_dict_t *dict_ptr, const char *key_ptr)
 
static const char * wlmcfg_dict_get_string_value (wlmcfg_dict_t *dict_ptr, const char *key_ptr)
 
static void wlmcfg_array_unref (wlmcfg_array_t *array_ptr)
 
static const char * wlmcfg_array_string_value_at (wlmcfg_array_t *array_ptr, size_t idx)
 

Variables

const bs_test_case_t wlmcfg_model_test_cases []
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Typedef Documentation

◆ wlmcfg_array_t

Forward declaration: An array (sequential store for objects).

◆ wlmcfg_dict_t

typedef struct _wlmcfg_dict_t wlmcfg_dict_t

Forward declaration: A dict (key/value store for objects).

◆ wlmcfg_object_t

Forward declaration: Base object type.

◆ wlmcfg_string_t

Forward declaration: A string.

Enumeration Type Documentation

◆ wlmcfg_type_t

Type of the object.

Function Documentation

◆ wlmcfg_array_at()

wlmcfg_object_t * wlmcfg_array_at ( wlmcfg_array_t * array_ptr,
size_t index )

Returns the object at the position index of the array.

Parameters
array_ptr
index
Returns
Pointer to the object at the specified position in the array. Returns NULL if index is out of bounds.

◆ wlmcfg_array_create()

wlmcfg_array_t * wlmcfg_array_create ( void )

Creates an array object.

Returns
The array object, or NULL on error.

◆ wlmcfg_array_from_object()

wlmcfg_array_t * wlmcfg_array_from_object ( wlmcfg_object_t * object_ptr)
Returns
the wlmcfg_array_t for object_ptr. NULL if not an array.

◆ wlmcfg_array_push_back()

bool wlmcfg_array_push_back ( wlmcfg_array_t * array_ptr,
wlmcfg_object_t * object_ptr )

Adds an object to the end of the array.

Parameters
array_ptr
object_ptr
Returns
true on success. Adding the object can fail if the array does not have space and fails to grow.

◆ wlmcfg_array_size()

size_t wlmcfg_array_size ( wlmcfg_array_t * array_ptr)
Returns
Size of the array, ie. the number of contained objects.

◆ wlmcfg_array_string_value_at()

static const char * wlmcfg_array_string_value_at ( wlmcfg_array_t * array_ptr,
size_t idx )
inlinestatic
Returns
the value of the string object at idx, or NULL on error.

◆ wlmcfg_array_unref()

static void wlmcfg_array_unref ( wlmcfg_array_t * array_ptr)
inlinestatic

Unreferences the array. Wraps to wlmcfg_object_unref.

◆ wlmcfg_dict_add()

bool wlmcfg_dict_add ( wlmcfg_dict_t * dict_ptr,
const char * key_ptr,
wlmcfg_object_t * object_ptr )

Adds an object to the dict.

Parameters
dict_ptr
key_ptr
object_ptrThe object to add. It will be duplicated by calling wlmcfg_object_ref.
Returns
true on success. Adding the object can fail if the key already exists, or if memory could not get allocated.

◆ wlmcfg_dict_create()

wlmcfg_dict_t * wlmcfg_dict_create ( void )

Creates a dict object.

Returns
The dict object, or NULL on error.

◆ wlmcfg_dict_foreach()

bool wlmcfg_dict_foreach ( wlmcfg_dict_t * dict_ptr,
bool(*)(const char *key_ptr, wlmcfg_object_t *object_ptr, void *userdata_ptr) fn,
void * userdata_ptr )

Executes fn for each key and object of the dict.

Parameters
dict_ptr
fn
userdata_ptr
Returns
true if all calls to fn returned true. The iteration will be aborted on the first failed call to fn.

◆ wlmcfg_dict_from_object()

wlmcfg_dict_t * wlmcfg_dict_from_object ( wlmcfg_object_t * object_ptr)
Returns
the wlmcfg_dict_t for object_ptr. NULL if not a dict.

◆ wlmcfg_dict_get()

wlmcfg_object_t * wlmcfg_dict_get ( wlmcfg_dict_t * dict_ptr,
const char * key_ptr )
Returns
the given object from the dict.

◆ wlmcfg_dict_get_array()

static wlmcfg_array_t * wlmcfg_dict_get_array ( wlmcfg_dict_t * dict_ptr,
const char * key_ptr )
inlinestatic
Returns
the array value of the specified object, or NULL on error.

◆ wlmcfg_dict_get_dict()

static wlmcfg_dict_t * wlmcfg_dict_get_dict ( wlmcfg_dict_t * dict_ptr,
const char * key_ptr )
inlinestatic
Returns
the dict value of the specified object, or NULL on error.

◆ wlmcfg_dict_get_string_value()

static const char * wlmcfg_dict_get_string_value ( wlmcfg_dict_t * dict_ptr,
const char * key_ptr )
inlinestatic
Returns
the string value of the specified object, or NULL on error.

◆ wlmcfg_dict_ref()

static wlmcfg_dict_t * wlmcfg_dict_ref ( wlmcfg_dict_t * dict_ptr)
inlinestatic

Gets a reference to dict_ptr.

◆ wlmcfg_dict_unref()

static void wlmcfg_dict_unref ( wlmcfg_dict_t * dict_ptr)
inlinestatic

Unreferences the dict. Wraps to wlmcfg_object_unref.

◆ wlmcfg_object_from_array()

wlmcfg_object_t * wlmcfg_object_from_array ( wlmcfg_array_t * array_ptr)
Returns
the superclass wlmcfg_object_t of the array.

◆ wlmcfg_object_from_dict()

wlmcfg_object_t * wlmcfg_object_from_dict ( wlmcfg_dict_t * dict_ptr)
Returns
the superclass wlmcfg_object_t of the dict.

◆ wlmcfg_object_from_string()

wlmcfg_object_t * wlmcfg_object_from_string ( wlmcfg_string_t * string_ptr)

Gets the superclass wlmcfg_object_t from the string.

◆ wlmcfg_object_ref()

wlmcfg_object_t * wlmcfg_object_ref ( wlmcfg_object_t * object_ptr)

Gets a reference to the object. Increases the reference count.

The reference should be released by calling wlmcfg_object_unref.

Parameters
object_ptr
Returns
Same as "object_ptr".

◆ wlmcfg_object_unref()

void wlmcfg_object_unref ( wlmcfg_object_t * object_ptr)

Removes reference to the object.

Once no more references are pending, will call all into the virtual dtor of the implementation.

Parameters
object_ptr

◆ wlmcfg_string_create()

wlmcfg_string_t * wlmcfg_string_create ( const char * value_ptr)

Creates a string object.

Parameters
value_ptr
Returns
The string object, or NULL on error.

◆ wlmcfg_string_from_object()

wlmcfg_string_t * wlmcfg_string_from_object ( wlmcfg_object_t * object_ptr)

Gets the wlmcfg_string_t for object_ptr. NULL if not a string.

◆ wlmcfg_string_unref()

static void wlmcfg_string_unref ( wlmcfg_string_t * string_ptr)
inlinestatic

Unreferences the string. Wraps to wlmcfg_object_unref.

◆ wlmcfg_string_value()

const char * wlmcfg_string_value ( const wlmcfg_string_t * string_ptr)

Returns the value of the string.

Parameters
string_ptr
Returns
Pointer to the string's value.

Variable Documentation

◆ wlmcfg_model_test_cases

const bs_test_case_t wlmcfg_model_test_cases[]
extern

Unit tests for the config data model.