C API Wrapper¶
The C API wrapper provides direct access to the ujotypes-c library functions.
-
ujotypes._ujotypes.
ujot_float_to_half
(value)¶ Convert single precision float to half precision float value
Parameters: value (float) – the float32 value to be converted Returns: binary float16 value representation Return type: (int)
-
ujotypes._ujotypes.
ujot_get_version
()¶ Get the current API and library version
Returns: (library version, api version) Return type: (tuple of (int, int))
-
ujotypes._ujotypes.
ujot_half_to_float
(value)¶ Convert half precision float to single precision float value
Parameters: value (int) – binary float16 value representation to be converted Returns: float32 value Return type: (float)
-
ujotypes._ujotypes.
ujot_read_from_buffer
(buffer)¶ Reads a container variant from a buffer
Parameters: buffer (bytes) – the Ujo representation of the container variant Returns: container variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_read_from_file
(filename)¶ Reads a container variant from a file
Parameters: filename (str) – full path to Ujo file to read Returns: container variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_binary
(variant)¶ Read the value from an binary variant
Parameters: variant (int) – variant handle Returns: (binary data, binary type) Return type: (tuple of (bytes, int))
-
ujotypes._ujotypes.
ujot_variant_as_bool
(variant)¶ Read the value from a bool variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_float16
(variant)¶ Read the value from an float16 variant
Parameters: variant (int) – variant handle Returns: binary float16 value representation Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_float32
(variant)¶ Read the value from an float32 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (float)
-
ujotypes._ujotypes.
ujot_variant_as_float64
(variant)¶ Read the value from an float64 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (float)
-
ujotypes._ujotypes.
ujot_variant_as_int16
(variant)¶ Read the value from an int16 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_int32
(variant)¶ Read the value from an int32 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_int64
(variant)¶ Read the value from an int64 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_int8
(variant)¶ Read the value from an int8 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_string_c
(variant)¶ Read the value from a c-string variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (str)
-
ujotypes._ujotypes.
ujot_variant_as_string_utf8
(variant)¶ Read the value from a UTF8-string variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (str)
-
ujotypes._ujotypes.
ujot_variant_as_timestamp
(variant)¶ Read the value from an timestamp variant
Parameters: variant (int) – variant handle Returns: (year, month, day, hour, minute, second, microsecond) Return type: (tuple of (int, int, int, int, int, int, int))
-
ujotypes._ujotypes.
ujot_variant_as_uint16
(variant)¶ Read the value from an uint16 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_uint32
(variant)¶ Read the value from an uint32 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_uint64
(variant)¶ Read the value from an uint64 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_as_uint8
(variant)¶ Read the value from an uint8 variant
Parameters: variant (int) – variant handle Returns: the value of the variant Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_decref
(variant)¶ Decrement variant reference counter
Parameters: variant (int) – variant handle
-
ujotypes._ujotypes.
ujot_variant_get_refcount
(variant)¶ Get current reference count
Parameters: variant (int) – variant handle Returns: reference counter value Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_get_type
(variant)¶ Determines the type of the given variant
Parameters: variant (int) – variant handle Returns: (type, subtype) Return type: (tuple of (int, int))
-
ujotypes._ujotypes.
ujot_variant_incref
(variant)¶ Increment variant reference counter
Parameters: variant (int) – variant handle
-
ujotypes._ujotypes.
ujot_variant_list_append
(list, value)¶ Appends a value to a list
Parameters: - list (int) – variant list handle
- value (int) – handle of variant to append to the list
Returns: index of the appended value
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_list_clear
(list)¶ Clears the list
Parameters: list (int) – variant list handle
-
ujotypes._ujotypes.
ujot_variant_list_contains
(list, value)¶ Checks if an item is in the list
Parameters: - list (int) – variant list handle
- value (int) – handle to variant to check, if in the list
Returns: index of the value or UJOT_LIST_INDEX_UNKNOWN if not found
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_list_contains_in_subset
(list, value, start, stop)¶ Checks if an item is in the subset of a list
If you specify a negative stop index, contains is checked for all elements from start index to the end of the list.
Parameters: - list (int) – variant list handle
- value (int) – handle to variant to check, if in the list
- start (int) – index where to start the subset (inclusive)
- stop (int) – index where to stop the subset (inclusive)
Returns: index of the value or UJOT_LIST_INDEX_UNKNOWN if not found
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_list_delete_item
(list, index)¶ Deletes an item in a list
Parameters: - list (int) – variant list handle
- index (int) – index of the item to be deleted
-
ujotypes._ujotypes.
ujot_variant_list_get_item
(list, index)¶ Gets a value from the list
Parameters: - list (int) – variant list handle
- index (int) – index to get the value from
Returns: (borrowed) variant handle
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_list_get_size
(list)¶ Gets the number of items in the list
Parameters: list (int) – variant list handle Returns: item count Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_list_insert
(list, value, index)¶ Inserts a value to a list
Parameters: - list (int) – variant list handle
- value (int) – handle of variant to insert into the list
- index (int) – index to insert the value at
-
ujotypes._ujotypes.
ujot_variant_list_set_item
(list, value, index)¶ Overwrites a value in a list
Parameters: - list (int) – variant list handle
- value (int) – handle of variant to set into the list
- index (int) – index to set the value at
-
ujotypes._ujotypes.
ujot_variant_map_clear
(map)¶ Remove all items from a map
Parameters: map (int) – variant map handle
-
ujotypes._ujotypes.
ujot_variant_map_delete
(map, key)¶ Delete from map by key
Parameters: - map (int) – variant map handle
- key (int) – variant handle of the key to be deleted
-
ujotypes._ujotypes.
ujot_variant_map_first
(map)¶ Set the iterator to the beginning of a map
Parameters: map (int) – variant map handle
-
ujotypes._ujotypes.
ujot_variant_map_get
(map, key)¶ Get a value from the map by key
Parameters: - map (int) – variant map handle
- key (int) – variant handle of the key
Returns: variant handle of the value or none, if key doesn’t exist
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_map_get_size
(map)¶ Gets the number of items in the map
Parameters: map (int) – variant map handle Returns: item count Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_map_haskey
(map, key)¶ Check if a key exists in a map
Parameters: - map (int) – variant map handle
- key (int) – variant handle of the key to search for
Returns: - UJOT_TRUE if key was found
- UJOT_FALSE if key wasn’t found
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_map_next
(map)¶ Get next item of a map
Parameters: map (int) – variant map handle Returns: - (key variant handle, value variant handle)
- None, if there are no more items in the map
Return type: (tuple of (int, int), None)
-
ujotypes._ujotypes.
ujot_variant_map_set
(map, key, value)¶ Set a key value pair in a map
Parameters: - map (int) – variant map handle
- key (int) – variant handle of the key
- value (int) – variant handle of the value
-
ujotypes._ujotypes.
ujot_variant_new_binary
(buffer, bin_type)¶ Creates a variant with an binary value
Parameters: - buffer (bytes) – binary data
- bin_type (int) – binary type
Returns: variant handle
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_bool
(value)¶ Creates a variant with an boolean value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_float16
(value)¶ Creates a variant with an float16 value
Parameters: value (int) – binary float16 value representation Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_float32
(value)¶ Creates a variant with an float32 value
Parameters: value (float) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_float64
(value)¶ Creates a variant with an float64 value
Parameters: value (float) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_int16
(value)¶ Creates a variant with an int16 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_int32
(value)¶ Creates a variant with an int32 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_int64
(value)¶ Creates a variant with an int64 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_int8
(value)¶ Creates a variant with an int8 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_list
()¶ Create a new variant list
Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_map
()¶ Create a new variant map
Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_none
()¶ Create new variant of type none
Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_string_c
(string)¶ Create a c-string variant
Parameters: string (str) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_string_utf8
(string)¶ Create an UTF8-string variant
Parameters: string (str) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_timestamp
(year, month, day, hour, minute, second, microsecond)¶ Creates a variant with an timestamp value
Parameters: - year (int) – the full year (e.g. 2018)
- month (int) – the month (1-12)
- day (int) – the day (1-31)
- hour (int) – the hour (0-23)
- minute (int) – the minute (0-59)
- second (int) – the second (0-59)
- microsecond (int) – the microsecond (0-999999)
Returns: variant handle
Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_uint16
(value)¶ Creates a variant with an uint16 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_uint32
(value)¶ Creates a variant with an uint32 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_uint64
(value)¶ Creates a variant with an uint64 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_new_uint8
(value)¶ Creates a variant with an uint8 value
Parameters: value (int) – the value to assign to the new variant Returns: variant handle Return type: (int)
-
ujotypes._ujotypes.
ujot_variant_type_check
(variant, type)¶ Check type of an Ujo variant
Parameters: - variant (int) – variant handle
- type (int) – type id to be checked
Returns: True if variant type matches
Return type: (bool)
-
ujotypes._ujotypes.
ujot_write_to_buffer
(variant)¶ Writes a container variant into a buffer
Parameters: variant (int) – container variant handle Returns: the Ujo representation of the container variant Return type: (bytes)
-
ujotypes._ujotypes.
ujot_write_to_file
(variant, filename)¶ Writes a container variant into a file
Parameters: - variant (int) – container variant handle
- filename (str) – full path to Ujo file to write