Astarte Device SDK ESP32
ESP32 device SDK for the Astarte platform
Loading...
Searching...
No Matches
astarte_bson_serializer.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2018-2023, SECO Mind Srl
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0
5 */
6
12#ifndef _ASTARTE_BSON_SERIALIZER_H_
13#define _ASTARTE_BSON_SERIALIZER_H_
14
15#include "astarte.h"
16
17#include <stdbool.h>
18#include <stdint.h>
19#include <string.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
26{
27 size_t capacity;
28 size_t size;
29 uint8_t *buf;
30} __attribute__((
31 deprecated("This sould never be used directly, use astarte_bson_serializer_handle_t")));
32
34{
35#pragma GCC diagnostic push
36#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
37 struct astarte_byte_array_t ba;
38#pragma GCC diagnostic pop
39} __attribute__((deprecated("Use the new typedefined astarte_bson_serializer_handle_t")));
40
41#pragma GCC diagnostic push
42#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
43typedef struct astarte_bson_serializer_t *astarte_bson_serializer_handle_t;
44#pragma GCC diagnostic pop
45
53void astarte_bson_serializer_init(astarte_bson_serializer_handle_t bson)
54 __attribute__((deprecated("Use astarte_bson_serializer_new instead")));
55
63astarte_bson_serializer_handle_t astarte_bson_serializer_new(void);
64
72void astarte_bson_serializer_destroy(astarte_bson_serializer_handle_t bson);
73
83const void *astarte_bson_serializer_get_document(astarte_bson_serializer_handle_t bson, int *size);
84
98 astarte_bson_serializer_handle_t bson, void *out_buf, int out_buf_len, int *out_doc_size);
99
106size_t astarte_bson_serializer_document_size(astarte_bson_serializer_handle_t bson);
107
114void astarte_bson_serializer_append_end_of_document(astarte_bson_serializer_handle_t bson);
115
125 astarte_bson_serializer_handle_t bson, const char *name, double value);
126
136 astarte_bson_serializer_handle_t bson, const char *name, int32_t value);
137
147 astarte_bson_serializer_handle_t bson, const char *name, int64_t value);
148
159 astarte_bson_serializer_handle_t bson, const char *name, const void *value, size_t size);
160
170 astarte_bson_serializer_handle_t bson, const char *name, const char *string);
171
181 astarte_bson_serializer_handle_t bson, const char *name, uint64_t epoch_millis);
182
192 astarte_bson_serializer_handle_t bson, const char *name, bool value);
193
203 astarte_bson_serializer_handle_t bson, const char *name, const void *document);
204
216 astarte_bson_serializer_handle_t bson, const char *name, const double *arr, int count);
217
229 astarte_bson_serializer_handle_t bson, const char *name, const int32_t *arr, int count);
230
242 astarte_bson_serializer_handle_t bson, const char *name, const int64_t *arr, int count);
243
255 astarte_bson_serializer_handle_t bson, const char *name, const char *const *arr, int count);
256
268astarte_err_t astarte_bson_serializer_append_binary_array(astarte_bson_serializer_handle_t bson,
269 const char *name, const void *const *arr, const int *sizes, int count);
270
283 astarte_bson_serializer_handle_t bson, const char *name, const int64_t *arr, int count);
284
296 astarte_bson_serializer_handle_t bson, const char *name, const bool *arr, int count);
297
298#ifdef __cplusplus
299}
300#endif
301
302#endif
Astarte types and defines.
astarte_err_t
Astarte return codes.
Definition astarte.h:28
astarte_err_t astarte_bson_serializer_append_int32_array(astarte_bson_serializer_handle_t bson, const char *name, const int32_t *arr, int count)
append an int32 array
const void * astarte_bson_serializer_get_document(astarte_bson_serializer_handle_t bson, int *size)
getter for the BSON serializer internal buffer.
astarte_err_t astarte_bson_serializer_append_int64_array(astarte_bson_serializer_handle_t bson, const char *name, const int64_t *arr, int count)
append an int64 array
void astarte_bson_serializer_destroy(astarte_bson_serializer_handle_t bson)
destroy given BSON serializer instance.
void astarte_bson_serializer_append_document(astarte_bson_serializer_handle_t bson, const char *name, const void *document)
append a sub-BSON document.
void astarte_bson_serializer_append_int64(astarte_bson_serializer_handle_t bson, const char *name, int64_t value)
append an int64 value
void astarte_bson_serializer_append_boolean(astarte_bson_serializer_handle_t bson, const char *name, bool value)
append a boolean value
astarte_err_t astarte_bson_serializer_write_document(astarte_bson_serializer_handle_t bson, void *out_buf, int out_buf_len, int *out_doc_size)
copy BSON serializer internal buffer to a different buffer.
void astarte_bson_serializer_append_double(astarte_bson_serializer_handle_t bson, const char *name, double value)
append a double value
astarte_err_t astarte_bson_serializer_append_string_array(astarte_bson_serializer_handle_t bson, const char *name, const char *const *arr, int count)
append a string array
void astarte_bson_serializer_append_datetime(astarte_bson_serializer_handle_t bson, const char *name, uint64_t epoch_millis)
append a date time value
astarte_err_t astarte_bson_serializer_append_boolean_array(astarte_bson_serializer_handle_t bson, const char *name, const bool *arr, int count)
append a boolean array
void astarte_bson_serializer_append_binary(astarte_bson_serializer_handle_t bson, const char *name, const void *value, size_t size)
append a binary blob value
void astarte_bson_serializer_append_end_of_document(astarte_bson_serializer_handle_t bson)
append end of document marker.
size_t astarte_bson_serializer_document_size(astarte_bson_serializer_handle_t bson)
return the document size
astarte_bson_serializer_handle_t astarte_bson_serializer_new(void)
create a new instance of the BSON serializer.
void astarte_bson_serializer_append_string(astarte_bson_serializer_handle_t bson, const char *name, const char *string)
append an UTF-8 string
astarte_err_t astarte_bson_serializer_append_double_array(astarte_bson_serializer_handle_t bson, const char *name, const double *arr, int count)
append a double array
astarte_err_t astarte_bson_serializer_append_binary_array(astarte_bson_serializer_handle_t bson, const char *name, const void *const *arr, const int *sizes, int count)
append a binary blob array
void astarte_bson_serializer_append_int32(astarte_bson_serializer_handle_t bson, const char *name, int32_t value)
append an int32 value
void astarte_bson_serializer_init(astarte_bson_serializer_handle_t bson) __attribute__((deprecated("Use astarte_bson_serializer_new instead")))
initialize given BSON serializer.
astarte_err_t astarte_bson_serializer_append_datetime_array(astarte_bson_serializer_handle_t bson, const char *name, const int64_t *arr, int count)
append a date time array
Definition astarte_bson_serializer.h:34
Definition astarte_bson_serializer.h:26