aboutsummaryrefslogtreecommitdiff
path: root/src/cbor.h
blob: d490e6c5862e5d0606a3a4e2f60f13f2f5fed76c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright (c) 2014-2020 Pavel Kalvoda <me@pavelkalvoda.com>
 *
 * libcbor is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 */

#ifndef LIBCBOR_H_
#define LIBCBOR_H_

#include "cbor/common.h"
#include "cbor/data.h"

#include "cbor/arrays.h"
#include "cbor/bytestrings.h"
#include "cbor/floats_ctrls.h"
#include "cbor/ints.h"
#include "cbor/maps.h"
#include "cbor/strings.h"
#include "cbor/tags.h"

#include "cbor/callbacks.h"
#include "cbor/cbor_export.h"
#include "cbor/encoding.h"
#include "cbor/serialization.h"
#include "cbor/streaming.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * ============================================================================
 * High level decoding
 * ============================================================================
 */

/** Loads data item from a buffer
 *
 * @param source The buffer
 * @param source_size
 * @param result[out] Result indicator. #CBOR_ERR_NONE on success
 * @return **new** CBOR item or `NULL` on failure. In that case, \p result
 * contains location and description of the error.
 */
CBOR_EXPORT cbor_item_t* cbor_load(cbor_data source, size_t source_size,
                                   struct cbor_load_result* result);

/** Deep copy of an item
 *
 * All the reference counts in the new structure are set to one.
 *
 * @param item[borrow] item to copy
 * @return **new** CBOR deep copy
 */
CBOR_EXPORT cbor_item_t* cbor_copy(cbor_item_t* item);

#if CBOR_PRETTY_PRINTER
#include <stdio.h>

CBOR_EXPORT void cbor_describe(cbor_item_t* item, FILE* out);
#endif

#ifdef __cplusplus
}
#endif

#endif  // LIBCBOR_H_