h5cpp  0.6.1
A modern C++ wrapper for the HDF5 C library
ebool.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5cpp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Authors:
23 // Jan Kotanski <jan.kotanski@desy.de>
24 // Created on: Sep 18, 2018
25 //
26 #pragma once
27 
30 #include <h5cpp/datatype/enum.hpp>
31 #include <h5cpp/error/error.hpp>
32 #include <sstream>
33 
34 namespace hdf5
35 {
36 namespace datatype
37 {
41 enum EBool : int8_t
42 {
43  False = 0,
44  True = 1
45 };
46 
47 
48 template<>
49 class TypeTrait<datatype::EBool> {
50  public:
51  using TypeClass = datatype::Enum;
52  using Type = datatype::EBool;
53 
54  static TypeClass create(const Type & = Type()) {
55  auto type = TypeClass::create(Type());
56  type.insert("FALSE", Type::False);
57  type.insert("TRUE", Type::True);
58  return type;
59  }
60  const static TypeClass & get(const Type & = Type()) {
61  const static TypeClass & cref_ = create();
62  return cref_;
63  }
64 };
65 
66 
73 DLL_EXPORT bool is_bool(const Enum & etype);
74 
75 } // namespace datatype
76 } // namespace hdf5
compound data type
Definition: enum.hpp:51
Datatype TypeClass
subtype of Datatype which will be used
Definition: type_trait.hpp:58
static TypeClass create(const T &=T())
create the new type instance
static const TypeClass & get(const T &=T())
reference to const static type instance
Type
Definition: type.hpp:43
TypeTrait< T >::DataspaceType create(const T &value)
factory function for dataspaces
Definition: type_trait.hpp:89
bool is_bool(const Enum &etype)
check if Enum is EBool
EBool
enumeration bool type
Definition: ebool.hpp:42
@ False
indicates a false value
Definition: ebool.hpp:43
@ True
indicates a true value
Definition: ebool.hpp:44
top-level namespace of the entire library
Definition: attribute.hpp:45
#define DLL_EXPORT
Definition: windows.hpp:29