55#ifdef CBOR_CONF_MAX_NESTING
56#define CBOR_MAX_NESTING CBOR_CONF_MAX_NESTING
58#define CBOR_MAX_NESTING (8)
61#define CBOR_UNSIGNED_SIZE(uint) ((uint) < CBOR_SIZE_1 \
63 : ((uint) <= UINT8_MAX \
65 : ((uint) <= UINT16_MAX \
67 : ((uint) <= UINT32_MAX \
70#define CBOR_BYTE_STRING_SIZE(bytes) (CBOR_UNSIGNED_SIZE(bytes) + (bytes))
76 CBOR_MAJOR_TYPE_NONE = -1,
77 CBOR_MAJOR_TYPE_UNSIGNED = 0x00,
78 CBOR_MAJOR_TYPE_SIGNED = 0x20,
79 CBOR_MAJOR_TYPE_BYTE_STRING = 0x40,
80 CBOR_MAJOR_TYPE_TEXT_STRING = 0x60,
81 CBOR_MAJOR_TYPE_ARRAY = 0x80,
82 CBOR_MAJOR_TYPE_MAP = 0xA0,
83 CBOR_MAJOR_TYPE_SIMPLE = 0xE0,
90 CBOR_SIMPLE_VALUE_NONE = -1,
91 CBOR_SIMPLE_VALUE_FALSE = 0xF4,
92 CBOR_SIMPLE_VALUE_TRUE = 0xF5,
93 CBOR_SIMPLE_VALUE_NULL = 0xF6,
94 CBOR_SIMPLE_VALUE_UNDEFINED = 0xF7,
120 const uint8_t *buffer_head;
123 size_t nesting_depth;
143 uint8_t *buffer,
size_t buffer_size);
169 const void *
object,
size_t object_size);
195 const uint8_t *data,
size_t data_size);
205 const char *text,
size_t text_size);
279 const uint8_t *cbor,
size_t cbor_size);
size_t cbor_end_writer(cbor_writer_state_t *state)
Finishes writing CBOR output.
struct cbor_writer_state_t cbor_writer_state_t
Structure of the internal state of a CBOR writer.
struct cbor_reader_state_t cbor_reader_state_t
Structure of the internal state of a CBOR reader.
void cbor_close_data(cbor_writer_state_t *state)
Stops enclosing subsequent CBOR objects in the innermost byte string.
void cbor_open_map(cbor_writer_state_t *state)
Adds subsequent entries to a map.
cbor_size_t cbor_read_signed(cbor_reader_state_t *state, int64_t *value)
Reads a signed integer.
void cbor_break_writer(cbor_writer_state_t *state)
Marks the CBOR output as erroneous.
size_t cbor_read_array(cbor_reader_state_t *state)
Reads the number of elements of an array.
cbor_major_type_t
Enumeration of major types.
bool cbor_end_reader(cbor_reader_state_t *state)
Ensures that no bytes remain unread.
cbor_simple_value_t
Enumeration of simple values.
cbor_size_t cbor_read_unsigned(cbor_reader_state_t *state, uint64_t *value)
Reads an unsigned integer.
cbor_simple_value_t cbor_read_simple(cbor_reader_state_t *state)
Reads a simple value.
void cbor_write_text(cbor_writer_state_t *state, const char *text, size_t text_size)
Appends a text string.
struct cbor_nesting_record_t cbor_nesting_record_t
Structure of a nesting record.
void cbor_write_unsigned(cbor_writer_state_t *state, uint64_t value)
Appends an unsigned integer.
cbor_major_type_t cbor_peek_next(cbor_reader_state_t *state)
Inspects the next major type.
void cbor_write_null(cbor_writer_state_t *state)
Appends the simple value null.
void cbor_open_data(cbor_writer_state_t *state)
Encloses subsequent CBOR objects in a byte string.
void cbor_write_bool(cbor_writer_state_t *state, bool boolean)
Appends a boolean simple value.
void cbor_open_array(cbor_writer_state_t *state)
Adds subsequent CBOR objects to an array.
const uint8_t * cbor_read_data(cbor_reader_state_t *state, size_t *data_size)
Reads a byte string.
void cbor_close_map(cbor_writer_state_t *state)
Stops adding subsequent entries to the innermost map.
void cbor_write_object(cbor_writer_state_t *state, const void *object, size_t object_size)
Appends an arbitrary CBOR object.
#define CBOR_MAX_NESTING
Defines how many arrays and maps can be open simultaneously while writing.
void cbor_init_writer(cbor_writer_state_t *state, uint8_t *buffer, size_t buffer_size)
Prepares for writing CBOR output.
cbor_size_t
Enumeration of size information in various major types.
void cbor_close_array(cbor_writer_state_t *state)
Stops adding subsequent CBOR objects to the innermost array.
void cbor_init_reader(cbor_reader_state_t *state, const uint8_t *cbor, size_t cbor_size)
Prepares for reading CBOR input.
void cbor_write_data(cbor_writer_state_t *state, const uint8_t *data, size_t data_size)
Appends a byte string.
void cbor_write_signed(cbor_writer_state_t *state, int64_t value)
Appends a signed integer.
size_t cbor_read_map(cbor_reader_state_t *state)
Reads the number of entries of a map.
void cbor_write_undefined(cbor_writer_state_t *state)
Appends the simple value undefined.
const char * cbor_read_text(cbor_reader_state_t *state, size_t *text_size)
Reads a text string.
@ CBOR_SIZE_NONE
error condition
Structure of a nesting record.
Structure of the internal state of a CBOR reader.
Structure of the internal state of a CBOR writer.