ubjsc  0.5
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 #include "ubjs_library.h"
133 
135 struct ubjs_prmtv;
136 
138 struct ubjs_array_iterator;
139 
141 struct ubjs_object_iterator;
142 
145 {
146  UOT_NULL,
163 };
164 
166 typedef struct ubjs_prmtv ubjs_prmtv;
167 
170 
173 
176 
181 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_null(void);
188 UBJS_EXPORT ubjs_result ubjs_prmtv_is_null(ubjs_prmtv *this, ubjs_bool *result);
189 
194 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_noop(void);
201 UBJS_EXPORT ubjs_result ubjs_prmtv_is_noop(ubjs_prmtv *this, ubjs_bool *result);
202 
207 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_true(void);
214 UBJS_EXPORT ubjs_result ubjs_prmtv_is_true(ubjs_prmtv *this, ubjs_bool *result);
215 
220 UBJS_EXPORT ubjs_prmtv *ubjs_prmtv_false(void);
227 UBJS_EXPORT ubjs_result ubjs_prmtv_is_false(ubjs_prmtv *this, ubjs_bool *result);
228 
238 UBJS_EXPORT ubjs_result ubjs_prmtv_int(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis);
248 UBJS_EXPORT ubjs_result ubjs_prmtv_uint(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis);
256 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int(ubjs_prmtv *this, ubjs_bool *result);
265 UBJS_EXPORT ubjs_result ubjs_prmtv_int_get(ubjs_prmtv *this, int64_t *pvalue);
266 
276 UBJS_EXPORT ubjs_result ubjs_prmtv_int8(ubjs_library *lib, int8_t value, ubjs_prmtv **pthis);
283 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int8(ubjs_prmtv *this, ubjs_bool *result);
289 UBJS_EXPORT ubjs_result ubjs_prmtv_int8_get(ubjs_prmtv *this, int8_t *pvalue);
295 UBJS_EXPORT ubjs_result ubjs_prmtv_int8_set(ubjs_prmtv *this, int8_t value);
296 
306 UBJS_EXPORT ubjs_result ubjs_prmtv_uint8(ubjs_library *lib, uint8_t value, ubjs_prmtv **pthis);
313 UBJS_EXPORT ubjs_result ubjs_prmtv_is_uint8(ubjs_prmtv *this, ubjs_bool *presult);
319 UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_get(ubjs_prmtv *this, uint8_t *pvalue);
325 UBJS_EXPORT ubjs_result ubjs_prmtv_uint8_set(ubjs_prmtv *this, uint8_t value);
326 
336 UBJS_EXPORT ubjs_result ubjs_prmtv_int16(ubjs_library *lib, int16_t value, ubjs_prmtv **pthis);
343 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int16(ubjs_prmtv *this, ubjs_bool *result);
349 UBJS_EXPORT ubjs_result ubjs_prmtv_int16_get(ubjs_prmtv *this, int16_t *pvalue);
355 UBJS_EXPORT ubjs_result ubjs_prmtv_int16_set(ubjs_prmtv *this, int16_t value);
356 
366 UBJS_EXPORT ubjs_result ubjs_prmtv_int32(ubjs_library *lib, int32_t value, ubjs_prmtv **pthis);
373 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int32(ubjs_prmtv *this, ubjs_bool *result);
379 UBJS_EXPORT ubjs_result ubjs_prmtv_int32_get(ubjs_prmtv *this, int32_t *pvalue);
385 UBJS_EXPORT ubjs_result ubjs_prmtv_int32_set(ubjs_prmtv *this, int32_t value);
386 
396 UBJS_EXPORT ubjs_result ubjs_prmtv_int64(ubjs_library *lib, int64_t value, ubjs_prmtv **pthis);
403 UBJS_EXPORT ubjs_result ubjs_prmtv_is_int64(ubjs_prmtv *this, ubjs_bool *result);
409 UBJS_EXPORT ubjs_result ubjs_prmtv_int64_get(ubjs_prmtv *this, int64_t *pvalue);
415 UBJS_EXPORT ubjs_result ubjs_prmtv_int64_set(ubjs_prmtv *this, int64_t value);
416 
426 UBJS_EXPORT ubjs_result ubjs_prmtv_float32(ubjs_library *lib, float32_t value, ubjs_prmtv **pthis);
433 UBJS_EXPORT ubjs_result ubjs_prmtv_is_float32(ubjs_prmtv *this, ubjs_bool *result);
439 UBJS_EXPORT ubjs_result ubjs_prmtv_float32_get(ubjs_prmtv *this, float32_t *pvalue);
445 UBJS_EXPORT ubjs_result ubjs_prmtv_float32_set(ubjs_prmtv *this, float32_t value);
446 
456 UBJS_EXPORT ubjs_result ubjs_prmtv_float64(ubjs_library *lib, float64_t value, ubjs_prmtv **pthis);
463 UBJS_EXPORT ubjs_result ubjs_prmtv_is_float64(ubjs_prmtv *this, ubjs_bool *result);
469 UBJS_EXPORT ubjs_result ubjs_prmtv_float64_get(ubjs_prmtv *this, float64_t *pvalue);
475 UBJS_EXPORT ubjs_result ubjs_prmtv_float64_set(ubjs_prmtv *this, float64_t value);
476 
495 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn(ubjs_library *lib, unsigned int length, char *text,
496  ubjs_prmtv **pthis);
503 UBJS_EXPORT ubjs_result ubjs_prmtv_is_hpn(ubjs_prmtv *this, ubjs_bool *result);
509 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_get_length(ubjs_prmtv *this, unsigned int *result);
518 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_copy_text(ubjs_prmtv *this, char *result);
530 UBJS_EXPORT ubjs_result ubjs_prmtv_hpn_set(ubjs_prmtv *this, unsigned int length, char *text);
531 
540 UBJS_EXPORT ubjs_result ubjs_prmtv_char(ubjs_library *lib, char value, ubjs_prmtv **pthis);
547 UBJS_EXPORT ubjs_result ubjs_prmtv_is_char(ubjs_prmtv *this, ubjs_bool *result);
553 UBJS_EXPORT ubjs_result ubjs_prmtv_char_get(ubjs_prmtv *this, char *pvalue);
559 UBJS_EXPORT ubjs_result ubjs_prmtv_char_set(ubjs_prmtv *this, char value);
560 
575 UBJS_EXPORT ubjs_result ubjs_prmtv_str(ubjs_library *lib, unsigned int length, char *text,
576  ubjs_prmtv **pthis);
583 UBJS_EXPORT ubjs_result ubjs_prmtv_is_str(ubjs_prmtv *this, ubjs_bool *result);
589 UBJS_EXPORT ubjs_result ubjs_prmtv_str_get_length(ubjs_prmtv *this, unsigned int *result);
598 UBJS_EXPORT ubjs_result ubjs_prmtv_str_copy_text(ubjs_prmtv *this, char *result);
605 UBJS_EXPORT ubjs_result ubjs_prmtv_str_set(ubjs_prmtv *this, unsigned int length, char *text);
606 
616 UBJS_EXPORT ubjs_result ubjs_prmtv_array(ubjs_library *lib, ubjs_prmtv **pthis);
617 
630 UBJS_EXPORT ubjs_result ubjs_prmtv_array_with_length(ubjs_library *lib, unsigned int length,
631  ubjs_prmtv **pthis);
632 
647  ubjs_prmtv_type type, unsigned int length, ubjs_prmtv **pthis);
654 UBJS_EXPORT ubjs_result ubjs_prmtv_is_array(ubjs_prmtv *this, ubjs_bool *result);
660 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_length(ubjs_prmtv *this, unsigned int *length);
669 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_first(ubjs_prmtv *this, ubjs_prmtv **pitem);
678 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_last(ubjs_prmtv *this, ubjs_prmtv **pitem);
688 UBJS_EXPORT ubjs_result ubjs_prmtv_array_get_at(ubjs_prmtv *this, unsigned int pos,
689  ubjs_prmtv **pitem);
722 UBJS_EXPORT ubjs_result ubjs_prmtv_array_add_at(ubjs_prmtv *this, unsigned int pos,
723  ubjs_prmtv *item);
757 UBJS_EXPORT ubjs_result ubjs_prmtv_array_delete_at(ubjs_prmtv *this, unsigned int pos);
758 
796 
806 UBJS_EXPORT ubjs_result ubjs_prmtv_object(ubjs_library *lib, ubjs_prmtv **pthis);
807 
820 UBJS_EXPORT ubjs_result ubjs_prmtv_object_with_length(ubjs_library *lib, unsigned int length,
821  ubjs_prmtv **pthis);
836  ubjs_prmtv_type type, unsigned int length, ubjs_prmtv **pthis);
837 
838 
845 UBJS_EXPORT ubjs_result ubjs_prmtv_is_object(ubjs_prmtv *this, ubjs_bool *result);
851 UBJS_EXPORT ubjs_result ubjs_prmtv_object_get_length(ubjs_prmtv *this, unsigned int *pvalue);
860 UBJS_EXPORT ubjs_result ubjs_prmtv_object_get(ubjs_prmtv *this, unsigned int key_length,
861  char *key, ubjs_prmtv **pvalue);
871 UBJS_EXPORT ubjs_result ubjs_prmtv_object_set(ubjs_prmtv *this, unsigned int key_length,
872  char *key, ubjs_prmtv *value);
882 UBJS_EXPORT ubjs_result ubjs_prmtv_object_delete(ubjs_prmtv *this, unsigned int key_length,
883  char *key);
884 
896  ubjs_object_iterator **iterator);
922  unsigned int *plen);
938 UBJS_EXPORT ubjs_result ubjs_object_iterator_copy_key(ubjs_object_iterator *this, char *text);
939 
953  ubjs_prmtv **pvalue);
954 
961 
968 
975 UBJS_EXPORT ubjs_result ubjs_prmtv_get_type(ubjs_prmtv *this, ubjs_prmtv_type *ptype);
976 
983 UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_get_length(ubjs_prmtv *this, unsigned int *plen);
984 
993 UBJS_EXPORT ubjs_result ubjs_prmtv_debug_string_copy(ubjs_prmtv *this, char *str);
994 
1000 UBJS_EXPORT ubjs_result ubjs_prmtv_free(ubjs_prmtv **pthis);
1001 
1002 #ifdef __cplusplus
1003 }
1004 #endif
1005 
1006 #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: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