h5cpp  0.5.0
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
hdf5::dataspace::create
TypeTrait< T >::DataspaceType create(const T &value)
factory function for dataspaces
Definition: type_trait.hpp:89
hdf5::datatype::True
@ True
indicates a true value
Definition: ebool.hpp:44
factory.hpp
hdf5::dataspace::Type
Type
Definition: type.hpp:43
datatype.hpp
hdf5::datatype::TypeTrait::create
static TypeClass create(const T &=T())
create the new type instance
hdf5::datatype::False
@ False
indicates a false value
Definition: ebool.hpp:43
hdf5::datatype::EBool
EBool
enumeration bool type
Definition: ebool.hpp:41
hdf5::datatype::TypeTrait::TypeClass
Datatype TypeClass
subtype of Datatype which will be used
Definition: type_trait.hpp:58
hdf5::datatype::TypeTrait::get
const static TypeClass & get(const T &=T())
reference to const static type instance
hdf5::datatype::is_bool
bool is_bool(const Enum &etype)
check if Enum is EBool
hdf5::datatype::Enum
compound data type
Definition: enum.hpp:50
DLL_EXPORT
#define DLL_EXPORT
Definition: windows.hpp:29
enum.hpp
hdf5
top-level namespace of the entire library
Definition: attribute.hpp:45
error.hpp