been checked into "HDF5 Development" branch. General ======= Various "copy edit" types of repairs. Revisions to document cross-linking. Added structural links tying all docs together (banners at top and bottom of documents, similar to Reference Manual banners of the Beta release). Set background color to white in all documents. NCSAfooterlogo.gif hdf2.jpg New image files to make the documents more self-contained (i.e., to prevent loading images from NCSA and HDF home servers). index.html Redesigned to isolate links external to the installation in a single location. Intro to HDF5 ============= H5.intro.html Fixed banner linking Intro to other docs. Set all URLs to be relative within the distribution; nothing points back to the HDF server. Updates to "Limits of the Current Release" and "Changes in the Current Release." HDF5 User's Guide ================= Changed several User Guide section titles such that all sections that are primarily about a particular interface are now titled in the format "The xxxxx Interface (H5x)". H5.user.html Commented out links to developer docs since they are marked in MANIFEST as not being for distribution in the release. Removed 2nd and 3rd indices from page. Changed "freeform" lists of sections (TOCs) to aligned tables. Datatypes.html Removed the sentence "I'm deferring definition until later since they're probably not as important as the other data types." from Section 3.3, "Properties of Date and Time Atomic Types." Added info regarding 'char' versus 'string' datatypes. Added as Section 3.7, "Character and String Datatype Issues." References.html Commented out substantial material (at end of document) from References planning document that is not appropriate for the User Guide but that is worth keeping around. Groups.html Final edits from elimination of "current working group." HDF5 Reference Manual ===================== Removed "Draft" from the <title>__</title> lines. RM_H5Front.html Removed 2nd and 3rd indices from page. Changed "freeform" lists of sections (TOCs) to aligned tables. RM_H5F.html RM_H5P.html Add file mounting information.
305 lines
14 KiB
HTML
305 lines
14 KiB
HTML
|
|
<html>
|
|
<head>
|
|
<title>Attributes</title>
|
|
</head>
|
|
|
|
<body bgcolor="#FFFFFF">
|
|
|
|
|
|
<hr>
|
|
<center>
|
|
<table border=0 width=98%>
|
|
<tr><td valign=top align=left>
|
|
<a href="H5.intro.html">Introduction to HDF5</a> <br>
|
|
<a href="RM_H5Front.html">HDF5 Reference Manual</a> <br>
|
|
<a href="index.html">Other HDF5 documents and links</a> <br>
|
|
<!--
|
|
<a href="Glossary.html">Glossary</a><br>
|
|
-->
|
|
</td>
|
|
<td valign=top align=right>
|
|
And in this document, the
|
|
<a href="H5.user.html">HDF5 User's Guide</a>:
|
|
<a href="Files.html">Files</a>
|
|
<br>
|
|
<a href="Datasets.html">Datasets</a>
|
|
<a href="Datatypes.html">Data Types</a>
|
|
<a href="Dataspaces.html">Dataspaces</a>
|
|
<a href="Groups.html">Groups</a>
|
|
<a href="References.html">References</a>
|
|
<br>
|
|
Attributes
|
|
<a href="Properties.html">Property Lists</a>
|
|
<a href="Errors.html">Error Handling</a>
|
|
<a href="Filters.html">Filters</a>
|
|
<a href="Caching.html">Caching</a>
|
|
<br>
|
|
<a href="Chunking.html">Chunking</a>
|
|
<a href="Debugging.html">Debugging</a>
|
|
<a href="Environment.html">Environment</a>
|
|
<a href="ddl.html">DDL</a>
|
|
<a href="Ragged.html">Ragged Arrays</a>
|
|
<!--
|
|
<hr>
|
|
And in this document, the
|
|
<a href="H5.user.html">HDF5 User's Guide</a>:
|
|
<a href="Attributes.html">H5A</a>
|
|
<a href="Datasets.html">H5D</a>
|
|
<a href="Errors.html">H5E</a>
|
|
<a href="Files.html">H5F</a>
|
|
<a href="Groups.html">H5G</a>
|
|
<a href="Properties.html">H5P</a>
|
|
<a href="References.html">H5R & H5I</a>
|
|
<a href="Ragged.html">H5RA</a>
|
|
<a href="Dataspaces.html">H5S</a>
|
|
<a href="Datatypes.html">H5T</a>
|
|
<a href="Filters.html">H5Z</a>
|
|
<a href="Caching.html">Caching</a>
|
|
<a href="Chunking.html">Chunking</a>
|
|
<a href="Debugging.html">Debugging</a>
|
|
<a href="Environment.html">Environment</a>
|
|
<a href="ddl.html">DDL</a>
|
|
-->
|
|
</td></tr>
|
|
</table>
|
|
</center>
|
|
<hr>
|
|
|
|
|
|
<h1>The Attribute Interface (H5A)</h1>
|
|
|
|
<h2>1. Introduction</h2>
|
|
|
|
<p>The appribute API (H5A) is primarily designed to easily allow small
|
|
datasets to be attached to primary datasets as metadata information.
|
|
Additional goals for the H5A interface include keeping storage
|
|
requirement for each attribute to a minimum and easily sharing
|
|
attributes among datasets.
|
|
<p>Because attributes are intended to be small objects, large datasets
|
|
intended as additional information for a primary dataset should be
|
|
stored as supplemental datasets in a group with the primary dataset.
|
|
Attributes can then be attached to the group containing everything to
|
|
indicate a particular type of dataset with supplemental datasets is
|
|
located in the group. How small is "small" is not defined by the
|
|
library and is up to the user's interpretation.
|
|
<p>Attributes are not seperate objects in the file, they are always
|
|
contained in the object header of the object they are attached to. The
|
|
I/O functions defined below are required to read or write attribute
|
|
information, not the H5D I/O routines.
|
|
|
|
<h2>2. Creating, Opening, Closing and Deleting Attributes</h2>
|
|
|
|
<p>Attributes are created with the <code>H5Acreate()</code> function,
|
|
and existing attributes can be accessed with either the
|
|
<code>H5Aopen_name()</code> or <code>H5Aopen_idx()</code> functions. All
|
|
three functions return an object ID which should be eventually released
|
|
by calling <code>H5Aclose()</code>.
|
|
|
|
<dl>
|
|
<dt><code>hid_t H5Acreate (hid_t <em>loc_id</em>, const char
|
|
*<em>name</em>, hid_t <em>type_id</em>, hid_t <em>space_id</em>,
|
|
hid_t <em>create_plist_id</em>)</code>
|
|
<dd>This function creates an attribute which is attached to the object
|
|
specified with <em>loc_id</em>. The name specified with <em>name</em>
|
|
for each attribute for an object must be unique for that object. The <em>type_id</em>
|
|
and <em>space_id</em> are created with the H5T and H5S interfaces
|
|
respectively. Currently only simple dataspaces are allowed for attribute
|
|
dataspaces. The <em>create_plist_id</em> property list is currently
|
|
unused, but will be used int the future for optional properties of
|
|
attributes. The attribute ID returned from this function must be released
|
|
with H5Aclose or resource leaks will develop. Attempting to create an
|
|
attribute with the same name as an already existing attribute will fail,
|
|
leaving the pre-existing attribute in place.
|
|
This function returns a attribute ID for success or negative for failure.
|
|
|
|
<br><br>
|
|
<dt><code>hid_t H5Aopen_name (hid_t <em>loc_id</em>, const char
|
|
*<em>name</em>)</code>
|
|
<dd> This function opens an attribute which is attached to the object
|
|
specified with <em>loc_id</em>. The name specified with <em>name</em>
|
|
indicates the attribute to access. The attribute ID returned from this
|
|
function must be released with H5Aclose or resource leaks will develop.
|
|
This function returns a attribute ID for success or negative for failure.
|
|
|
|
<br><br>
|
|
<dt><code>hid_t H5Aopen_idx (hid_t <em>loc_id</em>, unsigned
|
|
<em>idx</em>)</code>
|
|
<dd>This function opens an attribute which is attached to the object
|
|
specified with <em>loc_id</em>. The attribute specified with <em>idx</em>
|
|
indicates the <em>idx</em>th attribute to access, starting with '0'. The
|
|
attribute ID returned from this function must be released with H5Aclose or
|
|
resource leaks will develop.
|
|
This function returns a attribute ID for success or negative for failure.
|
|
|
|
<br><br>
|
|
<dt><code>herr_t H5Aclose (hid_t <em>attr_id</em>)</code>
|
|
<dd>This function releases an attribute from use. Further use of the
|
|
attribute ID will result in undefined behavior.
|
|
This function returns non-negative on success, negative on failure.
|
|
|
|
<br><br>
|
|
<dt><code>herr_t H5Adelete (hid_t <em>loc_id</em>,
|
|
const char *<em>name</em>)</code>
|
|
<dd>This function removes the named attribute from a dataset or group.
|
|
This function should not be used when attribute IDs are open on <em>loc_id</em>
|
|
as it may cause the internal indexes of the attributes to change and future
|
|
writes to the open attributes to produce incorrect results.
|
|
Returns non-negative on success, negative on failure.
|
|
</dl>
|
|
|
|
<h2>3. Attribute I/O Functions</h2>
|
|
|
|
<p>Attributes may only be written as an entire object, no partial I/O
|
|
is currently supported.
|
|
|
|
<dl>
|
|
<dt><code>herr_t H5Awrite (hid_t <em>attr_id</em>,
|
|
hid_t <em>mem_type_id</em>, void *<em>buf</em>)</code>
|
|
<dd>This function writes an attribute, specified with <em>attr_id</em>,
|
|
with <em>mem_type_id</em> specifying the datatype in memory. The entire
|
|
attribute is written from <em>buf</em> to the file.
|
|
This function returns non-negative on success, negative on failure.
|
|
|
|
<br><br>
|
|
<dt><code>herr_t H5Aread (hid_t <em>attr_id</em>,
|
|
hid_t <em>mem_type_id</em>, void *<em>buf</em>)</code>
|
|
<dd>This function read an attribute, specified with <em>attr_id</em>, with
|
|
<em>mem_type_id</em> specifying the datatype in memory. The entire
|
|
attribute is read into <em>buf</em> from the file.
|
|
This function returns non-negative on success, negative on failure.
|
|
|
|
</dl>
|
|
|
|
<h2>4. Attribute Inquiry Functions</h2>
|
|
|
|
<dl>
|
|
<dt><code>int H5Aiterate (hid_t <em>loc_id</em>,
|
|
unsigned *<em>attr_number</em>,
|
|
H5A_operator <em>operator</em>,
|
|
void *<em>operator_data</em>)</code>
|
|
<dd> This function interates over the attributes of dataset or group
|
|
specified with <em>loc_id</em>. For each attribute of the object, the
|
|
<em>operator_data</em> and some additional information (specified below)
|
|
are passed to the <em>operator</em> function. The iteration begins with
|
|
the <em>*attr_number</em> object in the group and the next attribute to be
|
|
processed by the operator is returned in <em>*attr_number</em>.
|
|
<P>The iterator returns a negative value if something is wrong, the return
|
|
value of the last operator if it was non-zero, or zero if all attributes
|
|
were processed.
|
|
<P>The prototype for H5A_operator_t is: <br>
|
|
<code>typedef herr_t (*H5A_operator_t)(hid_t <em>loc_id</em>,
|
|
const char *<em>attr_name</em>, void *<em>operator_data</em>);</code>
|
|
<P>The operation receives the ID for the group or dataset being iterated over
|
|
(<em>loc_id</em>), the name of the current attribute about the object (<em>attr_name</em>)
|
|
and the pointer to the operator data passed in to H5Aiterate
|
|
(<em>operator_data</em>). The return values from an operator are:
|
|
<ul>
|
|
<li>Zero causes the iterator to continue, returning zero when all
|
|
attributes have been processed.
|
|
<li>Positive causes the iterator to immediately return that positive
|
|
value, indicating short-circuit success. The iterator can be
|
|
restarted at the next attribute.
|
|
<li>Negative causes the iterator to immediately return that value,
|
|
indicating failure. The iterator can be restarted at the next
|
|
attribute.
|
|
</ul>
|
|
<br><br>
|
|
<dt><code>hid_t H5Aget_space (hid_t <em>attr_id</em>)</code>
|
|
<dd>This function retrieves a copy of the dataspace for an attribute.
|
|
The dataspace ID returned from this function must be released with H5Sclose
|
|
or resource leaks will develop.
|
|
This function returns a dataspace ID for success or negative for failure.
|
|
<br><br>
|
|
<dt><code>hid_t H5Aget_type (hid_t <em>attr_id</em>)</code>
|
|
<dd>This function retrieves a copy of the datatype for an attribute.
|
|
The datatype ID returned from this function must be released with H5Tclose
|
|
or resource leaks will develop.
|
|
This function returns a datatype ID for success or negative for failure.
|
|
<br><br>
|
|
<dt><code>size_t H5Aget_name (hid_t <em>attr_id</em>,
|
|
char *<em>buf</em>, size_t <em>buf_size</em>)</code>
|
|
<dd>This function retrieves the name of an attribute for an attribute ID.
|
|
Up to <em>buf_size</em> characters are stored in <em>buf</em> followed by a
|
|
'\0' string terminator. If the name of the attribute is longer than
|
|
<em>buf_size</em>-1, the string terminator is stored in the last position
|
|
of the buffer to properly terminate the string.
|
|
This function returns the length of the attribute's name (which may be
|
|
longer than <em>buf_size</em>) on success or negative for failure.
|
|
<br><br>
|
|
<dt><code>int H5Aget_num_attrs (hid_t <em>loc_id</em>)</code>
|
|
<dd>This function returns the number of attributes attached to a dataset or
|
|
group, <em>loc_id</em>.
|
|
This function returns non-negative for success or negative for failure.
|
|
</dl>
|
|
|
|
|
|
<hr>
|
|
<center>
|
|
<table border=0 width=98%>
|
|
<tr><td valign=top align=left>
|
|
<a href="H5.intro.html">Introduction to HDF5</a> <br>
|
|
<a href="RM_H5Front.html">HDF5 Reference Manual</a> <br>
|
|
<a href="index.html">Other HDF5 documents and links</a> <br>
|
|
<!--
|
|
<a href="Glossary.html">Glossary</a><br>
|
|
-->
|
|
</td>
|
|
<td valign=top align=right>
|
|
And in this document, the
|
|
<a href="H5.user.html">HDF5 User's Guide</a>:
|
|
<a href="Files.html">Files</a>
|
|
<br>
|
|
<a href="Datasets.html">Datasets</a>
|
|
<a href="Datatypes.html">Data Types</a>
|
|
<a href="Dataspaces.html">Dataspaces</a>
|
|
<a href="Groups.html">Groups</a>
|
|
<a href="References.html">References</a>
|
|
<br>
|
|
Attributes
|
|
<a href="Properties.html">Property Lists</a>
|
|
<a href="Errors.html">Error Handling</a>
|
|
<a href="Filters.html">Filters</a>
|
|
<a href="Caching.html">Caching</a>
|
|
<br>
|
|
<a href="Chunking.html">Chunking</a>
|
|
<a href="Debugging.html">Debugging</a>
|
|
<a href="Environment.html">Environment</a>
|
|
<a href="ddl.html">DDL</a>
|
|
<a href="Ragged.html">Ragged Arrays</a>
|
|
<!--
|
|
<hr>
|
|
And in this document, the
|
|
<a href="H5.user.html">HDF5 User's Guide</a>:
|
|
<a href="Attributes.html">H5A</a>
|
|
<a href="Datasets.html">H5D</a>
|
|
<a href="Errors.html">H5E</a>
|
|
<a href="Files.html">H5F</a>
|
|
<a href="Groups.html">H5G</a>
|
|
<a href="Properties.html">H5P</a>
|
|
<a href="References.html">H5R & H5I</a>
|
|
<a href="Ragged.html">H5RA</a>
|
|
<a href="Dataspaces.html">H5S</a>
|
|
<a href="Datatypes.html">H5T</a>
|
|
<a href="Filters.html">H5Z</a>
|
|
<a href="Caching.html">Caching</a>
|
|
<a href="Chunking.html">Chunking</a>
|
|
<a href="Debugging.html">Debugging</a>
|
|
<a href="Environment.html">Environment</a>
|
|
<a href="ddl.html">DDL</a>
|
|
-->
|
|
</td></tr>
|
|
</table>
|
|
</center>
|
|
|
|
|
|
<hr>
|
|
<address>
|
|
<a href="mailto:hdfhelp@ncsa.uiuc.edu">HDF Help Desk</a>
|
|
|
|
<br>
|
|
Last modified: 30 October 1998
|
|
|
|
</body>
|
|
</html>
|