Astarte Device SDK ESP32
ESP32 device SDK for the Astarte platform
|
Astarte BSON deserialization functions. More...
Go to the source code of this file.
Functions | |
const void * | astarte_bson_key_lookup (const char *key, const void *document, uint8_t *type) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_lookup' function " "in astarte_bson_deserializer.h"))) |
Look up the key from the document and return a pointer to the appropriate entry. More... | |
const void * | astarte_bson_first_item (const void *document) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_first_element' function " "in astarte_bson_deserializer.h"))) |
Get a pointer to the first item in a document's list. More... | |
void * | astarte_bson_next_item (const void *document, const void *current_item) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_next_element' function " "in astarte_bson_deserializer.h"))) |
Get a pointer to the next item in a document's list. More... | |
const char * | astarte_bson_key (const void *item) __attribute__((deprecated("Please use the deserialization functions in astarte_bson_deserializer.h"))) |
Get a pointer to the string containing an element name. More... | |
const char * | astarte_bson_value_to_string (const void *value_ptr, uint32_t *len) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_string' function " "in astarte_bson_deserializer.h"))) |
Parse a BSON string and return a pointer to the beginning of the UTF-8 string. More... | |
const char * | astarte_bson_value_to_binary (const void *value_ptr, uint32_t *len) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_binary' function " "in astarte_bson_deserializer.h"))) |
Parse a BSON binary and return a pointer to the beginning of the byte array. More... | |
const void * | astarte_bson_value_to_document (const void *value_ptr, uint32_t *len) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_document' function " "in astarte_bson_deserializer.h"))) |
Parse a BSON document and return a pointer to the beginning of the document. More... | |
int8_t | astarte_bson_value_to_int8 (const void *value_ptr) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_bool' function " "in astarte_bson_deserializer.h"))) |
Cast the input element to a int8. More... | |
int32_t | astarte_bson_value_to_int32 (const void *value_ptr) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_int32' function " "in astarte_bson_deserializer.h"))) |
Cast the input element to a int32. More... | |
int64_t | astarte_bson_value_to_int64 (const void *value_ptr) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_int64' function " "in astarte_bson_deserializer.h"))) |
Cast the input element to a int64. More... | |
double | astarte_bson_value_to_double (const void *value_ptr) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_element_to_double' function " "in astarte_bson_deserializer.h"))) |
Cast the input element to a double. More... | |
bool | astarte_bson_check_validity (const void *document, unsigned int file_size) __attribute__((deprecated("Please use the 'astarte_bson_deserializer_check_validity' function " "in astarte_bson_deserializer.h"))) |
Perform some checks on the validity of the BSON. More... | |
uint32_t | astarte_bson_document_size (const void *document) __attribute__((deprecated("Please use the deserialization functions in astarte_bson_deserializer.h"))) |
Get the size of the document. More... | |
Astarte BSON deserialization functions.
This library follows the v1.1 of the BSON standard, but does not provide support for the full specification, only for a smaller subset. For more information regarding the BSON format specifications see: https://bsonspec.org/spec.html.
bool astarte_bson_check_validity | ( | const void * | document, |
unsigned int | file_size | ||
) |
Perform some checks on the validity of the BSON.
[in] | document | Document for which to calculate the size. |
[in] | file_size | Size of the allocated buffer containing document. |
uint32_t astarte_bson_document_size | ( | const void * | document | ) |
Get the size of the document.
[in] | document | Document for which to calculate the size. |
const void* astarte_bson_first_item | ( | const void * | document | ) |
Get a pointer to the first item in a document's list.
N.B. The return value points to the beginning of the element, to the element type.
[in] | document | Document containing the list. |
const char* astarte_bson_key | ( | const void * | item | ) |
Get a pointer to the string containing an element name.
[in] | item | Pointer to the element from which the key should be extracted. |
const void* astarte_bson_key_lookup | ( | const char * | key, |
const void * | document, | ||
uint8_t * | type | ||
) |
Look up the key from the document and return a pointer to the appropriate entry.
This function loops over all the elements in the document's list and return a pointer to the first element with a name matching the specified key. N.B. The return value points to the content of the element, past the element type and name.
[in] | key | String representing the key to find in the document. |
[in] | document | Document to use for the search. |
[out] | type | Returned element type, see 'astarte_bson_types.h' for its possible values. |
void* astarte_bson_next_item | ( | const void * | document, |
const void * | current_item | ||
) |
Get a pointer to the next item in a document's list.
N.B. The return value points to the beginning of the element, to the element type.
[in] | document | Document containing the list. |
[in] | current_item | Pointer to the current element. |
const char* astarte_bson_value_to_binary | ( | const void * | value_ptr, |
uint32_t * | len | ||
) |
Parse a BSON binary and return a pointer to the beginning of the byte array.
[in] | value_ptr | Pointer to the value to parse. |
[out] | len | Size of the parsed byte array. |
const void* astarte_bson_value_to_document | ( | const void * | value_ptr, |
uint32_t * | len | ||
) |
Parse a BSON document and return a pointer to the beginning of the document.
This function does not perform actual parsing, using the original pointer as a document would work in the exact same way.
[in] | value_ptr | Pointer to the value to parse. |
[out] | len | Size of the document. |
double astarte_bson_value_to_double | ( | const void * | value_ptr | ) |
Cast the input element to a double.
[in] | value_ptr | Pointer to the value to parse. |
int32_t astarte_bson_value_to_int32 | ( | const void * | value_ptr | ) |
Cast the input element to a int32.
[in] | value_ptr | Pointer to the value to parse. |
int64_t astarte_bson_value_to_int64 | ( | const void * | value_ptr | ) |
Cast the input element to a int64.
[in] | value_ptr | Pointer to the value to parse. |
int8_t astarte_bson_value_to_int8 | ( | const void * | value_ptr | ) |
Cast the input element to a int8.
This function does not perform actual parsing, performing a manual casting would work in the same way.
[in] | value_ptr | Pointer to the value to parse. |
const char* astarte_bson_value_to_string | ( | const void * | value_ptr, |
uint32_t * | len | ||
) |
Parse a BSON string and return a pointer to the beginning of the UTF-8 string.
[in] | value_ptr | Pointer to the value to parse. |
[out] | len | Size of the parsed string. |