Diffusion C API
6.2.9
|
Utilities for handling CBOR-encoded data. More...
Data Structures | |
struct | cbor_parser_s |
union | CBOR_VALUE_UNION_T |
struct | cbor_val_s |
A CBOR value/token as returned by cbor_next_val(). More... | |
struct | cbor_generator_s |
A CBOR generator is a wrapper for encoded data and the length of that data. More... | |
Macros | |
#define | CBOR_VAL_FALSE |
Initial byte which maps to a JSON "false" value. | |
#define | CBOR_VAL_TRUE |
Initial byte which maps to a JSON "true" value. | |
#define | CBOR_VAL_NULL |
Initial byte which maps to a JSON "null" value. | |
#define | CBOR_VAL_UNDEFINED |
Initial byte which maps to a JSON "undefined" value. | |
#define | CBOR_VAL_BREAK |
Initial byte indicating the termination of a indefinte-length collection. | |
Typedefs | |
typedef struct cbor_val_s | CBOR_VAL_T |
A CBOR value/token as returned by cbor_next_val(). | |
typedef struct cbor_generator_s | CBOR_GENERATOR_T |
A CBOR generator is a wrapper for encoded data and the length of that data. More... | |
Enumerations | |
enum | CBOR_TYPE_T |
CBOR major types. | |
Functions | |
CBOR_PARSER_T * | cbor_parser_create (const char *data, size_t len) |
Create a CBOR parser. More... | |
void | cbor_parser_free (CBOR_PARSER_T *parser) |
Free memory associated with a CBOR parser. More... | |
CBOR_VAL_T * | cbor_next_val (CBOR_PARSER_T *parser) |
Get the next available token from a CBOR parser. More... | |
void | cbor_val_free (CBOR_VAL_T *val) |
Free memory associated with a CBOR_VAL_T. More... | |
CBOR_GENERATOR_T * | cbor_generator_create () |
Creates a generator to be used for encoding CBOR data. More... | |
void | cbor_generator_free (CBOR_GENERATOR_T *generator) |
Free memory associated with a CBOR generator. More... | |
int | cbor_write_uint (CBOR_GENERATOR_T *generator, uint64_t val) |
Encode an unsigned integer value into the smallest possible CBOR encoding. More... | |
int | cbor_write_negint (CBOR_GENERATOR_T *generator, int64_t val) |
Encode an negative integer value into the smallest possible CBOR encoding. More... | |
int | cbor_write_byte_string (CBOR_GENERATOR_T *generator, const char *bytes, int64_t len) |
Encode a stream of bytes as CBOR. More... | |
int | cbor_write_text_string (CBOR_GENERATOR_T *generator, const char *bytes, int64_t len) |
Encode a stream of bytes as CBOR. More... | |
int | cbor_write_array (CBOR_GENERATOR_T *generator, int64_t size) |
Encode an array start marker as CBOR. More... | |
int | cbor_write_map (CBOR_GENERATOR_T *generator, int64_t size) |
Encode a map start marker as CBOR. More... | |
int | cbor_write_float (CBOR_GENERATOR_T *generator, double val) |
Encode a floating point value in CBOR format. More... | |
int | cbor_write_break (CBOR_GENERATOR_T *generator) |
Encode a "break" value in CBOR format, for terminating indefinite-length CBOR collections. More... | |
int | cbor_write_false (CBOR_GENERATOR_T *generator) |
Encode a "false" value in CBOR format. More... | |
int | cbor_write_true (CBOR_GENERATOR_T *generator) |
Encode a "true" value in CBOR format. More... | |
int | cbor_write_null (CBOR_GENERATOR_T *generator) |
Encode a "null" value in CBOR format. More... | |
int | cbor_write_undefined (CBOR_GENERATOR_T *generator) |
Encode an "undefined" value in CBOR format. More... | |
Utilities for handling CBOR-encoded data.
Copyright © 2017 Push Technology Ltd., All Rights Reserved.
Use is subject to license terms.
NOTICE: All information contained herein is, and remains the property of Push Technology. The intellectual and technical concepts contained herein are proprietary to Push Technology and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
typedef struct cbor_generator_s CBOR_GENERATOR_T |
A CBOR generator is a wrapper for encoded data and the length of that data.
Once all items have been written to the generator, the encoded data can be accessed directly from the structure.
CBOR_GENERATOR_T* cbor_generator_create | ( | ) |
Creates a generator to be used for encoding CBOR data.
A | new CBOR generator, or NULL on error. |
void cbor_generator_free | ( | CBOR_GENERATOR_T * | generator | ) |
Free memory associated with a CBOR generator.
generator | The CBOR generator to be freed. |
CBOR_VAL_T* cbor_next_val | ( | CBOR_PARSER_T * | parser | ) |
Get the next available token from a CBOR parser.
parser | A pointer to a CBOR parser. |
CBOR_PARSER_T* cbor_parser_create | ( | const char * | data, |
size_t | len | ||
) |
Create a CBOR parser.
data | A pointer to CBOR-encoded data. The data is not copied and must be available during the lifetime of the parser. |
len | Length of the CBOR-encoded data. |
void cbor_parser_free | ( | CBOR_PARSER_T * | parser | ) |
Free memory associated with a CBOR parser.
parser | A pointer to a CBOR_PARSER_T. If NULL, this function has no effect. |
void cbor_val_free | ( | CBOR_VAL_T * | val | ) |
Free memory associated with a CBOR_VAL_T.
A | pointer to a CBOR_VAL_T structure, or NULL. |
int cbor_write_array | ( | CBOR_GENERATOR_T * | generator, |
int64_t | size | ||
) |
Encode an array start marker as CBOR.
A marker denoting an indefinte-length array can be written using this function by setting len to -1. It is neccessary to call cbor_write_break()
once the data items inside an array of this type have been written.
generator | The CBOR generator to encode into. |
size | The length of the array to be encoded. |
int cbor_write_break | ( | CBOR_GENERATOR_T * | generator | ) |
Encode a "break" value in CBOR format, for terminating indefinite-length CBOR collections.
generator | The CBOR generator to which the encoded value is appended. |
int cbor_write_byte_string | ( | CBOR_GENERATOR_T * | generator, |
const char * | bytes, | ||
int64_t | len | ||
) |
Encode a stream of bytes as CBOR.
A marker denoting an indefinte-length byte string can be written using this function by setting len to -1. It is neccessary to call cbor_write_break()
once the data items inside a byte string of this type has been written.
generator | The CBOR generator to encode into. |
bytes | A pointer to the bytes to be encoded. |
len | The length of the bytes to be encoded. |
int cbor_write_false | ( | CBOR_GENERATOR_T * | generator | ) |
Encode a "false" value in CBOR format.
generator | The CBOR generator to which the encoded value is appended. |
int cbor_write_float | ( | CBOR_GENERATOR_T * | generator, |
double | val | ||
) |
Encode a floating point value in CBOR format.
Automatically detects the smallest possible encoding to use.
generator | The CBOR generator to which the encoded value is appended. |
val | The value to be encoded. |
int cbor_write_map | ( | CBOR_GENERATOR_T * | generator, |
int64_t | size | ||
) |
Encode a map start marker as CBOR.
The length of a map is equal to the number of key/value pairs that it contains.
A marker denoting an indefinte-length map can be written using this function by setting len to -1. It is neccessary to call cbor_write_break()
once the data items inside a map of this type have been written.
generator | The CBOR generator to encode into. |
size | The length of the map to be encoded. |
int cbor_write_negint | ( | CBOR_GENERATOR_T * | generator, |
int64_t | val | ||
) |
Encode an negative integer value into the smallest possible CBOR encoding.
generator | The CBOR generator to encode into. |
val | The value to be encoded. |
int cbor_write_null | ( | CBOR_GENERATOR_T * | generator | ) |
Encode a "null" value in CBOR format.
generator | The CBOR generator to which the encoded value is appended. |
int cbor_write_text_string | ( | CBOR_GENERATOR_T * | generator, |
const char * | bytes, | ||
int64_t | len | ||
) |
Encode a stream of bytes as CBOR.
A marker denoting an indefinte-length text string can be written using this function by setting len to -1. It is neccessary to call cbor_write_break()
once the data items inside a text string of this type have been written.
generator | The CBOR generator to encode into. |
bytes | A pointer to the bytes to be encoded. |
len | The length of the bytes to be encoded. |
int cbor_write_true | ( | CBOR_GENERATOR_T * | generator | ) |
Encode a "true" value in CBOR format.
generator | The CBOR generator to which the encoded value is appended. |
int cbor_write_uint | ( | CBOR_GENERATOR_T * | generator, |
uint64_t | val | ||
) |
Encode an unsigned integer value into the smallest possible CBOR encoding.
generator | The CBOR generator to encode into. |
val | The value to be encoded. |
int cbor_write_undefined | ( | CBOR_GENERATOR_T * | generator | ) |
Encode an "undefined" value in CBOR format.
generator | The CBOR generator to which the encoded value is appended. |