123 #ifndef HAVE_UBJS_PRIMITIVES 124 #define HAVE_UBJS_PRIMITIVES 647 ubjs_prmtv_type type,
unsigned int length,
ubjs_prmtv **pthis);
836 ubjs_prmtv_type type,
unsigned int length,
ubjs_prmtv **pthis);
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.
Definition: ubjs_primitives.c:1031
Library handle, allocation callbacks, glues.
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.
Definition: ubjs_primitives.c:1863
UBJS_EXPORT ubjs_result ubjs_prmtv_float32(ubjs_library *lib, float32_t value, ubjs_prmtv **pthis)
Returns float32 primitive for given value.
Definition: ubjs_primitives.c:485
UBJS_EXPORT ubjs_result ubjs_prmtv_array(ubjs_library *lib, ubjs_prmtv **pthis)
Returns array primitive for an empty array.
Definition: ubjs_primitives.c:1058
UBJS_EXPORT ubjs_result ubjs_prmtv_is_hpn(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a high-precision number primitive.
Definition: ubjs_primitives.c:988
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.
Definition: ubjs_primitives.c:1565
UBJS_EXPORT ubjs_result ubjs_prmtv_float32_get(ubjs_prmtv *this, float32_t *pvalue)
Gets the value of the int32 primitive.
Definition: ubjs_primitives.c:514
Definitions of common types, ubjson markers and some utilities.
struct ubjs_prmtv ubjs_prmtv
Definition: ubjs_primitives.h:166
UBJS_EXPORT ubjs_result ubjs_prmtv_is_char(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a char primitive.
Definition: ubjs_primitives.c:615
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_null(void)
Returns null primitive.
Definition: ubjs_primitives.c:35
Definition: ubjs_primitives.h:157
UBJS_EXPORT ubjs_result ubjs_prmtv_is_uint8(ubjs_prmtv *this, ubjs_bool *presult)
Checks whether the primitive is an uint8 primitive.
Definition: ubjs_primitives.c:283
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_last(ubjs_prmtv *this)
Deletes the last item from array primitive.
Definition: ubjs_primitives.c:1314
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.
Definition: ubjs_primitives.c:1380
Definition: ubjs_primitives.h:162
UBJS_EXPORT ubjs_result ubjs_prmtv_is_str(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a str primitive.
Definition: ubjs_primitives.c:676
Definition: ubjs_primitives.h:151
UBJS_EXPORT ubjs_result ubjs_prmtv_int16_get(ubjs_prmtv *this, int16_t *pvalue)
Gets the value of the int16 primitive.
Definition: ubjs_primitives.c:349
UBJS_EXPORT ubjs_result ubjs_prmtv_str_copy_text(ubjs_prmtv *this, char *result)
Copies the string primitive's content to provided array.
Definition: ubjs_primitives.c:703
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...
Definition: ubjs_primitives.c:1759
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int8(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is an int8 primitive.
Definition: ubjs_primitives.c:228
Definition: ubjs_primitives.h:154
Definition: ubjs_primitives.h:160
Library handle.
Definition: ubjs_library.h:827
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int16(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is an int16 primitive.
Definition: ubjs_primitives.c:338
UBJS_EXPORT ubjs_result ubjs_object_iterator_next(ubjs_object_iterator *this)
Tries to advance the object iterator.
Definition: ubjs_primitives.c:1627
Definition: ubjs_primitives.h:156
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_first(ubjs_prmtv *this, ubjs_prmtv **pitem)
Gets reference to first item of the array primitive.
Definition: ubjs_primitives.c:1223
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.
Definition: ubjs_primitives.c:1684
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is any integer primitive.
Definition: ubjs_primitives.c:193
UBJS_EXPORT ubjs_result ubjs_prmtv_object_get_length(ubjs_prmtv *this, unsigned int *pvalue)
Gets the object primitive's length.
Definition: ubjs_primitives.c:1553
UBJS_EXPORT ubjs_result ubjs_prmtv_is_float32(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a float32 primitive.
Definition: ubjs_primitives.c:503
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_false(void)
Returns false primitive.
Definition: ubjs_primitives.c:83
UBJS_EXPORT ubjs_result ubjs_prmtv_int16(ubjs_library *lib, int16_t value, ubjs_prmtv **pthis)
Returns int16 primitive for given value.
Definition: ubjs_primitives.c:320
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_length(ubjs_prmtv *this, unsigned int *length)
Gets the array primitive's length.
Definition: ubjs_primitives.c:1210
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.
Definition: ubjs_primitives.c:1262
UBJS_EXPORT ubjs_result ubjs_prmtv_str_get_length(ubjs_prmtv *this, unsigned int *result)
Gets the string primitive's length.
Definition: ubjs_primitives.c:687
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int32(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is an int32 primitive.
Definition: ubjs_primitives.c:393
UBJS_EXPORT ubjs_result ubjs_array_iterator_next(ubjs_array_iterator *this)
Tries to advance the array iterator.
Definition: ubjs_primitives.c:1360
ubjs_bool
Wrapper around regular C-like booleans.
Definition: ubjs_common.h:59
struct ubjs_array_iterator ubjs_array_iterator
Definition: ubjs_primitives.h:169
UBJS_EXPORT ubjs_result ubjs_prmtv_char(ubjs_library *lib, char value, ubjs_prmtv **pthis)
Returns char primitive for given value.
Definition: ubjs_primitives.c:597
UBJS_EXPORT ubjs_result ubjs_prmtv_int8_get(ubjs_prmtv *this, int8_t *pvalue)
Gets the value of the int8 primitive.
Definition: ubjs_primitives.c:239
UBJS_EXPORT ubjs_result ubjs_prmtv_str(ubjs_library *lib, unsigned int length, char *text, ubjs_prmtv **pthis)
Returns str primitive for given string.
Definition: ubjs_primitives.c:653
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.
Definition: ubjs_primitives.c:1015
UBJS_EXPORT ubjs_result ubjs_prmtv_object(ubjs_library *lib, ubjs_prmtv **pthis)
Returns object primitive for an empty object.
Definition: ubjs_primitives.c:1401
UBJS_EXPORT ubjs_result ubjs_prmtv_is_object(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is an object primitive.
Definition: ubjs_primitives.c:1542
UBJS_EXPORT ubjs_result ubjs_prmtv_free(ubjs_prmtv **pthis)
Frees the primitive. After this returns UR_OK, *pthis is equal to 0.
Definition: ubjs_primitives.c:1695
UBJS_EXPORT ubjs_result ubjs_prmtv_float64_set(ubjs_prmtv *this, float64_t value)
Sets the value of the float64 primitive.
Definition: ubjs_primitives.c:584
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.
Definition: ubjs_primitives.c:126
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.
Definition: ubjs_primitives.c:1606
Definition: ubjs_primitives.h:161
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.
Definition: ubjs_primitives.c:1579
UBJS_EXPORT ubjs_result ubjs_array_iterator_get(ubjs_array_iterator *this, ubjs_prmtv **item)
Gets the item from the array iterator.
Definition: ubjs_primitives.c:1370
UBJS_EXPORT ubjs_result ubjs_prmtv_int64_get(ubjs_prmtv *this, int64_t *pvalue)
Gets the value of the int8 primitive.
Definition: ubjs_primitives.c:459
Definition: ubjs_primitives.h:158
UBJS_EXPORT ubjs_result ubjs_prmtv_char_get(ubjs_prmtv *this, char *pvalue)
Gets the value of the char primitive.
Definition: ubjs_primitives.c:626
Definition: ubjs_primitives.h:149
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.
Definition: ubjs_primitives.c:958
UBJS_EXPORT ubjs_result ubjs_prmtv_int64(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis)
Returns int64 primitive for given value.
Definition: ubjs_primitives.c:430
ubjs_result
Enum that defines the result of a method.
Definition: ubjs_common.h:73
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_first(ubjs_prmtv *this)
Deletes the first item from array primitive.
Definition: ubjs_primitives.c:1301
Definition: ubjs_primitives.h:152
UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_get_length(ubjs_prmtv *this, unsigned int *result)
Gets the high-precision number primitive's string length.
Definition: ubjs_primitives.c:999
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.
Definition: ubjs_primitives.c:1288
struct ubjs_object_iterator ubjs_object_iterator
Definition: ubjs_primitives.h:172
Definition: ubjs_primitives.h:159
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_true(void)
Returns true primitive.
Definition: ubjs_primitives.c:67
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.
Definition: ubjs_primitives.c:1249
UBJS_EXPORT ubjs_result ubjs_prmtv_int32(ubjs_library *lib, int32_t value, ubjs_prmtv **pthis)
Returns int32 primitive for given value.
Definition: ubjs_primitives.c:375
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.
Definition: ubjs_primitives.c:1108
UBJS_EXPORT ubjs_result ubjs_object_iterator_get_value(ubjs_object_iterator *this, ubjs_prmtv **pvalue)
Gets the value from the object iterator.
Definition: ubjs_primitives.c:1657
UBJS_EXPORT ubjs_result ubjs_prmtv_is_float64(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a float64 primitive.
Definition: ubjs_primitives.c:559
UBJS_EXPORT ubjs_result ubjs_prmtv_int32_set(ubjs_prmtv *this, int32_t value)
Sets the value of the int32 primitive.
Definition: ubjs_primitives.c:417
UBJS_EXPORT ubjs_result ubjs_prmtv_int16_set(ubjs_prmtv *this, int16_t value)
Sets the value of the int16 primitive.
Definition: ubjs_primitives.c:362
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.
Definition: ubjs_primitives.c:1082
UBJS_EXPORT ubjs_result ubjs_prmtv_is_array(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is an array primitive.
Definition: ubjs_primitives.c:1199
UBJS_EXPORT ubjs_result ubjs_prmtv_float32_set(ubjs_prmtv *this, float32_t value)
Sets the value of the float32 primitive.
Definition: ubjs_primitives.c:528
UBJS_EXPORT ubjs_result ubjs_prmtv_int32_get(ubjs_prmtv *this, int32_t *pvalue)
Gets the value of the int32 primitive.
Definition: ubjs_primitives.c:404
UBJS_EXPORT ubjs_result ubjs_prmtv_char_set(ubjs_prmtv *this, char value)
Sets the value of the char primitive.
Definition: ubjs_primitives.c:640
UBJS_EXPORT ubjs_result ubjs_prmtv_uint8(ubjs_library *lib, uint8_t value, ubjs_prmtv **pthis)
Returns uint8 primitive for given value.
Definition: ubjs_primitives.c:265
UBJS_EXPORT ubjs_result ubjs_prmtv_is_int64(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is an int64 primitive.
Definition: ubjs_primitives.c:448
Definition: ubjs_primitives.h:155
UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_set(ubjs_prmtv *this, uint8_t value)
Sets the value of the uint8 primitive.
Definition: ubjs_primitives.c:307
UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_last(ubjs_prmtv *this, ubjs_prmtv **pitem)
Gets reference to last item of the array primitive.
Definition: ubjs_primitives.c:1236
UBJS_EXPORT ubjs_result ubjs_prmtv_int8_set(ubjs_prmtv *this, int8_t value)
Sets the value of the int8 primitive.
Definition: ubjs_primitives.c:252
UBJS_EXPORT ubjs_result ubjs_prmtv_array_iterate(ubjs_prmtv *this, ubjs_array_iterator **iterator)
Returns iterator over this array.
Definition: ubjs_primitives.c:1340
double float64_t
Typedef to have consistency in naming all int/float types.
Definition: ubjs_common.h:51
Definition: ubjs_primitives.h:150
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.
Definition: ubjs_primitives.c:1451
Definition: ubjs_primitives.h:148
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.
Definition: ubjs_primitives.c:1425
UBJS_EXPORT ubjs_result ubjs_prmtv_float64_get(ubjs_prmtv *this, float64_t *pvalue)
Gets the value of the int64 primitive.
Definition: ubjs_primitives.c:570
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.
Definition: ubjs_primitives.c:1275
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_at(ubjs_prmtv *this, unsigned int pos)
Deletes the n-th item from array primitive.
Definition: ubjs_primitives.c:1327
Definition: ubjs_primitives.h:153
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.
Definition: ubjs_primitives.c:1637
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.
Definition: ubjs_primitives.c:1647
float float32_t
Typedef to have consistency in naming all int/float types.
Definition: ubjs_common.h:45
UBJS_EXPORT ubjs_result ubjs_prmtv_float64(ubjs_library *lib, float64_t value, ubjs_prmtv **pthis)
Returns float64 primitive for given value.
Definition: ubjs_primitives.c:541
UBJS_EXPORT ubjs_result ubjs_prmtv_is_null(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a null primitive.
Definition: ubjs_primitives.c:40
UBJS_EXPORT ubjs_result ubjs_prmtv_object_delete(ubjs_prmtv *this, unsigned int key_length, char *key)
Deletes the value for specified key.
Definition: ubjs_primitives.c:1593
UBJS_EXPORT ubjs_result ubjs_prmtv_int8(ubjs_library *lib, int8_t value, ubjs_prmtv **pthis)
Returns int8 primitive for given value.
Definition: ubjs_primitives.c:210
UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_get(ubjs_prmtv *this, uint8_t *pvalue)
Gets the value of the uint8 primitive.
Definition: ubjs_primitives.c:294
UBJS_EXPORT ubjs_result ubjs_prmtv_is_false(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a false primitive.
Definition: ubjs_primitives.c:88
UBJS_EXPORT ubjs_result ubjs_prmtv_is_true(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a true primitive.
Definition: ubjs_primitives.c:72
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_noop(void)
Returns no-op primitive.
Definition: ubjs_primitives.c:51
UBJS_EXPORT ubjs_result ubjs_prmtv_int64_set(ubjs_prmtv *this, int64_t value)
Sets the value of the int64 primitive.
Definition: ubjs_primitives.c:472
UBJS_EXPORT ubjs_result ubjs_prmtv_int(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis)
Returns the best int primitive wrapping given value.
Definition: ubjs_primitives.c:99
UBJS_EXPORT ubjs_result ubjs_prmtv_is_noop(ubjs_prmtv *this, ubjs_bool *result)
Checks whether the primitive is a no-op primitive.
Definition: ubjs_primitives.c:56
ubjs_prmtv_type
Definition: ubjs_primitives.h:144
Definition: ubjs_primitives.h:147
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.
Definition: ubjs_primitives.c:1667
UBJS_EXPORT ubjs_result ubjs_prmtv_str_set(ubjs_prmtv *this, unsigned int length, char *text)
Sets the value of the string primitive.
Definition: ubjs_primitives.c:719
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.
Definition: ubjs_primitives.c:149