1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to you under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * https://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 14 * implied. See the License for the specific language governing 15 * permissions and limitations under the License. 16 */ 17 #ifndef AVRO_SCHEMA_PRIV_H 18 #define AVRO_SCHEMA_PRIV_H 19 20 #include <avro/platform.h> 21 #include "avro/basics.h" 22 #include "avro/schema.h" 23 #include "avro_private.h" 24 #include "st.h" 25 26 struct avro_record_field_t { 27 int index; 28 char *name; 29 avro_schema_t type; 30 /* 31 * TODO: default values 32 */ 33 }; 34 35 struct avro_record_schema_t { 36 struct avro_obj_t obj; 37 char *name; 38 char *space; 39 st_table *fields; 40 st_table *fields_byname; 41 }; 42 43 struct avro_enum_schema_t { 44 struct avro_obj_t obj; 45 char *name; 46 char *space; 47 st_table *symbols; 48 st_table *symbols_byname; 49 }; 50 51 struct avro_array_schema_t { 52 struct avro_obj_t obj; 53 avro_schema_t items; 54 }; 55 56 struct avro_map_schema_t { 57 struct avro_obj_t obj; 58 avro_schema_t values; 59 }; 60 61 struct avro_union_schema_t { 62 struct avro_obj_t obj; 63 st_table *branches; 64 st_table *branches_byname; 65 }; 66 67 struct avro_fixed_schema_t { 68 struct avro_obj_t obj; 69 const char *name; 70 const char *space; 71 int64_t size; 72 }; 73 74 struct avro_link_schema_t { 75 struct avro_obj_t obj; 76 avro_schema_t to; 77 }; 78 79 #define avro_schema_to_record(schema_) (container_of(schema_, struct avro_record_schema_t, obj)) 80 #define avro_schema_to_enum(schema_) (container_of(schema_, struct avro_enum_schema_t, obj)) 81 #define avro_schema_to_array(schema_) (container_of(schema_, struct avro_array_schema_t, obj)) 82 #define avro_schema_to_map(schema_) (container_of(schema_, struct avro_map_schema_t, obj)) 83 #define avro_schema_to_union(schema_) (container_of(schema_, struct avro_union_schema_t, obj)) 84 #define avro_schema_to_fixed(schema_) (container_of(schema_, struct avro_fixed_schema_t, obj)) 85 #define avro_schema_to_link(schema_) (container_of(schema_, struct avro_link_schema_t, obj)) 86 87 #endif 88