libcbor 0.12.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Loading...
Searching...
No Matches
bytestrings.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2020 Pavel Kalvoda <me@pavelkalvoda.com>
3 *
4 * libcbor is free software; you can redistribute it and/or modify
5 * it under the terms of the MIT license. See LICENSE for details.
6 */
7
8#ifndef LIBCBOR_BYTESTRINGS_H
9#define LIBCBOR_BYTESTRINGS_H
10
11#include "cbor/cbor_export.h"
12#include "cbor/common.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/*
19 * ============================================================================
20 * Byte string manipulation
21 * ============================================================================
22 */
23
32CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t* item);
33
40CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t* item);
41
48CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t* item);
49
62
71CBOR_EXPORT void cbor_bytestring_set_handle(
73 size_t length);
74
85 const cbor_item_t* item);
86
93CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t* item);
94
108CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t* item,
109 cbor_item_t* chunk);
110
121
132
144CBOR_EXPORT cbor_item_t* cbor_build_bytestring(cbor_data handle, size_t length);
145
146#ifdef __cplusplus
147}
148#endif
149
150#endif // LIBCBOR_BYTESTRINGS_H
cbor_mutable_data cbor_bytestring_handle(const cbor_item_t *item)
Get the handle to the binary data.
Definition bytestrings.c:17
bool cbor_bytestring_is_definite(const cbor_item_t *item)
Is the byte string definite?
Definition bytestrings.c:22
bool cbor_bytestring_is_indefinite(const cbor_item_t *item)
Is the byte string indefinite?
Definition bytestrings.c:27
cbor_item_t * cbor_new_definite_bytestring(void)
Creates a new definite byte string.
Definition bytestrings.c:31
bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk)
Appends a chunk to the bytestring.
Definition bytestrings.c:92
size_t cbor_bytestring_length(const cbor_item_t *item)
Returns the length of the binary data.
Definition bytestrings.c:12
cbor_item_t ** cbor_bytestring_chunks_handle(const cbor_item_t *item)
Get the handle to the array of chunks.
Definition bytestrings.c:80
cbor_item_t * cbor_new_indefinite_bytestring(void)
Creates a new indefinite byte string.
Definition bytestrings.c:42
cbor_item_t * cbor_build_bytestring(cbor_data handle, size_t length)
Creates a new byte string and initializes it.
Definition bytestrings.c:61
size_t cbor_bytestring_chunk_count(const cbor_item_t *item)
Get the number of chunks this string consist of.
Definition bytestrings.c:86
void cbor_bytestring_set_handle(cbor_item_t *item, cbor_mutable_data data, size_t length)
Set the handle to the binary data.
Definition bytestrings.c:71
#define CBOR_RESTRICT_POINTER
Definition common.h:36
#define _CBOR_NODISCARD
Definition common.h:93
const unsigned char * cbor_data
Definition data.h:20
unsigned char * cbor_mutable_data
Definition data.h:21
The item handle.
Definition data.h:171