HDF5 C++ API Reference Manual

- Main Page
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Hierarchy
- Class Members

# H5::Attribute Class Reference

`#include <H5Attribute.h>`

Inheritance diagram for H5::Attribute:

List of all members.

## Public Member Functions
virtual void | close ()
| Closes this attribute.
H5std_string | getFileName () const
| Gets the name of the file, in which this attribute belongs.
ssize_t | getName (size_t buf_size, H5std_string &attr_name) const
| Gets the name of this attribute, returning its length.
H5std_string | getName (size_t buf_size) const
| This is an overloaded member function, provided for convenience. It differs from the above function in that it returns the attribute's name, not the length.
H5std_string | getName () const
| This is an overloaded member function, provided for convenience. It differs from the above functions in that it doesn't take any arguments and returns the attribute's name.
virtual DataSpace | getSpace () const
| Gets a copy of the dataspace for this attribute.
virtual hsize_t | getStorageSize () const
| Returns the amount of storage size required for this attribute.
virtual size_t | getInMemDataSize () const
| Gets the size in memory of the attribute's data.
void | read (const DataType &mem_type, void *buf) const
| Reads data from this attribute.
void | read (const DataType &mem_type, H5std_string &strg) const
| This is an overloaded member function, provided for convenience. It reads a H5std_string from this attribute.
void | write (const DataType &mem_type, const void *buf) const
| Writes data to this attribute.
void | write (const DataType &mem_type, const H5std_string &strg) const
| This is an overloaded member function, provided for convenience. It writes a H5std_string to this attribute.
H5G_obj_t | getRefObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
| Retrieves the type of object that an object reference points to.
H5G_obj_t | getObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
| This function was misnamed and will be deprecated in favor of Attribute::getRefObjType; please use getRefObjType instead.
virtual H5std_string | fromClass () const
| Attribute (const hid_t attr_id)
| Creates an Attribute object using the id of an existing attribute.
| Attribute (const Attribute &original)
| Copy constructor: makes a copy of the original Attribute object.
| Attribute ()
| Default constructor: Creates a stub attribute.
virtual hid_t | getId () const
virtual | ~Attribute ()
| Properly terminates access to this attribute.
## Protected Member Functions
virtual void | p_setId (const hid_t new_id)
| Sets the identifier of this object to a new value.

## Constructor & Destructor Documentation

H5::Attribute::Attribute | ( | const hid_t | existing_id | ) |

Creates an Attribute object using the id of an existing attribute.

Parameters:

  | existing_id | - IN: Id of an existing attribute

Exceptions:

  | H5::AttributeIException |

H5::Attribute::Attribute | ( | const Attribute & | original | ) |

Copy constructor: makes a copy of the original Attribute object.

Parameters:

  | original | - IN: Original Attribute object to copy

H5::Attribute::Attribute | ( |  | ) |

Default constructor: Creates a stub attribute.

H5::Attribute::~Attribute | ( |  | ) | `[virtual]`

Properly terminates access to this attribute.

## Member Function Documentation

void H5::Attribute::close | ( |  | ) | `[virtual]`

Closes this attribute.

Exceptions:

  | H5::AttributeIException |

H5std_string H5::Attribute::getFileName | ( |  | ) | const

Gets the name of the file, in which this attribute belongs.

Returns:
  File name

Exceptions:

  | H5::IdComponentException |

ssize_t H5::Attribute::getName | ( | size_t | buf_size,
|  | H5std_string & | attr_name |
| ) |  |  | const

Gets the name of this attribute, returning its length.

Parameters:

  | buf_size | - IN: Desired length of the name
  | attr_name | - OUT: Buffer for the name string

Returns:
  Length of the attribute name

Exceptions:

  | H5::AttributeIException |

H5std_string H5::Attribute::getName | ( | size_t | buf_size | ) | const

This is an overloaded member function, provided for convenience. It differs from the above function in that it returns the attribute's name, not the length.

Returns:
  Name of the attribute

Parameters:

  | buf_size | - IN: Desired length of the name

Exceptions:

  | H5::AttributeIException |

H5std_string H5::Attribute::getName | ( |  | ) | const

This is an overloaded member function, provided for convenience. It differs from the above functions in that it doesn't take any arguments and returns the attribute's name.

Returns:
  Name of the attribute

Exceptions:

  | H5::AttributeIException |

DataSpace H5::Attribute::getSpace | ( |  | ) | const`[virtual]`

Gets a copy of the dataspace for this attribute.

Returns:
  Dataspace instance

Exceptions:

  | H5::AttributeIException |

Implements H5::AbstractDs.

hsize_t H5::Attribute::getStorageSize | ( |  | ) | const`[virtual]`

Returns the amount of storage size required for this attribute.

Returns:
  Size of the storage or 0, for no data

Exceptions:

  | H5::AttributeIException |

Implements H5::AbstractDs.

size_t H5::Attribute::getInMemDataSize | ( |  | ) | const`[virtual]`

Gets the size in memory of the attribute's data.

Returns:
  Size of data (in memory)

Exceptions:

  | H5::AttributeIException |

Implements H5::AbstractDs.

void H5::Attribute::read | ( | const DataType & | mem_type,
|  | void * | buf |
| ) |  |  | const

Reads data from this attribute.

Parameters:

  | mem_type | - IN: Attribute datatype (in memory)
  | buf | - OUT: Buffer for read data

Exceptions:

  | H5::AttributeIException |

void H5::Attribute::read | ( | const DataType & | mem_type,
|  | H5std_string & | strg |
| ) |  |  | const

This is an overloaded member function, provided for convenience. It reads a H5std_string from this attribute.

Parameters:

  | mem_type | - IN: Attribute datatype (in memory)
  | strg | - IN: Buffer for read string

Exceptions:

  | H5::AttributeIException |

void H5::Attribute::write | ( | const DataType & | mem_type,
|  | const void * | buf |
| ) |  |  | const

Writes data to this attribute.

Parameters:

  | mem_type | - IN: Attribute datatype (in memory)
  | buf | - IN: Data to be written

Exceptions:

  | H5::AttributeIException |

void H5::Attribute::write | ( | const DataType & | mem_type,
|  | const H5std_string & | strg |
| ) |  |  | const

This is an overloaded member function, provided for convenience. It writes a H5std_string to this attribute.

Parameters:

  | mem_type | - IN: Attribute datatype (in memory)
  | strg | - IN: Data to be written

Exceptions:

  | H5::AttributeIException |

H5G_obj_t H5::Attribute::getRefObjType | ( | void * | ref,
|  | H5R_type_t | ref_type = `H5R_OBJECT` |
| ) |  |  | const

Retrieves the type of object that an object reference points to.

Parameters:

  | ref | - IN: Reference to query
  | ref_type | - IN: Type of reference to query, valid values are: `H5R_OBJECT` is an object reference. `H5R_DATASET_REGION` is a dataset region reference.

Returns:
  An object type, which can be one of the following:
  - `H5G_LINK` (0) is a symbolic link.
  - `H5G_GROUP` (1) is a group.
  - `H5G_DATASET` (2) is a dataset.
  - `H5G_TYPE` Object (3) a named datatype

Exceptions:

  | H5::AttributeIException |

H5G_obj_t H5::Attribute::getObjType | ( | void * | ref,
|  | H5R_type_t | ref_type = `H5R_OBJECT` |
| ) |  |  | const

This function was misnamed and will be deprecated in favor of Attribute::getRefObjType; please use getRefObjType instead.

virtual H5std_string H5::Attribute::fromClass | ( |  | ) | const`[inline, virtual]`

Implements H5::AbstractDs.

hid_t H5::Attribute::getId | ( |  | ) | const`[virtual]`

Implements H5::IdComponent.

void H5::Attribute::p_setId | ( | const hid_t | new_id | ) | `[protected, virtual]`

Sets the identifier of this object to a new value.

Exceptions:

  | H5::IdComponentException | when the attempt to close the HDF5 object fails