HDF5 Extras  0.0.1
Convenience Functions for using HDF5 Better
Functions
H5ATTR.h File Reference
#include <string.h>
#include <stdlib.h>
#include <hdf5.h>
#include "bstrlib.h"
#include "gmalloc.h"
#include "globals.h"

Go to the source code of this file.

Functions

herr_t H5ATTRset_attribute (hid_t obj_id, const_bstring attr_name, hid_t type_id, size_t rank, hsize_t *dims, const_bstring attr_data)
 
herr_t H5ATTRset_attribute_string (hid_t obj_id, const_bstring attr_name, const_bstring attr_data, hsize_t attr_size, int cset)
 H5ATTRset_attribute_string sets the value of a string attribute. More...
 
herr_t H5ATTRget_attribute (hid_t loc_id, const_bstring attr_name, hid_t type_id, void *data)
 
hsize_t H5ATTRget_attribute_string (hid_t obj_id, const_bstring attr_name, bstring data, int *cset)
 H5ATTRget_attribute_string gets the value of a string attribute. More...
 
hsize_t H5ATTRget_attribute_vlen_string_array (hid_t obj_id, const char *attr_name, char ***data, int *cset)
 
herr_t H5ATTRfind_attribute (hid_t loc_id, const_bstring attr_name)
 
herr_t H5ATTRget_type_ndims (hid_t loc_id, const_bstring attr_name, hid_t *type_id, H5T_class_t *class_id, size_t *type_size, int *rank)
 
herr_t H5ATTRget_dims (hid_t loc_id, const_bstring attr_name, hsize_t *dims)
 

Function Documentation

hsize_t H5ATTRget_attribute_string ( hid_t  obj_id,
const_bstring  attr_name,
bstring  data,
int *  cset 
)

H5ATTRget_attribute_string gets the value of a string attribute.

See also
H5ATTRset_attribute_string()
Parameters
[in]obj_idThe id of the object to which the attribute should be attached. This is usually a group.
[in]attr_nameThe name of the attribute to be set.
[out]attr_dataThe value for the attribute, as a safe string.
[in]csetThe character set for the string. Valid values are: H5T_CSET_ASCII and H5T_CSET_UTF8.
Returns
On success it returns the length of the string, on failure it returns ERROR (-1).
Example
Read the value of the descriptor metadata item.
1 hid_t object_id;
2 bstring desc_value=bfromcstr("");
3 bstring descriptor = bfromcstr("descriptor");
4 if( H5ATTRget_attribute_string( object_id, descriptor,desc_value,
5  H5T_CSET_ASCII) == ERROR){
6  printf("ERROR getting the attribute value\n");
7 }
8 bdestroy(descriptor);
9 ...use the desc_value ....
10 bdestroy(desc_value);
Details
This function is normally called by GS_GetStringAttribute, which is the preferred function for getting values of string attributes.
herr_t H5ATTRset_attribute_string ( hid_t  obj_id,
const_bstring  attr_name,
const_bstring  attr_data,
hsize_t  attr_size,
int  cset 
)

H5ATTRset_attribute_string sets the value of a string attribute.

See also
H5ATTRget_attribute_string()
Parameters
[in]obj_idThe id of the object to which the attribute should be attached. This is usually a group.
[in]attr_nameThe name of the attribute to be set.
[in]attr_dataThe value for the attribute, as a safe string.
[in]attr_sizeThe number of characters in attr_data.
[in]csetThe character set for the string. Valid values are: H5T_CSET_ASCII and H5T_CSET_UTF8.
Returns
On success it returns SUCCESS (0), on failure it returns ERROR (-1).
Example
Set the value of descriptor to "Arizona".
1 hid_t object_id;
2 bstring descriptor=bfromcstr("descriptor");
3 bstring arizona = bfromcstr("Arizona");
4 if( H5ATTRset_attribute_string( object_id, descriptor,
5  arizona,7,H5T_CSET_ASCII)
6  == ERROR){
7  printf("ERROR setting the attribute value\n");
8 }
9 bdestroy(descriptor);
10 bdestroy(arizona);
Details
This function is normally called by GS_SetStringAttribute, which is the preferred function for setting values of string attributes.