ubjsc  0.6
Enterprise-grade C library for manipulating UBJSON
Typedefs | Enumerations | Functions
ubjs_primitives.h File Reference

Wrappers over ubjson primitive types. More...

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

Go to the source code of this file.

Typedefs

typedef struct ubjs_prmtv ubjs_prmtv
 
typedef struct ubjs_array_iterator ubjs_array_iterator
 
typedef struct ubjs_object_iterator ubjs_object_iterator
 
typedef enum ubjs_prmtv_type ubjs_prmtv_type
 

Enumerations

enum  ubjs_prmtv_type {
  UOT_NULL, UOT_NOOP, UOT_TRUE, UOT_FALSE,
  UOT_INT8, UOT_UINT8, UOT_INT16, UOT_INT32,
  UOT_INT64, UOT_FLOAT32, UOT_FLOAT64, UOT_HPN,
  UOT_CHAR, UOT_STR, UOT_ARRAY, UOT_OBJECT,
  UOT_MAX
}
 

Functions

UBJS_EXPORT ubjs_prmtvubjs_prmtv_null (void)
 Returns null primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_null (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a null primitive. More...
 
UBJS_EXPORT ubjs_prmtvubjs_prmtv_noop (void)
 Returns no-op primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_noop (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a no-op primitive. More...
 
UBJS_EXPORT ubjs_prmtvubjs_prmtv_true (void)
 Returns true primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_true (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a true primitive. More...
 
UBJS_EXPORT ubjs_prmtvubjs_prmtv_false (void)
 Returns false primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_false (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a false primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int (ubjs_library *lib, int64_t value, ubjs_prmtv **pthis)
 Returns the best int primitive wrapping given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_uint (ubjs_library *lib, int64_t value, ubjs_prmtv **pthis)
 Returns the best unsigned int primitive wrapping given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is any integer primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int_get (ubjs_prmtv *this, int64_t *pvalue)
 Gets the value of the integer primitive, regardless of its type. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int8 (ubjs_library *lib, int8_t value, ubjs_prmtv **pthis)
 Returns int8 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int8 (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is an int8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int8_get (ubjs_prmtv *this, int8_t *pvalue)
 Gets the value of the int8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int8_set (ubjs_prmtv *this, int8_t value)
 Sets the value of the int8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_uint8 (ubjs_library *lib, uint8_t value, ubjs_prmtv **pthis)
 Returns uint8 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_uint8 (ubjs_prmtv *this, ubjs_bool *presult)
 Checks whether the primitive is an uint8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_get (ubjs_prmtv *this, uint8_t *pvalue)
 Gets the value of the uint8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_set (ubjs_prmtv *this, uint8_t value)
 Sets the value of the uint8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int16 (ubjs_library *lib, int16_t value, ubjs_prmtv **pthis)
 Returns int16 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int16 (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is an int16 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int16_get (ubjs_prmtv *this, int16_t *pvalue)
 Gets the value of the int16 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int16_set (ubjs_prmtv *this, int16_t value)
 Sets the value of the int16 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int32 (ubjs_library *lib, int32_t value, ubjs_prmtv **pthis)
 Returns int32 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int32 (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is an int32 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int32_get (ubjs_prmtv *this, int32_t *pvalue)
 Gets the value of the int32 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int32_set (ubjs_prmtv *this, int32_t value)
 Sets the value of the int32 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int64 (ubjs_library *lib, int64_t value, ubjs_prmtv **pthis)
 Returns int64 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int64 (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is an int64 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int64_get (ubjs_prmtv *this, int64_t *pvalue)
 Gets the value of the int8 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_int64_set (ubjs_prmtv *this, int64_t value)
 Sets the value of the int64 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_float32 (ubjs_library *lib, float32_t value, ubjs_prmtv **pthis)
 Returns float32 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_float32 (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a float32 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_float32_get (ubjs_prmtv *this, float32_t *pvalue)
 Gets the value of the int32 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_float32_set (ubjs_prmtv *this, float32_t value)
 Sets the value of the float32 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_float64 (ubjs_library *lib, float64_t value, ubjs_prmtv **pthis)
 Returns float64 primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_float64 (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a float64 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_float64_get (ubjs_prmtv *this, float64_t *pvalue)
 Gets the value of the int64 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_float64_set (ubjs_prmtv *this, float64_t value)
 Sets the value of the float64 primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_hpn (ubjs_library *lib, unsigned int length, char *text, ubjs_prmtv **pthis)
 Returns high-precision number primitive for given string. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_hpn (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a high-precision number primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_get_length (ubjs_prmtv *this, unsigned int *result)
 Gets the high-precision number primitive's string length. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_copy_text (ubjs_prmtv *this, char *result)
 Copies the high-precision number primitive's string content to provided array. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_set (ubjs_prmtv *this, unsigned int length, char *text)
 Sets the string value of the high-precision number primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_char (ubjs_library *lib, char value, ubjs_prmtv **pthis)
 Returns char primitive for given value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_char (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a char primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_char_get (ubjs_prmtv *this, char *pvalue)
 Gets the value of the char primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_char_set (ubjs_prmtv *this, char value)
 Sets the value of the char primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_str (ubjs_library *lib, unsigned int length, char *text, ubjs_prmtv **pthis)
 Returns str primitive for given string. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_str (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is a str primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_str_get_length (ubjs_prmtv *this, unsigned int *result)
 Gets the string primitive's length. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_str_copy_text (ubjs_prmtv *this, char *result)
 Copies the string primitive's content to provided array. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_str_set (ubjs_prmtv *this, unsigned int length, char *text)
 Sets the value of the string primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array (ubjs_library *lib, ubjs_prmtv **pthis)
 Returns array primitive for an empty array. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_with_length (ubjs_library *lib, unsigned int length, ubjs_prmtv **pthis)
 Returns array primitive for an empty array, with initial size known. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_with_length_and_type (ubjs_library *lib, ubjs_prmtv_type type, unsigned int length, ubjs_prmtv **pthis)
 Returns array primitive for an empty array, with initial size known and item type. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_array (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is an array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_length (ubjs_prmtv *this, unsigned int *length)
 Gets the array primitive's length. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_first (ubjs_prmtv *this, ubjs_prmtv **pitem)
 Gets reference to first item of the array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_last (ubjs_prmtv *this, ubjs_prmtv **pitem)
 Gets reference to last item of the array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_at (ubjs_prmtv *this, unsigned int pos, ubjs_prmtv **pitem)
 Gets reference to n-th item of the array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_first (ubjs_prmtv *this, ubjs_prmtv *item)
 Inserts an item into array primitive as a first one. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_last (ubjs_prmtv *this, ubjs_prmtv *item)
 Inserts an item into array primitive as a last one. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_at (ubjs_prmtv *this, unsigned int pos, ubjs_prmtv *item)
 Inserts an item into array primitive before an existing n-th one. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_first (ubjs_prmtv *this)
 Deletes the first item from array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_last (ubjs_prmtv *this)
 Deletes the last item from array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_at (ubjs_prmtv *this, unsigned int pos)
 Deletes the n-th item from array primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_array_iterate (ubjs_prmtv *this, ubjs_array_iterator **iterator)
 Returns iterator over this array. More...
 
UBJS_EXPORT ubjs_result ubjs_array_iterator_next (ubjs_array_iterator *this)
 Tries to advance the array iterator. More...
 
UBJS_EXPORT ubjs_result ubjs_array_iterator_get (ubjs_array_iterator *this, ubjs_prmtv **item)
 Gets the item from the array iterator. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object (ubjs_library *lib, ubjs_prmtv **pthis)
 Returns object primitive for an empty object. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_with_length (ubjs_library *lib, unsigned int length, ubjs_prmtv **pthis)
 Returns object primitive for an empty object, with initial size known. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_with_length_and_type (ubjs_library *lib, ubjs_prmtv_type type, unsigned int length, ubjs_prmtv **pthis)
 Returns object primitive for an empty objecty, with initial size known and item type. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_is_object (ubjs_prmtv *this, ubjs_bool *result)
 Checks whether the primitive is an object primitive. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_get_length (ubjs_prmtv *this, unsigned int *pvalue)
 Gets the object primitive's length. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_get (ubjs_prmtv *this, unsigned int key_length, char *key, ubjs_prmtv **pvalue)
 Gets the value for specified key. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_set (ubjs_prmtv *this, unsigned int key_length, char *key, ubjs_prmtv *value)
 Sets the value for specified key. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_delete (ubjs_prmtv *this, unsigned int key_length, char *key)
 Deletes the value for specified key. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_object_iterate (ubjs_prmtv *this, ubjs_object_iterator **iterator)
 Returns iterator over this object. The object must exist thru the life of the iterator. If you ubjs_prmtv_free the object before you ubjs_object_iterator_free, behavior is undefined. More...
 
UBJS_EXPORT ubjs_result ubjs_object_iterator_next (ubjs_object_iterator *this)
 Tries to advance the object iterator. More...
 
UBJS_EXPORT ubjs_result ubjs_object_iterator_get_key_length (ubjs_object_iterator *this, unsigned int *plen)
 Gets the key's length from the object iterator. More...
 
UBJS_EXPORT ubjs_result ubjs_object_iterator_copy_key (ubjs_object_iterator *this, char *text)
 Copies the key from the object iterator to provided array. More...
 
UBJS_EXPORT ubjs_result ubjs_object_iterator_get_value (ubjs_object_iterator *this, ubjs_prmtv **pvalue)
 Gets the value from the object iterator. More...
 
UBJS_EXPORT ubjs_result ubjs_array_iterator_free (ubjs_array_iterator **pthis)
 Frees the iterator. After this returns UR_OK, *pthis is equal to 0. More...
 
UBJS_EXPORT ubjs_result ubjs_object_iterator_free (ubjs_object_iterator **pthis)
 Frees the iterator. After this returns UR_OK, *pthis is equal to 0. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_get_type (ubjs_prmtv *this, ubjs_prmtv_type *ptype)
 Gets the primitive's type. After this returns UR_OK, *ptype has a value. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_get_length (ubjs_prmtv *this, unsigned int *plen)
 Calculates the length of would-be-serialized debug string for the primitive. After this returns UR_OK, *this gets a dynamically allocated null-terminated string. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_copy (ubjs_prmtv *this, char *str)
 Serializes the primitive and copies the debug string to provided array. More...
 
UBJS_EXPORT ubjs_result ubjs_prmtv_free (ubjs_prmtv **pthis)
 Frees the primitive. After this returns UR_OK, *pthis is equal to 0. More...
 

Detailed Description

Wrappers over ubjson primitive types.

Ubjson defines a number of types and they all are wrapped over an umbrella ubjs_prmtv structure.

Common operations:

Types supported:

Since
0.2

Typedef Documentation

◆ ubjs_array_iterator

Struct for array's iterator.

◆ ubjs_object_iterator

Struct for objects's iterator.

◆ ubjs_prmtv

typedef struct ubjs_prmtv ubjs_prmtv

Abstract struct for all ubjson primitives.

◆ ubjs_prmtv_type

Legal primitive types.

Enumeration Type Documentation

◆ ubjs_prmtv_type

Legal primitive types.

Enumerator
UOT_NOOP 

null

UOT_TRUE 

no-op

UOT_FALSE 

true

UOT_INT8 

false

UOT_UINT8 

int8

UOT_INT16 

uint8

UOT_INT32 

int16

UOT_INT64 

int32

UOT_FLOAT32 

int64

UOT_FLOAT64 

float32

UOT_HPN 

float64

UOT_CHAR 

high-precision number

UOT_STR 

char

UOT_ARRAY 

str

UOT_OBJECT 

array

UOT_MAX 

object

Sentinel value.

Function Documentation

◆ ubjs_array_iterator_free()

UBJS_EXPORT ubjs_result ubjs_array_iterator_free ( ubjs_array_iterator **  pthis)

Frees the iterator. After this returns UR_OK, *pthis is equal to 0.

Parameters
pthisPointer to existing iterator.
Returns
UR_ERROR if pthis is 0, else UR_OK.

References ubjs_prmtv_free(), UR_ERROR, and UR_OK.

Here is the call graph for this function:

◆ ubjs_array_iterator_get()

UBJS_EXPORT ubjs_result ubjs_array_iterator_get ( ubjs_array_iterator this,
ubjs_prmtv **  item 
)

Gets the item from the array iterator.

The array must exist thru the life of the iterator. If you ubjs_prmtv_free the array before you ubjs_array_iterator_free, behavior is undefined.

If ubjs_array_iterator_next returned UR_ERROR, this will also return UR_ERROR. Else after this method returns UR_OK, and *item gets a value.

Parameters
thisIterator.
itemPointer to where put the item.
Returns
UR_ERROR if any of this/item are 0, or previous call to ubjs_array_iterator_next returned UR_ERROR. Else UR_OK.

References UR_ERROR.

◆ ubjs_array_iterator_next()

UBJS_EXPORT ubjs_result ubjs_array_iterator_next ( ubjs_array_iterator this)

Tries to advance the array iterator.

The array must exist thru the life of the iterator. If you ubjs_prmtv_free the array before you ubjs_array_iterator_free, behavior is undefined.

If this returns UR_OK, you can safely call ubjs_array_iterator_get to get the item at this position.

Parameters
thisIterator.
Returns
UR_ERROR if iterator are 0, or the iterator would go beyond the array's bounds. Else UR_OK.

References UR_ERROR.

◆ ubjs_object_iterator_copy_key()

UBJS_EXPORT ubjs_result ubjs_object_iterator_copy_key ( ubjs_object_iterator this,
char *  text 
)

Copies the key from the object iterator to provided array.

Target array must be preallocated. Before the call, you may want to ubjs_prmtv_str_get_length and allocate the target array.

The object must exist thru the life of the iterator. If you ubjs_prmtv_free the object before you ubjs_array_iterator_free, behavior is undefined.

If ubjs_array_iterator_next returned UR_ERROR, this will also return UR_ERROR. Else after this method returns UR_OK, and *text gets a value.

Parameters
thisIterator.
textTarget array.
Returns
UR_ERROR if any of this/text are 0, or previous call to ubjs_object_iterator_next returned UR_ERROR. Else UR_OK.

References UR_ERROR.

◆ ubjs_object_iterator_free()

UBJS_EXPORT ubjs_result ubjs_object_iterator_free ( ubjs_object_iterator **  pthis)

Frees the iterator. After this returns UR_OK, *pthis is equal to 0.

Parameters
pthisPointer to existing iterator.
Returns
UR_ERROR if pthis is 0, else UR_OK.

References UR_ERROR, and UR_OK.

◆ ubjs_object_iterator_get_key_length()

UBJS_EXPORT ubjs_result ubjs_object_iterator_get_key_length ( ubjs_object_iterator this,
unsigned int *  plen 
)

Gets the key's length from the object iterator.

The object must exist thru the life of the iterator. If you ubjs_prmtv_free the object before you ubjs_array_iterator_free, behavior is undefined.

If ubjs_array_iterator_next returned UR_ERROR, this will also return UR_ERROR. Else after this method returns UR_OK, and *plen gets a value.

Parameters
thisIterator.
plenPointer to where put key's length.
Returns
UR_ERROR if any of this/plen are 0, or previous call to ubjs_object_iterator_next returned UR_ERROR. Else UR_OK.

References UR_ERROR.

◆ ubjs_object_iterator_get_value()

UBJS_EXPORT ubjs_result ubjs_object_iterator_get_value ( ubjs_object_iterator this,
ubjs_prmtv **  pvalue 
)

Gets the value from the object iterator.

The object must exist thru the life of the iterator. If you ubjs_prmtv_free the object before you ubjs_array_iterator_free, behavior is undefined.

If ubjs_array_iterator_next returned UR_ERROR, this will also return UR_ERROR. Else after this method returns UR_OK, and *pvalue gets a value.

Parameters
thisIterator.
pvaluePointer to where put value.
Returns
UR_ERROR if any of this/plen are 0, or previous call to ubjs_object_iterator_next returned UR_ERROR. Else UR_OK.

References UR_ERROR.

◆ ubjs_object_iterator_next()

UBJS_EXPORT ubjs_result ubjs_object_iterator_next ( ubjs_object_iterator this)

Tries to advance the object iterator.

The object must exist thru the life of the iterator. If you ubjs_prmtv_free the object before you ubjs_array_iterator_free, behavior is undefined.

If this returns UR_OK, you can safely call ubjs_object_iterator_get to get the item at this position.

Parameters
thisIterator.
Returns
UR_ERROR if iterator are 0, or the iterator would go beyond the object's bounds. Else UR_OK.

References UR_ERROR.

◆ ubjs_prmtv_array()

UBJS_EXPORT ubjs_result ubjs_prmtv_array ( ubjs_library lib,
ubjs_prmtv **  pthis 
)

Returns array primitive for an empty array.

After this returns UR_OK, *pthis points to a valid array primitive.

Parameters
libLibrary handle.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis are 0, else UR_OK.
Since
0.4

References ubjs_glue_array_builder::build_f, ubjs_glue_array_builder::free_f, ubjs_glue_array_builder::set_value_free_f, UOT_ARRAY, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_array_add_at()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_at ( ubjs_prmtv this,
unsigned int  pos,
ubjs_prmtv item 
)

Inserts an item into array primitive before an existing n-th one.

This means that existing n-th item will become (n + 1)-th. pos == 0 is the same as ubjs_prmtv_array_add_first. pos == ubjs_prmtv_array_get_length is the same as ubjs_prmtv_array_add_last. What happens when iterating over the array during adding items - this is undefined behavior.

Parameters
thisPrimitive.
posPosition of the item. Must be within 0..(ubjs_prmtv_array_get_length).
itemNew item.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or pos is not within range 0..(ubjs_prmtv_array_get_length). Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_add_first()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_first ( ubjs_prmtv this,
ubjs_prmtv item 
)

Inserts an item into array primitive as a first one.

This means that the existing first item becomes the second. What happens when iterating over the array during adding items - this is undefined behavior.

Parameters
thisPrimitive.
itemNew item.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array. Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_add_last()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_last ( ubjs_prmtv this,
ubjs_prmtv item 
)

Inserts an item into array primitive as a last one.

This means that the existing last item becomes the second-last. What happens when iterating over the array during adding items - this is undefined behavior.

Parameters
thisPrimitive.
itemNew item.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array. Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_delete_at()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_at ( ubjs_prmtv this,
unsigned int  pos 
)

Deletes the n-th item from array primitive.

This means that the (n + 1)-th item becomes the n-th. What happens when iterating over the array during deleting items - this is undefined behavior.

The item does get ubjs_prmtv_free-d.

Parameters
thisPrimitive.
posPosition of the item. Must be within 0..(ubjs_prmtv_array_get_length - 1).
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or pos is not within range 0..(ubjs_prmtv_array_get_length - 1). Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_delete_first()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_first ( ubjs_prmtv this)

Deletes the first item from array primitive.

This means that the existing second item becomes the first. What happens when iterating over the array during deleting items - this is undefined behavior.

The item does get ubjs_prmtv_free-d.

Parameters
thisPrimitive.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or the array is empty. Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_delete_last()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_last ( ubjs_prmtv this)

Deletes the last item from array primitive.

This means that the existing second-last item becomes the last. What happens when iterating over the array during deleting items - this is undefined behavior.

The item does get ubjs_prmtv_free-d.

Parameters
thisPrimitive.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or the array is empty. Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_get_at()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_at ( ubjs_prmtv this,
unsigned int  pos,
ubjs_prmtv **  pitem 
)

Gets reference to n-th item of the array primitive.

This is the internal reference to an item and must not be ubjs_prmtv_free-d.

Parameters
thisPrimitive.
posPosition of the item. Must be within 0..(ubjs_prmtv_array_get_length - 1).
pitemPointer to where set the item.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or pos is not within range 0..(ubjs_prmtv_array_get_length - 1). Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_get_first()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_first ( ubjs_prmtv this,
ubjs_prmtv **  pitem 
)

Gets reference to first item of the array primitive.

This is the internal reference to an item and must not be ubjs_prmtv_free-d.

Parameters
thisPrimitive.
pitemPointer to where set the item.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or array is empty. Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_get_last()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_last ( ubjs_prmtv this,
ubjs_prmtv **  pitem 
)

Gets reference to last item of the array primitive.

This is the internal reference to an item and must not be ubjs_prmtv_free-d.

Parameters
thisPrimitive.
pitemPointer to where set the item.
Returns
UR_ERROR if any of this/pitem is 0, this is not an array, or array is empty. Else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_get_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_length ( ubjs_prmtv this,
unsigned int *  length 
)

Gets the array primitive's length.

Parameters
thisPrimitive.
lengthPointer to where set the value.
Returns
UR_ERROR if any of this/result is 0, or this is not an array, else UR_OK.

References UOT_ARRAY, and UR_ERROR.

◆ ubjs_prmtv_array_iterate()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_iterate ( ubjs_prmtv this,
ubjs_array_iterator **  iterator 
)

Returns iterator over this array.

The array must exist thru the life of the iterator. If you ubjs_prmtv_free the array before you ubjs_array_iterator_free, behavior is undefined.

After this returns UR_OK, *pthis points to new iterator. First call to ubjs_array_iterator_next will point to 0-th item.

Parameters
thisExisting array primitive.
iteratorPointer to where put newly created iterator.
Returns
UR_ERROR if any of this/iterator are 0, or this is not an array. Else UR_OK.

References UOT_ARRAY, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_array_with_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_with_length ( ubjs_library lib,
unsigned int  length,
ubjs_prmtv **  pthis 
)

Returns array primitive for an empty array, with initial size known.

Call this if you know you will add n-items.

After this returns UR_OK, *pthis points to a valid array primitive.

Parameters
libLibrary handle.
lengthInitial length.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis are 0, else UR_OK.
Since
0.4

References ubjs_glue_array_builder::build_f, ubjs_glue_array_builder::free_f, ubjs_glue_array_builder::set_length_f, ubjs_glue_array_builder::set_value_free_f, UOT_ARRAY, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_array_with_length_and_type()

UBJS_EXPORT ubjs_result ubjs_prmtv_array_with_length_and_type ( ubjs_library lib,
ubjs_prmtv_type  type,
unsigned int  length,
ubjs_prmtv **  pthis 
)

Returns array primitive for an empty array, with initial size known and item type.

Call this if you know you will add n-items of exactly one type.

After this returns UR_OK, *pthis points to a valid array primitive.

Parameters
libLibrary handle.
typeItem type.
lengthInitial length.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis are 0, else UR_OK.
Since
0.4

References UOT_MAX, and UR_ERROR.

◆ ubjs_prmtv_char()

UBJS_EXPORT ubjs_result ubjs_prmtv_char ( ubjs_library lib,
char  value,
ubjs_prmtv **  pthis 
)

Returns char primitive for given value.

After this returns UR_OK, *pthis points to a valid char primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if lib/pthis is 0, else UR_OK.

References UOT_CHAR, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_char_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_char_get ( ubjs_prmtv this,
char *  pvalue 
)

Gets the value of the char primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not a char, else UR_OK.

References UOT_CHAR, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_char_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_char_set ( ubjs_prmtv this,
char  value 
)

Sets the value of the char primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not a char, else UR_OK.

References UOT_CHAR, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_debug_string_copy()

UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_copy ( ubjs_prmtv this,
char *  str 
)

Serializes the primitive and copies the debug string to provided array.

Target array must be preallocated. Before the call, you may want to ubjs_prmtv_debug_string_get_length and allocate the target array.

Parameters
thisExisting primitive.
strPointer to where put debug string.
Returns
UR_ERROR if any of this/str is 0, else UR_OK.

References UR_ERROR.

Referenced by ubjs_parser_parse().

Here is the caller graph for this function:

◆ ubjs_prmtv_debug_string_get_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_get_length ( ubjs_prmtv this,
unsigned int *  plen 
)

Calculates the length of would-be-serialized debug string for the primitive. After this returns UR_OK, *this gets a dynamically allocated null-terminated string.

Parameters
thisExisting primitive.
plenPointer to where put debug string's length.
Returns
UR_ERROR if any of this/pstr is 0, else UR_OK.

References UR_ERROR.

Referenced by ubjs_parser_parse().

Here is the caller graph for this function:

◆ ubjs_prmtv_false()

UBJS_EXPORT ubjs_prmtv* ubjs_prmtv_false ( void  )

Returns false primitive.

This is a singleton and ubj_prmtv_free do nothing.

◆ ubjs_prmtv_float32()

UBJS_EXPORT ubjs_result ubjs_prmtv_float32 ( ubjs_library lib,
float32_t  value,
ubjs_prmtv **  pthis 
)

Returns float32 primitive for given value.

After this returns UR_OK, *pthis points to a valid float32 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if pthis is 0, else UR_OK.
Since
0.4

References UOT_FLOAT32, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_float32_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_float32_get ( ubjs_prmtv this,
float32_t pvalue 
)

Gets the value of the int32 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not a float32, else UR_OK.

References UOT_FLOAT32, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_float32_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_float32_set ( ubjs_prmtv this,
float32_t  value 
)

Sets the value of the float32 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not a float32, else UR_OK.

References UOT_FLOAT32, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_float64()

UBJS_EXPORT ubjs_result ubjs_prmtv_float64 ( ubjs_library lib,
float64_t  value,
ubjs_prmtv **  pthis 
)

Returns float64 primitive for given value.

After this returns UR_OK, *pthis points to a valid float64 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if pthis is 0, else UR_OK.
Since
0.4

References UOT_FLOAT64, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_float64_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_float64_get ( ubjs_prmtv this,
float64_t pvalue 
)

Gets the value of the int64 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not a float64, else UR_OK.

References UOT_FLOAT64, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_float64_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_float64_set ( ubjs_prmtv this,
float64_t  value 
)

Sets the value of the float64 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not a float64, else UR_OK.

References UOT_FLOAT64, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_free()

UBJS_EXPORT ubjs_result ubjs_prmtv_free ( ubjs_prmtv **  pthis)

Frees the primitive. After this returns UR_OK, *pthis is equal to 0.

Parameters
pthisPointer to existing primitive.
Returns
UR_ERROR if any of pthis / *pthis is 0, else UR_OK.

References UR_ERROR.

Referenced by ubjs_array_iterator_free(), and ubjs_parser_parse().

Here is the caller graph for this function:

◆ ubjs_prmtv_get_type()

UBJS_EXPORT ubjs_result ubjs_prmtv_get_type ( ubjs_prmtv this,
ubjs_prmtv_type ptype 
)

Gets the primitive's type. After this returns UR_OK, *ptype has a value.

Parameters
thisExisting primitive.
ptypePointer to where put primitive's type.
Returns
UR_ERROR if any of this/ptype is 0, else UR_OK.

References UR_ERROR, and UR_OK.

Referenced by ubjs_parser_parse().

Here is the caller graph for this function:

◆ ubjs_prmtv_hpn()

UBJS_EXPORT ubjs_result ubjs_prmtv_hpn ( ubjs_library lib,
unsigned int  length,
char *  text,
ubjs_prmtv **  pthis 
)

Returns high-precision number primitive for given string.

The string does not need to be null terminated. In fact, you must provide its length at first. Only bytes (0..length-1) will make into final primitive.

The string is parsed the same as json "number" type. See http://www.json.org/number.gif. If the string does not conform to the format, this method returns UR_ERROR.

After this returns UR_OK, *pthis points to a valid str primitive.

Parameters
libLibrary handle.
lengthThe length of the original string.
textOriginal string.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/text/pthis are 0, or string is invalid number. Else UR_OK.
Since
0.4

References UFALSE, UOT_HPN, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_hpn_copy_text()

UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_copy_text ( ubjs_prmtv this,
char *  result 
)

Copies the high-precision number primitive's string content to provided array.

Target array must be preallocated. Before the call, you may want to ubjs_prmtv_str_get_length and allocate the target array.

Parameters
thisPrimitive.
resultTarget array.
Returns
UR_ERROR if any of this/result is 0, or this is not a hpn, else UR_OK.

References UOT_HPN, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_hpn_get_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_get_length ( ubjs_prmtv this,
unsigned int *  result 
)

Gets the high-precision number primitive's string length.

Parameters
thisPrimitive.
resultPointer to where set the value.
Returns
UR_ERROR if any of this/result is 0, or this is not a hpn, else UR_OK.

References UOT_HPN, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_hpn_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_set ( ubjs_prmtv this,
unsigned int  length,
char *  text 
)

Sets the string value of the high-precision number primitive.

The string is parsed the same as json "number" type. See http://www.json.org/number.gif. If the string does not conform to the format, this method returns UR_ERROR.

Parameters
thisPrimitive.
lengthNew length of the string.
textNew string.
Returns
UR_ERROR if of any of this/text is 0, string is invalid number, or this is not a hpn. Else UR_OK.

References UFALSE, UOT_HPN, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_int()

UBJS_EXPORT ubjs_result ubjs_prmtv_int ( ubjs_library lib,
int64_t  value,
ubjs_prmtv **  pthis 
)

Returns the best int primitive wrapping given value.

After this returns UR_OK, *pthis points to a valid (u)int8/int16/int32/int64 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis is 0, else UR_OK.
Since
0.4

References ubjs_prmtv_int16(), ubjs_prmtv_int32(), ubjs_prmtv_int64(), ubjs_prmtv_int8(), ubjs_prmtv_uint8(), and UR_ERROR.

Here is the call graph for this function:

◆ ubjs_prmtv_int16()

UBJS_EXPORT ubjs_result ubjs_prmtv_int16 ( ubjs_library lib,
int16_t  value,
ubjs_prmtv **  pthis 
)

Returns int16 primitive for given value.

After this returns UR_OK, *pthis points to a valid int16 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if pthis is 0, else UR_OK.
Since
0.4

References UOT_INT16, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int(), and ubjs_prmtv_uint().

Here is the caller graph for this function:

◆ ubjs_prmtv_int16_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_int16_get ( ubjs_prmtv this,
int16_t *  pvalue 
)

Gets the value of the int16 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not an int16, else UR_OK.

References UOT_INT16, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int_get().

Here is the caller graph for this function:

◆ ubjs_prmtv_int16_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_int16_set ( ubjs_prmtv this,
int16_t  value 
)

Sets the value of the int16 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not an int16, else UR_OK.

References UOT_INT16, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_int32()

UBJS_EXPORT ubjs_result ubjs_prmtv_int32 ( ubjs_library lib,
int32_t  value,
ubjs_prmtv **  pthis 
)

Returns int32 primitive for given value.

After this returns UR_OK, *pthis points to a valid int32 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if pthis is 0, else UR_OK.
Since
0.4

References UOT_INT32, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int(), and ubjs_prmtv_uint().

Here is the caller graph for this function:

◆ ubjs_prmtv_int32_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_int32_get ( ubjs_prmtv this,
int32_t *  pvalue 
)

Gets the value of the int32 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not an int32, else UR_OK.

References UOT_INT32, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int_get().

Here is the caller graph for this function:

◆ ubjs_prmtv_int32_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_int32_set ( ubjs_prmtv this,
int32_t  value 
)

Sets the value of the int32 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not an int32, else UR_OK.

References UOT_INT32, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_int64()

UBJS_EXPORT ubjs_result ubjs_prmtv_int64 ( ubjs_library lib,
int64_t  value,
ubjs_prmtv **  pthis 
)

Returns int64 primitive for given value.

After this returns UR_OK, *pthis points to a valid int64 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if pthis is 0, else UR_OK.
Since
0.4

References UOT_INT64, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int(), and ubjs_prmtv_uint().

Here is the caller graph for this function:

◆ ubjs_prmtv_int64_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_int64_get ( ubjs_prmtv this,
int64_t *  pvalue 
)

Gets the value of the int8 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not an int64, else UR_OK.

References UOT_INT64, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int_get().

Here is the caller graph for this function:

◆ ubjs_prmtv_int64_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_int64_set ( ubjs_prmtv this,
int64_t  value 
)

Sets the value of the int64 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not an int64, else UR_OK.

References UOT_INT64, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_int8()

UBJS_EXPORT ubjs_result ubjs_prmtv_int8 ( ubjs_library lib,
int8_t  value,
ubjs_prmtv **  pthis 
)

Returns int8 primitive for given value.

After this returns UR_OK, *pthis points to a valid int8 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if pthis is 0, else UR_OK.
Since
0.4

References UOT_INT8, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int().

Here is the caller graph for this function:

◆ ubjs_prmtv_int8_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_int8_get ( ubjs_prmtv this,
int8_t *  pvalue 
)

Gets the value of the int8 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not an int8, else UR_OK.

References UOT_INT8, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int_get().

Here is the caller graph for this function:

◆ ubjs_prmtv_int8_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_int8_set ( ubjs_prmtv this,
int8_t  value 
)

Sets the value of the int8 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not an int8, else UR_OK.

References UOT_INT8, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_int_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_int_get ( ubjs_prmtv this,
int64_t *  pvalue 
)

Gets the value of the integer primitive, regardless of its type.

Recognized primitive types are (u)int8/int16/int32/int64. The output value is upcasted to int64_t.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, else UR_OK.

References ubjs_prmtv_int16_get(), ubjs_prmtv_int32_get(), ubjs_prmtv_int64_get(), ubjs_prmtv_int8_get(), ubjs_prmtv_uint8_get(), UOT_INT16, UOT_INT32, UOT_INT64, UOT_INT8, UOT_UINT8, UR_ERROR, and UR_OK.

Referenced by ubjs_parser_parse().

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

◆ ubjs_prmtv_is_array()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_array ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is an array primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_ARRAY, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_char()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_char ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a char primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_CHAR, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_false()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_false ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a false primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_float32()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_float32 ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a float32 primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_FLOAT32, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_float64()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_float64 ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a float64 primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_FLOAT64, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_hpn()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_hpn ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a high-precision number primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_HPN, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_int()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_int ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is any integer primitive.

Any integer primitive means (u)int8/int16/int32/int64.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_INT16, UOT_INT32, UOT_INT64, UOT_INT8, UOT_UINT8, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_int16()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_int16 ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is an int16 primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_INT16, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_int32()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_int32 ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is an int32 primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_INT32, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_int64()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_int64 ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is an int64 primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_INT64, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_int8()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_int8 ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is an int8 primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_INT8, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_noop()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_noop ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a no-op primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_null()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_null ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a null primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_object()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_object ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is an object primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_OBJECT, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_str()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_str ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a str primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_STR, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_true()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_true ( ubjs_prmtv this,
ubjs_bool result 
)

Checks whether the primitive is a true primitive.

Parameters
thisPrimitive.
resultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_is_uint8()

UBJS_EXPORT ubjs_result ubjs_prmtv_is_uint8 ( ubjs_prmtv this,
ubjs_bool presult 
)

Checks whether the primitive is an uint8 primitive.

Parameters
thisPrimitive.
presultPointer to where set the result - UTRUE/UFALSE.
Returns
UR_ERROR if any of this/result is 0, else UR_OK.

References UFALSE, UOT_UINT8, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_noop()

UBJS_EXPORT ubjs_prmtv* ubjs_prmtv_noop ( void  )

Returns no-op primitive.

This is a singleton and ubj_prmtv_free do nothing.

◆ ubjs_prmtv_null()

UBJS_EXPORT ubjs_prmtv* ubjs_prmtv_null ( void  )

Returns null primitive.

This is a singleton and ubj_prmtv_free do nothing.

◆ ubjs_prmtv_object()

UBJS_EXPORT ubjs_result ubjs_prmtv_object ( ubjs_library lib,
ubjs_prmtv **  pthis 
)

Returns object primitive for an empty object.

After this returns UR_OK, *pthis points to a valid object primitive.

Parameters
libLibrary handle.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis are 0, else UR_OK.
Since
0.4

References ubjs_glue_dict_builder::build_f, ubjs_glue_dict_builder::free_f, ubjs_glue_dict_builder::set_value_free_f, UOT_OBJECT, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_object_delete()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_delete ( ubjs_prmtv this,
unsigned int  key_length,
char *  key 
)

Deletes the value for specified key.

The value gets ubjs_prmtv_free-d.

Parameters
thisPrimitive.
key_lengthLength of the key.
keyKey.
Returns
UR_ERROR if any of this/key is 0, this is not an object, or there is no such key in object. Else UR_OK.

References UOT_OBJECT, and UR_ERROR.

◆ ubjs_prmtv_object_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_get ( ubjs_prmtv this,
unsigned int  key_length,
char *  key,
ubjs_prmtv **  pvalue 
)

Gets the value for specified key.

Parameters
thisPrimitive.
key_lengthLength of the key.
keyKey.
pvaluePointer to where put the value.
Returns
UR_ERROR if any of this/key/pvalue is 0, this is not an object, or there is no such key in object. Else UR_OK.

References UOT_OBJECT, and UR_ERROR.

◆ ubjs_prmtv_object_get_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_get_length ( ubjs_prmtv this,
unsigned int *  pvalue 
)

Gets the object primitive's length.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/result is 0, or this is not an object, else UR_OK.

References UOT_OBJECT, and UR_ERROR.

◆ ubjs_prmtv_object_iterate()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_iterate ( ubjs_prmtv this,
ubjs_object_iterator **  iterator 
)

Returns iterator over this object. The object must exist thru the life of the iterator. If you ubjs_prmtv_free the object before you ubjs_object_iterator_free, behavior is undefined.

After this returns UR_OK, *pthis points to new iterator. First call to ubjs_object_iterator_next will point to 0-th item.

Parameters
thisExisting object primitive.
iteratorPointer to where put newly created iterator.
Returns
UR_ERROR if any of this/iterator are 0, or this is not an object. Else UR_OK.

References UOT_OBJECT, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_object_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_set ( ubjs_prmtv this,
unsigned int  key_length,
char *  key,
ubjs_prmtv value 
)

Sets the value for specified key.

If there already exists such key in object, its value gets ubjs_prmtv_free-d.

Parameters
thisPrimitive.
key_lengthLength of the key.
keyKey.
valueNew value.
Returns
UR_ERROR if any of this/key is 0, this is not an object. Else UR_OK.

References UOT_OBJECT, and UR_ERROR.

◆ ubjs_prmtv_object_with_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_with_length ( ubjs_library lib,
unsigned int  length,
ubjs_prmtv **  pthis 
)

Returns object primitive for an empty object, with initial size known.

Call this if you know you will add n-items.

After this returns UR_OK, *pthis points to a valid object primitive.

Parameters
libLibrary handle.
lengthInitial length.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis are 0, else UR_OK.
Since
0.4

References ubjs_glue_dict_builder::build_f, ubjs_glue_dict_builder::free_f, ubjs_glue_dict_builder::set_length_f, ubjs_glue_dict_builder::set_value_free_f, UOT_OBJECT, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_object_with_length_and_type()

UBJS_EXPORT ubjs_result ubjs_prmtv_object_with_length_and_type ( ubjs_library lib,
ubjs_prmtv_type  type,
unsigned int  length,
ubjs_prmtv **  pthis 
)

Returns object primitive for an empty objecty, with initial size known and item type.

Call this if you know you will add n-items of exactly one type.

After this returns UR_OK, *pthis points to a valid object primitive.

Parameters
libLibrary handle.
typeItem type.
lengthLength.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/pthis are 0, else UR_OK.
Since
0.4

References UOT_MAX, and UR_ERROR.

◆ ubjs_prmtv_str()

UBJS_EXPORT ubjs_result ubjs_prmtv_str ( ubjs_library lib,
unsigned int  length,
char *  text,
ubjs_prmtv **  pthis 
)

Returns str primitive for given string.

The string does not need to be null terminated. In fact, you must provide its length at first. Only bytes (0..length-1) will make into final primitive.

After this returns UR_OK, *pthis points to a valid str primitive.

Parameters
libLibrary handle.
lengthThe length of the original string.
textOriginal string.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of lib/text/pthis are 0, else UR_OK.
Since
0.4

References UOT_STR, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_str_copy_text()

UBJS_EXPORT ubjs_result ubjs_prmtv_str_copy_text ( ubjs_prmtv this,
char *  result 
)

Copies the string primitive's content to provided array.

Target array must be preallocated. Before the call, you may want to ubjs_prmtv_str_get_length and allocate the target array.

Parameters
thisPrimitive.
resultTarget array.
Returns
UR_ERROR if any of this/result is 0, or this is not a str, else UR_OK.

References UOT_STR, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_str_get_length()

UBJS_EXPORT ubjs_result ubjs_prmtv_str_get_length ( ubjs_prmtv this,
unsigned int *  result 
)

Gets the string primitive's length.

Parameters
thisPrimitive.
resultPointer to where set the value.
Returns
UR_ERROR if any of this/result is 0, or this is not a str, else UR_OK.

References UOT_STR, UR_ERROR, and UR_OK.

◆ ubjs_prmtv_str_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_str_set ( ubjs_prmtv this,
unsigned int  length,
char *  text 
)

Sets the value of the string primitive.

Parameters
thisPrimitive.
lengthNew length of the string.
textNew string.
Returns
UR_ERROR if of any of this/text is 0, or this is not a str, else UR_OK.

References UFALSE, UOT_STR, UR_ERROR, UR_OK, and UTRUE.

◆ ubjs_prmtv_true()

UBJS_EXPORT ubjs_prmtv* ubjs_prmtv_true ( void  )

Returns true primitive.

This is a singleton and ubj_prmtv_free do nothing.

◆ ubjs_prmtv_uint()

UBJS_EXPORT ubjs_result ubjs_prmtv_uint ( ubjs_library lib,
int64_t  value,
ubjs_prmtv **  pthis 
)

Returns the best unsigned int primitive wrapping given value.

After this returns UR_OK, *pthis points to a valid uint8/int16/int32/int64 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if lib is 0, else UR_OK.
Since
0.4

References ubjs_prmtv_int16(), ubjs_prmtv_int32(), ubjs_prmtv_int64(), ubjs_prmtv_uint8(), and UR_ERROR.

Here is the call graph for this function:

◆ ubjs_prmtv_uint8()

UBJS_EXPORT ubjs_result ubjs_prmtv_uint8 ( ubjs_library lib,
uint8_t  value,
ubjs_prmtv **  pthis 
)

Returns uint8 primitive for given value.

After this returns UR_OK, *pthis points to a valid uint8 primitive.

Parameters
libLibrary handle.
valueThe value.
pthisPointer to where put newly created primitive.
Returns
UR_ERROR if any of pthis/lib is 0, else UR_OK.
Since
0.4

References UOT_UINT8, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int(), and ubjs_prmtv_uint().

Here is the caller graph for this function:

◆ ubjs_prmtv_uint8_get()

UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_get ( ubjs_prmtv this,
uint8_t *  pvalue 
)

Gets the value of the uint8 primitive.

Parameters
thisPrimitive.
pvaluePointer to where set the value.
Returns
UR_ERROR if any of this/pvalue is 0, or this is not an uint8, else UR_OK.

References UOT_UINT8, UR_ERROR, and UR_OK.

Referenced by ubjs_prmtv_int_get().

Here is the caller graph for this function:

◆ ubjs_prmtv_uint8_set()

UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_set ( ubjs_prmtv this,
uint8_t  value 
)

Sets the value of the uint8 primitive.

Parameters
thisPrimitive.
valueNew value.
Returns
UR_ERROR if of this is 0, or this is not an uint8, else UR_OK.

References UOT_UINT8, UR_ERROR, and UR_OK.