#include <zcbor_decode.h>
#include <zcbor_encode.h>
Go to the source code of this file.
|
#define | ZCBOR_U32_MAP_ENTRY(_u32, _decode, _value) |
| Define CBOR map entry to be decoded, referenced by uint32_t key.
|
|
#define | ZCBOR_TSTR_LIT_MAP_ENTRY(_tstr_lit, _decode, _value) |
| Define CBOR map entry to be decoded, referenced by literal string key.
|
|
◆ ZCBOR_TSTR_LIT_MAP_ENTRY
#define ZCBOR_TSTR_LIT_MAP_ENTRY |
( |
| _tstr_lit, |
|
|
| _decode, |
|
|
| _value ) |
Value: { \
.key = \
{ \
.tstr = {(const uint8_t *) _tstr_lit, sizeof(_tstr_lit) - 1}, \
}, \
.decode = _decode, .value = _value, \
}
@ ZCBOR_MAP_KEY_TYPE_TSTR
Define CBOR map entry to be decoded, referenced by literal string key.
- Parameters
-
_tstr_lit | Map key (literal string, e.g. "my_key") |
_decode | Map value decode callback |
_value | Value passed to decode callback |
Definition at line 122 of file zcbor_utils.h.
◆ ZCBOR_U32_MAP_ENTRY
#define ZCBOR_U32_MAP_ENTRY |
( |
| _u32, |
|
|
| _decode, |
|
|
| _value ) |
Value: { \
.key = \
{ \
.u32 = _u32, \
}, \
.decode = _decode, .value = _value, \
}
Define CBOR map entry to be decoded, referenced by uint32_t key.
- Parameters
-
_u32 | Map key |
_decode | Map value decode callback |
_value | Value passed to decode callback |
Definition at line 105 of file zcbor_utils.h.
◆ anonymous enum
Enumerator |
---|
ZCBOR_MAP_KEY_TYPE_U32 | |
ZCBOR_MAP_KEY_TYPE_TSTR | |
Definition at line 15 of file zcbor_utils.h.
◆ zcbor_list_or_map_end()
static bool zcbor_list_or_map_end |
( |
zcbor_state_t * | state | ) |
|
|
inlinestatic |
Check the end of CBOR list or map.
- Return values
-
true | Reached end of list or map |
false | There are more items (from list of map) to be processed |
Definition at line 44 of file zcbor_utils.h.
◆ zcbor_map_decode()
int zcbor_map_decode |
( |
zcbor_state_t * | zsd, |
|
|
struct zcbor_map_entry * | entries, |
|
|
size_t | num_entries ) |
Decode CBOR map with specified entries.
Decode CBOR map with entries specified by entries. All specified entries need to exist in processed CBOR map.
- Parameters
-
[in,out] | zsd | The current state of the decoding |
[in] | entries | Array with entries to be decoded |
[in] | num_entries | Number of entries (size of entries array) |
- Return values
-
0 | On success |
-EBADMSG | Failed to parse all map entries |
-ENOENT | Map was empty |
<0 | Other error returned from @ entries decode callback |
◆ zcbor_map_int64_decode()
int zcbor_map_int64_decode |
( |
zcbor_state_t * | zsd, |
|
|
void * | value ) |
Decode int64_t value from CBOR map.
Callback for decoding int64_t value from CBOR map using zcbor_map_decode().
- Parameters
-
[in,out] | zsd | The current state of the decoding |
[out] | value | Pointer to int64_t value where result of decoding is saved. |
- Return values
-
0 | On success |
<0 | POSIX error code on error |
◆ zcbor_map_tstr_decode()
int zcbor_map_tstr_decode |
( |
zcbor_state_t * | zsd, |
|
|
void * | value ) |
Decode text string value from CBOR map.
Callback for decoding tstr (struct zcbor_string) value from CBOR map using zcbor_map_decode().
- Parameters
-
[in,out] | zsd | The current state of the decoding |
[out] | value | Pointer to struct 'struct zcbor_string' value where result of decoding is saved. |
- Return values
-
0 | On success |
<0 | POSIX error code on error |