1 module deimos.cbor.callbacks;
2 
3 import deimos.cbor.data;
4 
5 /*
6  * Copyright (c) 2014-2019 Pavel Kalvoda <me@pavelkalvoda.com>
7  *
8  * libcbor is free software; you can redistribute it and/or modify
9  * it under the terms of the MIT license. See LICENSE for details.
10  */
11 
12 /** Callback prototype */
13 alias cbor_int8_callback = void function(void*, ubyte);
14 
15 /** Callback prototype */
16 alias cbor_int16_callback = void function(void*, ushort);
17 
18 /** Callback prototype */
19 alias cbor_int32_callback = void function(void*, uint);
20 
21 /** Callback prototype */
22 alias cbor_int64_callback = void function(void*, ulong);
23 
24 /** Callback prototype */
25 alias cbor_simple_callback = void function(void*);
26 
27 /** Callback prototype */
28 alias cbor_string_callback = void function(void*, cbor_data, size_t);
29 
30 /** Callback prototype */
31 alias cbor_collection_callback = void function(void*, size_t);
32 
33 /** Callback prototype */
34 alias cbor_float_callback = void function(void*, float);
35 
36 /** Callback prototype */
37 alias cbor_double_callback = void function(void*, double);
38 
39 /** Callback prototype */
40 alias cbor_bool_callback = void function(void*, bool);
41 
42 /** Callback bundle -- passed to the decoder */
43 struct cbor_callbacks
44 {
45     /** Unsigned int */
46     cbor_int8_callback uint8;
47     /** Unsigned int */
48     cbor_int16_callback uint16;
49     /** Unsigned int */
50     cbor_int32_callback uint32;
51     /** Unsigned int */
52     cbor_int64_callback uint64;
53 
54     /** Negative int */
55     cbor_int64_callback negint64;
56     /** Negative int */
57     cbor_int32_callback negint32;
58     /** Negative int */
59     cbor_int16_callback negint16;
60     /** Negative int */
61     cbor_int8_callback negint8;
62 
63     /** Definite byte string */
64     cbor_simple_callback byte_string_start;
65     /** Indefinite byte string start */
66     cbor_string_callback byte_string;
67 
68     /** Definite string */
69     cbor_string_callback string;
70     /** Indefinite string start */
71     cbor_simple_callback string_start;
72 
73     /** Definite array */
74     cbor_simple_callback indef_array_start;
75     /** Indefinite array */
76     cbor_collection_callback array_start;
77 
78     /** Definite map */
79     cbor_simple_callback indef_map_start;
80     /** Indefinite map */
81     cbor_collection_callback map_start;
82 
83     /** Tags */
84     cbor_int64_callback tag;
85 
86     /** Half float */
87     cbor_float_callback float2;
88     /** Single float */
89     cbor_float_callback float4;
90     /** Double float */
91     cbor_double_callback float8;
92     /** Undef */
93     cbor_simple_callback undefined;
94     /** Null */
95     cbor_simple_callback null_;
96     /** Bool */
97     cbor_bool_callback boolean;
98 
99     /** Indefinite item break */
100     cbor_simple_callback indef_break;
101 }
102 
103 extern (C):
104 
105 /** Dummy callback implementation - does nothing */
106 void cbor_null_uint8_callback(void*, ubyte);
107 
108 /** Dummy callback implementation - does nothing */
109 void cbor_null_uint16_callback(void*, ushort);
110 
111 /** Dummy callback implementation - does nothing */
112 void cbor_null_uint32_callback(void*, uint);
113 
114 /** Dummy callback implementation - does nothing */
115 void cbor_null_uint64_callback(void*, ulong);
116 
117 /** Dummy callback implementation - does nothing */
118 void cbor_null_negint8_callback(void*, ubyte);
119 
120 /** Dummy callback implementation - does nothing */
121 void cbor_null_negint16_callback(void*, ushort);
122 
123 /** Dummy callback implementation - does nothing */
124 void cbor_null_negint32_callback(void*, uint);
125 
126 /** Dummy callback implementation - does nothing */
127 void cbor_null_negint64_callback(void*, ulong);
128 
129 /** Dummy callback implementation - does nothing */
130 void cbor_null_string_callback(void*, cbor_data, size_t);
131 
132 /** Dummy callback implementation - does nothing */
133 void cbor_null_string_start_callback(void*);
134 
135 /** Dummy callback implementation - does nothing */
136 void cbor_null_byte_string_callback(void*, cbor_data, size_t);
137 
138 /** Dummy callback implementation - does nothing */
139 void cbor_null_byte_string_start_callback(void*);
140 
141 /** Dummy callback implementation - does nothing */
142 void cbor_null_array_start_callback(void*, size_t);
143 
144 /** Dummy callback implementation - does nothing */
145 void cbor_null_indef_array_start_callback(void*);
146 
147 /** Dummy callback implementation - does nothing */
148 void cbor_null_map_start_callback(void*, size_t);
149 
150 /** Dummy callback implementation - does nothing */
151 void cbor_null_indef_map_start_callback(void*);
152 
153 /** Dummy callback implementation - does nothing */
154 void cbor_null_tag_callback(void*, ulong);
155 
156 /** Dummy callback implementation - does nothing */
157 void cbor_null_float2_callback(void*, float);
158 
159 /** Dummy callback implementation - does nothing */
160 void cbor_null_float4_callback(void*, float);
161 
162 /** Dummy callback implementation - does nothing */
163 void cbor_null_float8_callback(void*, double);
164 
165 /** Dummy callback implementation - does nothing */
166 void cbor_null_null_callback(void*);
167 
168 /** Dummy callback implementation - does nothing */
169 void cbor_null_undefined_callback(void*);
170 
171 /** Dummy callback implementation - does nothing */
172 void cbor_null_boolean_callback(void*, bool);
173 
174 /** Dummy callback implementation - does nothing */
175 void cbor_null_indef_break_callback(void*);
176 
177 /** Dummy callback bundle - does nothing */
178 extern __gshared const cbor_callbacks cbor_empty_callbacks;