-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved STL datatype traits to contrib/stl
Update #548
- Loading branch information
1 parent
700f41c
commit 84a8713
Showing
9 changed files
with
196 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(stl) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include <h5cpp/datatype/type_trait.hpp> | ||
#include <array> | ||
|
||
namespace hdf5 { | ||
namespace datatype { | ||
|
||
template<typename T, size_t N> | ||
class TypeTrait<std::array<T, N>> { | ||
public: | ||
using Type = std::array<T, N>; | ||
using TypeClass = typename TypeTrait<T>::TypeClass; | ||
static TypeClass create(const Type & = Type()) { | ||
return TypeTrait<typename std::remove_const<T>::type>::create(); | ||
} | ||
const static TypeClass & get(const Type & = Type()) { | ||
const static TypeClass & cref_ = TypeTrait<typename std::remove_const<T>::type>::create(); | ||
return cref_; | ||
} | ||
}; | ||
} // end of namespace datatype | ||
|
||
namespace dataspace { | ||
|
||
} // end of namespace dataspace | ||
} // end of namespace hdf5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// (c) Copyright 2021 DESY, ESS | ||
// 2021 Eugen Wintersberger <[email protected]> | ||
// | ||
// This file is part of h5cpp. | ||
// | ||
// This library is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License as published | ||
// by the Free Software Foundation; either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
// License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this library; if not, write to the | ||
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor | ||
// Boston, MA 02110-1301 USA | ||
// =========================================================================== | ||
// | ||
// Authors: Eugen Wintersberger <[email protected]> | ||
// Created on: Dec 23, 2021 | ||
// | ||
#pragma once | ||
|
||
#include <h5cpp/datatype/type_trait.hpp> | ||
#include <complex> | ||
|
||
namespace hdf5 { | ||
namespace datatype { | ||
|
||
template<typename T> | ||
class TypeTrait<std::complex<T>> | ||
{ | ||
private: | ||
using element_type = TypeTrait<T>; | ||
|
||
public: | ||
using Type = std::complex<T>; | ||
using TypeClass = Compound; | ||
|
||
static TypeClass create(const Type & = Type()) | ||
{ | ||
datatype::Compound type = datatype::Compound::create( | ||
sizeof(std::complex<T>)); | ||
|
||
type.insert("real", 0, element_type::create(T())); | ||
type.insert("imag", alignof(T), element_type::create(T())); | ||
|
||
return type; | ||
} | ||
const static TypeClass & get(const Type & = Type()) { | ||
const static TypeClass & cref_ = create(); | ||
return cref_; | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// (c) Copyright 2017 DESY,ESS | ||
// | ||
// This file is part of h5cpp. | ||
// | ||
// This library is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License as published | ||
// by the Free Software Foundation; either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
// License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this library; if not, write to the | ||
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor | ||
// Boston, MA 02110-1301 USA | ||
// =========================================================================== | ||
// | ||
// Authors: Eugen Wintersberger <[email protected]> | ||
// Sebastian Koenig <[email protected]> | ||
// Jan Kotanski <[email protected]> | ||
// Created on: Aug 28, 2017 | ||
// | ||
#pragma once | ||
|
||
#include <h5cpp/contrib/stl/array.hpp> | ||
#include <h5cpp/contrib/stl/string.hpp> | ||
#include <h5cpp/contrib/stl/vector.hpp> | ||
#include <h5cpp/contrib/stl/complex.hpp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <h5cpp/datatype/type_trait.hpp> | ||
#include <string> | ||
|
||
namespace hdf5 { | ||
namespace datatype { | ||
|
||
template<> | ||
class TypeTrait<std::string> { | ||
public: | ||
using Type = std::string; | ||
using TypeClass = String; | ||
static TypeClass create(const Type & = Type()) { | ||
return datatype::String::variable(); | ||
} | ||
const static TypeClass & get(const Type & = Type()) { | ||
const static TypeClass & cref_ = create(); | ||
return cref_; | ||
} | ||
}; | ||
|
||
|
||
template<typename CharT> | ||
class TypeTrait<std::basic_string<CharT>> { | ||
private: | ||
|
||
public: | ||
using Type = std::basic_string<CharT>; | ||
using TypeClass = String; | ||
|
||
static TypeClass create(const Type & = Type()) { | ||
static_assert(std::is_same<CharT, char>::value, "Only support 8Bit characters"); | ||
|
||
String type = String::variable(); | ||
type.encoding(CharacterEncoding::UTF8); | ||
return type; | ||
|
||
} | ||
const static TypeClass & get(const Type & = Type()) { | ||
const static TypeClass & cref_ = create(); | ||
return cref_; | ||
} | ||
|
||
}; | ||
} // end of namespace datatype | ||
|
||
namespace dataspace { | ||
|
||
} // end of namespace dataspace | ||
} // end of namespace hdf5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <h5cpp/datatype/type_trait.hpp> | ||
|
||
namespace hdf5 { | ||
namespace datatype { | ||
|
||
template<typename T> | ||
class TypeTrait<std::vector<T>> { | ||
public: | ||
using Type = std::vector<T>; | ||
using TypeClass = typename TypeTrait<T>::TypeClass; | ||
static TypeClass create(const Type & = Type()) { | ||
return TypeTrait<typename std::remove_const<T>::type>::create(); | ||
} | ||
const static TypeClass & get(const Type & = Type()) { | ||
const static TypeClass & cref_ = create(); | ||
return cref_; | ||
} | ||
}; | ||
|
||
} // end of namespace datatype | ||
} // end of namespace hdf5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters