ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
as_numeric_datatype.hpp
Go to the documentation of this file.
1#ifndef RITSUKO_AS_NUMERIC_DATATYPE_HPP
2#define RITSUKO_AS_NUMERIC_DATATYPE_HPP
3
4#include <type_traits>
5#include <cstdint>
6#include "H5Cpp.h"
7
13namespace ritsuko {
14
15namespace hdf5 {
16
25template<typename Type_>
26const H5::PredType& as_numeric_datatype() {
27 if constexpr(std::is_same<Type_, uint8_t>::value) {
28 return H5::PredType::NATIVE_UINT8;
29 } else if constexpr(std::is_same<Type_, int8_t>::value) {
30 return H5::PredType::NATIVE_INT8;
31 } else if constexpr(std::is_same<Type_, uint16_t>::value) {
32 return H5::PredType::NATIVE_UINT16;
33 } else if constexpr(std::is_same<Type_, int16_t>::value) {
34 return H5::PredType::NATIVE_INT16;
35 } else if constexpr(std::is_same<Type_, uint32_t>::value) {
36 return H5::PredType::NATIVE_UINT32;
37 } else if constexpr(std::is_same<Type_, int32_t>::value) {
38 return H5::PredType::NATIVE_INT32;
39 } else if constexpr(std::is_same<Type_, uint64_t>::value) {
40 return H5::PredType::NATIVE_UINT64;
41 } else if constexpr(std::is_same<Type_, int64_t>::value) {
42 return H5::PredType::NATIVE_INT64;
43
44 } else if constexpr(std::is_same<Type_, char>::value) {
45 return H5::PredType::NATIVE_CHAR;
46 } else if constexpr(std::is_same<Type_, unsigned char>::value) {
47 return H5::PredType::NATIVE_UCHAR;
48 } else if constexpr(std::is_same<Type_, signed char>::value) {
49 return H5::PredType::NATIVE_SCHAR;
50 } else if constexpr(std::is_same<Type_, short>::value) {
51 return H5::PredType::NATIVE_SHORT;
52 } else if constexpr(std::is_same<Type_, unsigned short>::value) {
53 return H5::PredType::NATIVE_USHORT;
54 } else if constexpr(std::is_same<Type_, int>::value) {
55 return H5::PredType::NATIVE_INT;
56 } else if constexpr(std::is_same<Type_, unsigned int>::value) {
57 return H5::PredType::NATIVE_UINT;
58 } else if constexpr(std::is_same<Type_, long>::value) {
59 return H5::PredType::NATIVE_LONG;
60 } else if constexpr(std::is_same<Type_, unsigned long>::value) {
61 return H5::PredType::NATIVE_ULONG;
62 } else if constexpr(std::is_same<Type_, long long>::value) {
63 return H5::PredType::NATIVE_LLONG;
64 } else if constexpr(std::is_same<Type_, unsigned long long>::value) {
65 return H5::PredType::NATIVE_ULLONG;
66
67 } else if constexpr(std::is_same<Type_, float>::value) {
68 return H5::PredType::NATIVE_FLOAT;
69 } else {
70 static_assert(std::is_same<Type_, double>::value, "specified type is not yet supported");
71 return H5::PredType::NATIVE_DOUBLE;
72 }
73}
74
75}
76
77}
78
79#endif
const H5::PredType & as_numeric_datatype()
Definition as_numeric_datatype.hpp:26
Assorted helper functions for parsing and validation.
Definition choose_missing_placeholder.hpp:15