1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef RMF_SRC_BACKEND_AVRO_ALLJSON_H_779595758__H_ 20 #define RMF_SRC_BACKEND_AVRO_ALLJSON_H_779595758__H_ 21 22 #include <boost/any.hpp> 23 #include "avrocpp/api/Specific.hh" 24 #include "avrocpp/api/Encoder.hh" 25 #include "avrocpp/api/Decoder.hh" 26 27 namespace RMF_avro_backend { 28 struct File { 29 std::string description; 30 std::string producer; 31 int32_t version; 32 }; 33 34 struct Node { 35 std::string name; 36 std::string type; 37 std::vector<int32_t> children; 38 }; 39 40 struct IntData { 41 std::map<std::string, int32_t> index; 42 std::map<std::string, std::vector<int32_t> > nodes; 43 }; 44 45 struct FloatData { 46 std::map<std::string, int32_t> index; 47 std::map<std::string, std::vector<double> > nodes; 48 }; 49 50 struct StringData { 51 std::map<std::string, int32_t> index; 52 std::map<std::string, std::vector<std::string> > nodes; 53 }; 54 55 struct IndexData { 56 std::map<std::string, int32_t> index; 57 std::map<std::string, std::vector<int32_t> > nodes; 58 }; 59 60 struct NodeIDData { 61 std::map<std::string, int32_t> index; 62 std::map<std::string, std::vector<int32_t> > nodes; 63 }; 64 65 struct IntsData { 66 std::map<std::string, int32_t> index; 67 std::map<std::string, std::vector<std::vector<int32_t> > > nodes; 68 }; 69 70 struct FloatsData { 71 std::map<std::string, int32_t> index; 72 std::map<std::string, std::vector<std::vector<double> > > nodes; 73 }; 74 75 struct StringsData { 76 std::map<std::string, int32_t> index; 77 std::map<std::string, std::vector<std::vector<std::string> > > nodes; 78 }; 79 80 struct IndexesData { 81 std::map<std::string, int32_t> index; 82 std::map<std::string, std::vector<std::vector<int32_t> > > nodes; 83 }; 84 85 struct NodeIDsData { 86 std::map<std::string, int32_t> index; 87 std::map<std::string, std::vector<std::vector<int32_t> > > nodes; 88 }; 89 90 struct Data { 91 int32_t frame; 92 IntData int_data; 93 FloatData float_data; 94 StringData string_data; 95 IndexData index_data; 96 NodeIDData node_id_data; 97 IntsData ints_data; 98 FloatsData floats_data; 99 StringsData strings_data; 100 IndexesData indexes_data; 101 NodeIDsData node_ids_data; 102 }; 103 104 struct All { 105 File file; 106 std::vector<Node> nodes; 107 std::vector<Node> frames; 108 std::map<std::string, std::vector<Data> > category; 109 }; 110 } 111 namespace internal_avro { 112 template <> 113 struct codec_traits<RMF_avro_backend::File> { 114 template <class Encoder> 115 static void encode(Encoder& e, const RMF_avro_backend::File& v) { 116 internal_avro::encode(e, v.description); 117 internal_avro::encode(e, v.producer); 118 internal_avro::encode(e, v.version); 119 } 120 template <class Decoder> 121 static void decode(Decoder& d, RMF_avro_backend::File& v) { 122 internal_avro::decode(d, v.description); 123 internal_avro::decode(d, v.producer); 124 internal_avro::decode(d, v.version); 125 } 126 }; 127 128 template <> 129 struct codec_traits<RMF_avro_backend::Node> { 130 template <class Encoder> 131 static void encode(Encoder& e, const RMF_avro_backend::Node& v) { 132 internal_avro::encode(e, v.name); 133 internal_avro::encode(e, v.type); 134 internal_avro::encode(e, v.children); 135 } 136 template <class Decoder> 137 static void decode(Decoder& d, RMF_avro_backend::Node& v) { 138 internal_avro::decode(d, v.name); 139 internal_avro::decode(d, v.type); 140 internal_avro::decode(d, v.children); 141 } 142 }; 143 144 template <> 145 struct codec_traits<RMF_avro_backend::IntData> { 146 template <class Encoder> 147 static void encode(Encoder& e, const RMF_avro_backend::IntData& v) { 148 internal_avro::encode(e, v.index); 149 internal_avro::encode(e, v.nodes); 150 } 151 template <class Decoder> 152 static void decode(Decoder& d, RMF_avro_backend::IntData& v) { 153 internal_avro::decode(d, v.index); 154 internal_avro::decode(d, v.nodes); 155 } 156 }; 157 158 template <> 159 struct codec_traits<RMF_avro_backend::FloatData> { 160 template <class Encoder> 161 static void encode(Encoder& e, const RMF_avro_backend::FloatData& v) { 162 internal_avro::encode(e, v.index); 163 internal_avro::encode(e, v.nodes); 164 } 165 template <class Decoder> 166 static void decode(Decoder& d, RMF_avro_backend::FloatData& v) { 167 internal_avro::decode(d, v.index); 168 internal_avro::decode(d, v.nodes); 169 } 170 }; 171 172 template <> 173 struct codec_traits<RMF_avro_backend::StringData> { 174 template <class Encoder> 175 static void encode(Encoder& e, const RMF_avro_backend::StringData& v) { 176 internal_avro::encode(e, v.index); 177 internal_avro::encode(e, v.nodes); 178 } 179 template <class Decoder> 180 static void decode(Decoder& d, RMF_avro_backend::StringData& v) { 181 internal_avro::decode(d, v.index); 182 internal_avro::decode(d, v.nodes); 183 } 184 }; 185 186 template <> 187 struct codec_traits<RMF_avro_backend::IndexData> { 188 template <class Encoder> 189 static void encode(Encoder& e, const RMF_avro_backend::IndexData& v) { 190 internal_avro::encode(e, v.index); 191 internal_avro::encode(e, v.nodes); 192 } 193 template <class Decoder> 194 static void decode(Decoder& d, RMF_avro_backend::IndexData& v) { 195 internal_avro::decode(d, v.index); 196 internal_avro::decode(d, v.nodes); 197 } 198 }; 199 200 template <> 201 struct codec_traits<RMF_avro_backend::NodeIDData> { 202 template <class Encoder> 203 static void encode(Encoder& e, const RMF_avro_backend::NodeIDData& v) { 204 internal_avro::encode(e, v.index); 205 internal_avro::encode(e, v.nodes); 206 } 207 template <class Decoder> 208 static void decode(Decoder& d, RMF_avro_backend::NodeIDData& v) { 209 internal_avro::decode(d, v.index); 210 internal_avro::decode(d, v.nodes); 211 } 212 }; 213 214 template <> 215 struct codec_traits<RMF_avro_backend::IntsData> { 216 template <class Encoder> 217 static void encode(Encoder& e, const RMF_avro_backend::IntsData& v) { 218 internal_avro::encode(e, v.index); 219 internal_avro::encode(e, v.nodes); 220 } 221 template <class Decoder> 222 static void decode(Decoder& d, RMF_avro_backend::IntsData& v) { 223 internal_avro::decode(d, v.index); 224 internal_avro::decode(d, v.nodes); 225 } 226 }; 227 228 template <> 229 struct codec_traits<RMF_avro_backend::FloatsData> { 230 template <class Encoder> 231 static void encode(Encoder& e, const RMF_avro_backend::FloatsData& v) { 232 internal_avro::encode(e, v.index); 233 internal_avro::encode(e, v.nodes); 234 } 235 template <class Decoder> 236 static void decode(Decoder& d, RMF_avro_backend::FloatsData& v) { 237 internal_avro::decode(d, v.index); 238 internal_avro::decode(d, v.nodes); 239 } 240 }; 241 242 template <> 243 struct codec_traits<RMF_avro_backend::StringsData> { 244 template <class Encoder> 245 static void encode(Encoder& e, const RMF_avro_backend::StringsData& v) { 246 internal_avro::encode(e, v.index); 247 internal_avro::encode(e, v.nodes); 248 } 249 template <class Decoder> 250 static void decode(Decoder& d, RMF_avro_backend::StringsData& v) { 251 internal_avro::decode(d, v.index); 252 internal_avro::decode(d, v.nodes); 253 } 254 }; 255 256 template <> 257 struct codec_traits<RMF_avro_backend::IndexesData> { 258 template <class Encoder> 259 static void encode(Encoder& e, const RMF_avro_backend::IndexesData& v) { 260 internal_avro::encode(e, v.index); 261 internal_avro::encode(e, v.nodes); 262 } 263 template <class Decoder> 264 static void decode(Decoder& d, RMF_avro_backend::IndexesData& v) { 265 internal_avro::decode(d, v.index); 266 internal_avro::decode(d, v.nodes); 267 } 268 }; 269 270 template <> 271 struct codec_traits<RMF_avro_backend::NodeIDsData> { 272 template <class Encoder> 273 static void encode(Encoder& e, const RMF_avro_backend::NodeIDsData& v) { 274 internal_avro::encode(e, v.index); 275 internal_avro::encode(e, v.nodes); 276 } 277 template <class Decoder> 278 static void decode(Decoder& d, RMF_avro_backend::NodeIDsData& v) { 279 internal_avro::decode(d, v.index); 280 internal_avro::decode(d, v.nodes); 281 } 282 }; 283 284 template <> 285 struct codec_traits<RMF_avro_backend::Data> { 286 template <class Encoder> 287 static void encode(Encoder& e, const RMF_avro_backend::Data& v) { 288 internal_avro::encode(e, v.frame); 289 internal_avro::encode(e, v.int_data); 290 internal_avro::encode(e, v.float_data); 291 internal_avro::encode(e, v.string_data); 292 internal_avro::encode(e, v.index_data); 293 internal_avro::encode(e, v.node_id_data); 294 internal_avro::encode(e, v.ints_data); 295 internal_avro::encode(e, v.floats_data); 296 internal_avro::encode(e, v.strings_data); 297 internal_avro::encode(e, v.indexes_data); 298 internal_avro::encode(e, v.node_ids_data); 299 } 300 template <class Decoder> 301 static void decode(Decoder& d, RMF_avro_backend::Data& v) { 302 internal_avro::decode(d, v.frame); 303 internal_avro::decode(d, v.int_data); 304 internal_avro::decode(d, v.float_data); 305 internal_avro::decode(d, v.string_data); 306 internal_avro::decode(d, v.index_data); 307 internal_avro::decode(d, v.node_id_data); 308 internal_avro::decode(d, v.ints_data); 309 internal_avro::decode(d, v.floats_data); 310 internal_avro::decode(d, v.strings_data); 311 internal_avro::decode(d, v.indexes_data); 312 internal_avro::decode(d, v.node_ids_data); 313 } 314 }; 315 316 template <> 317 struct codec_traits<RMF_avro_backend::All> { 318 template <class Encoder> 319 static void encode(Encoder& e, const RMF_avro_backend::All& v) { 320 internal_avro::encode(e, v.file); 321 internal_avro::encode(e, v.nodes); 322 internal_avro::encode(e, v.frames); 323 internal_avro::encode(e, v.category); 324 } 325 template <class Decoder> 326 static void decode(Decoder& d, RMF_avro_backend::All& v) { 327 internal_avro::decode(d, v.file); 328 internal_avro::decode(d, v.nodes); 329 internal_avro::decode(d, v.frames); 330 internal_avro::decode(d, v.category); 331 } 332 }; 333 } 334 #endif 335