ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
is_utf8_cstring.hpp
Go to the documentation of this file.
1#ifndef RITSUKO_IS_UTF8_STRING_HPP
2#define RITSUKO_IS_UTF8_STRING_HPP
3
4#include <type_traits>
5#include <cstdint>
6#include "H5Cpp.h"
7
13namespace ritsuko {
14
15namespace hdf5 {
16
29inline bool is_utf8_cstring(const H5::StrType& stype) {
30 const auto spad = stype.getStrpad();
31 if (spad == H5T_STR_NULLTERM || spad == H5T_STR_NULLPAD) {
32 const auto cset = stype.getCset();
33 return (cset == H5T_CSET_ASCII || cset == H5T_CSET_UTF8);
34 } else {
35 return false;
36 }
37}
38
46inline bool is_utf8_cstring(const H5::DataSet& data) {
47 if (data.getTypeClass() != H5T_STRING) {
48 return false;
49 }
50 return is_utf8_cstring(H5::StrType(data));
51}
52
60inline bool is_utf8_cstring(const H5::Attribute& attr) {
61 if (attr.getTypeClass() != H5T_STRING) {
62 return false;
63 }
64 return is_utf8_cstring(attr.getStrType());
65}
66
70// For back-compatiblity.
71inline bool is_utf8_string(const H5::StrType& stype) {
72 return is_utf8_cstring(stype);
73}
74
75inline bool is_utf8_string(const H5::DataSet& data) {
76 return is_utf8_cstring(data);
77}
78
79inline bool is_utf8_string(const H5::Attribute& attr) {
80 return is_utf8_cstring(attr);
81}
86}
87
88}
89
90#endif
bool is_utf8_cstring(const H5::StrType &stype)
Definition is_utf8_cstring.hpp:29
Helper functions for ArtifactDB parsing and validation.
Definition Pointer.hpp:22