Skip to content

Commit

Permalink
Add overload to read attributes using only options, and for reading a…
Browse files Browse the repository at this point in the history
…s a custom h5Type
  • Loading branch information
DavidAce committed Apr 6, 2022
1 parent 2bc2354 commit ba15d79
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions include/h5pp/details/h5ppFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -996,24 +996,36 @@ namespace h5pp {
}

template<typename DataType>
void readAttribute(DataType &data,
std::string_view attrName,
std::string_view linkPath,
const OptDimsType &dataDims = std::nullopt) const {
void readAttribute(DataType &data,
std::string_view attrName,
std::string_view linkPath,
const OptDimsType &dataDims = std::nullopt,
std::optional<hid::h5t> h5Type = std::nullopt) const {
static_assert(not std::is_const_v<DataType>);
Options options;
options.linkPath = linkPath;
options.attrName = attrName;
options.dataDims = dataDims;
options.h5Type = std::move(h5Type);
readAttribute(data, options);
}

template<typename DataType>
[[nodiscard]] DataType
readAttribute(std::string_view attrName, std::string_view linkPath, const OptDimsType &dataDims = std::nullopt) const {
[[nodiscard]] DataType readAttribute(const Options &options) const {
static_assert(not std::is_const_v<DataType>);
DataType data;
readAttribute(data, options);
return data;
}

template<typename DataType>
[[nodiscard]] DataType readAttribute(std::string_view attrName,
std::string_view linkPath,
const OptDimsType &dataDims = std::nullopt,
std::optional<hid::h5t> h5Type = std::nullopt) const {
static_assert(not std::is_const_v<DataType>);
DataType data;
readAttribute(data, attrName, linkPath, dataDims);
readAttribute(data, attrName, linkPath, dataDims, h5Type);
return data;
}

Expand Down

0 comments on commit ba15d79

Please sign in to comment.