Avro C++

LogicalType.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_LogicalType_hh__
20 #define avro_LogicalType_hh__
21
22 #include <iostream>
23
24 #include "Config.hh"
25
26 namespace avro {
27
28 class AVRO_DECL LogicalType {
29 public:
30 enum Type {
31 NONE,
32 DECIMAL,
33 DATE,
34 TIME_MILLIS,
35 TIME_MICROS,
36 TIMESTAMP_MILLIS,
37 TIMESTAMP_MICROS,
38 DURATION,
39 UUID
40 };
41
42 explicit LogicalType(Type type);
43
44 Type type() const;
45
46 // Precision and scale can only be set for the DECIMAL logical type.
47 // Precision must be positive and scale must be either positive or zero. The
48 // setters will throw an exception if they are called on any type other
49 // than DECIMAL.
50 void setPrecision(int precision);
51 int precision() const { return precision_; }
52 void setScale(int scale);
53 int scale() const { return scale_; }
54
55 void printJson(std::ostream &os) const;
56
57 private:
58 Type type_;
59 int precision_;
60 int scale_;
61 };
62
63 } // namespace avro
64
65 #endif
avro::LogicalType
Definition: LogicalType.hh:28
avro
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30