aboutsummaryrefslogtreecommitdiff
path: root/src/cbor/callbacks.h
blob: 9e5965f2d92142317b1e7c980a3efa1b7e3f2a7a (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * 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_CALLBACKS_H
#define LIBCBOR_CALLBACKS_H

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

#ifdef __cplusplus
extern "C" {
#endif

/** Callback prototype */
typedef void (*cbor_int8_callback)(void *, uint8_t);

/** Callback prototype */
typedef void (*cbor_int16_callback)(void *, uint16_t);

/** Callback prototype */
typedef void (*cbor_int32_callback)(void *, uint32_t);

/** Callback prototype */
typedef void (*cbor_int64_callback)(void *, uint64_t);

/** Callback prototype */
typedef void (*cbor_simple_callback)(void *);

/** Callback prototype */
typedef void (*cbor_string_callback)(void *, cbor_data, size_t);

/** Callback prototype */
typedef void (*cbor_collection_callback)(void *, size_t);

/** Callback prototype */
typedef void (*cbor_float_callback)(void *, float);

/** Callback prototype */
typedef void (*cbor_double_callback)(void *, double);

/** Callback prototype */
typedef void (*cbor_bool_callback)(void *, bool);

/** Callback bundle -- passed to the decoder */
struct cbor_callbacks {
  /** Unsigned int */
  cbor_int8_callback uint8;
  /** Unsigned int */
  cbor_int16_callback uint16;
  /** Unsigned int */
  cbor_int32_callback uint32;
  /** Unsigned int */
  cbor_int64_callback uint64;

  /** Negative int */
  cbor_int64_callback negint64;
  /** Negative int */
  cbor_int32_callback negint32;
  /** Negative int */
  cbor_int16_callback negint16;
  /** Negative int */
  cbor_int8_callback negint8;

  /** Definite byte string */
  cbor_simple_callback byte_string_start;
  /** Indefinite byte string start */
  cbor_string_callback byte_string;

  /** Definite string */
  cbor_string_callback string;
  /** Indefinite string start */
  cbor_simple_callback string_start;

  /** Definite array */
  cbor_simple_callback indef_array_start;
  /** Indefinite array */
  cbor_collection_callback array_start;

  /** Definite map */
  cbor_simple_callback indef_map_start;
  /** Indefinite map */
  cbor_collection_callback map_start;

  /** Tags */
  cbor_int64_callback tag;

  /** Half float */
  cbor_float_callback float2;
  /** Single float */
  cbor_float_callback float4;
  /** Double float */
  cbor_double_callback float8;
  /** Undef */
  cbor_simple_callback undefined;
  /** Null */
  cbor_simple_callback null;
  /** Bool */
  cbor_bool_callback boolean;

  /** Indefinite item break */
  cbor_simple_callback indef_break;
};

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_uint8_callback(void *, uint8_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_uint16_callback(void *, uint16_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_uint32_callback(void *, uint32_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_uint64_callback(void *, uint64_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_negint8_callback(void *, uint8_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_negint16_callback(void *, uint16_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_negint32_callback(void *, uint32_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_negint64_callback(void *, uint64_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_string_callback(void *, cbor_data, size_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_string_start_callback(void *);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_byte_string_callback(void *, cbor_data, size_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_byte_string_start_callback(void *);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_array_start_callback(void *, size_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_indef_array_start_callback(void *);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_map_start_callback(void *, size_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_indef_map_start_callback(void *);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_tag_callback(void *, uint64_t);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_float2_callback(void *, float);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_float4_callback(void *, float);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_float8_callback(void *, double);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_null_callback(void *);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_undefined_callback(void *);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_boolean_callback(void *, bool);

/** Dummy callback implementation - does nothing */
CBOR_EXPORT void cbor_null_indef_break_callback(void *);

/** Dummy callback bundle - does nothing */
CBOR_EXPORT extern const struct cbor_callbacks cbor_empty_callbacks;

#ifdef __cplusplus
}
#endif

#endif  // LIBCBOR_CALLBACKS_H