28 #ifndef HAVE_UBJS_LIBRARY 29 #define HAVE_UBJS_LIBRARY 46 typedef void *(*ubjs_library_alloc_f)(
unsigned long len);
162 unsigned int length);
178 unsigned int item_size);
387 unsigned int length);
403 unsigned int item_size);
447 char *key,
void **pvalue);
459 char *key,
void *value);
533 struct ubjs_glue_array_builder
560 struct ubjs_glue_array
610 struct ubjs_glue_array_iterator
632 struct ubjs_glue_dict_builder
659 struct ubjs_glue_dict
690 struct ubjs_glue_dict_iterator
ubjs_library_alloc_f alloc_f
Alloc callback.
Definition: ubjs_library.h:721
ubjs_glue_array_get_at get_at_f
Definition: ubjs_library.h:581
void *(* ubjs_library_alloc_f)(unsigned long len)
Allocation functor.
Definition: ubjs_library.h:46
UBJS_EXPORT ubjs_result ubjs_library_builder_init(ubjs_library_builder *this)
Initializes the library handle builder.
Definition: ubjs_library.c:32
ubjs_glue_array_iterator_get get_f
Definition: ubjs_library.h:625
ubjs_library_free_f free_f
Free callback.
Definition: ubjs_library.h:724
ubjs_glue_dict_iterator_get_key_length get_key_length_f
Definition: ubjs_library.h:705
ubjs_result(* ubjs_glue_dict_iterator_copy_key)(ubjs_glue_dict_iterator *this, char *text)
Copies the key to specified array.
Definition: ubjs_library.h:507
ubjs_result(* ubjs_glue_array_iterate)(ubjs_glue_array *this, ubjs_glue_array_iterator **piterator)
Creates an iterator over glued array.
Definition: ubjs_library.h:307
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.
Definition: ubjs_library.h:142
ubjs_glue_array_free free_f
Definition: ubjs_library.h:569
Definitions of common types, ubjson markers and some utilities.
ubjs_result(* ubjs_glue_array_iterator_next)(ubjs_glue_array_iterator *this)
Tries to iterate to next item.
Definition: ubjs_library.h:316
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.
Definition: ubjs_library.h:186
void * userdata
Definition: ubjs_library.h:665
ubjs_result(* ubjs_glue_array_get_first)(ubjs_glue_array *this, void **pvalue)
Gets the value of first item.
Definition: ubjs_library.h:219
ubjs_glue_array_get_length get_length_f
Definition: ubjs_library.h:572
ubjs_result(* ubjs_glue_dict_delete)(ubjs_glue_dict *this, unsigned int key_length, char *key)
Deletes a key, with its value.
Definition: ubjs_library.h:469
ubjs_result(* ubjs_glue_array_builder_set_length_f)(ubjs_glue_array_builder *this, unsigned int length)
Sets the predicted length for the array.
Definition: ubjs_library.h:161
ubjs_glue_array_delete_at delete_at_f
Definition: ubjs_library.h:599
ubjs_result(* ubjs_glue_dict_iterator_next)(ubjs_glue_dict_iterator *this)
Tries to iterate to next item.
Definition: ubjs_library.h:488
ubjs_glue_dict_set set_f
Definition: ubjs_library.h:677
UBJS_EXPORT ubjs_result ubjs_library_new_stdlib(ubjs_library **pthis)
Initializes the library handle using stdlib's malloc() and free().
Definition: ubjs_library.c:118
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.
Definition: ubjs_library.c:58
ubjs_result(* ubjs_glue_array_delete_last)(ubjs_glue_array *this)
Delete the last item.
Definition: ubjs_library.h:288
ubjs_result(* ubjs_glue_array_delete_at)(ubjs_glue_array *this, unsigned int index)
Delete the item at index.
Definition: ubjs_library.h:297
ubjs_result(* ubjs_glue_array_add_at)(ubjs_glue_array *this, unsigned int index, void *value)
Add the value of item at an index.
Definition: ubjs_library.h:271
ubjs_library * lib
Definition: ubjs_library.h:536
ubjs_glue_dict_builder_set_length_f set_length_f
Definition: ubjs_library.h:646
ubjs_result(* ubjs_glue_array_builder_new_f)(ubjs_library *lib, ubjs_glue_array_builder **pthis)
Creates a new array glue builder.
Definition: ubjs_library.h:119
ubjs_library * lib
Definition: ubjs_library.h:635
ubjs_glue_array_builder_set_item_size_f set_item_size_f
Definition: ubjs_library.h:550
ubjs_glue_dict_builder_set_item_size_f set_item_size_f
Definition: ubjs_library.h:649
ubjs_result(* ubjs_glue_array_builder_free_f)(ubjs_glue_array_builder **)
Frees the array glue builder.
Definition: ubjs_library.h:130
ubjs_glue_dict_iterator_next next_f
Definition: ubjs_library.h:702
ubjs_glue_dict * object
Definition: ubjs_library.h:693
ubjs_glue_array_add_first add_first_f
Definition: ubjs_library.h:584
ubjs_glue_array_add_at add_at_f
Definition: ubjs_library.h:590
ubjs_glue_dict_iterator_get_value get_value_f
Definition: ubjs_library.h:711
ubjs_glue_dict_get get_f
Definition: ubjs_library.h:674
ubjs_result(* ubjs_glue_dict_free)(ubjs_glue_dict **)
Frees the dictionary glue.
Definition: ubjs_library.h:422
ubjs_result(* ubjs_glue_dict_builder_set_length_f)(ubjs_glue_dict_builder *this, unsigned int length)
Sets the predicted length for the dictionary.
Definition: ubjs_library.h:386
ubjs_result(* ubjs_glue_array_get_last)(ubjs_glue_array *this, void **pvalue)
Gets the value of last item.
Definition: ubjs_library.h:230
void * userdata
Definition: ubjs_library.h:696
Glue to an array.
Definition: ubjs_library.h:560
ubjs_glue_dict_iterate iterate_f
Definition: ubjs_library.h:683
ubjs_result(* ubjs_glue_dict_get)(ubjs_glue_dict *this, unsigned int key_length, char *key, void **pvalue)
Gets the value under a key.
Definition: ubjs_library.h:446
ubjs_result(* ubjs_glue_array_iterator_free)(ubjs_glue_array_iterator **pthis)
Frees the array iterator glue.
Definition: ubjs_library.h:336
UBJS_EXPORT ubjs_result ubjs_library_get_alloc_f(ubjs_library *this, ubjs_library_alloc_f *palloc_f)
Definition: ubjs_library.c:132
void(* ubjs_library_free_f)(void *ptr)
Deallocation functor.
Definition: ubjs_library.h:55
ubjs_glue_dict_delete delete_f
Definition: ubjs_library.h:680
UBJS_EXPORT ubjs_result ubjs_library_free(ubjs_library **pthis)
Deinitializes the library handle.
Definition: ubjs_library.c:154
ubjs_glue_dict_get_length get_length_f
Definition: ubjs_library.h:671
void * userdata
Definition: ubjs_library.h:538
ubjs_result(* ubjs_glue_dict_iterate)(ubjs_glue_dict *this, ubjs_glue_dict_iterator **piterator)
Creates an iterator over glued dictionary.
Definition: ubjs_library.h:479
ubjs_result(* ubjs_glue_array_add_last)(ubjs_glue_array *this, void *value)
Add the value at end.
Definition: ubjs_library.h:261
ubjs_glue_array_iterate iterate_f
Definition: ubjs_library.h:602
ubjs_library * lib
Definition: ubjs_library.h:662
ubjs_glue_array_delete_last delete_last_f
Definition: ubjs_library.h:596
ubjs_result(* ubjs_glue_dict_builder_new_f)(ubjs_library *lib, ubjs_glue_dict_builder **pthis)
Creates a new dictionary glue builder.
Definition: ubjs_library.h:344
ubjs_result
Enum that defines the result of a method.
Definition: ubjs_common.h:73
ubjs_result(* ubjs_glue_dict_iterator_free)(ubjs_glue_dict_iterator **pthis)
Frees the dictionary iterator glue.
Definition: ubjs_library.h:527
ubjs_glue_dict_iterator_copy_key copy_key_f
Definition: ubjs_library.h:708
ubjs_glue_dict_builder_set_value_free_f set_value_free_f
Definition: ubjs_library.h:643
ubjs_glue_array_get_first get_first_f
Definition: ubjs_library.h:575
ubjs_library * lib
Definition: ubjs_library.h:563
ubjs_glue_array_builder_set_length_f set_length_f
Definition: ubjs_library.h:547
Glue to array iterator.
Definition: ubjs_library.h:610
Builder for dictionary glues.
Definition: ubjs_library.h:632
Glue to dictionary iterator.
Definition: ubjs_library.h:690
ubjs_glue_array_builder_free_f free_f
Definition: ubjs_library.h:541
ubjs_glue_dict_iterator_free free_f
Definition: ubjs_library.h:699
ubjs_glue_array_add_last add_last_f
Definition: ubjs_library.h:587
ubjs_result(* ubjs_glue_array_delete_first)(ubjs_glue_array *this)
Delete the first item.
Definition: ubjs_library.h:280
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.
Definition: ubjs_library.h:367
ubjs_result(* ubjs_glue_array_free)(ubjs_glue_array **)
Frees the array glue.
Definition: ubjs_library.h:197
ubjs_result(* ubjs_glue_array_get_length)(ubjs_glue_array *this, unsigned int *pvalue)
Gets the length of the array under a glue.
Definition: ubjs_library.h:208
ubjs_result(* ubjs_glue_array_iterator_get)(ubjs_glue_array_iterator *this, void **pvalue)
Gets current item's value.
Definition: ubjs_library.h:325
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 sto...
Definition: ubjs_library.c:70
ubjs_result(* ubjs_glue_array_get_at)(ubjs_glue_array *this, unsigned int index, void **pvalue)
Gets the value of item under an index.
Definition: ubjs_library.h:242
ubjs_result(* ubjs_glue_dict_set)(ubjs_glue_dict *this, unsigned int key_length, char *key, void *value)
Sets the value under a key.
Definition: ubjs_library.h:458
void * userdata
Definition: ubjs_library.h:616
ubjs_result(* ubjs_glue_dict_iterator_get_value)(ubjs_glue_dict_iterator *this, void **pvalue)
Gets current value.
Definition: ubjs_library.h:516
Library handle builder.
Definition: ubjs_library.h:718
ubjs_result(* ubjs_glue_dict_get_length)(ubjs_glue_dict *this, unsigned int *pvalue)
Gets the length of the dictionary under a glue.
Definition: ubjs_library.h:433
ubjs_result(* ubjs_glue_dict_builder_free_f)(ubjs_glue_dict_builder **)
Frees the dictionary glue builder.
Definition: ubjs_library.h:355
ubjs_glue_dict_builder_build_f build_f
Definition: ubjs_library.h:652
void * userdata
Definition: ubjs_library.h:637
ubjs_glue_array_iterator_free free_f
Definition: ubjs_library.h:619
ubjs_glue_array_builder_build_f build_f
Definition: ubjs_library.h:553
ubjs_glue_array_iterator_next next_f
Definition: ubjs_library.h:622
void * userdata
Definition: ubjs_library.h:566
ubjs_glue_dict_builder_free_f free_f
Definition: ubjs_library.h:640
ubjs_result(* ubjs_glue_dict_builder_set_item_size_f)(ubjs_glue_dict_builder *this, unsigned int item_size)
Sets the predicted item size.
Definition: ubjs_library.h:402
Builder for array glues.
Definition: ubjs_library.h:533
ubjs_result(* ubjs_glue_array_add_first)(ubjs_glue_array *this, void *value)
Add the value at beginning.
Definition: ubjs_library.h:252
ubjs_glue_array * array
Definition: ubjs_library.h:613
ubjs_glue_dict_free free_f
Definition: ubjs_library.h:668
ubjs_result(* ubjs_glue_array_builder_set_item_size_f)(ubjs_glue_array_builder *this, unsigned int item_size)
Sets the predicted item size.
Definition: ubjs_library.h:177
UBJS_EXPORT ubjs_result ubjs_library_get_free_f(ubjs_library *this, ubjs_library_free_f *pfree_f)
Definition: ubjs_library.c:143
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.
Definition: ubjs_library.c:46
ubjs_glue_array_delete_first delete_first_f
Definition: ubjs_library.h:593
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_prmt...
Definition: ubjs_library.h:111
struct ubjs_library ubjs_library
Library handle.
Definition: ubjs_library.h:67
UBJS_EXPORT ubjs_result ubjs_library_builder_build(ubjs_library_builder *this, ubjs_library **plib)
Builds the library and returns it.
Definition: ubjs_library.c:94
ubjs_glue_array_builder_new_f glue_array_builder
Glue array builder.
Definition: ubjs_library.h:727
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.
Definition: ubjs_library.h:411
ubjs_glue_dict_builder_new_f glue_dict_builder
Glue dict builder.
Definition: ubjs_library.h:730
ubjs_glue_array_get_last get_last_f
Definition: ubjs_library.h:578
ubjs_result(* ubjs_glue_dict_iterator_get_key_length)(ubjs_glue_dict_iterator *this, unsigned int *plen)
Gets current key's length.
Definition: ubjs_library.h:497
Glue to a dictionary.
Definition: ubjs_library.h:659
ubjs_glue_array_builder_set_value_free_f set_value_free_f
Definition: ubjs_library.h:544
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 stor...
Definition: ubjs_library.c:82