Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check error code of ?get_cset. #861

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions include/highfive/bits/H5ReadWrite_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@
// converter issues on HDF5 <=v1.12.0 when loading ASCII strings first.
// See https://github.com/HDFGroup/hdf5/issues/544 for further information.

bool is_dst_string = H5Tget_class(dst.getId()) == H5T_STRING;
bool is_src_string = H5Tget_class(src.getId()) == H5T_STRING;
bool is_dst_string = detail::h5t_get_class(dst.getId()) == H5T_STRING;
bool is_src_string = detail::h5t_get_class(src.getId()) == H5T_STRING;

if (is_dst_string && is_src_string) {
if (H5Tget_cset(src.getId()) == H5T_CSET_ASCII) {
H5Tset_cset(dst.getId(), H5T_CSET_ASCII);
if (detail::h5t_get_cset(src.getId()) == H5T_CSET_ASCII) {
detail::h5t_set_cset(dst.getId(), H5T_CSET_ASCII);

Check warning on line 85 in include/highfive/bits/H5ReadWrite_misc.hpp

View check run for this annotation

Codecov / codecov/patch

include/highfive/bits/H5ReadWrite_misc.hpp#L85

Added line #L85 was not covered by tests
}
}
}

template <>
struct string_type_checker<void> {
inline static DataType getDataType(const DataType& element_type, const DataType& dtype) {
if (H5Tget_class(element_type.getId()) == H5T_STRING) {
if (detail::h5t_get_class(element_type.getId()) == H5T_STRING) {
enforce_ascii_hack(element_type, dtype);
}
return element_type;
Expand Down
9 changes: 9 additions & 0 deletions include/highfive/bits/h5t_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,14 @@
}
}

inline H5T_class_t h5t_get_class(hid_t type_id) {
H5T_class_t class_id = H5Tget_class(type_id);
if (class_id == H5T_NO_CLASS) {
throw DataTypeException("Failed to get class of type");

Check warning on line 65 in include/highfive/bits/h5t_wrapper.hpp

View check run for this annotation

Codecov / codecov/patch

include/highfive/bits/h5t_wrapper.hpp#L65

Added line #L65 was not covered by tests
}

return class_id;
}

} // namespace detail
} // namespace HighFive