libcbor 0.12.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
|
Go to the source code of this file.
Functions | |
size_t | cbor_bytestring_length (const cbor_item_t *item) |
Returns the length of the binary data. | |
bool | cbor_bytestring_is_definite (const cbor_item_t *item) |
Is the byte string definite? | |
bool | cbor_bytestring_is_indefinite (const cbor_item_t *item) |
Is the byte string indefinite? | |
cbor_mutable_data | cbor_bytestring_handle (const cbor_item_t *item) |
Get the handle to the binary data. | |
void | cbor_bytestring_set_handle (cbor_item_t *item, cbor_mutable_data data, size_t length) |
Set the handle to the binary data. | |
cbor_item_t ** | cbor_bytestring_chunks_handle (const cbor_item_t *item) |
Get the handle to the array of chunks. | |
size_t | cbor_bytestring_chunk_count (const cbor_item_t *item) |
Get the number of chunks this string consist of. | |
bool | cbor_bytestring_add_chunk (cbor_item_t *item, cbor_item_t *chunk) |
Appends a chunk to the bytestring. | |
cbor_item_t * | cbor_new_definite_bytestring (void) |
Creates a new definite byte string. | |
cbor_item_t * | cbor_new_indefinite_bytestring (void) |
Creates a new indefinite byte string. | |
cbor_item_t * | cbor_build_bytestring (cbor_data handle, size_t length) |
Creates a new byte string and initializes it. | |
cbor_item_t * cbor_build_bytestring | ( | cbor_data | handle, |
size_t | length ) |
Creates a new byte string and initializes it.
The handle
will be copied to a newly allocated block
handle | Block of binary data |
length | Length of data |
NULL
if memory allocation fails Definition at line 61 of file bytestrings.c.
bool cbor_bytestring_add_chunk | ( | cbor_item_t * | item, |
cbor_item_t * | chunk ) |
Appends a chunk to the bytestring.
Indefinite byte strings only.
May realloc the chunk storage.
item | An indefinite byte string |
chunk | A definite byte string. Its reference count will be be increased by one. |
chunk
is not increased and the item
is left intact. Definition at line 92 of file bytestrings.c.
size_t cbor_bytestring_chunk_count | ( | const cbor_item_t * | item | ) |
Get the number of chunks this string consist of.
item | A indefinite bytestring |
Definition at line 86 of file bytestrings.c.
cbor_item_t ** cbor_bytestring_chunks_handle | ( | const cbor_item_t * | item | ) |
Get the handle to the array of chunks.
Manipulations with the memory block (e.g. sorting it) are allowed, but the validity and the number of chunks must be retained.
item | A indefinite byte string |
Definition at line 80 of file bytestrings.c.
cbor_mutable_data cbor_bytestring_handle | ( | const cbor_item_t * | item | ) |
Get the handle to the binary data.
Definite items only. Modifying the data is allowed. In that case, the caller takes responsibility for the effect on items this item might be a part of
item | A definite byte string |
NULL
if no data have been assigned yet. Definition at line 17 of file bytestrings.c.
bool cbor_bytestring_is_definite | ( | const cbor_item_t * | item | ) |
Is the byte string definite?
item | a byte string |
Definition at line 22 of file bytestrings.c.
bool cbor_bytestring_is_indefinite | ( | const cbor_item_t * | item | ) |
Is the byte string indefinite?
item | a byte string |
Definition at line 27 of file bytestrings.c.
size_t cbor_bytestring_length | ( | const cbor_item_t * | item | ) |
Returns the length of the binary data.
For definite byte strings only
item | a definite bytestring |
Definition at line 12 of file bytestrings.c.
void cbor_bytestring_set_handle | ( | cbor_item_t * | item, |
cbor_mutable_data | data, | ||
size_t | length ) |
Set the handle to the binary data.
item | A definite byte string |
data | The memory block. The caller gives up the ownership of the block. libcbor will deallocate it when appropriate using the free implementation configured using cbor_set_allocs |
length | Length of the data block |
Definition at line 71 of file bytestrings.c.
cbor_item_t * cbor_new_definite_bytestring | ( | void | ) |
Creates a new definite byte string.
The handle is initialized to NULL
and length to 0
NULL
if memory allocation fails Definition at line 31 of file bytestrings.c.
cbor_item_t * cbor_new_indefinite_bytestring | ( | void | ) |
Creates a new indefinite byte string.
The chunks array is initialized to NULL
and chunk count to 0
NULL
if memory allocation fails Definition at line 42 of file bytestrings.c.