IODA Bundle
ColumnType.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef odc_api_ColumnType_H
12 #define odc_api_ColumnType_H
13 
14 #include <cstdint>
15 #include <cstddef>
16 
17 namespace odc {
18 namespace api {
19 
20 //------------------------------------------------------------------------------------------------------------
21 
22 enum ColumnType {
23  IGNORE = 0,
24  INTEGER = 1,
25  REAL = 2,
26  STRING = 3,
27  BITFIELD = 4,
28  DOUBLE = 5
29 };
30 
31 constexpr int NUM_TYPES = 6;
32 
33 template <ColumnType ty> struct OdbTypes{};
34 
35 // Specialisations
36 
37 template <> struct OdbTypes<IGNORE> {
38  static constexpr const char* name = "ignore";
39  // Size undefined
40 };
41 template <> struct OdbTypes<INTEGER> {
42  static constexpr const char* name = "integer";
43  static constexpr size_t size = sizeof(int64_t);
44 };
45 template <> struct OdbTypes<REAL> {
46  static constexpr const char* name = "real";
47  static constexpr size_t size = sizeof(float);
48 };
49 template <> struct OdbTypes<STRING> {
50  static constexpr const char* name = "string";
51  // Size variable
52 };
53 template <> struct OdbTypes<BITFIELD> {
54  static constexpr const char* name = "bitfield";
55  static constexpr size_t size = sizeof(int64_t);
56 };
57 template <> struct OdbTypes<DOUBLE> {
58  static constexpr const char* name = "double";
59  static constexpr size_t size = sizeof(double);
60 };
61 
62 //------------------------------------------------------------------------------------------------------------
63 
64 } // namespace api
65 } // namespace odc
66 
67 #endif // odc_api_ColumnType_H
constexpr int NUM_TYPES
Definition: ColumnType.h:31
@ BITFIELD
Definition: ColumnType.h:27
Definition: ColumnInfo.h:23