Skip to content

Commit

Permalink
Return the AttrInfo object when writing attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAce committed Oct 31, 2020
1 parent c98ef30 commit eb39897
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions h5pp/include/h5pp/details/h5ppFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,12 @@ namespace h5pp {
}

template<typename DataType>
void createAttribute(const DataType &data, const DimsType &dataDims, std::string_view attrName, std::string_view linkPath) {
AttrInfo createAttribute(const DataType &data, const DimsType &dataDims, std::string_view attrName, std::string_view linkPath) {
Options options;
options.linkPath = linkPath;
options.attrName = attrName;
options.dataDims = dataDims;
createAttribute(data, options);
return createAttribute(data, options);
}

template<typename DataType>
Expand All @@ -668,17 +668,18 @@ namespace h5pp {
}

template<typename DataType>
void writeAttribute(const DataType &data, const Options &options) {
AttrInfo writeAttribute(const DataType &data, const Options &options) {
if(permission == h5pp::FilePermission::READONLY)
throw std::runtime_error(h5pp::format("Attempted to write on read-only file [{}]", filePath.string()));
options.assertWellDefined();
auto dataInfo = h5pp::scan::scanDataInfo(data, options);
auto attrInfo = createAttribute(data, options);
h5pp::hdf5::writeAttribute(data, dataInfo, attrInfo);
return attrInfo;
}

template<typename DataType>
void writeAttribute(const DataType & data,
AttrInfo writeAttribute(const DataType & data,
std::string_view attrName,
std::string_view linkPath,
const OptDimsType & dataDims = std::nullopt,
Expand All @@ -688,7 +689,7 @@ namespace h5pp {
options.attrName = attrName;
options.dataDims = dataDims;
options.h5Type = std::move(h5Type);
writeAttribute(data, options);
return writeAttribute(data, options);
}

template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
Expand Down

0 comments on commit eb39897

Please sign in to comment.