Class representing an Attribute of a DataSet or Group.
More...
#include <H5Attribute.hpp>
◆ Attribute()
HighFive::Attribute::Attribute |
( |
| ) |
|
|
delete |
◆ getCreatePropertyList()
The create property list used for this attribute.
Some of HDF5 properties/setting of an attribute are defined by a create property list. This method returns a copy of the create property list used during creation of the attribute.
auto acpl = attr.getCreatePropertyList();
file.createAttribute("foo", 42, acpl);
- Since
- 2.5.0
◆ getDataType()
DataType HighFive::Attribute::getDataType |
( |
| ) |
const |
|
inline |
Get the DataType of the Attribute.
Class representing an Attribute of a DataSet or Group.
Definition H5Attribute.hpp:46
DataType getDataType() const
Get the DataType of the Attribute.
Definition H5Attribute_misc.hpp:37
- Since
- 1.0
◆ getMemSpace()
DataSpace HighFive::Attribute::getMemSpace |
( |
| ) |
const |
|
inline |
◆ getName()
std::string HighFive::Attribute::getName |
( |
| ) |
const |
|
inline |
Get the name of the current Attribute.
auto attr = dset.createAttribute<std::string>(
"my_attribute",
DataSpace::From(string_list));
std::cout << attr.getName() << std::endl;
static DataSpace From(const T &value)
Automatically deduce the DataSpace from a container/value.
Definition H5Dataspace_misc.hpp:128
- Since
- 2.2.2
◆ getSpace()
DataSpace HighFive::Attribute::getSpace |
( |
| ) |
const |
|
inline |
Get the DataSpace of the current Attribute.
DataSpace getSpace() const
Get the DataSpace of the current Attribute.
Definition H5Attribute_misc.hpp:43
- Since
- 1.0
◆ getStorageSize()
size_t HighFive::Attribute::getStorageSize |
( |
| ) |
const |
|
inline |
The number of bytes required to store the attribute in the HDF5 file.
size_t getStorageSize() const
The number of bytes required to store the attribute in the HDF5 file.
Definition H5Attribute_misc.hpp:33
- Since
- 1.0
◆ Object() [1/4]
HighFive::Object::Object |
( |
| ) |
|
|
inlineprotected |
◆ Object() [2/4]
HighFive::Object::Object |
( |
const Object & | other | ) |
|
|
inlineprotected |
◆ Object() [3/4]
HighFive::Object::Object |
( |
hid_t | hid | ) |
|
|
inlineexplicitprotected |
◆ Object() [4/4]
HighFive::Object::Object |
( |
Object && | other | ) |
|
|
inlineprotectednoexcept |
◆ read() [1/4]
template<typename T >
T HighFive::Attribute::read |
( |
| ) |
const |
|
inline |
Get the value of the Attribute.
std::vector<int> value = attr.
read<std::vector<int>>();
T read() const
Get the value of the Attribute.
Definition H5Attribute_misc.hpp:54
- Since
- 2.5.0
◆ read() [2/4]
template<typename T >
void HighFive::Attribute::read |
( |
T & | array | ) |
const |
|
inline |
Get the value of the Attribute in a buffer.
Read the attribute into an existing object. Only available for supported types T
. If array
has preallocated the correct amount of memory, then this routine should not trigger reallocation. Otherwise, if supported, the object will be resized.
An exception is raised if the numbers of dimension of the buffer and of the attribute are different.
std::vector<int> value(3);
file.getAttribute("foo").read(value);
- Since
- 1.0
◆ read() [3/4]
template<typename T >
void HighFive::Attribute::read |
( |
T * | array | ) |
const |
|
inline |
Read the attribute into a buffer.
- Deprecated
- use
read(T&
or read_raw
.
◆ read() [4/4]
template<typename T >
void HighFive::Attribute::read |
( |
T * | array, |
|
|
const DataType & | mem_datatype ) const |
|
inline |
Read the attribute into a pre-allocated buffer.
- Deprecated
- use
read(T&
or read_raw
.
◆ read_raw() [1/2]
template<typename T >
void HighFive::Attribute::read_raw |
( |
T * | array | ) |
const |
|
inline |
Read the attribute into a buffer. Behaves like Attribute::read(T*, const DataType&) const but additionally this overload deduces the memory datatype from T
.
- Parameters
-
array | Pointer to the first byte of pre-allocated memory. |
- Note
- If possible prefer either Attribute::read() const or Attribute::read(T&) const.
auto attr = file.getAttribute("foo");
size_t n_elements = attr.getSpace().getElementCount();
int * ptr = (int*) malloc(n_elements*sizeof(int));
attr.read(ptr);
- Since
- 2.2.2
◆ read_raw() [2/2]
template<typename T >
void HighFive::Attribute::read_raw |
( |
T * | array, |
|
|
const DataType & | mem_datatype ) const |
|
inline |
Read the attribute into a pre-allocated buffer.
- Parameters
-
array | A pointer to the first byte of sufficient pre-allocated memory. |
mem_datatype | The DataType of the array. |
- Note
- This is the shallowest wrapper around
H5Aread
. If possible prefer either Attribute::read() const or Attribute::read(T&) const.
auto attr = file.getAttribute("foo");
size_t n_elements = attr.getSpace().getElementCount();
int * ptr = (int*) malloc(n_elements*sizeof(int));
attr.read(ptr, mem_datatype);
- Since
- 2.2.2
◆ write()
template<typename T >
void HighFive::Attribute::write |
( |
const T & | value | ) |
|
|
inline |
Write the value into the Attribute.
Write the value to the attribute. For supported types T
, this overload will write the value to the attribute. The datatype and dataspace are deduced automatically. However, since the attribute has already been created, the dimensions of value
must match those of the attribute.
dset.createAttribute("foo", std::vector<int>{1, 2, 3});
std::vector<int> value{4, 5, 6};
dset.getAttribute<
int>(
"foo").
write(value);
void write(const T &value)
Write the value into the Attribute.
Definition H5Attribute_misc.hpp:131
- Since
- 1.0
◆ write_raw() [1/2]
template<typename T >
void HighFive::Attribute::write_raw |
( |
const T * | buffer | ) |
|
|
inline |
Write from a raw pointer.
Much like Attribute::write_raw(const T*, const DataType&). Additionally, this overload attempts to automatically deduce the datatype of the buffer. Note, that the file datatype is already set.
- Parameters
-
buffer | Pointer to the first byte. |
- Note
- If possible prefer Attribute::write.
std::vector<std::array<int, 3>> value{{1, 2, 3}, {4, 5, 6}};
int * ptr = (int*) value.data();
attr.write(ptr);
- Since
- 2.2.2
◆ write_raw() [2/2]
template<typename T >
void HighFive::Attribute::write_raw |
( |
const T * | buffer, |
|
|
const DataType & | mem_datatype ) |
|
inline |
Write from a raw pointer.
Values that have been correctly arranged memory, can be written directly by passing a raw pointer.
- Parameters
-
buffer | Pointer to the first byte of the value. |
mem_datatype | The DataType of the buffer. |
- Note
- This is the shallowest wrapper around
H5Awrite
. It's useful if you need full control. If possible prefer Attribute::write.
std::vector<std::array<int, 3>> value{{1, 2, 3}, {4, 5, 6}};
int * ptr = (int*) value.data();
attr.
write(ptr, AtomicType<int>());
- Since
- 2.2.2
◆ type
The documentation for this class was generated from the following files: