ubjsc  0.6
Enterprise-grade C library for manipulating UBJSON
Data Structures | Typedefs | Functions
ubjs_library.h File Reference

Library handle, allocation callbacks, glues. More...

#include <ubjs_common.h>
Include dependency graph for ubjs_library.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ubjs_glue_array_builder
 Builder for array glues. More...
 
struct  ubjs_glue_array
 Glue to an array. More...
 
struct  ubjs_glue_array_iterator
 Glue to array iterator. More...
 
struct  ubjs_glue_dict_builder
 Builder for dictionary glues. More...
 
struct  ubjs_glue_dict
 Glue to a dictionary. More...
 
struct  ubjs_glue_dict_iterator
 Glue to dictionary iterator. More...
 
struct  ubjs_library_builder
 Library handle builder. More...
 

Typedefs

typedef void *(* ubjs_library_alloc_f) (unsigned long len)
 Allocation functor. More...
 
typedef void(* ubjs_library_free_f) (void *ptr)
 Deallocation functor. More...
 
typedef struct ubjs_library_builder ubjs_library_builder
 Library handle builder. More...
 
typedef struct ubjs_library ubjs_library
 Library handle. More...
 
typedef struct ubjs_glue_array ubjs_glue_array
 Glue to a array. More...
 
typedef struct ubjs_glue_array_builder ubjs_glue_array_builder
 Builder for array glues. More...
 
typedef struct ubjs_glue_array_iterator ubjs_glue_array_iterator
 Glue to a array iterator. More...
 
typedef struct ubjs_glue_dict ubjs_glue_dict
 Glue to a dictionary. More...
 
typedef struct ubjs_glue_dict_builder ubjs_glue_dict_builder
 Builder for dictionary glues. More...
 
typedef struct ubjs_glue_dict_iterator ubjs_glue_dict_iterator
 Glue to a dictionary iterator. More...
 
typedef void(* ubjs_glue_value_free) (void *pvalue)
 Frees the value held in a glue. Note that this is a generic callback, not related to actual ubjs_prmtv_object()-s. More...
 
typedef ubjs_result(* ubjs_glue_array_builder_new_f) (ubjs_library *lib, ubjs_glue_array_builder **pthis)
 Creates a new array glue builder. More...
 
typedef ubjs_result(* ubjs_glue_array_builder_free_f) (ubjs_glue_array_builder **)
 Frees the array glue builder. More...
 
typedef ubjs_result(* ubjs_glue_array_builder_set_value_free_f) (ubjs_glue_array_builder *this, ubjs_glue_value_free value_free)
 Sets the value free callback method. More...
 
typedef ubjs_result(* ubjs_glue_array_builder_set_length_f) (ubjs_glue_array_builder *this, unsigned int length)
 Sets the predicted length for the array. More...
 
typedef ubjs_result(* ubjs_glue_array_builder_set_item_size_f) (ubjs_glue_array_builder *this, unsigned int item_size)
 Sets the predicted item size. More...
 
typedef ubjs_result(* ubjs_glue_array_builder_build_f) (ubjs_glue_array_builder *this, ubjs_glue_array **parr)
 Callback that creates a new array glue based on what was passed to builder. More...
 
typedef ubjs_result(* ubjs_glue_array_free) (ubjs_glue_array **)
 Frees the array glue. More...
 
typedef ubjs_result(* ubjs_glue_array_get_length) (ubjs_glue_array *this, unsigned int *pvalue)
 Gets the length of the array under a glue. More...
 
typedef ubjs_result(* ubjs_glue_array_get_first) (ubjs_glue_array *this, void **pvalue)
 Gets the value of first item. More...
 
typedef ubjs_result(* ubjs_glue_array_get_last) (ubjs_glue_array *this, void **pvalue)
 Gets the value of last item. More...
 
typedef ubjs_result(* ubjs_glue_array_get_at) (ubjs_glue_array *this, unsigned int index, void **pvalue)
 Gets the value of item under an index. More...
 
typedef ubjs_result(* ubjs_glue_array_add_first) (ubjs_glue_array *this, void *value)
 Add the value at beginning. More...
 
typedef ubjs_result(* ubjs_glue_array_add_last) (ubjs_glue_array *this, void *value)
 Add the value at end. More...
 
typedef ubjs_result(* ubjs_glue_array_add_at) (ubjs_glue_array *this, unsigned int index, void *value)
 Add the value of item at an index. More...
 
typedef ubjs_result(* ubjs_glue_array_delete_first) (ubjs_glue_array *this)
 Delete the first item. More...
 
typedef ubjs_result(* ubjs_glue_array_delete_last) (ubjs_glue_array *this)
 Delete the last item. More...
 
typedef ubjs_result(* ubjs_glue_array_delete_at) (ubjs_glue_array *this, unsigned int index)
 Delete the item at index. More...
 
typedef ubjs_result(* ubjs_glue_array_iterate) (ubjs_glue_array *this, ubjs_glue_array_iterator **piterator)
 Creates an iterator over glued array. More...
 
typedef ubjs_result(* ubjs_glue_array_iterator_next) (ubjs_glue_array_iterator *this)
 Tries to iterate to next item. More...
 
typedef ubjs_result(* ubjs_glue_array_iterator_get) (ubjs_glue_array_iterator *this, void **pvalue)
 Gets current item's value. More...
 
typedef ubjs_result(* ubjs_glue_array_iterator_free) (ubjs_glue_array_iterator **pthis)
 Frees the array iterator glue. More...
 
typedef ubjs_result(* ubjs_glue_dict_builder_new_f) (ubjs_library *lib, ubjs_glue_dict_builder **pthis)
 Creates a new dictionary glue builder. More...
 
typedef ubjs_result(* ubjs_glue_dict_builder_free_f) (ubjs_glue_dict_builder **)
 Frees the dictionary glue builder. More...
 
typedef ubjs_result(* ubjs_glue_dict_builder_set_value_free_f) (ubjs_glue_dict_builder *this, ubjs_glue_value_free value_free)
 Sets the value free callback method. More...
 
typedef ubjs_result(* ubjs_glue_dict_builder_set_length_f) (ubjs_glue_dict_builder *this, unsigned int length)
 Sets the predicted length for the dictionary. More...
 
typedef ubjs_result(* ubjs_glue_dict_builder_set_item_size_f) (ubjs_glue_dict_builder *this, unsigned int item_size)
 Sets the predicted item size. More...
 
typedef ubjs_result(* ubjs_glue_dict_builder_build_f) (ubjs_glue_dict_builder *this, ubjs_glue_dict **pdict)
 Callback that creates a new dictionary glue based on what was passed to builder. More...
 
typedef ubjs_result(* ubjs_glue_dict_free) (ubjs_glue_dict **)
 Frees the dictionary glue. More...
 
typedef ubjs_result(* ubjs_glue_dict_get_length) (ubjs_glue_dict *this, unsigned int *pvalue)
 Gets the length of the dictionary under a glue. More...
 
typedef ubjs_result(* ubjs_glue_dict_get) (ubjs_glue_dict *this, unsigned int key_length, char *key, void **pvalue)
 Gets the value under a key. More...
 
typedef ubjs_result(* ubjs_glue_dict_set) (ubjs_glue_dict *this, unsigned int key_length, char *key, void *value)
 Sets the value under a key. More...
 
typedef ubjs_result(* ubjs_glue_dict_delete) (ubjs_glue_dict *this, unsigned int key_length, char *key)
 Deletes a key, with its value. More...
 
typedef ubjs_result(* ubjs_glue_dict_iterate) (ubjs_glue_dict *this, ubjs_glue_dict_iterator **piterator)
 Creates an iterator over glued dictionary. More...
 
typedef ubjs_result(* ubjs_glue_dict_iterator_next) (ubjs_glue_dict_iterator *this)
 Tries to iterate to next item. More...
 
typedef ubjs_result(* ubjs_glue_dict_iterator_get_key_length) (ubjs_glue_dict_iterator *this, unsigned int *plen)
 Gets current key's length. More...
 
typedef ubjs_result(* ubjs_glue_dict_iterator_copy_key) (ubjs_glue_dict_iterator *this, char *text)
 Copies the key to specified array. More...
 
typedef ubjs_result(* ubjs_glue_dict_iterator_get_value) (ubjs_glue_dict_iterator *this, void **pvalue)
 Gets current value. More...
 
typedef ubjs_result(* ubjs_glue_dict_iterator_free) (ubjs_glue_dict_iterator **pthis)
 Frees the dictionary iterator glue. More...
 

Functions

UBJS_EXPORT ubjs_result ubjs_library_builder_init (ubjs_library_builder *this)
 Initializes the library handle builder. More...
 
UBJS_EXPORT ubjs_result ubjs_library_builder_set_alloc_f (ubjs_library_builder *this, ubjs_library_alloc_f alloc_f)
 Sets the allocation functor for to use for everything. More...
 
UBJS_EXPORT ubjs_result ubjs_library_builder_set_free_f (ubjs_library_builder *this, ubjs_library_free_f free_f)
 Sets the deallocation functor for to use for everything. More...
 
UBJS_EXPORT ubjs_result ubjs_library_builder_set_glue_array_builder (ubjs_library_builder *this, ubjs_glue_array_builder_new_f builder)
 Sets the array glue builder. This allows to select a different implementation of actual key-value store used in arrays. More...
 
UBJS_EXPORT ubjs_result ubjs_library_builder_set_glue_dict_builder (ubjs_library_builder *this, ubjs_glue_dict_builder_new_f builder)
 Sets the dict glue builder. This allows to select a different implementation of actual key-value store used in dictionaries. More...
 
UBJS_EXPORT ubjs_result ubjs_library_builder_build (ubjs_library_builder *this, ubjs_library **plib)
 Builds the library and returns it. More...
 
UBJS_EXPORT ubjs_result ubjs_library_get_alloc_f (ubjs_library *this, ubjs_library_alloc_f *palloc_f)
 
UBJS_EXPORT ubjs_result ubjs_library_get_free_f (ubjs_library *this, ubjs_library_free_f *pfree_f)
 
UBJS_EXPORT ubjs_result ubjs_library_new_stdlib (ubjs_library **pthis)
 Initializes the library handle using stdlib's malloc() and free(). More...
 
UBJS_EXPORT ubjs_result ubjs_library_free (ubjs_library **pthis)
 Deinitializes the library handle. More...
 

Detailed Description

Library handle, allocation callbacks, glues.

Since
0.2

Typedef Documentation

◆ ubjs_glue_array

Glue to a array.

Since
0.5

◆ ubjs_glue_array_add_at

typedef ubjs_result(* ubjs_glue_array_add_at) (ubjs_glue_array *this, unsigned int index, void *value)

Add the value of item at an index.

Parameters
thisGlue.
indexIndex.
valueValue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_add_first

typedef ubjs_result(* ubjs_glue_array_add_first) (ubjs_glue_array *this, void *value)

Add the value at beginning.

Parameters
thisGlue.
valueValue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_add_last

typedef ubjs_result(* ubjs_glue_array_add_last) (ubjs_glue_array *this, void *value)

Add the value at end.

Parameters
thisGlue.
valueValue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_builder

Builder for array glues.

Since
0.5

◆ ubjs_glue_array_builder_build_f

typedef ubjs_result(* ubjs_glue_array_builder_build_f) (ubjs_glue_array_builder *this, ubjs_glue_array **parr)

Callback that creates a new array glue based on what was passed to builder.

Parameters
thisBuilder..
parrPointer to where put new array glue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_builder_free_f

typedef ubjs_result(* ubjs_glue_array_builder_free_f) (ubjs_glue_array_builder **)

Frees the array glue builder.

After this returns UR_OK, it is guaranteed that pthis points to 0.

Parameters
pthisPointer to existing builder.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_builder_new_f

typedef ubjs_result(* ubjs_glue_array_builder_new_f) (ubjs_library *lib, ubjs_glue_array_builder **pthis)

Creates a new array glue builder.

Parameters
libLibrary handle.
pthisPointer to where put new builder.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_builder_set_item_size_f

typedef ubjs_result(* ubjs_glue_array_builder_set_item_size_f) (ubjs_glue_array_builder *this, unsigned int item_size)

Sets the predicted item size.

If this is called, this gives the clue for implementation that every item will be exactly n sized. If this is called, it is called exactly 1 time.

If this is not called, implementation still must be prepared for any item size.

Default is stdlib's free().

Parameters
thisBuilder.
value_freeCallback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_builder_set_length_f

typedef ubjs_result(* ubjs_glue_array_builder_set_length_f) (ubjs_glue_array_builder *this, unsigned int length)

Sets the predicted length for the array.

If this is called, this gives the clue for implementation that n items will be added to the array after creation. If this is called, it is called exactly 1 time.

Warning
This does not mean that the array's size will always remain fixed. Implementation must be ready for any new item to be added, or existing to be removed - the size can change.

If this is not called, implementation still must be prepared for any array size.

Default is stdlib's free().

Parameters
thisBuilder.
value_freeCallback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_builder_set_value_free_f

typedef ubjs_result(* ubjs_glue_array_builder_set_value_free_f) (ubjs_glue_array_builder *this, ubjs_glue_value_free value_free)

Sets the value free callback method.

This is required.

Default is stdlib's free().

Parameters
thisBuilder.
value_freeCallback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_delete_at

typedef ubjs_result(* ubjs_glue_array_delete_at) (ubjs_glue_array *this, unsigned int index)

Delete the item at index.

Parameters
thisGlue.
indexIndex.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_delete_first

typedef ubjs_result(* ubjs_glue_array_delete_first) (ubjs_glue_array *this)

Delete the first item.

Parameters
thisGlue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_delete_last

typedef ubjs_result(* ubjs_glue_array_delete_last) (ubjs_glue_array *this)

Delete the last item.

Parameters
thisGlue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_free

typedef ubjs_result(* ubjs_glue_array_free) (ubjs_glue_array **)

Frees the array glue.

After this returns UR_OK, it is guaranteed that pthis points to 0.

Parameters
pthisPointer to where glue is.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_get_at

typedef ubjs_result(* ubjs_glue_array_get_at) (ubjs_glue_array *this, unsigned int index, void **pvalue)

Gets the value of item under an index.

After this returns UR_OK, it is guaranteed that pvalue contains the value.

Parameters
thisGlue.
indexIndex.
pvaluePointer to where put value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_get_first

typedef ubjs_result(* ubjs_glue_array_get_first) (ubjs_glue_array *this, void **pvalue)

Gets the value of first item.

After this returns UR_OK, it is guaranteed that pvalue contains the value.

Parameters
thisGlue.
pvaluePointer to where put value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_get_last

typedef ubjs_result(* ubjs_glue_array_get_last) (ubjs_glue_array *this, void **pvalue)

Gets the value of last item.

After this returns UR_OK, it is guaranteed that pvalue contains the value.

Parameters
thisGlue.
pvaluePointer to where put value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_get_length

typedef ubjs_result(* ubjs_glue_array_get_length) (ubjs_glue_array *this, unsigned int *pvalue)

Gets the length of the array under a glue.

After this returns UR_OK, it is guaranteed that pvalue contains the length.

Parameters
thisGlue.
pvaluePointer to where put value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_iterate

typedef ubjs_result(* ubjs_glue_array_iterate) (ubjs_glue_array *this, ubjs_glue_array_iterator **piterator)

Creates an iterator over glued array.

Parameters
thisGlue.
piteratorPointer to where put iterator.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_iterator

Glue to a array iterator.

Since
0.5

◆ ubjs_glue_array_iterator_free

typedef ubjs_result(* ubjs_glue_array_iterator_free) (ubjs_glue_array_iterator **pthis)

Frees the array iterator glue.

After this returns UR_OK, it is guaranteed that pthis points to 0.

Parameters
pthisPointer to where glue is.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_iterator_get

typedef ubjs_result(* ubjs_glue_array_iterator_get) (ubjs_glue_array_iterator *this, void **pvalue)

Gets current item's value.

Parameters
thisGlue.
pvaluePointer to where put the value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_array_iterator_next

typedef ubjs_result(* ubjs_glue_array_iterator_next) (ubjs_glue_array_iterator *this)

Tries to iterate to next item.

Parameters
thisGlue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict

Glue to a dictionary.

Since
0.5

◆ ubjs_glue_dict_builder

Builder for dictionary glues.

Since
0.5

◆ ubjs_glue_dict_builder_build_f

typedef ubjs_result(* ubjs_glue_dict_builder_build_f) (ubjs_glue_dict_builder *this, ubjs_glue_dict **pdict)

Callback that creates a new dictionary glue based on what was passed to builder.

Parameters
thisBuilder..
pdictPointer to where put new dictionary glue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_builder_free_f

typedef ubjs_result(* ubjs_glue_dict_builder_free_f) (ubjs_glue_dict_builder **)

Frees the dictionary glue builder.

After this returns UR_OK, it is guaranteed that pthis points to 0.

Parameters
pthisPointer to existing builder.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_builder_new_f

typedef ubjs_result(* ubjs_glue_dict_builder_new_f) (ubjs_library *lib, ubjs_glue_dict_builder **pthis)

Creates a new dictionary glue builder.

Parameters
libLibrary handle.
pthisPointer to where put new builder.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_builder_set_item_size_f

typedef ubjs_result(* ubjs_glue_dict_builder_set_item_size_f) (ubjs_glue_dict_builder *this, unsigned int item_size)

Sets the predicted item size.

If this is called, this gives the clue for implementation that every item will be exactly n sized. If this is called, it is called exactly 1 time.

If this is not called, implementation still must be prepared for any item size.

Default is stdlib's free().

Parameters
thisBuilder.
value_freeCallback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_builder_set_length_f

typedef ubjs_result(* ubjs_glue_dict_builder_set_length_f) (ubjs_glue_dict_builder *this, unsigned int length)

Sets the predicted length for the dictionary.

If this is called, this gives the clue for implementation that n items will be added to the dictionary after creation. If this is called, it is called exactly 1 time.

Warning
This does not mean that the dictionary's size will always remain fixed. Implementation must be ready for any new item to be added, or existing to be removed - the size can change.

If this is not called, implementation still must be prepared for any dictionary size.

Default is stdlib's free().

Parameters
thisBuilder.
value_freeCallback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_builder_set_value_free_f

typedef ubjs_result(* ubjs_glue_dict_builder_set_value_free_f) (ubjs_glue_dict_builder *this, ubjs_glue_value_free value_free)

Sets the value free callback method.

This is required.

Default is stdlib's free().

Parameters
thisBuilder.
value_freeCallback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_delete

typedef ubjs_result(* ubjs_glue_dict_delete) (ubjs_glue_dict *this, unsigned int key_length, char *key)

Deletes a key, with its value.

Parameters
thisGlue.
key_lengthKey length.
keyKey.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_free

typedef ubjs_result(* ubjs_glue_dict_free) (ubjs_glue_dict **)

Frees the dictionary glue.

After this returns UR_OK, it is guaranteed that pthis points to 0.

Parameters
pthisPointer to where glue is.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_get

typedef ubjs_result(* ubjs_glue_dict_get) (ubjs_glue_dict *this, unsigned int key_length, char *key, void **pvalue)

Gets the value under a key.

After this returns UR_OK, it is guaranteed that pvalue contains the value.

Parameters
thisGlue.
key_lengthKey length.
keyKey.
pvaluePointer to where put value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_get_length

typedef ubjs_result(* ubjs_glue_dict_get_length) (ubjs_glue_dict *this, unsigned int *pvalue)

Gets the length of the dictionary under a glue.

After this returns UR_OK, it is guaranteed that pvalue contains the length.

Parameters
thisGlue.
pvaluePointer to where put value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_iterate

typedef ubjs_result(* ubjs_glue_dict_iterate) (ubjs_glue_dict *this, ubjs_glue_dict_iterator **piterator)

Creates an iterator over glued dictionary.

Parameters
thisGlue.
piteratorPointer to where put iterator.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_iterator

Glue to a dictionary iterator.

Since
0.5

◆ ubjs_glue_dict_iterator_copy_key

typedef ubjs_result(* ubjs_glue_dict_iterator_copy_key) (ubjs_glue_dict_iterator *this, char *text)

Copies the key to specified array.

Parameters
thisGlue.
textAllocated array.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_iterator_free

typedef ubjs_result(* ubjs_glue_dict_iterator_free) (ubjs_glue_dict_iterator **pthis)

Frees the dictionary iterator glue.

After this returns UR_OK, it is guaranteed that pthis points to 0.

Parameters
pthisPointer to where glue is.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_iterator_get_key_length

typedef ubjs_result(* ubjs_glue_dict_iterator_get_key_length) (ubjs_glue_dict_iterator *this, unsigned int *plen)

Gets current key's length.

Parameters
thisGlue.
plenPointer to where put key's length.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_iterator_get_value

typedef ubjs_result(* ubjs_glue_dict_iterator_get_value) (ubjs_glue_dict_iterator *this, void **pvalue)

Gets current value.

Parameters
thisGlue.
pvaluePointer to where put the value.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_iterator_next

typedef ubjs_result(* ubjs_glue_dict_iterator_next) (ubjs_glue_dict_iterator *this)

Tries to iterate to next item.

Parameters
thisGlue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_dict_set

typedef ubjs_result(* ubjs_glue_dict_set) (ubjs_glue_dict *this, unsigned int key_length, char *key, void *value)

Sets the value under a key.

Parameters
thisGlue.
key_lengthKey length.
keyKey.
valueValue.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.5

◆ ubjs_glue_value_free

typedef void(* ubjs_glue_value_free) (void *pvalue)

Frees the value held in a glue. Note that this is a generic callback, not related to actual ubjs_prmtv_object()-s.

Parameters
pvaluePointer to value to be freed.
Since
0.5

◆ ubjs_library

typedef struct ubjs_library ubjs_library

Library handle.

Since
0.4

◆ ubjs_library_alloc_f

typedef void*(* ubjs_library_alloc_f) (unsigned long len)

Allocation functor.

This roughly follows the prototype for malloc().

Parameters
lenLength.
Returns
Allocated pointer.
Since
0.4

◆ ubjs_library_builder

Library handle builder.

Since
0.5

◆ ubjs_library_free_f

typedef void(* ubjs_library_free_f) (void *ptr)

Deallocation functor.

This roughly follows the prototype for free().

Parameters
ptrAllocated pointer.
Since
0.4

Function Documentation

◆ ubjs_library_builder_build()

UBJS_EXPORT ubjs_result ubjs_library_builder_build ( ubjs_library_builder this,
ubjs_library **  plib 
)

Builds the library and returns it.

After this returns UR_OK, it is guaranteed that plib points to newly initialized library handle.

Parameters
thisBuilder.
plibPointer to where put newly created library handle.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Since
0.5

References ubjs_glue_array_array_builder_new(), ubjs_glue_dict_list_builder_new(), UR_ERROR, and UR_OK.

Referenced by ubjs_library_new_stdlib().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ubjs_library_builder_init()

UBJS_EXPORT ubjs_result ubjs_library_builder_init ( ubjs_library_builder this)

Initializes the library handle builder.

Required once to initialize library.

Parameters
thisbuilder.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Since
0.6

References ubjs_glue_dict_iterator::free_f, UR_ERROR, and UR_OK.

Referenced by ubjs_library_new_stdlib().

Here is the caller graph for this function:

◆ ubjs_library_builder_set_alloc_f()

UBJS_EXPORT ubjs_result ubjs_library_builder_set_alloc_f ( ubjs_library_builder this,
ubjs_library_alloc_f  alloc_f 
)

Sets the allocation functor for to use for everything.

By default, ubjs uses stdlib's malloc().

Parameters
thisBuilder.
alloc_fAllocation functor.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Since
0.5

References UR_ERROR, and UR_OK.

◆ ubjs_library_builder_set_free_f()

UBJS_EXPORT ubjs_result ubjs_library_builder_set_free_f ( ubjs_library_builder this,
ubjs_library_free_f  free_f 
)

Sets the deallocation functor for to use for everything.

By default, ubjs uses stdlib's free().

Parameters
thisBuilder.
free_fDeallocation functor.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Since
0.5

References ubjs_glue_dict_iterator::free_f, UR_ERROR, and UR_OK.

◆ ubjs_library_builder_set_glue_array_builder()

UBJS_EXPORT ubjs_result ubjs_library_builder_set_glue_array_builder ( ubjs_library_builder this,
ubjs_glue_array_builder_new_f  builder 
)

Sets the array glue builder. This allows to select a different implementation of actual key-value store used in arrays.

By default, ubjs uses ubjs_glue_array_array_builder - built-in doubly-linked list.

Parameters
thisBuilder.
builderGlue array builder.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Since
0.5

References UR_ERROR, and UR_OK.

◆ ubjs_library_builder_set_glue_dict_builder()

UBJS_EXPORT ubjs_result ubjs_library_builder_set_glue_dict_builder ( ubjs_library_builder this,
ubjs_glue_dict_builder_new_f  builder 
)

Sets the dict glue builder. This allows to select a different implementation of actual key-value store used in dictionaries.

By default, ubjs uses ubjs_glue_dict_list_builder - built-in doubly-linked list.

Parameters
thisBuilder.
builderGlue dict builder.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Since
0.5

References UR_ERROR, and UR_OK.

◆ ubjs_library_free()

UBJS_EXPORT ubjs_result ubjs_library_free ( ubjs_library **  pthis)

Deinitializes the library handle.

After this returns UR_OK, it is guaranteed that pthis points to already allocated library handle.

Parameters
pthisPointer to library handle.
Returns
UR_ERROR if any of pthis is not 0, otherwise UR_OK.
Since
0.4

References UR_ERROR, and UR_OK.

◆ ubjs_library_get_alloc_f()

UBJS_EXPORT ubjs_result ubjs_library_get_alloc_f ( ubjs_library this,
ubjs_library_alloc_f palloc_f 
)

\ Brief Gets library's alloc callback.

Parameters
thisLibrary.
palloc_fPointer to where put alloc callback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.6

References UR_ERROR, and UR_OK.

◆ ubjs_library_get_free_f()

UBJS_EXPORT ubjs_result ubjs_library_get_free_f ( ubjs_library this,
ubjs_library_free_f pfree_f 
)

\ Brief Gets library's free callback.

Parameters
thisLibrary.
pfree_fPointer to where put free callback.
Returns
UR_OK if succedeed, otherwise UR_ERROR.
Since
0.6

References UR_ERROR, and UR_OK.

◆ ubjs_library_new_stdlib()

UBJS_EXPORT ubjs_result ubjs_library_new_stdlib ( ubjs_library **  pthis)

Initializes the library handle using stdlib's malloc() and free().

After this returns UR_OK, it is guaranteed that pthis points to already allocated library handle.

Required for most operations.

Parameters
pthisPointer to where put new library handle.
Returns
UR_ERROR if universe exploded, otherwise UR_OK.
Deprecated:
Use ubjs_library_builder to build library.
Since
0.4

References ubjs_library_builder_build(), ubjs_library_builder_init(), UR_ERROR, and UR_OK.

Here is the call graph for this function: