Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
kaa_common_schema.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef KAA_COMMON_SCHEMA_H_
18 #define KAA_COMMON_SCHEMA_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <stddef.h>
25 
26 #include "avro_src/avro/io.h"
27 #include "collections/kaa_list.h"
28 
29 
30 
31 /*
32  * Do not change neither name or value of these constants.
33  */
34 #define AVRO_NULL_SIZE 0
35 #define AVRO_FLOAT_SIZE 4
36 #define AVRO_DOUBLE_SIZE 8
37 
38 
39 
40 typedef void (*serialize_fn)(avro_writer_t writer, void *data);
41 
51 typedef void *(*deserialize_fn)();
52 
56 typedef void *(*deserialize_wo_ctx_fn)(avro_reader_t reader);
57 
61 typedef void *(*deserialize_w_ctx_fn)(avro_reader_t reader, void *context);
62 
63 typedef size_t (*get_size_fn)(void *data);
64 typedef void (*destroy_fn)(void *data);
65 
66 
67 
68 typedef struct {
69  uint8_t* buffer;
70  int32_t size;
71 
73 } kaa_bytes_t;
74 
75 typedef struct {
76  char* data;
77 
79 } kaa_string_t;
80 
81 typedef struct {
82  uint8_t type;
83  void *data;
84 
88 } kaa_union_t;
89 
90 
91 
92 kaa_string_t *kaa_string_move_create(const char *data, destroy_fn destroy);
93 kaa_string_t *kaa_string_copy_create(const char *data);
94 
95 void kaa_string_destroy(void *data);
96 void kaa_string_serialize(avro_writer_t writer, void *data);
98 size_t kaa_string_get_size(void *data);
99 
100 
101 
102 kaa_bytes_t *kaa_bytes_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy);
103 kaa_bytes_t *kaa_bytes_copy_create(const uint8_t *data, size_t data_len);
104 
105 void kaa_bytes_destroy(void *data);
106 void kaa_bytes_serialize(avro_writer_t writer, void *data);
108 size_t kaa_bytes_get_size(void *data);
109 
110 
111 
112 kaa_bytes_t *kaa_fixed_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy);
113 kaa_bytes_t *kaa_fixed_copy_create(const uint8_t *data, size_t data_len);
114 
115 void kaa_fixed_destroy(void *data);
116 void kaa_fixed_serialize(avro_writer_t writer, void *data);
117 kaa_bytes_t *kaa_fixed_deserialize(avro_reader_t reader, void *context);
118 size_t kaa_fixed_get_size(void *data);
119 
120 
121 
122 void kaa_boolean_serialize(avro_writer_t writer, void *data);
123 int8_t *kaa_boolean_deserialize(avro_reader_t reader);
124 size_t kaa_boolean_get_size(void *data);
125 
126 
127 
128 void kaa_int_serialize(avro_writer_t writer, void *data);
129 int32_t *kaa_int_deserialize(avro_reader_t reader);
130 size_t kaa_int_get_size(void *data);
131 
132 
133 
134 void kaa_long_serialize(avro_writer_t writer, void *data);
135 int64_t *kaa_long_deserialize(avro_reader_t reader);
136 size_t kaa_long_get_size(void *data);
137 
138 
139 
140 void kaa_enum_serialize(avro_writer_t writer, void *data);
142 size_t kaa_enum_get_size(void *data);
143 
144 
145 
146 void kaa_float_serialize(avro_writer_t writer, void *data);
147 float *kaa_float_deserialize(avro_reader_t reader);
148 size_t kaa_float_get_size(void *data);
149 
150 
151 
152 void kaa_double_serialize(avro_writer_t writer, void *data);
153 double *kaa_double_deserialize(avro_reader_t reader);
154 size_t kaa_double_get_size(void *data);
155 
156 
157 
158 void kaa_array_serialize(avro_writer_t writer, kaa_list_t *array, serialize_fn serialize);
160 kaa_list_t *kaa_array_deserialize_w_ctx(avro_reader_t reader, deserialize_w_ctx_fn deserialize, void *deserialize_context);
161 size_t kaa_array_get_size(kaa_list_t *array, get_size_fn get_size);
162 
163 
164 
165 void kaa_null_serialize(avro_writer_t writer, void *data);
166 void *kaa_null_deserialize(avro_reader_t reader);
167 void kaa_null_destroy(void *data);
168 size_t kaa_null_get_size(void* data);
169 
170 void kaa_data_destroy(void *data);
171 
172 size_t avro_long_get_size(int64_t l);
173 
174 #ifdef __cplusplus
175 } // extern "C"
176 #endif
177 #endif /* KAA_COMMON_SCHEMA_H_ */
void kaa_null_destroy(void *data)
size_t kaa_double_get_size(void *data)
destroy_fn destroy
Definition: kaa_common_schema.h:78
kaa_list_t * kaa_array_deserialize_wo_ctx(avro_reader_t reader, deserialize_wo_ctx_fn deserialize)
int8_t * kaa_boolean_deserialize(avro_reader_t reader)
void kaa_data_destroy(void *data)
kaa_bytes_t * kaa_fixed_copy_create(const uint8_t *data, size_t data_len)
Definition: kaa_common_schema.h:68
void(* destroy_fn)(void *data)
Definition: kaa_common_schema.h:64
size_t kaa_int_get_size(void *data)
void kaa_array_serialize(avro_writer_t writer, kaa_list_t *array, serialize_fn serialize)
size_t kaa_array_get_size(kaa_list_t *array, get_size_fn get_size)
double * kaa_double_deserialize(avro_reader_t reader)
int32_t * kaa_int_deserialize(avro_reader_t reader)
size_t(* get_size_fn)(void *data)
Definition: kaa_common_schema.h:63
void kaa_fixed_serialize(avro_writer_t writer, void *data)
serialize_fn serialize
Definition: kaa_common_schema.h:85
char * data
Definition: kaa_common_schema.h:76
void kaa_boolean_serialize(avro_writer_t writer, void *data)
void kaa_int_serialize(avro_writer_t writer, void *data)
void kaa_string_destroy(void *data)
kaa_string_t * kaa_string_deserialize(avro_reader_t reader)
void kaa_fixed_destroy(void *data)
get_size_fn get_size
Definition: kaa_common_schema.h:86
destroy_fn destroy
Definition: kaa_common_schema.h:87
destroy_fn destroy
Definition: kaa_common_schema.h:72
void kaa_string_serialize(avro_writer_t writer, void *data)
kaa_bytes_t * kaa_fixed_deserialize(avro_reader_t reader, void *context)
Definition: kaa_common_schema.h:81
size_t kaa_float_get_size(void *data)
struct kaa_list_t kaa_list_t
Definition: kaa_list.h:30
size_t kaa_bytes_get_size(void *data)
uint8_t type
Definition: kaa_common_schema.h:82
Definition: io.h:33
size_t kaa_string_get_size(void *data)
kaa_string_t * kaa_string_move_create(const char *data, destroy_fn destroy)
int32_t size
Definition: kaa_common_schema.h:70
size_t kaa_enum_get_size(void *data)
kaa_bytes_t * kaa_bytes_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy)
void kaa_double_serialize(avro_writer_t writer, void *data)
int64_t * kaa_long_deserialize(avro_reader_t reader)
void *(* deserialize_w_ctx_fn)(avro_reader_t reader, void *context)
See deserialize_fn.
Definition: kaa_common_schema.h:61
void *(* deserialize_wo_ctx_fn)(avro_reader_t reader)
See deserialize_fn.
Definition: kaa_common_schema.h:56
void * data
Definition: kaa_common_schema.h:83
void kaa_enum_serialize(avro_writer_t writer, void *data)
void kaa_bytes_destroy(void *data)
kaa_bytes_t * kaa_bytes_copy_create(const uint8_t *data, size_t data_len)
void kaa_null_serialize(avro_writer_t writer, void *data)
kaa_string_t * kaa_string_copy_create(const char *data)
uint8_t * buffer
Definition: kaa_common_schema.h:69
size_t kaa_long_get_size(void *data)
kaa_list_t * kaa_array_deserialize_w_ctx(avro_reader_t reader, deserialize_w_ctx_fn deserialize, void *deserialize_context)
kaa_bytes_t * kaa_fixed_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy)
void kaa_float_serialize(avro_writer_t writer, void *data)
Definition: kaa_common_schema.h:75
size_t avro_long_get_size(int64_t l)
size_t kaa_fixed_get_size(void *data)
void(* serialize_fn)(avro_writer_t writer, void *data)
Definition: kaa_common_schema.h:40
kaa_bytes_t * kaa_bytes_deserialize(avro_reader_t reader)
int * kaa_enum_deserialize(avro_reader_t reader)
size_t kaa_null_get_size(void *data)
void kaa_bytes_serialize(avro_writer_t writer, void *data)
size_t kaa_boolean_get_size(void *data)
void kaa_long_serialize(avro_writer_t writer, void *data)
void * kaa_null_deserialize(avro_reader_t reader)
Definition: io.h:27
float * kaa_float_deserialize(avro_reader_t reader)