-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split object.hpp into multiple header files
- Loading branch information
Showing
9 changed files
with
118 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2019-2022 Simons Foundation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Authors: Olivier Parcollet, Nils Wentzell | ||
|
||
/** | ||
* @file | ||
* @brief Provides a compound type and type traits for complex numbers. | ||
*/ | ||
|
||
#ifndef LIBH5_COMPLEX_HPP | ||
#define LIBH5_COMPLEX_HPP | ||
|
||
#include <complex> | ||
#include <type_traits> | ||
|
||
namespace h5 { | ||
|
||
/** | ||
* @brief A complex compound type consisting of two doubles to represent a complex number. | ||
* @details This type can be used to read/write complex numbers from/to HDF5 files. | ||
*/ | ||
struct dcplx_t { | ||
/// Real part. | ||
double r; | ||
|
||
/// Imaginary part. | ||
double i; | ||
}; | ||
|
||
// Type trait to check if a type is std::complex. | ||
template <typename T> | ||
struct _is_complex : std::false_type {}; | ||
|
||
// Specialization of h5::_is_complex for std::complex. | ||
template <typename T> | ||
struct _is_complex<std::complex<T>> : std::true_type {}; | ||
|
||
/** | ||
* @brief Boolean type trait set to true for std::complex types. | ||
* @tparam T Type to check. | ||
*/ | ||
template <typename T> | ||
constexpr bool is_complex_v = _is_complex<T>::value; | ||
|
||
} // namespace h5 | ||
|
||
#endif // LIBH5_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
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
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
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
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,46 @@ | ||
// Copyright (c) 2019-2022 Simons Foundation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Authors: Olivier Parcollet, Nils Wentzell | ||
|
||
/** | ||
* @file | ||
* @brief Provides some utility functions for h5. | ||
*/ | ||
|
||
#ifndef LIBH5_UTILS_HPP | ||
#define LIBH5_UTILS_HPP | ||
|
||
#include <stdexcept> | ||
#include <sstream> | ||
|
||
namespace h5 { | ||
|
||
/** | ||
* @brief Create a std::runtime_error with an error message constructed from the given arguments. | ||
* | ||
* @tparam Ts Types of the arguments. | ||
* @param ts Arguments streamed into the error message string. | ||
* @return std::runtime_error. | ||
*/ | ||
template <typename... Ts> | ||
[[nodiscard]] std::runtime_error make_runtime_error(Ts const &...ts) { | ||
std::stringstream ss; | ||
(ss << ... << ts); | ||
return std::runtime_error{ss.str()}; | ||
} | ||
|
||
} // namespace h5 | ||
|
||
#endif // LIBH5_UTILS_HPP |