Avro C++
Types.hh
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  * https://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 avro_Types_hh__
20 #define avro_Types_hh__
21 
22 #include <iostream>
23 
24 #include "Config.hh"
25 
26 namespace avro {
27 
31 enum Type {
32 
51  // The following is a pseudo-type used in implementation
52 
55 };
56 
62 inline constexpr bool isPrimitive(Type t) noexcept {
63  return (t >= AVRO_STRING) && (t < AVRO_RECORD);
64 }
65 
71 inline constexpr bool isCompound(Type t) noexcept {
72  return (t >= AVRO_RECORD) && (t < AVRO_NUM_TYPES);
73 }
74 
78 inline constexpr bool isAvroType(Type t) noexcept {
79  return (t >= AVRO_STRING) && (t < AVRO_NUM_TYPES);
80 }
81 
86 inline constexpr bool isAvroTypeOrPseudoType(Type t) noexcept {
87  return (t >= AVRO_STRING) && (t <= AVRO_NUM_TYPES);
88 }
89 
93 AVRO_DECL const std::string &toString(Type type) noexcept;
94 
98 AVRO_DECL std::ostream &operator<<(std::ostream &os, avro::Type type);
99 
101 struct AVRO_DECL Null {};
102 
108 std::ostream &operator<<(std::ostream &os, const Null &null);
109 
110 } // namespace avro
111 
112 #endif
avro::AVRO_NULL
@ AVRO_NULL
Definition: Types.hh:40
avro::AVRO_LONG
@ AVRO_LONG
Definition: Types.hh:36
avro::AVRO_ENUM
@ AVRO_ENUM
Definition: Types.hh:43
avro::toString
const AVRO_DECL std::string & toString(Type type) noexcept
Converts the given type into a string.
avro::AVRO_FLOAT
@ AVRO_FLOAT
Definition: Types.hh:37
avro::isPrimitive
constexpr bool isPrimitive(Type t) noexcept
Returns true if and only if the given type is a primitive.
Definition: Types.hh:62
avro::AVRO_BOOL
@ AVRO_BOOL
Definition: Types.hh:39
avro::AVRO_STRING
@ AVRO_STRING
Definition: Types.hh:33
avro::AVRO_NUM_TYPES
@ AVRO_NUM_TYPES
Definition: Types.hh:49
avro::AVRO_BYTES
@ AVRO_BYTES
Definition: Types.hh:34
avro::isAvroType
constexpr bool isAvroType(Type t) noexcept
Returns true if and only if the given type is a valid avro type.
Definition: Types.hh:78
avro::AVRO_INT
@ AVRO_INT
Definition: Types.hh:35
avro
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
avro::AVRO_ARRAY
@ AVRO_ARRAY
Definition: Types.hh:44
avro::AVRO_DOUBLE
@ AVRO_DOUBLE
Definition: Types.hh:38
avro::isCompound
constexpr bool isCompound(Type t) noexcept
Returns true if and only if the given type is a non primitive valid type.
Definition: Types.hh:71
avro::AVRO_FIXED
@ AVRO_FIXED
Definition: Types.hh:47
avro::Null
define a type to represent Avro Null in template functions
Definition: Types.hh:101
avro::AVRO_RECORD
@ AVRO_RECORD
Definition: Types.hh:42
avro::AVRO_SYMBOLIC
@ AVRO_SYMBOLIC
Definition: Types.hh:53
avro::AVRO_UNKNOWN
@ AVRO_UNKNOWN
Definition: Types.hh:54
avro::Type
Type
The "type" for the schema.
Definition: Types.hh:31
avro::AVRO_UNION
@ AVRO_UNION
Definition: Types.hh:46
avro::isAvroTypeOrPseudoType
constexpr bool isAvroTypeOrPseudoType(Type t) noexcept
Returns true if and only if the given type is within the valid range of enumeration.
Definition: Types.hh:86
avro::AVRO_MAP
@ AVRO_MAP
Definition: Types.hh:45