Astarte Device SDK ESP32
ESP32 device SDK for the Astarte platform
astarte_bson_serializer.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2016, Ispirata Srl, info@ispirata.com.
3  *
4  * SPDX-License-Identifier: LGPL-2.1+ 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
22 extern "C" {
23 #endif
24 
26 {
27  int capacity;
28  int size;
29  uint8_t *buf;
30 };
31 
33 {
34  struct astarte_byte_array_t ba;
35 };
36 
45 
53 
62  const struct astarte_bson_serializer_t *bs, int *size);
63 
76  const struct astarte_bson_serializer_t *bs, void *out_buf, int out_buf_len, int *out_doc_size);
77 
85 
93 
104  struct astarte_bson_serializer_t *bs, const char *name, double value);
105 
116  struct astarte_bson_serializer_t *bs, const char *name, int32_t value);
117 
128  struct astarte_bson_serializer_t *bs, const char *name, int64_t value);
129 
141  struct astarte_bson_serializer_t *bs, const char *name, const void *value, int size);
142 
154  struct astarte_bson_serializer_t *bs, const char *name, const char *string);
155 
166  struct astarte_bson_serializer_t *bs, const char *name, uint64_t epoch_millis);
167 
178  struct astarte_bson_serializer_t *bs, const char *name, bool value);
179 
190  struct astarte_bson_serializer_t *bs, const char *name, const void *document);
191 
203  struct astarte_bson_serializer_t *bs, const char *name, const double *double_array, int count);
204 
216  struct astarte_bson_serializer_t *bs, const char *name, const int32_t *int32_array, int count);
217 
229  struct astarte_bson_serializer_t *bs, const char *name, const int64_t *int64_array, int count);
230 
242  const char *name, const char *const *string_array, int count);
243 
256  const char *name, const void *const *binary_array, const int *sizes, int count);
257 
270  const char *name, const int64_t *epoch_millis_array, int count);
271 
283  struct astarte_bson_serializer_t *bs, const char *name, const bool *boolean_array, int count);
284 
285 #ifdef __cplusplus
286 }
287 #endif
288 
289 #endif
Astarte types and defines.
astarte_err_t
Astarte return codes.
Definition: astarte.h:28
astarte_err_t astarte_bson_serializer_write_document(const struct astarte_bson_serializer_t *bs, 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_end_of_document(struct astarte_bson_serializer_t *bs)
append end of document marker.
void astarte_bson_serializer_append_binary(struct astarte_bson_serializer_t *bs, const char *name, const void *value, int size)
append a binary blob value
void astarte_bson_serializer_append_int32_array(struct astarte_bson_serializer_t *bs, const char *name, const int32_t *int32_array, int count)
append an int32 array
void astarte_bson_serializer_append_double(struct astarte_bson_serializer_t *bs, const char *name, double value)
append a double value
void astarte_bson_serializer_append_int64(struct astarte_bson_serializer_t *bs, const char *name, int64_t value)
append an int64 value
void astarte_bson_serializer_append_string(struct astarte_bson_serializer_t *bs, const char *name, const char *string)
append an UTF-8 string
void astarte_bson_serializer_init(struct astarte_bson_serializer_t *bs)
initialize given BSON serializer.
int astarte_bson_serializer_document_size(const struct astarte_bson_serializer_t *bs)
return document size
void astarte_bson_serializer_append_document(struct astarte_bson_serializer_t *bs, const char *name, const void *document)
append a sub-BSON document.
void astarte_bson_serializer_append_binary_array(struct astarte_bson_serializer_t *bs, const char *name, const void *const *binary_array, const int *sizes, int count)
append a binary blob array
void astarte_bson_serializer_append_datetime(struct astarte_bson_serializer_t *bs, const char *name, uint64_t epoch_millis)
append a date time value
void astarte_bson_serializer_append_string_array(struct astarte_bson_serializer_t *bs, const char *name, const char *const *string_array, int count)
append a string array
void astarte_bson_serializer_append_int32(struct astarte_bson_serializer_t *bs, const char *name, int32_t value)
append an int32 value
void astarte_bson_serializer_append_double_array(struct astarte_bson_serializer_t *bs, const char *name, const double *double_array, int count)
append a double array
void astarte_bson_serializer_append_boolean_array(struct astarte_bson_serializer_t *bs, const char *name, const bool *boolean_array, int count)
append a boolean array
void astarte_bson_serializer_append_datetime_array(struct astarte_bson_serializer_t *bs, const char *name, const int64_t *epoch_millis_array, int count)
append a date time array
void astarte_bson_serializer_append_boolean(struct astarte_bson_serializer_t *bs, const char *name, bool value)
append a boolean value
const void * astarte_bson_serializer_get_document(const struct astarte_bson_serializer_t *bs, int *size)
return bson serializer internal buffer.
void astarte_bson_serializer_append_int64_array(struct astarte_bson_serializer_t *bs, const char *name, const int64_t *int64_array, int count)
append an int64 array
void astarte_bson_serializer_destroy(struct astarte_bson_serializer_t *bs)
destroy given BSON serializer.
Definition: astarte_bson_serializer.h:33
Definition: astarte_bson_serializer.h:26