ubjsc  0.4-dev
Enterprise-grade C library for manipulating UBJSON
ubjs_primitives.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Tomasz Sieprawski
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  **/
123 #ifndef HAVE_UBJS_PRIMITIVES
124 #define HAVE_UBJS_PRIMITIVES
125 
126 #ifdef __cplusplus
127 extern "C"
128 {
129 #endif
130 
131 #include "ubjs_common.h"
132 
134 struct ubjs_prmtv;
135 
137 struct ubjs_array_iterator;
138 
140 struct ubjs_object_iterator;
141 
144 {
145  UOT_NULL,
162 };
163 
165 typedef struct ubjs_prmtv ubjs_prmtv;
166 
169 
172 
175 
180 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_null();
187 UBJS_EXPORT ubjs_result ubjs_prmtv_is_null(ubjs_prmtv *this, ubjs_bool *result);
188 
193 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_noop();
200 UBJS_EXPORT ubjs_result ubjs_prmtv_is_noop(ubjs_prmtv *this, ubjs_bool *result);
201 
206 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_true();
213 UBJS_EXPORT ubjs_result ubjs_prmtv_is_true(ubjs_prmtv *this, ubjs_bool *result);
214 
219 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_false();
226 UBJS_EXPORT ubjs_result ubjs_prmtv_is_false(ubjs_prmtv *this, ubjs_bool *result);
227 
237 UBJS_EXPORT ubjs_result ubjs_prmtv_int(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis);
247 UBJS_EXPORT ubjs_result ubjs_prmtv_uint(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis);
255 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int(ubjs_prmtv *this, ubjs_bool *result);
264 UBJS_EXPORT ubjs_result ubjs_prmtv_int_get(ubjs_prmtv *this, int64_t *pvalue);
265 
275 UBJS_EXPORT ubjs_result ubjs_prmtv_int8(ubjs_library *lib, int8_t value, ubjs_prmtv **pthis);
282 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int8(ubjs_prmtv *this, ubjs_bool *result);
288 UBJS_EXPORT ubjs_result ubjs_prmtv_int8_get(ubjs_prmtv *this, int8_t *pvalue);
294 UBJS_EXPORT ubjs_result ubjs_prmtv_int8_set(ubjs_prmtv *this, int8_t value);
295 
305 UBJS_EXPORT ubjs_result ubjs_prmtv_uint8(ubjs_library *lib, uint8_t value, ubjs_prmtv **pthis);
312 UBJS_EXPORT ubjs_result ubjs_prmtv_is_uint8(ubjs_prmtv *this, ubjs_bool *presult);
318 UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_get(ubjs_prmtv *this, uint8_t *pvalue);
324 UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_set(ubjs_prmtv *this, uint8_t value);
325 
335 UBJS_EXPORT ubjs_result ubjs_prmtv_int16(ubjs_library *lib, int16_t value, ubjs_prmtv **pthis);
342 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int16(ubjs_prmtv *this, ubjs_bool *result);
348 UBJS_EXPORT ubjs_result ubjs_prmtv_int16_get(ubjs_prmtv *this, int16_t *pvalue);
354 UBJS_EXPORT ubjs_result ubjs_prmtv_int16_set(ubjs_prmtv *this, int16_t value);
355 
365 UBJS_EXPORT ubjs_result ubjs_prmtv_int32(ubjs_library *lib, int32_t value, ubjs_prmtv **pthis);
372 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int32(ubjs_prmtv *this, ubjs_bool *result);
378 UBJS_EXPORT ubjs_result ubjs_prmtv_int32_get(ubjs_prmtv *this, int32_t *pvalue);
384 UBJS_EXPORT ubjs_result ubjs_prmtv_int32_set(ubjs_prmtv *this, int32_t value);
385 
395 UBJS_EXPORT ubjs_result ubjs_prmtv_int64(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis);
402 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int64(ubjs_prmtv *this, ubjs_bool *result);
408 UBJS_EXPORT ubjs_result ubjs_prmtv_int64_get(ubjs_prmtv *this, int64_t *pvalue);
414 UBJS_EXPORT ubjs_result ubjs_prmtv_int64_set(ubjs_prmtv *this, int64_t value);
415 
425 UBJS_EXPORT ubjs_result ubjs_prmtv_float32(ubjs_library *lib, float32_t value, ubjs_prmtv **pthis);
432 UBJS_EXPORT ubjs_result ubjs_prmtv_is_float32(ubjs_prmtv *this, ubjs_bool *result);
438 UBJS_EXPORT ubjs_result ubjs_prmtv_float32_get(ubjs_prmtv *this, float32_t *pvalue);
444 UBJS_EXPORT ubjs_result ubjs_prmtv_float32_set(ubjs_prmtv *this, float32_t value);
445 
455 UBJS_EXPORT ubjs_result ubjs_prmtv_float64(ubjs_library *lib, float64_t value, ubjs_prmtv **pthis);
462 UBJS_EXPORT ubjs_result ubjs_prmtv_is_float64(ubjs_prmtv *this, ubjs_bool *result);
468 UBJS_EXPORT ubjs_result ubjs_prmtv_float64_get(ubjs_prmtv *this, float64_t *pvalue);
474 UBJS_EXPORT ubjs_result ubjs_prmtv_float64_set(ubjs_prmtv *this, float64_t value);
475 
494 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn(ubjs_library *lib, unsigned int length, char *text,
495  ubjs_prmtv **pthis);
502 UBJS_EXPORT ubjs_result ubjs_prmtv_is_hpn(ubjs_prmtv *this, ubjs_bool *result);
508 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_get_length(ubjs_prmtv *this, unsigned int *result);
517 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_copy_text(ubjs_prmtv *this, char *result);
529 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_set(ubjs_prmtv *this, unsigned int length, char *text);
530 
539 UBJS_EXPORT ubjs_result ubjs_prmtv_char(ubjs_library *lib, char value, ubjs_prmtv **pthis);
546 UBJS_EXPORT ubjs_result ubjs_prmtv_is_char(ubjs_prmtv *this, ubjs_bool *result);
552 UBJS_EXPORT ubjs_result ubjs_prmtv_char_get(ubjs_prmtv *this, char *pvalue);
558 UBJS_EXPORT ubjs_result ubjs_prmtv_char_set(ubjs_prmtv *this, char value);
559 
574 UBJS_EXPORT ubjs_result ubjs_prmtv_str(ubjs_library *lib, unsigned int length, char *text,
575  ubjs_prmtv **pthis);
582 UBJS_EXPORT ubjs_result ubjs_prmtv_is_str(ubjs_prmtv *this, ubjs_bool *result);
588 UBJS_EXPORT ubjs_result ubjs_prmtv_str_get_length(ubjs_prmtv *this, unsigned int *result);
597 UBJS_EXPORT ubjs_result ubjs_prmtv_str_copy_text(ubjs_prmtv *this, char *result);
604 UBJS_EXPORT ubjs_result ubjs_prmtv_str_set(ubjs_prmtv *this, unsigned int length, char *text);
605 
615 UBJS_EXPORT ubjs_result ubjs_prmtv_array(ubjs_library *lib, ubjs_prmtv **pthis);
622 UBJS_EXPORT ubjs_result ubjs_prmtv_is_array(ubjs_prmtv *this, ubjs_bool *result);
628 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_length(ubjs_prmtv *this, unsigned int *length);
637 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_first(ubjs_prmtv *this, ubjs_prmtv **pitem);
646 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_last(ubjs_prmtv *this, ubjs_prmtv **pitem);
656 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_at(ubjs_prmtv *this, unsigned int pos,
657  ubjs_prmtv **pitem);
690 UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_at(ubjs_prmtv *this, unsigned int pos,
691  ubjs_prmtv *item);
725 UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_at(ubjs_prmtv *this, unsigned int pos);
726 
764 
774 UBJS_EXPORT ubjs_result ubjs_prmtv_object(ubjs_library *lib, ubjs_prmtv **pthis);
781 UBJS_EXPORT ubjs_result ubjs_prmtv_is_object(ubjs_prmtv *this, ubjs_bool *result);
787 UBJS_EXPORT ubjs_result ubjs_prmtv_object_get_length(ubjs_prmtv *this, unsigned int *pvalue);
796 UBJS_EXPORT ubjs_result ubjs_prmtv_object_get(ubjs_prmtv *this, unsigned int key_length,
797  char *key, ubjs_prmtv **pvalue);
807 UBJS_EXPORT ubjs_result ubjs_prmtv_object_set(ubjs_prmtv *this, unsigned int key_length,
808  char *key, ubjs_prmtv *value);
818 UBJS_EXPORT ubjs_result ubjs_prmtv_object_delete(ubjs_prmtv *this, unsigned int key_length,
819  char *key);
820 
832  ubjs_object_iterator **iterator);
858  unsigned int *plen);
874 UBJS_EXPORT ubjs_result ubjs_object_iterator_copy_key(ubjs_object_iterator *this, char *text);
875 
889  ubjs_prmtv **pvalue);
890 
897 
904 
911 UBJS_EXPORT ubjs_result ubjs_prmtv_get_type(ubjs_prmtv *this, ubjs_prmtv_type *ptype);
912 
919 UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_get_length(ubjs_prmtv *this, unsigned int *plen);
920 
929 UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_copy(ubjs_prmtv *this, char *str);
930 
936 UBJS_EXPORT ubjs_result ubjs_prmtv_free(ubjs_prmtv **pthis);
937 
938 #ifdef __cplusplus
939 }
940 #endif
941 
942 #endif
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