h5cpp  0.5.2
A modern C++ wrapper for the HDF5 C library
vector.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
5 
6 namespace hdf5 {
7 namespace datatype {
8 
9 template<typename T>
10 class TypeTrait<std::vector<T>> {
11  public:
12  using Type = std::vector<T>;
13  using TypeClass = typename TypeTrait<T>::TypeClass;
14  static TypeClass create(const Type & = Type()) {
15  return TypeTrait<typename std::remove_const<T>::type>::create();
16  }
17  const static TypeClass & get(const Type & = Type()) {
18  const static TypeClass & cref_ = create();
19  return cref_;
20  }
21 };
22 
23 } // end of namespace datatype
24 
25 namespace dataspace {
26 
27 template<typename T>
28 class TypeTrait<std::vector<T>> {
29  public:
31 
32  static Simple create(const std::vector<T> &value) {
33  return Simple(hdf5::Dimensions{value.size()}, hdf5::Dimensions{value.size()});
34  }
35 
36  static const Dataspace & get(const std::vector<T> & value, DataspacePool & pool) {
37  return pool.getSimple(value.size());
38  }
39 
40  static void *ptr(std::vector<T> &data) {
41  return reinterpret_cast<void *>(data.data());
42  }
43 
44  static const void *cptr(const std::vector<T> &data) {
45  return reinterpret_cast<const void *>(data.data());
46  }
47 };
48 
49 } // end of namespace dataspace
50 } // end of namespace hdf5
data space object pool
Definition: pool.hpp:42
const Simple & getSimple(size_t size)
reference of Simple data spaces
dataspace base class
Definition: dataspace.hpp:41
simple multidimensional dataspace
Definition: simple.hpp:43
static const Dataspace & get(const std::vector< T > &value, DataspacePool &pool)
Definition: vector.hpp:36
static const void * cptr(const std::vector< T > &data)
Definition: vector.hpp:44
static Simple create(const std::vector< T > &value)
Definition: vector.hpp:32
static void * ptr(std::vector< T > &data)
Definition: vector.hpp:40
type trait for dataspace construction
Definition: type_trait.hpp:54
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
top-level namespace of the entire library
Definition: attribute.hpp:45
std::vector< hsize_t > Dimensions
Definition: types.hpp:32