h5cpp 0.7.0
A modern C++ wrapper for the HDF5 C library
string.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <string>
6
7namespace hdf5 {
8namespace datatype {
9
10template<>
11class TypeTrait<std::string> {
12 public:
13 using Type = std::string;
14 using TypeClass = String;
15 static TypeClass create(const Type & = Type()) {
17 }
18 const static TypeClass & get(const Type & = Type()) {
19 const static TypeClass & cref_ = create();
20 return cref_;
21 }
22};
23
24
25template<typename CharT>
26class TypeTrait<std::basic_string<CharT>> {
27 private:
28
29 public:
30 using Type = std::basic_string<CharT>;
31 using TypeClass = String;
32
33 static TypeClass create(const Type & = Type()) {
34 static_assert(std::is_same<CharT, char>::value, "Only support 8Bit characters");
35
36 String type = String::variable();
37 type.encoding(CharacterEncoding::UTF8);
38 return type;
39
40 }
41 const static TypeClass & get(const Type & = Type()) {
42 const static TypeClass & cref_ = create();
43 return cref_;
44 }
45
46};
47} // end of namespace datatype
48
49namespace dataspace {
50
51} // end of namespace dataspace
52} // end of namespace hdf5
static String variable()
construct variable-length string
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
@ String
indicates a string type
top-level namespace of the entire library
Definition: attribute.hpp:45