libcbor 0.12.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Loading...
Searching...
No Matches
encoding.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2020 Pavel Kalvoda <me@pavelkalvoda.com>
3 *
4 * libcbor is free software; you can redistribute it and/or modify
5 * it under the terms of the MIT license. See LICENSE for details.
6 */
7
8#ifndef LIBCBOR_ENCODING_H
9#define LIBCBOR_ENCODING_H
10
11#include "cbor/cbor_export.h"
12#include "cbor/common.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/*
19 * All cbor_encode_* methods take 2 or 3 arguments:
20 * - a logical `value` to encode (except for trivial items such as NULLs)
21 * - an output `buffer` pointer
22 * - a `buffer_size` specification
23 *
24 * They serialize the `value` into one or more bytes and write the bytes to the
25 * output `buffer` and return either the number of bytes written, or 0 if the
26 * `buffer_size` was too small to small to fit the serialized value (in which
27 * case it is not modified).
28 */
29
30_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint8(uint8_t, unsigned char*,
31 size_t);
32
33_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint16(uint16_t, unsigned char*,
34 size_t);
35
36_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint32(uint32_t, unsigned char*,
37 size_t);
38
39_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint64(uint64_t, unsigned char*,
40 size_t);
41
42_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint(uint64_t, unsigned char*,
43 size_t);
44
45_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint8(uint8_t, unsigned char*,
46 size_t);
47
48_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint16(uint16_t,
49 unsigned char*, size_t);
50
51_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint32(uint32_t,
52 unsigned char*, size_t);
53
54_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint64(uint64_t,
55 unsigned char*, size_t);
56
57_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint(uint64_t, unsigned char*,
58 size_t);
59
60_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bytestring_start(size_t,
61 unsigned char*,
62 size_t);
63
64_CBOR_NODISCARD CBOR_EXPORT size_t
65cbor_encode_indef_bytestring_start(unsigned char*, size_t);
66
67_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_string_start(size_t,
68 unsigned char*,
69 size_t);
70
71_CBOR_NODISCARD CBOR_EXPORT size_t
72cbor_encode_indef_string_start(unsigned char*, size_t);
73
74_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_array_start(size_t,
75 unsigned char*,
76 size_t);
77
78_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_array_start(unsigned char*,
79 size_t);
80
81_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_map_start(size_t, unsigned char*,
82 size_t);
83
84_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_map_start(unsigned char*,
85 size_t);
86
87_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_tag(uint64_t, unsigned char*,
88 size_t);
89
90_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bool(bool, unsigned char*,
91 size_t);
92
93_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_null(unsigned char*, size_t);
94
95_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char*, size_t);
96
120_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_half(float, unsigned char*,
121 size_t);
126_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_single(float, unsigned char*,
127 size_t);
128
133_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_double(double, unsigned char*,
134 size_t);
135
136_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_break(unsigned char*, size_t);
137
138_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_ctrl(uint8_t, unsigned char*,
139 size_t);
140
141#ifdef __cplusplus
142}
143#endif
144
145#endif // LIBCBOR_ENCODING_H
#define _CBOR_NODISCARD
Definition common.h:93
size_t cbor_encode_null(unsigned char *, size_t)
Definition encoding.c:122
size_t cbor_encode_negint16(uint16_t, unsigned char *, size_t)
Definition encoding.c:44
size_t cbor_encode_indef_array_start(unsigned char *, size_t)
Definition encoding.c:98
size_t cbor_encode_tag(uint64_t, unsigned char *, size_t)
Definition encoding.c:112
size_t cbor_encode_indef_bytestring_start(unsigned char *, size_t)
Definition encoding.c:78
size_t cbor_encode_negint(uint64_t, unsigned char *, size_t)
Definition encoding.c:59
size_t cbor_encode_negint64(uint64_t, unsigned char *, size_t)
Definition encoding.c:54
size_t cbor_encode_bytestring_start(size_t, unsigned char *, size_t)
Definition encoding.c:64
size_t cbor_encode_uint64(uint64_t, unsigned char *, size_t)
Definition encoding.c:29
size_t cbor_encode_uint16(uint16_t, unsigned char *, size_t)
Definition encoding.c:19
size_t cbor_encode_half(float, unsigned char *, size_t)
Encodes a half-precision float.
Definition encoding.c:130
size_t cbor_encode_string_start(size_t, unsigned char *, size_t)
Definition encoding.c:83
size_t cbor_encode_double(double, unsigned char *, size_t)
Encodes a double precision float.
Definition encoding.c:194
size_t cbor_encode_indef_string_start(unsigned char *, size_t)
Definition encoding.c:88
size_t cbor_encode_uint(uint64_t, unsigned char *, size_t)
Definition encoding.c:34
size_t cbor_encode_indef_map_start(unsigned char *, size_t)
Definition encoding.c:108
size_t cbor_encode_array_start(size_t, unsigned char *, size_t)
Definition encoding.c:93
size_t cbor_encode_single(float, unsigned char *, size_t)
Encodes a single precision float.
Definition encoding.c:180
size_t cbor_encode_map_start(size_t, unsigned char *, size_t)
Definition encoding.c:103
size_t cbor_encode_uint32(uint32_t, unsigned char *, size_t)
Definition encoding.c:24
size_t cbor_encode_bool(bool, unsigned char *, size_t)
Definition encoding.c:117
size_t cbor_encode_ctrl(uint8_t, unsigned char *, size_t)
Definition encoding.c:211
size_t cbor_encode_negint8(uint8_t, unsigned char *, size_t)
Definition encoding.c:39
size_t cbor_encode_break(unsigned char *, size_t)
Definition encoding.c:207
size_t cbor_encode_negint32(uint32_t, unsigned char *, size_t)
Definition encoding.c:49
size_t cbor_encode_undef(unsigned char *, size_t)
Definition encoding.c:126
size_t cbor_encode_uint8(uint8_t, unsigned char *, size_t)
Definition encoding.c:14