123 #ifndef HAVE_UBJS_PRIMITIVES 124 #define HAVE_UBJS_PRIMITIVES 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:971
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_false()
Returns false primitive.
Definition: ubjs_primitives.c:82
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:1707
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:484
UBJS_EXPORT ubjs_result ubjs_prmtv_array(ubjs_library *lib, ubjs_prmtv **pthis)
Returns array primitive for an empty array.
Definition: ubjs_primitives.c:998
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:928
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:1404
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:513
Definitions of common types, ubjson markers and some utilities.
struct ubjs_prmtv ubjs_prmtv
Definition: ubjs_primitives.h:165
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:614
Definition: ubjs_primitives.h:156
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:282
UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_last(ubjs_prmtv *this)
Deletes the last item from array primitive.
Definition: ubjs_primitives.c:1237
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:1342
Definition: ubjs_primitives.h:161
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:675
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_null()
Returns null primitive.
Definition: ubjs_primitives.c:34
Definition: ubjs_primitives.h:150
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:348
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:702
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:1606
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:227
Definition: ubjs_primitives.h:153
Definition: ubjs_primitives.h:159
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:337
UBJS_EXPORT ubjs_result ubjs_object_iterator_next(ubjs_object_iterator *this)
Tries to advance the object iterator.
Definition: ubjs_primitives.c:1467
Definition: ubjs_primitives.h:155
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:1045
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:1524
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:192
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:1392
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:502
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:319
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:1031
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:1142
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:686
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:392
UBJS_EXPORT ubjs_result ubjs_array_iterator_next(ubjs_array_iterator *this)
Tries to advance the array iterator.
Definition: ubjs_primitives.c:1311
ubjs_bool
Wrapper around regular C-like booleans.
Definition: ubjs_common.h:59
struct ubjs_array_iterator ubjs_array_iterator
Definition: ubjs_primitives.h:168
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:596
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:238
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:652
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:955
UBJS_EXPORT ubjs_result ubjs_prmtv_object(ubjs_library *lib, ubjs_prmtv **pthis)
Returns object primitive for an empty object.
Definition: ubjs_primitives.c:1362
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:1381
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:1535
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:583
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:125
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:1457
Definition: ubjs_primitives.h:160
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:1418
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_true()
Returns true primitive.
Definition: ubjs_primitives.c:66
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:1331
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:458
Definition: ubjs_primitives.h:157
UBJS_EXPORT ubjs_result ubjs_prmtv_char_get(ubjs_prmtv *this, char *pvalue)
Gets the value of the char primitive.
Definition: ubjs_primitives.c:625
Definition: ubjs_primitives.h:148
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:898
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:429
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:1209
Definition: ubjs_primitives.h:151
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:939
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:1182
struct ubjs_object_iterator ubjs_object_iterator
Definition: ubjs_primitives.h:171
Definition: ubjs_primitives.h:158
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:1081
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:374
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:1497
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:558
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:416
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:361
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:1019
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:527
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:403
UBJS_EXPORT ubjs_prmtv * ubjs_prmtv_noop()
Returns no-op primitive.
Definition: ubjs_primitives.c:50
UBJS_EXPORT ubjs_result ubjs_prmtv_char_set(ubjs_prmtv *this, char value)
Sets the value of the char primitive.
Definition: ubjs_primitives.c:639
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:264
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:447
Definition: ubjs_primitives.h:154
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:306
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:1063
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:251
UBJS_EXPORT ubjs_result ubjs_prmtv_array_iterate(ubjs_prmtv *this, ubjs_array_iterator **iterator)
Returns iterator over this array.
Definition: ubjs_primitives.c:1298
double float64_t
Typedef to have consistency in naming all int/float types.
Definition: ubjs_common.h:51
Definition: ubjs_primitives.h:149
Definition: ubjs_primitives.h:147
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:569
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:1166
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:1258
Definition: ubjs_primitives.h:152
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:1477
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:1487
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:540
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:39
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:1432
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:209
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:293
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:87
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:71
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:471
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:98
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:55
struct ubjs_library ubjs_library
Library handle.
Definition: ubjs_common.h:203
ubjs_prmtv_type
Definition: ubjs_primitives.h:143
Definition: ubjs_primitives.h:146
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:1507
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:718
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:148