37#include "tinycbor-version.h"
39#define TINYCBOR_VERSION ((TINYCBOR_VERSION_MAJOR << 16) | (TINYCBOR_VERSION_MINOR << 8) | TINYCBOR_VERSION_PATCH)
55# define SIZE_MAX ((size_t)-1)
61#ifndef CBOR_PRIVATE_API
62# define CBOR_PRIVATE_API
64#ifndef CBOR_INLINE_API
65# if defined(__cplusplus)
66# define CBOR_INLINE inline
67# define CBOR_INLINE_API inline
69# define CBOR_INLINE_API static CBOR_INLINE
71# define CBOR_INLINE __inline
72# elif defined(__GNUC__)
73# define CBOR_INLINE __inline__
74# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
75# define CBOR_INLINE inline
82typedef enum CborType {
83 CborIntegerType = 0x00,
84 CborByteStringType = 0x40,
85 CborTextStringType = 0x60,
89 CborSimpleType = 0xe0,
90 CborBooleanType = 0xf5,
92 CborUndefinedType = 0xf7,
93 CborHalfFloatType = 0xf9,
95 CborDoubleType = 0xfb,
97 CborInvalidType = 0xff
100typedef uint64_t CborTag;
101typedef enum CborKnownTags {
102 CborDateTimeStringTag = 0,
103 CborUnixTime_tTag = 1,
104 CborPositiveBignumTag = 2,
105 CborNegativeBignumTag = 3,
108 CborCOSE_Encrypt0Tag = 16,
109 CborCOSE_Mac0Tag = 17,
110 CborCOSE_Sign1Tag = 18,
111 CborExpectedBase64urlTag = 21,
112 CborExpectedBase64Tag = 22,
113 CborExpectedBase16Tag = 23,
114 CborEncodedCborTag = 24,
116 CborBase64urlTag = 33,
118 CborRegularExpressionTag = 35,
119 CborMimeMessageTag = 36,
120 CborCOSE_EncryptTag = 96,
121 CborCOSE_MacTag = 97,
122 CborCOSE_SignTag = 98,
123 CborSignatureTag = 55799
127#define CborDateTimeStringTag CborDateTimeStringTag
128#define CborUnixTime_tTag CborUnixTime_tTag
129#define CborPositiveBignumTag CborPositiveBignumTag
130#define CborNegativeBignumTag CborNegativeBignumTag
131#define CborDecimalTag CborDecimalTag
132#define CborBigfloatTag CborBigfloatTag
133#define CborCOSE_Encrypt0Tag CborCOSE_Encrypt0Tag
134#define CborCOSE_Mac0Tag CborCOSE_Mac0Tag
135#define CborCOSE_Sign1Tag CborCOSE_Sign1Tag
136#define CborExpectedBase64urlTag CborExpectedBase64urlTag
137#define CborExpectedBase64Tag CborExpectedBase64Tag
138#define CborExpectedBase16Tag CborExpectedBase16Tag
139#define CborEncodedCborTag CborEncodedCborTag
140#define CborUrlTag CborUrlTag
141#define CborBase64urlTag CborBase64urlTag
142#define CborBase64Tag CborBase64Tag
143#define CborRegularExpressionTag CborRegularExpressionTag
144#define CborMimeMessageTag CborMimeMessageTag
145#define CborCOSE_EncryptTag CborCOSE_EncryptTag
146#define CborCOSE_MacTag CborCOSE_MacTag
147#define CborCOSE_SignTag CborCOSE_SignTag
148#define CborSignatureTag CborSignatureTag
152typedef enum CborError {
157 CborErrorUnknownLength,
158 CborErrorAdvancePastEOF,
162 CborErrorGarbageAtEnd = 256,
163 CborErrorUnexpectedEOF,
164 CborErrorUnexpectedBreak,
165 CborErrorUnknownType,
166 CborErrorIllegalType,
167 CborErrorIllegalNumber,
168 CborErrorIllegalSimpleType,
169 CborErrorNoMoreStringChunks,
172 CborErrorUnknownSimpleType = 512,
174 CborErrorInappropriateTagForType,
175 CborErrorDuplicateObjectKeys,
176 CborErrorInvalidUtf8TextString,
177 CborErrorExcludedType,
178 CborErrorExcludedValue,
179 CborErrorImproperValue,
180 CborErrorOverlongEncoding,
181 CborErrorMapKeyNotString,
182 CborErrorMapNotSorted,
183 CborErrorMapKeysNotUnique,
186 CborErrorTooManyItems = 768,
187 CborErrorTooFewItems,
190 CborErrorDataTooLarge = 1024,
191 CborErrorNestingTooDeep,
192 CborErrorUnsupportedType,
193 CborErrorUnimplementedValidation,
196 CborErrorJsonObjectKeyIsAggregate = 1280,
197 CborErrorJsonObjectKeyNotString,
198 CborErrorJsonNotImplemented,
200 CborErrorOutOfMemory = (int) (~0U / 2 + 1),
201 CborErrorInternalError = (int) (~0U / 2)
208typedef enum CborEncoderAppendType
210 CborEncoderAppendCborData = 0,
211 CborEncoderAppendStringData = 1
212} CborEncoderAppendType;
214typedef CborError (*CborEncoderWriteFunction)(
void *,
const void *, size_t, CborEncoderAppendType);
218 CborIteratorFlag_WriterFunction = 0x01,
219 CborIteratorFlag_ContainerIsMap_ = 0x20
226 ptrdiff_t bytes_needed;
227 CborEncoderWriteFunction writer;
235static const size_t CborIndefiniteLength = SIZE_MAX;
237#ifndef CBOR_NO_ENCODER_API
239CBOR_API
void cbor_encoder_init_writer(
CborEncoder *encoder, CborEncoderWriteFunction writer,
void *);
246CBOR_INLINE_API CborError cbor_encode_text_stringz(
CborEncoder *encoder,
const char *
string)
251CBOR_INLINE_API CborError cbor_encode_boolean(
CborEncoder *encoder,
bool value)
253CBOR_INLINE_API CborError cbor_encode_null(
CborEncoder *encoder)
255CBOR_INLINE_API CborError cbor_encode_undefined(
CborEncoder *encoder)
258CBOR_INLINE_API CborError cbor_encode_half_float(
CborEncoder *encoder,
const void *value)
260CBOR_API CborError cbor_encode_float_as_half_float(
CborEncoder *encoder,
float value);
261CBOR_INLINE_API CborError cbor_encode_float(
CborEncoder *encoder,
float value)
263CBOR_INLINE_API CborError cbor_encode_double(
CborEncoder *encoder,
double value)
271CBOR_INLINE_API uint8_t *_cbor_encoder_get_buffer_pointer(
const CborEncoder *encoder)
273 return encoder->data.ptr;
276CBOR_INLINE_API
size_t cbor_encoder_get_buffer_size(
const CborEncoder *encoder,
const uint8_t *buffer)
278 return (
size_t)(encoder->data.ptr - buffer);
281CBOR_INLINE_API
size_t cbor_encoder_get_extra_bytes_needed(
const CborEncoder *encoder)
283 return encoder->end ? 0 : (size_t)encoder->data.bytes_needed;
289enum CborParserGlobalFlags
291 CborParserFlag_ExternalSource = 0x01
294enum CborParserIteratorFlags
298 CborIteratorFlag_IntegerValueIs64Bit = 0x01,
299 CborIteratorFlag_IntegerValueTooLarge = 0x02,
302 CborIteratorFlag_NegativeInteger = 0x04,
305 CborIteratorFlag_BeforeFirstStringChunk = 0x04,
306 CborIteratorFlag_IteratingStringChunks = 0x08,
309 CborIteratorFlag_UnknownLength = 0x10,
313 CborIteratorFlag_ContainerIsMap = 0x20,
314 CborIteratorFlag_NextIsMapKey = 0x40
318struct CborParserOperations
320 bool (*can_read_bytes)(
void *token,
size_t len);
321 void *(*read_bytes)(
void *token,
void *dst,
size_t offset,
size_t len);
322 void (*advance_bytes)(
void *token,
size_t len);
323 CborError (*transfer_string)(
void *token,
const void **userptr,
size_t offset,
size_t len);
330 const struct CborParserOperations *ops;
332 enum CborParserGlobalFlags flags;
334typedef struct CborParser CborParser;
338 const CborParser *parser;
350#ifndef CBOR_NO_PARSER_API
351CBOR_API CborError
cbor_parser_init(
const uint8_t *buffer,
size_t size, uint32_t flags, CborParser *parser,
CborValue *it);
352CBOR_API CborError cbor_parser_init_reader(
const struct CborParserOperations *ops, CborParser *parser,
CborValue *it,
void *token);
356CBOR_INLINE_API
bool cbor_value_at_end(
const CborValue *it)
357{
return it->remaining == 0; }
358CBOR_INLINE_API
const uint8_t *cbor_value_get_next_byte(
const CborValue *it)
359{
return it->source.ptr; }
360CBOR_API CborError cbor_value_reparse(
CborValue *it);
363CBOR_INLINE_API
bool cbor_value_is_container(
const CborValue *it)
364{
return it->type == CborArrayType || it->type == CborMapType; }
368CBOR_PRIVATE_API uint64_t _cbor_value_decode_int64_internal(
const CborValue *value);
369CBOR_INLINE_API uint64_t _cbor_value_extract_int64_helper(
const CborValue *value)
371 return value->flags & CborIteratorFlag_IntegerValueTooLarge ?
372 _cbor_value_decode_int64_internal(value) : value->extra;
375CBOR_INLINE_API
bool cbor_value_is_valid(
const CborValue *value)
376{
return value && value->type != CborInvalidType; }
377CBOR_INLINE_API CborType cbor_value_get_type(
const CborValue *value)
378{
return (CborType)value->type; }
381CBOR_INLINE_API
bool cbor_value_is_null(
const CborValue *value)
382{
return value->type == CborNullType; }
383CBOR_INLINE_API
bool cbor_value_is_undefined(
const CborValue *value)
384{
return value->type == CborUndefinedType; }
387CBOR_INLINE_API
bool cbor_value_is_boolean(
const CborValue *value)
388{
return value->type == CborBooleanType; }
389CBOR_INLINE_API CborError cbor_value_get_boolean(
const CborValue *value,
bool *result)
391 assert(cbor_value_is_boolean(value));
392 *result = !!value->extra;
397CBOR_INLINE_API
bool cbor_value_is_simple_type(
const CborValue *value)
398{
return value->type == CborSimpleType; }
399CBOR_INLINE_API CborError cbor_value_get_simple_type(
const CborValue *value, uint8_t *result)
401 assert(cbor_value_is_simple_type(value));
402 *result = (uint8_t)value->extra;
407CBOR_INLINE_API
bool cbor_value_is_integer(
const CborValue *value)
408{
return value->type == CborIntegerType; }
409CBOR_INLINE_API
bool cbor_value_is_unsigned_integer(
const CborValue *value)
410{
return cbor_value_is_integer(value) && (value->flags & CborIteratorFlag_NegativeInteger) == 0; }
411CBOR_INLINE_API
bool cbor_value_is_negative_integer(
const CborValue *value)
412{
return cbor_value_is_integer(value) && (value->flags & CborIteratorFlag_NegativeInteger); }
414CBOR_INLINE_API CborError cbor_value_get_raw_integer(
const CborValue *value, uint64_t *result)
416 assert(cbor_value_is_integer(value));
417 *result = _cbor_value_extract_int64_helper(value);
421CBOR_INLINE_API CborError cbor_value_get_uint64(
const CborValue *value, uint64_t *result)
423 assert(cbor_value_is_unsigned_integer(value));
424 *result = _cbor_value_extract_int64_helper(value);
428CBOR_INLINE_API CborError cbor_value_get_int64(
const CborValue *value, int64_t *result)
430 assert(cbor_value_is_integer(value));
431 *result = (int64_t) _cbor_value_extract_int64_helper(value);
432 if (value->flags & CborIteratorFlag_NegativeInteger)
433 *result = -*result - 1;
437CBOR_INLINE_API CborError cbor_value_get_int(
const CborValue *value,
int *result)
439 assert(cbor_value_is_integer(value));
440 *result = (int) _cbor_value_extract_int64_helper(value);
441 if (value->flags & CborIteratorFlag_NegativeInteger)
442 *result = -*result - 1;
449CBOR_INLINE_API
bool cbor_value_is_length_known(
const CborValue *value)
450{
return (value->flags & CborIteratorFlag_UnknownLength) == 0; }
453CBOR_INLINE_API
bool cbor_value_is_tag(
const CborValue *value)
454{
return value->type == CborTagType; }
455CBOR_INLINE_API CborError cbor_value_get_tag(
const CborValue *value, CborTag *result)
457 assert(cbor_value_is_tag(value));
458 *result = _cbor_value_extract_int64_helper(value);
464CBOR_INLINE_API
bool cbor_value_is_byte_string(
const CborValue *value)
465{
return value->type == CborByteStringType; }
466CBOR_INLINE_API
bool cbor_value_is_text_string(
const CborValue *value)
467{
return value->type == CborTextStringType; }
469CBOR_INLINE_API CborError cbor_value_get_string_length(
const CborValue *value,
size_t *length)
472 assert(cbor_value_is_byte_string(value) || cbor_value_is_text_string(value));
473 if (!cbor_value_is_length_known(value))
474 return CborErrorUnknownLength;
475 v = _cbor_value_extract_int64_helper(value);
478 return CborErrorDataTooLarge;
482CBOR_PRIVATE_API CborError _cbor_value_copy_string(
const CborValue *value,
void *buffer,
484CBOR_PRIVATE_API CborError _cbor_value_dup_string(
const CborValue *value,
void **buffer,
489CBOR_INLINE_API CborError cbor_value_copy_text_string(
const CborValue *value,
char *buffer,
492 assert(cbor_value_is_text_string(value));
493 return _cbor_value_copy_string(value, buffer, buflen, next);
495CBOR_INLINE_API CborError cbor_value_copy_byte_string(
const CborValue *value, uint8_t *buffer,
498 assert(cbor_value_is_byte_string(value));
499 return _cbor_value_copy_string(value, buffer, buflen, next);
505 assert(cbor_value_is_text_string(value));
506 return _cbor_value_dup_string(value, (
void **)buffer, buflen, next);
511 assert(cbor_value_is_byte_string(value));
512 return _cbor_value_dup_string(value, (
void **)buffer, buflen, next);
515CBOR_PRIVATE_API CborError _cbor_value_get_string_chunk_size(
const CborValue *value,
size_t *len);
516CBOR_INLINE_API CborError cbor_value_get_string_chunk_size(
const CborValue *value,
size_t *len)
518 assert(value->flags & CborIteratorFlag_IteratingStringChunks);
519 return _cbor_value_get_string_chunk_size(value, len);
522CBOR_INLINE_API
bool cbor_value_string_iteration_at_end(
const CborValue *value)
525 return cbor_value_get_string_chunk_size(value, &dummy) == CborErrorNoMoreStringChunks;
528CBOR_PRIVATE_API CborError _cbor_value_begin_string_iteration(
CborValue *value);
529CBOR_INLINE_API CborError cbor_value_begin_string_iteration(
CborValue *value)
531 assert(cbor_value_is_text_string(value) || cbor_value_is_byte_string(value));
532 assert(!(value->flags & CborIteratorFlag_IteratingStringChunks));
533 return _cbor_value_begin_string_iteration(value);
536CBOR_PRIVATE_API CborError _cbor_value_finish_string_iteration(
CborValue *value);
537CBOR_INLINE_API CborError cbor_value_finish_string_iteration(
CborValue *value)
539 assert(cbor_value_string_iteration_at_end(value));
540 return _cbor_value_finish_string_iteration(value);
543CBOR_PRIVATE_API CborError _cbor_value_get_string_chunk(
const CborValue *value,
const void **bufferptr,
545CBOR_INLINE_API CborError cbor_value_get_text_string_chunk(
const CborValue *value,
const char **bufferptr,
548 assert(cbor_value_is_text_string(value));
549 return _cbor_value_get_string_chunk(value, (
const void **)bufferptr, len, next);
551CBOR_INLINE_API CborError cbor_value_get_byte_string_chunk(
const CborValue *value,
const uint8_t **bufferptr,
554 assert(cbor_value_is_byte_string(value));
555 return _cbor_value_get_string_chunk(value, (
const void **)bufferptr, len, next);
561CBOR_INLINE_API
bool cbor_value_is_array(
const CborValue *value)
562{
return value->type == CborArrayType; }
563CBOR_INLINE_API
bool cbor_value_is_map(
const CborValue *value)
564{
return value->type == CborMapType; }
566CBOR_INLINE_API CborError cbor_value_get_array_length(
const CborValue *value,
size_t *length)
569 assert(cbor_value_is_array(value));
570 if (!cbor_value_is_length_known(value))
571 return CborErrorUnknownLength;
572 v = _cbor_value_extract_int64_helper(value);
575 return CborErrorDataTooLarge;
579CBOR_INLINE_API CborError cbor_value_get_map_length(
const CborValue *value,
size_t *length)
582 assert(cbor_value_is_map(value));
583 if (!cbor_value_is_length_known(value))
584 return CborErrorUnknownLength;
585 v = _cbor_value_extract_int64_helper(value);
588 return CborErrorDataTooLarge;
595CBOR_INLINE_API
bool cbor_value_is_half_float(
const CborValue *value)
596{
return value->type == CborHalfFloatType; }
598CBOR_INLINE_API CborError cbor_value_get_half_float(
const CborValue *value,
void *result)
600 assert(cbor_value_is_half_float(value));
601 assert((value->flags & CborIteratorFlag_IntegerValueTooLarge) == 0);
604 memcpy(result, &value->extra,
sizeof(value->extra));
608CBOR_INLINE_API
bool cbor_value_is_float(
const CborValue *value)
609{
return value->type == CborFloatType; }
610CBOR_INLINE_API CborError cbor_value_get_float(
const CborValue *value,
float *result)
613 assert(cbor_value_is_float(value));
614 assert(value->flags & CborIteratorFlag_IntegerValueTooLarge);
615 data = (uint32_t)_cbor_value_decode_int64_internal(value);
616 memcpy(result, &data,
sizeof(*result));
620CBOR_INLINE_API
bool cbor_value_is_double(
const CborValue *value)
621{
return value->type == CborDoubleType; }
622CBOR_INLINE_API CborError cbor_value_get_double(
const CborValue *value,
double *result)
625 assert(cbor_value_is_double(value));
626 assert(value->flags & CborIteratorFlag_IntegerValueTooLarge);
627 data = _cbor_value_decode_int64_internal(value);
628 memcpy(result, &data,
sizeof(*result));
633#ifndef CBOR_NO_VALIDATION_API
635enum CborValidationFlags {
643 CborValidateShortestIntegrals = 0x0001,
644 CborValidateShortestFloatingPoint = 0x0002,
645 CborValidateShortestNumbers = CborValidateShortestIntegrals | CborValidateShortestFloatingPoint,
646 CborValidateNoIndeterminateLength = 0x0100,
647 CborValidateMapIsSorted = 0x0200 | CborValidateNoIndeterminateLength,
649 CborValidateCanonicalFormat = 0x0fff,
651 CborValidateMapKeysAreUnique = 0x1000 | CborValidateMapIsSorted,
652 CborValidateTagUse = 0x2000,
653 CborValidateUtf8 = 0x4000,
655 CborValidateStrictMode = 0xfff00,
657 CborValidateMapKeysAreString = 0x100000,
658 CborValidateNoUndefined = 0x200000,
659 CborValidateNoTags = 0x400000,
660 CborValidateFiniteFloatingPoint = 0x800000,
664 CborValidateNoUnknownSimpleTypesSA = 0x4000000,
665 CborValidateNoUnknownSimpleTypes = 0x8000000 | CborValidateNoUnknownSimpleTypesSA,
666 CborValidateNoUnknownTagsSA = 0x10000000,
667 CborValidateNoUnknownTagsSR = 0x20000000 | CborValidateNoUnknownTagsSA,
668 CborValidateNoUnknownTags = 0x40000000 | CborValidateNoUnknownTagsSR,
670 CborValidateCompleteData = (int)0x80000000,
672 CborValidateStrictest = (
int)~0U,
673 CborValidateBasic = 0
680#ifndef CBOR_NO_PRETTY_API
682enum CborPrettyFlags {
683 CborPrettyNumericEncodingIndicators = 0x01,
684 CborPrettyTextualEncodingIndicators = 0,
686 CborPrettyIndicateIndeterminateLength = 0x02,
687 CborPrettyIndicateIndetermineLength = CborPrettyIndicateIndeterminateLength,
688 CborPrettyIndicateOverlongNumbers = 0x04,
690 CborPrettyShowStringFragments = 0x100,
691 CborPrettyMergeStringFragments = 0,
693 CborPrettyDefaultFlags = CborPrettyIndicateIndeterminateLength
696typedef CborError (*CborStreamFunction)(
void *token,
const char *fmt, ...)
698 __attribute__((__format__(printf, 2, 3)))
705#if !defined(__STDC_HOSTED__) || __STDC_HOSTED__-0 == 1
CborError cbor_value_to_pretty(FILE *out, const CborValue *value)
Converts the current CBOR type pointed to by value to its textual representation and writes it to the...
Definition cbor.h:708
CborError cbor_value_dup_text_string(const CborValue *value, char **buffer, size_t *buflen, CborValue *next)
Allocates memory for the string pointed by value and copies it into this buffer.
Definition cbor.h:502
CBOR_API CborError cbor_value_get_half_float_as_float(const CborValue *value, float *result)
Retrieves the CBOR half-precision floating point (16-bit) value that value points to,...
Definition cborparser_float.c:44
CBOR_API CborError cbor_value_to_pretty_advance_flags(FILE *out, CborValue *value, int flags)
Converts the current CBOR type pointed to by value to its textual representation and writes it to the...
Definition cborpretty_stdio.c:83
CborError cbor_value_dup_byte_string(const CborValue *value, uint8_t **buffer, size_t *buflen, CborValue *next)
Allocates memory for the string pointed by value and copies it into this buffer.
Definition cbor.h:508
CBOR_API CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value)
Converts the current CBOR type pointed to by value to its textual representation and writes it to the...
Definition cborpretty_stdio.c:63
CBOR_API const char * cbor_error_string(CborError error)
Returns the error string corresponding to the CBOR error condition error.
Definition cborerrorstrings.c:80
CBOR_API CborError cbor_encode_negative_int(CborEncoder *encoder, uint64_t absolute_value)
Appends the negative 64-bit integer whose absolute value is absolute_value to the CBOR stream provide...
Definition cborencoder.c:368
CBOR_API CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length)
Appends the byte string string of length length to the CBOR stream provided by encoder.
Definition cborencoder.c:470
CBOR_API void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t size, int flags)
Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size.
Definition cborencoder.c:203
CBOR_API CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value)
Appends the unsigned 64-bit integer value to the CBOR stream provided by encoder.
Definition cborencoder.c:355
CBOR_API CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length)
Appends the text string string of length length to the CBOR stream provided by encoder.
Definition cborencoder.c:482
CBOR_API CborError cbor_encoder_close_container(CborEncoder *parentEncoder, const CborEncoder *containerEncoder)
Closes the CBOR container (array or map) provided by containerEncoder and updates the CBOR stream pro...
Definition cborencoder.c:573
CBOR_API CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag)
Appends the CBOR tag tag to the CBOR stream provided by encoder.
Definition cborencoder.c:439
CBOR_API CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value)
Appends the CBOR Simple Type of value value to the CBOR stream provided by encoder.
Definition cborencoder.c:395
CBOR_API CborError cbor_encoder_create_array(CborEncoder *parentEncoder, CborEncoder *arrayEncoder, size_t length)
Creates a CBOR array in the CBOR stream provided by parentEncoder and initializes arrayEncoder so tha...
Definition cborencoder.c:530
CBOR_API CborError cbor_encoder_close_container_checked(CborEncoder *parentEncoder, const CborEncoder *containerEncoder)
Definition cborencoder_close_container_checked.c:52
CBOR_API CborError cbor_encoder_create_map(CborEncoder *parentEncoder, CborEncoder *mapEncoder, size_t length)
Creates a CBOR map in the CBOR stream provided by parentEncoder and initializes mapEncoder so that it...
Definition cborencoder.c:554
CBOR_API CborError cbor_encode_int(CborEncoder *encoder, int64_t value)
Appends the signed 64-bit integer value to the CBOR stream provided by encoder.
Definition cborencoder.c:379
CBOR_API CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value)
Appends the floating-point value of type fpType and pointed to by value to the CBOR stream provided b...
Definition cborencoder.c:416
CBOR_API CborError cbor_value_enter_container(const CborValue *it, CborValue *recursed)
Creates a CborValue iterator pointing to the first element of the container represented by it and sav...
Definition cborparser.c:581
CBOR_API CborError cbor_value_validate_basic(const CborValue *it)
Performs a basic validation of the CBOR stream pointed by it and returns the error it found.
Definition cborparser.c:445
CBOR_API CborError cbor_value_skip_tag(CborValue *it)
Advances the CBOR value it until it no longer points to a tag.
Definition cborparser.c:554
CBOR_API CborError cbor_value_validate(const CborValue *it, uint32_t flags)
Performs a full validation, controlled by the flags options, of the CBOR stream pointed by it and ret...
Definition cborvalidation.c:644
CBOR_API CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
Updates it to point to the next element after the container.
Definition cborparser.c:630
CBOR_API CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result)
Retrieves the CBOR integer value that value points to and stores it in result.
Definition cborparser.c:815
CBOR_API CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it)
Initializes the CBOR parser for parsing size bytes beginning at buffer.
Definition cborparser.c:346
CBOR_API CborError cbor_value_advance_fixed(CborValue *it)
Advances the CBOR value it by one fixed-size position.
Definition cborparser.c:466
CBOR_API CborError cbor_value_text_string_equals(const CborValue *value, const char *string, bool *result)
Compares the entry value with the string string and stores the result in result.
Definition cborparser.c:1326
CBOR_API CborError cbor_value_calculate_string_length(const CborValue *value, size_t *length)
Calculates the length of the byte or text string that value points to and stores it in len.
Definition cborparser.c:966
CBOR_API CborError cbor_value_advance(CborValue *it)
Advances the CBOR value it by one element, skipping over containers.
Definition cborparser.c:518
CBOR_API CborError cbor_value_map_find_value(const CborValue *map, const char *string, CborValue *element)
Attempts to find the value in map map that corresponds to the text string entry string.
Definition cborparser.c:1414
CBOR_API CborError cbor_value_get_int_checked(const CborValue *value, int *result)
Retrieves the CBOR integer value that value points to and stores it in result.
Definition cborparser.c:855
CBOR_API CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *token, CborValue *value, int flags)
Converts the current CBOR type pointed by value to its textual representation and writes it to the st...
Definition cborpretty.c:574
Structure used to encode to CBOR.
Definition cbor.h:223
This type contains one value parsed from the CBOR stream.
Definition cbor.h:337