Please, help us to better serve our user community by answering the following short survey: https://www.hdfgroup.org/website-survey/
HDF5 1.14.5
API Reference
Loading...
Searching...
No Matches
HDF5 Lite APIs (H5LT,H5LD)

Detailed Description

Functions used to simplify creating and manipulating datasets, attributes and other features (H5LT, H5LD)

The HDF5 Lite API consists of higher-level functions which do more operations per call than the basic HDF5 interface. The purpose is to wrap intuitive functions around certain sets of features in the existing APIs. It has the following sets of functions listed below.

Note
Programming hints:
To use any of these functions or subroutines, you must first include the relevant include file (C) or module (Fortran) in your application.
The following line includes the HDF5 Lite package, H5LT, in C applications:
#include "hdf5_hl.h"
This line includes the H5LT module in Fortran applications:
use h5lt
This module contains Fortran interfaces for H5LT.
Definition H5LTff.F90:38

Namespaces

module  h5lt
 This module contains Fortran interfaces for H5LT.
 

Functions

H5_HLDLL herr_t H5LDget_dset_dims (hid_t did, hsize_t *cur_dims)
 Retrieves the current dimension sizes of a dataset.
 
H5_HLDLL size_t H5LDget_dset_type_size (hid_t did, const char *fields)
 Returns the size in bytes of the dataset's datatype.
 
H5_HLDLL herr_t H5LDget_dset_elmts (hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf)
 Retrieves selected data from the dataset.
 
H5_HLDLL herr_t H5LTmake_dataset (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t type_id, const void *buffer)
 Creates and writes a dataset of a type type_id.
 
H5_HLDLL herr_t H5LTmake_dataset_char (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const char *buffer)
 Creates and writes a dataset.
 
H5_HLDLL herr_t H5LTmake_dataset_short (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const short *buffer)
 Creates and writes a dataset.
 
H5_HLDLL herr_t H5LTmake_dataset_int (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const int *buffer)
 Creates and writes a dataset.
 
H5_HLDLL herr_t H5LTmake_dataset_long (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const long *buffer)
 Creates and writes a dataset.
 
H5_HLDLL herr_t H5LTmake_dataset_float (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const float *buffer)
 Creates and writes a dataset.
 
H5_HLDLL herr_t H5LTmake_dataset_double (hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const double *buffer)
 Creates and writes a dataset.
 
H5_HLDLL herr_t H5LTmake_dataset_string (hid_t loc_id, const char *dset_name, const char *buf)
 Creates and writes a dataset with string datatype.
 
H5_HLDLL herr_t H5LTread_dataset (hid_t loc_id, const char *dset_name, hid_t type_id, void *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_char (hid_t loc_id, const char *dset_name, char *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_short (hid_t loc_id, const char *dset_name, short *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_int (hid_t loc_id, const char *dset_name, int *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_long (hid_t loc_id, const char *dset_name, long *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_float (hid_t loc_id, const char *dset_name, float *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_double (hid_t loc_id, const char *dset_name, double *buffer)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTread_dataset_string (hid_t loc_id, const char *dset_name, char *buf)
 Reads a dataset from disk.
 
H5_HLDLL herr_t H5LTget_dataset_ndims (hid_t loc_id, const char *dset_name, int *rank)
 Gets the dimensionality of a dataset.
 
H5_HLDLL herr_t H5LTget_dataset_info (hid_t loc_id, const char *dset_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size)
 Retrieves information about a dataset.
 
H5_HLDLL herr_t H5LTfind_dataset (hid_t loc_id, const char *name)
 Determines whether a dataset exists.
 
H5_HLDLL herr_t H5LTset_attribute_string (hid_t loc_id, const char *obj_name, const char *attr_name, const char *attr_data)
 Creates and writes a string attribute.
 
H5_HLDLL herr_t H5LTset_attribute_char (hid_t loc_id, const char *obj_name, const char *attr_name, const char *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_uchar (hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned char *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_short (hid_t loc_id, const char *obj_name, const char *attr_name, const short *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_ushort (hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned short *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_int (hid_t loc_id, const char *obj_name, const char *attr_name, const int *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_uint (hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_long (hid_t loc_id, const char *obj_name, const char *attr_name, const long *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_long_long (hid_t loc_id, const char *obj_name, const char *attr_name, const long long *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_ulong (hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_ullong (hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long long *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_float (hid_t loc_id, const char *obj_name, const char *attr_name, const float *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTset_attribute_double (hid_t loc_id, const char *obj_name, const char *attr_name, const double *buffer, size_t size)
 Creates and writes an attribute.
 
H5_HLDLL herr_t H5LTget_attribute (hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_string (hid_t loc_id, const char *obj_name, const char *attr_name, char *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_char (hid_t loc_id, const char *obj_name, const char *attr_name, char *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_uchar (hid_t loc_id, const char *obj_name, const char *attr_name, unsigned char *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_short (hid_t loc_id, const char *obj_name, const char *attr_name, short *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_ushort (hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_int (hid_t loc_id, const char *obj_name, const char *attr_name, int *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_uint (hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_long (hid_t loc_id, const char *obj_name, const char *attr_name, long *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_long_long (hid_t loc_id, const char *obj_name, const char *attr_name, long long *data)
 Reads a long long attribute.
 
H5_HLDLL herr_t H5LTget_attribute_ulong (hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_ullong (hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long long *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_float (hid_t loc_id, const char *obj_name, const char *attr_name, float *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_double (hid_t loc_id, const char *obj_name, const char *attr_name, double *data)
 Reads an attribute from disk.
 
H5_HLDLL herr_t H5LTget_attribute_ndims (hid_t loc_id, const char *obj_name, const char *attr_name, int *rank)
 Gets the dimensionality of an attribute.
 
H5_HLDLL herr_t H5LTget_attribute_info (hid_t loc_id, const char *obj_name, const char *attr_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size)
 Gets information about an attribute.
 
H5_HLDLL hid_t H5LTtext_to_dtype (const char *text, H5LT_lang_t lang_type)
 Creates an HDF5 datatype given a text description.
 
H5_HLDLL herr_t H5LTdtype_to_text (hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len)
 Creates a text description of an HDF5 datatype.
 
H5_HLDLL herr_t H5LTfind_attribute (hid_t loc_id, const char *name)
 Determines whether an attribute exists.
 
H5_HLDLL htri_t H5LTpath_valid (hid_t loc_id, const char *path, hbool_t check_object_valid)
 Determines whether an HDF5 path is valid and, optionally, whether the path resolves to an HDF5 object.
 
H5_HLDLL hid_t H5LTopen_file_image (void *buf_ptr, size_t buf_size, unsigned flags)
 Opens an HDF5 file image in memory.
 

Function Documentation

◆ H5LDget_dset_dims()

H5_HLDLL herr_t H5LDget_dset_dims ( hid_t  did,
hsize_t cur_dims 
)

Retrieves the current dimension sizes of a dataset.


Parameters
[in]didThe dataset identifier
[out]cur_dimsThe current dimension sizes of the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LDget_dset_dims() retrieves the current dimension sizes for the dataset did through the parameter cur_dims. It will return failure if cur_dims is NULL.

Note
See Also:
Dataset Watch functions (used with h5watch):
Example:
See the example code in H5LDget_dset_elmts() for usage of this routine.
Since
1.10.0

◆ H5LDget_dset_elmts()

H5_HLDLL herr_t H5LDget_dset_elmts ( hid_t  did,
const hsize_t prev_dims,
const hsize_t cur_dims,
const char *  fields,
void *  buf 
)

Retrieves selected data from the dataset.


Parameters
[in]didThe dataset identifier
[in]prev_dimsThe previous dimension size of the dataset
[in]cur_dimsThe current dimension sizes of the dataset
[in]fieldsA string containing a comma-separated list of fields for a compound datatype
[out]bufBuffer for storing data retrieved from the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LDget_dset_dims() retrieves selected data of the dataset did and stores the data in the parameter buf. The difference between the parameters prev_dims and cur_dims indicates the dimension sizes of the data to be selected from the dataset. Note that cur_dims must have at least one dimension whose size is greater than the corresponding dimension in prev_dims. Users can determine the size of buf by multiplying the datatype size of the dataset by the number of selected elements.

If the parameter fields is NULL, this routine returns data for the selected elements of the dataset. If fields is not NULL and the dataset has a compound datatype, fields is a string containing a comma-separated list of fields. Each name in fields specifies a field in the compound datatype, and this routine returns data of the selected fields for the dataset's selected elements. Note that ’,’ is the separator for the fields of a compound datatype while ’.’ is the separator for a nested field. Use backslash to escape characters in field names that conflict with these two separators.

Note
See Also:
Dataset Watch functions (used with h5watch):
Examples:

For the first example, DSET1 is a two-dimensional chunked dataset with atomic type defined below:

DATASET "DSET1" {DATATYPE H5T_STD_I32LE DATASPACE SIMPLE{(4, 13) / (60, 100)} : : }
#define H5T_STD_I32LE
Definition H5Tpublic.h:323

The following coding sample illustrates the reading of data elements appended to the dataset DSET1:

/* open the HDF5 file */
/* open the dataset */
did = H5Dopen2(fid, "DSET1", H5P_DEFAULT);
:
:
/* define hsize_t dims[2]; */
/* define hsize_t new_dims[2]; */
/* get the dataset's current dimension sizes */
H5LDget_dset_dims(did, dims);
/* extend the dataset by 2 */
new_dims[0] = dims[0] + 2;
new_dims[1] = dims[1] + 2;
H5Dset_extent(did, new_dims)
/* write data to the extended dataset */
: :
/* get the size of the dataset's data type */
type_size = H5LDget_dset_type_size(did, NULL);
:
:
/* allocate buffer for storing selected data elements from the dataset */
/* calculate # of selected elements from dims & new_dims */
/* buffer size = type_size * number of selected elements */
:
:
/* read the selected elements from the dataset into buf */
H5LDget_dset_elmts(did, dims, new_dims, NULL, buf);
:
:
H5Dclose(did);
H5Fclose(fid);
#define H5F_ACC_RDWR
Definition H5Fpublic.h:49
#define H5P_DEFAULT
Definition H5Ppublic.h:228
hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id)
Opens an existing dataset.
herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[])
Changes the sizes of a dataset's dimensions.
herr_t H5Dclose(hid_t dset_id)
Closes the specified dataset.
hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
Opens an existing HDF5 file.
herr_t H5Fclose(hid_t file_id)
Terminates access to an HDF5 file.
H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf)
Retrieves selected data from the dataset.
H5_HLDLL size_t H5LDget_dset_type_size(hid_t did, const char *fields)
Returns the size in bytes of the dataset's datatype.
H5_HLDLL herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims)
Retrieves the current dimension sizes of a dataset.

The output buffer will contain data elements selected from DSET1 as follows:

data for elements (0, 13), (0, 14)
data for elements (1, 13), (1, 14)
data for elements (2, 13), (2, 14)
data for elements (3, 13), (3, 14)
data for elements (4, 0), (4, 1), (4, 2)......................(4, 13), (4, 14)
data for elements (5, 0), (5, 1), (5, 2)......................(5, 13), (5, 14)

For the second example, DSET2 is a one-dimensional chunked dataset with compound type defined below:

DATASET "DSET2" {
DATATYPE H5T_COMPOUND {
{
}
"c";
{
{
}
"c";
}
"s2";
}
DATASPACE SIMPLE
{
(5) / (5)
}
::
}
@ H5T_ARRAY
Definition H5Tpublic.h:42
@ H5T_COMPOUND
Definition H5Tpublic.h:38

The following coding sample illustrates the reading of data elements appended to the dataset DSET2 with compound datatype. This example selects only 2 fields: the fourth field d and a subfield of the sixth field s2.c:

/* open the HDF5 file */
/* open the dataset */
did = H5Dopen2(fid, "DSET2", H5P_DEFAULT);
/* define hsize_t dims[1]; */
/* define hsize_t new_dims[1]; */
:
:
/* get the dataset's current dimension size */
H5LDget_dset_dims(did, dims);
/* extend the dataset by 2 */
new_dims[0] = dims[0] + 2;
H5Dset_extent(did, new_dims);
:
:
/* write data to the extended part of the dataset */
:
:
/* #define fields "d,s2.c" */
/* get the size of the dataset's data type for the selected fields */
type_size = H5LDget_dset_type_size(did, fields);
:
:
/* allocate buffer for storing selected data elements from the dataset */
/* calculate # of selected elements from dims & new_dims */
/* buffer size = type_size * number of selected elements */
:
:
/* read the selected elements from the dataset into buf */
H5LD_get_dset_elmts(did, dims, new_dims, fields, buf);
:
:
H5Dclose(did);
H5Fclose(fid);

The output buffer will contain data for d and s2.c selected from DSET2 as follows:

Data for element (5): integer value for "d", 4 integer values for array "s2.c"
Data for element (6): integer value for "d", 4 integer values for array "s2.c"
Since
1.10.0

◆ H5LDget_dset_type_size()

H5_HLDLL size_t H5LDget_dset_type_size ( hid_t  did,
const char *  fields 
)

Returns the size in bytes of the dataset's datatype.


Parameters
[in]didThe dataset identifier
[in]fieldsThe pointer to a comma-separated list of fields for a compound datatype
Returns
If successful, returns the size in bytes of the dataset's datatype. Otherwise, returns 0.

H5LDget_dset_type_size() allows the user to find out the datatype size for the dataset associated with did. If the parameter fields is NULL, this routine just returns the size of the dataset's datatype. If the dataset has a compound datatype and fields is non-NULL, this routine returns the size of the datatype(s) for the selected fields specified in fields. Note that ’,’ is the separator for the fields of a compound datatype while ’.’ (dot) is the separator for a nested field. Use a backslash ( \ ) to escape characters in field names that conflict with these two separators.

Note
See Also:
Dataset Watch functions (used with h5watch):
Example:
See the example code in H5LDget_dset_elmts() for usage of this routine.
Since
1.10.0

◆ H5LTdtype_to_text()

H5_HLDLL herr_t H5LTdtype_to_text ( hid_t  dtype,
char *  str,
H5LT_lang_t  lang_type,
size_t *  len 
)

Creates a text description of an HDF5 datatype.


Parameters
[in]dtypeIdentifier of the datatype to be converted
[out]strBuffer for the text description of the datatype
[in]lang_typeThe language used to describe the datatype. The currently supported language is H5LT_DDL.
[out]lenThe size of buffer needed to store the text description
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

Given an HDF5 datatype identifier, this function creates a description of this datatype in lang_type language format. A preliminary H5LTdtype_to_text() call can be made to determine the size of the buffer needed with a NULL passed in for str. This value is returned as len. That value can then be assigned to len for a second H5Ttype_to_text() call, which will retrieve the actual text description for the datatype.

If len is not big enough for the description, the text description will be truncated to fit in the buffer.

Currently only DDL (H5LT_DDL) is supported for lang_type. The complete DDL definition of HDF5 data types can be found in the specifications chapter of the HDF5 User's Guide.

Example
An example of DDL definition of enum type is shown as follows.
“H5T_ENUM
{
“Bob” 0;
“Elena” 1;
“Quincey” 2;
“Frank” 3;
}
#define H5T_NATIVE_INT
Definition H5Tpublic.h:780

◆ H5LTfind_attribute()

H5_HLDLL herr_t H5LTfind_attribute ( hid_t  loc_id,
const char *  name 
)

Determines whether an attribute exists.


Parameters
[in]loc_idIdentifier of the object to which the attribute is expected to be attached
[in]nameAttribute name
Returns
Returns zero (false), a positive (true) or a negative (failure) value.

H5LTfind_attribute() determines whether an attribute named name exists attached to the object specified by loc_id.

loc_id must be an object identifier and name must specify an attribute that is expected to be attached to that object.

◆ H5LTfind_dataset()

H5_HLDLL herr_t H5LTfind_dataset ( hid_t  loc_id,
const char *  name 
)

Determines whether a dataset exists.


Parameters
[in]loc_idIdentifier of the group containing the dataset
[in]nameDataset name
Returns
Returns zero (false), a positive (true) or a negative (failure) value.

H5LTfind_dataset() determines whether a dataset named name exists in the group specified by loc_id.

loc_id must be a group identifier and name must specify a dataset that is a member of that group.

◆ H5LTget_attribute()

H5_HLDLL herr_t H5LTget_attribute ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
hid_t  mem_type_id,
void *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[in]mem_type_idIdentifier of the memory datatype
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute() reads an attribute named attr_name with the memory type mem_type_id.

◆ H5LTget_attribute_char()

H5_HLDLL herr_t H5LTget_attribute_char ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
char *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_char() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The datatype of the attribute is H5T_NATIVE_CHAR.

◆ H5LTget_attribute_double()

H5_HLDLL herr_t H5LTget_attribute_double ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
double *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_double() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_DOUBLE.

◆ H5LTget_attribute_float()

H5_HLDLL herr_t H5LTget_attribute_float ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
float *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_float() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_FLOAT.

◆ H5LTget_attribute_info()

H5_HLDLL herr_t H5LTget_attribute_info ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
hsize_t dims,
H5T_class_t type_class,
size_t *  type_size 
)

Gets information about an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dimsThe dimensions of the attribute
[out]type_classThe class identifier. H5T_class_t is defined in H5Tpublic.h. For a list of valid class types see: H5Tget_class().
[out]type_sizeThe size of the datatype in bytes
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_info() gets information about an attribute named attr_name attached to the object specified by the name obj_name.

Example
H5T_class_t type_class;
size_t type_size;
hsize_t dims[0];
... status = H5LTget_attribute_info(file_id, "/", STRNAME, dims, &type_class, &type_size);
if (type_class == H5T_STRING) {
printf("Attribute is a string.\n");
printf("String size: %i\n", type_size);
H5T_class_t
Definition H5Tpublic.h:30
@ H5T_STRING
Definition H5Tpublic.h:35
uint64_t hsize_t
Definition H5public.h:301
H5_HLDLL herr_t H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const char *attr_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size)
Gets information about an attribute.

◆ H5LTget_attribute_int()

H5_HLDLL herr_t H5LTget_attribute_int ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
int *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_int() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_INT.

◆ H5LTget_attribute_long()

H5_HLDLL herr_t H5LTget_attribute_long ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
long *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_long() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_LONG.

◆ H5LTget_attribute_long_long()

H5_HLDLL herr_t H5LTget_attribute_long_long ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
long long *  data 
)

Reads a long long attribute.


Parameters
[in]loc_idLocation of the object to which the attribute is attached
[in]obj_nameThat object's name
[in]attr_nameAttribute name
[out]dataAttribute value
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_long_long() reads the attribute specified by loc_id and obj_name.

◆ H5LTget_attribute_ndims()

H5_HLDLL herr_t H5LTget_attribute_ndims ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
int *  rank 
)

Gets the dimensionality of an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]rankThe dimensionality of the attribute
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_ndims() gets the dimensionality of an attribute named attr_name that is attached to the object specified by the name obj_name.

◆ H5LTget_attribute_short()

H5_HLDLL herr_t H5LTget_attribute_short ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
short *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_short() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_SHORT

◆ H5LTget_attribute_string()

H5_HLDLL herr_t H5LTget_attribute_string ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
char *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_string() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The datatype is a string.

Version
1.8.9 The content of the buffer returned by the Fortran subroutine has changed in this release:
If the returned buffer requires padding, h5ltget_attribute_string_f() now employs space padding; this buffer was previously returned with a C NULL terminator.

◆ H5LTget_attribute_uchar()

H5_HLDLL herr_t H5LTget_attribute_uchar ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
unsigned char *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_uchar() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_UCHAR

◆ H5LTget_attribute_uint()

H5_HLDLL herr_t H5LTget_attribute_uint ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
unsigned int *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_uint() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_INT.

◆ H5LTget_attribute_ullong()

H5_HLDLL herr_t H5LTget_attribute_ullong ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
unsigned long long *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_ullong() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_ULLONG.

◆ H5LTget_attribute_ulong()

H5_HLDLL herr_t H5LTget_attribute_ulong ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
unsigned long *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_ulong() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_ULONG.

◆ H5LTget_attribute_ushort()

H5_HLDLL herr_t H5LTget_attribute_ushort ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
unsigned short *  data 
)

Reads an attribute from disk.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to read the attribute from
[in]obj_nameThe name of the object that the attribute is attached to
[in]attr_nameThe attribute name
[out]dataBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_attribute_ushort() reads an attribute named attr_name that is attached to the object specified by the name obj_name. The HDF5 datatype of the attribute is H5T_NATIVE_USHORT.

◆ H5LTget_dataset_info()

H5_HLDLL herr_t H5LTget_dataset_info ( hid_t  loc_id,
const char *  dset_name,
hsize_t dims,
H5T_class_t type_class,
size_t *  type_size 
)

Retrieves information about a dataset.


Parameters
[in]loc_idIdentifier of the object to locate the dataset within
[in]dset_nameThe dataset name
[out]dimsThe dimensions of the dataset
[out]type_classThe class identifier. H5T_class_t is defined in H5Tpublic.h. See H5Tget_class() for a list of class types.
[out]type_sizeThe size of the datatype in bytes
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_dataset_info() retrieves information about a dataset named dset_name attached to the object loc_id.

◆ H5LTget_dataset_ndims()

H5_HLDLL herr_t H5LTget_dataset_ndims ( hid_t  loc_id,
const char *  dset_name,
int *  rank 
)

Gets the dimensionality of a dataset.


Parameters
[in]loc_idIdentifier of the object to locate the dataset within
[in]dset_nameThe dataset name
[out]rankThe dimensionality of the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTget_dataset_ndims() gets the dimensionality of a dataset named dset_name exists attached to the object loc_id.

◆ H5LTmake_dataset()

H5_HLDLL herr_t H5LTmake_dataset ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
hid_t  type_id,
const void *  buffer 
)

Creates and writes a dataset of a type type_id.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]type_idIdentifier of the datatype to use when creating the dataset
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The parameter type_id can be any valid HDF5 Prdefined Native Datatypes; For example, setting type_id to H5T_NATIVE_INT will result in a dataset of signed integer datatype.

Version
1.10.0 Fortran 2003 subroutine added to accept a C address of the data buffer.
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTmake_dataset_char()

H5_HLDLL herr_t H5LTmake_dataset_char ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
const char *  buffer 
)

Creates and writes a dataset.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_char() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be character, H5T_NATIVE_CHAR.

◆ H5LTmake_dataset_double()

H5_HLDLL herr_t H5LTmake_dataset_double ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
const double *  buffer 
)

Creates and writes a dataset.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_double() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be native floating-point double, H5T_NATIVE_DOUBLE.

Version
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTmake_dataset_float()

H5_HLDLL herr_t H5LTmake_dataset_float ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
const float *  buffer 
)

Creates and writes a dataset.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_float() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be native floating point, H5T_NATIVE_FLOAT.

Version
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTmake_dataset_int()

H5_HLDLL herr_t H5LTmake_dataset_int ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
const int *  buffer 
)

Creates and writes a dataset.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_int() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be native signed integer, H5T_NATIVE_INT.

Version
Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTmake_dataset_long()

H5_HLDLL herr_t H5LTmake_dataset_long ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
const long *  buffer 
)

Creates and writes a dataset.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_long() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be long signed integer, H5T_NATIVE_LONG.

◆ H5LTmake_dataset_short()

H5_HLDLL herr_t H5LTmake_dataset_short ( hid_t  loc_id,
const char *  dset_name,
int  rank,
const hsize_t dims,
const short *  buffer 
)

Creates and writes a dataset.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe Name of the dataset to create
[in]rankNumber of dimensions of dataspace
[in]dimsAn array of the size of each dimension
[in]bufferBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_short() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be short signed integer, H5T_NATIVE_SHORT.

◆ H5LTmake_dataset_string()

H5_HLDLL herr_t H5LTmake_dataset_string ( hid_t  loc_id,
const char *  dset_name,
const char *  buf 
)

Creates and writes a dataset with string datatype.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to create
[in]bufBuffer with data to be written to the dataset
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTmake_dataset_string() creates and writes a dataset named dset_name attached to the object specified by the identifier loc_id.

The dataset's datatype will be C string, H5T_C_S1.

◆ H5LTopen_file_image()

H5_HLDLL hid_t H5LTopen_file_image ( void *  buf_ptr,
size_t  buf_size,
unsigned  flags 
)

Opens an HDF5 file image in memory.


Parameters
[in]buf_ptrA pointer to the supplied initial image
[in]buf_sizeSize of the supplied buffer
[in]flagsFlags specifying whether to open the image read-only or read/write, whether HDF5 is to take control of the buffer, and instruction regarding releasing the buffer.
Returns
Returns a file identifier if successful; otherwise returns a negative value.
Warning
Failure Modes:
H5LTopen_file_image() will fail if either buf_ptr is NULL or buf_size equals 0 (zero).

H5LTopen_file_image() opens the HDF5 file image that is located in system memory at the address indicated by buf_ptr of size buf_size. H5LTopen_file_image() opens a file image with the Core driver, H5FD_CORE.

A value of NULL for buf_ptr is invalid and will cause the function to fail.

A value of 0 for buf_size is invalid and will cause the function to fail.

The flags passed in flags specify whether to open the image read-only or read/write, whether HDF5 is to take control of the buffer, and instruction regarding releasing the buffer. Valid values are:

  • H5LT_FILE_IMAGE_OPEN_RW
    • Specifies opening the file image in read/write mode.
    • Default without this flag: File image will be opened read-only.
  • H5LT_FILE_IMAGE_DONT_COPY
    • Specifies to not copy the provided file image buffer; the buffer will be used directly. HDF5 will release the file image when finished.
    • Default without this flag: Copy the file image buffer and open the copied file image.
  • H5LT_FILE_IMAGE_DONT_RELEASE
    • Specifies that HDF5 is not to release the buffer when the file opened with H5LTopen_file_image() is closed; releasing the buffer will be left to the application.
    • Default without this flag: HDF5 will automatically release the file image buffer after the file image is closed. This flag is valid only when used with H5LT_FILE_IMAGE_DONT_COPY.
Note
Motivation:
H5LTopen_file_image() and other elements of HDF5 are used to load an image of an HDF5 file into system memory and open that image as a regular HDF5 file. An application can then use the file without the overhead of disk I/O.
Recommended Reading:
This function is part of the file image operations feature set. It is highly recommended to study the guide HDF5 File Image Operations before using this feature set.
See the “See Also” section below for links to other elements of HDF5 file image operations.
Todo:
There is no "See Also" section???
Since
1.8.9

◆ H5LTpath_valid()

H5_HLDLL htri_t H5LTpath_valid ( hid_t  loc_id,
const char *  path,
hbool_t  check_object_valid 
)

Determines whether an HDF5 path is valid and, optionally, whether the path resolves to an HDF5 object.


Parameters
[in]loc_idIdentifier of an object in the file
[in]pathThe path to the object to check; links in path may be of any type.
[in]check_object_validIf TRUE, determine whether the final component of path resolves to an object; if FALSE, do not check.
Returns
Upon success:
If check_object_valid is set to FALSE:
Returns TRUE if the path is valid; otherwise returns FALSE.
If check_object_valid is set to TRUE:
Returns TRUE if the path is valid and resolves to an HDF5 object; otherwise returns FALSE.
Upon error, returns a negative value.

H5LTpath_valid() checks the validity of path relative to the identifier of an object, loc_id. Optionally, check_object_valid can be set to determine whether the final component of path resolves to an HDF5 object; if not, the final component is a dangling link.

The meaning of the function's return value depends on the value of check_object_valid:

If check_object_valid is set to FALSE, H5LTpath_valid() will check all links in path to verify that they exist. If all the links in path exist, the function will return TRUE; otherwise the function will return FALSE.

If check_object_valid is set to TRUE, H5LTpath_valid() will first check the links in path, as described above. If all the links exist, check_object_valid will then determine whether the final component of path resolves to an actual HDF5 object. H5LTpath_valid() will return TRUE if all the links in path exist and the final component resolves to an actual object; otherwise, it will return FALSE.

path can be any one of the following:

  • An absolute path, which starts with a slash (/) indicating the file's root group, followed by the members
  • A relative path with respect to loc_id
  • A dot (.), if loc_id is the object identifier for the object itself.

If path is an absolute path, then loc_id can be an identifier for any object in the file as it is used only to identify the file. If path is a relative path, then loc_id must be a file or a group identifier.

Note
Note on Behavior Change: The behavior of H5LTpath_valid() was changed in the 1.10.0 release in the case where the root group, “/”, is the value of path. This change is described below:
  • Let loc_id denote a valid HDF5 file identifier, and let check_object_valid be set to true or false. A call to H5LTpath_valid() with arguments loc_id, “/”, and check_object_valid returns a positive value; in other words, H5LTpath_valid(loc_id, "/", check_object_valid) returns a positive value. In HDF5 version 1.8.16, this function returns 0.
  • Let ‘root’ denote a valid HDF5 group identifier that refers to the root group of an HDF5 file, and let check_object_valid be set to true or false. A call to H5LTpath_valid() with arguments ‘root’, “/”, and check_object_valid returns a positive value; in other words, H5LTpath_valid(root, "/", check_object_valid) returns a positive value. In HDF5 version 1.8.16, this function returns 0.
Version
1.10.0 Function behavior changed in this release. See the “Note on Behavior Change” section above.

◆ H5LTread_dataset()

H5_HLDLL herr_t H5LTread_dataset ( hid_t  loc_id,
const char *  dset_name,
hid_t  type_id,
void *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[in]type_idIdentifier of the datatype to use when reading the dataset
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset() reads a dataset named dset_name attached to the object specified by the identifier loc_id.

Version
1.10.0 Fortran 2003 subroutine added to accept a C address of the data buffer.
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTread_dataset_char()

H5_HLDLL herr_t H5LTread_dataset_char ( hid_t  loc_id,
const char *  dset_name,
char *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_char() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_NATIVE_CHAR.

◆ H5LTread_dataset_double()

H5_HLDLL herr_t H5LTread_dataset_double ( hid_t  loc_id,
const char *  dset_name,
double *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_double() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_NATIVE_DOUBLE.

Version
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTread_dataset_float()

H5_HLDLL herr_t H5LTread_dataset_float ( hid_t  loc_id,
const char *  dset_name,
float *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_float() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_NATIVE_FLOAT.

Version
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTread_dataset_int()

H5_HLDLL herr_t H5LTread_dataset_int ( hid_t  loc_id,
const char *  dset_name,
int *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_int() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_NATIVE_INT.

Version
1.8.7 Fortran subroutine modified in this release to accommodate arrays with more than three dimensions.

◆ H5LTread_dataset_long()

H5_HLDLL herr_t H5LTread_dataset_long ( hid_t  loc_id,
const char *  dset_name,
long *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_long() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_NATIVE_LONG.

◆ H5LTread_dataset_short()

H5_HLDLL herr_t H5LTread_dataset_short ( hid_t  loc_id,
const char *  dset_name,
short *  buffer 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufferBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_short() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_NATIVE_SHORT.

◆ H5LTread_dataset_string()

H5_HLDLL herr_t H5LTread_dataset_string ( hid_t  loc_id,
const char *  dset_name,
char *  buf 
)

Reads a dataset from disk.


Parameters
[in]loc_idLocation identifier. The identifier may be that of a file or group.
[in]dset_nameThe name of the dataset to read
[out]bufBuffer with data
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTread_dataset_string() reads a dataset named dset_name attached to the object specified by the identifier loc_id. The HDF5 datatype is H5T_C_S1.

◆ H5LTset_attribute_char()

H5_HLDLL herr_t H5LTset_attribute_char ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const char *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_char() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_CHAR.

◆ H5LTset_attribute_double()

H5_HLDLL herr_t H5LTset_attribute_double ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const double *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_double() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_DOUBLE.

◆ H5LTset_attribute_float()

H5_HLDLL herr_t H5LTset_attribute_float ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const float *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_float() creates and writes a numerical floating point attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_FLOAT.

◆ H5LTset_attribute_int()

H5_HLDLL herr_t H5LTset_attribute_int ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const int *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_int() creates and writes a numerical integer attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_INT.

◆ H5LTset_attribute_long()

H5_HLDLL herr_t H5LTset_attribute_long ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const long *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_long() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_LONG.

◆ H5LTset_attribute_long_long()

H5_HLDLL herr_t H5LTset_attribute_long_long ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const long long *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idLocation of the object to which the attribute is to be attached
[in]obj_nameThat object's name
[in]attr_nameAttribute name
[in]bufferAttribute value
[in]sizeAttribute size
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_long_long() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name.

The attribute has a dimensionality of 1 and its HDF5 datatype is H5T_NATIVE_LLONG.

◆ H5LTset_attribute_short()

H5_HLDLL herr_t H5LTset_attribute_short ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const short *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_short() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_SHORT.

◆ H5LTset_attribute_string()

H5_HLDLL herr_t H5LTset_attribute_string ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const char *  attr_data 
)

Creates and writes a string attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]attr_dataBuffer with data to be written to the attribute
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_string() creates and writes a string attribute named attr_name and attaches it to the object specified by the name obj_name. If the attribute already exists, it is overwritten.

◆ H5LTset_attribute_uchar()

H5_HLDLL herr_t H5LTset_attribute_uchar ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const unsigned char *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_uchar() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_UCHAR.

◆ H5LTset_attribute_uint()

H5_HLDLL herr_t H5LTset_attribute_uint ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const unsigned int *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_uint() creates and writes a numerical integer attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_UINT.

◆ H5LTset_attribute_ullong()

H5_HLDLL herr_t H5LTset_attribute_ullong ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const unsigned long long *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idLocation of the object to which the attribute is to be attached
[in]obj_nameThat object's name
[in]attr_nameAttribute name
[in]bufferAttribute value
[in]sizeAttribute size
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_ullong() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name.

The attribute has a dimensionality of 1 and its HDF5 datatype is H5T_NATIVE_ULLONG.

◆ H5LTset_attribute_ulong()

H5_HLDLL herr_t H5LTset_attribute_ulong ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const unsigned long *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_ulong() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_ULONG.

◆ H5LTset_attribute_ushort()

H5_HLDLL herr_t H5LTset_attribute_ushort ( hid_t  loc_id,
const char *  obj_name,
const char *  attr_name,
const unsigned short *  buffer,
size_t  size 
)

Creates and writes an attribute.


Parameters
[in]loc_idIdentifier of the object (dataset or group) to create the attribute within
[in]obj_nameThe name of the object to attach the attribute
[in]attr_nameThe attribute name
[in]bufferBuffer with data to be written to the attribute
[in]sizeThe size of the 1D array (one in the case of a scalar attribute). This value is used by H5Screate_simple() to create the dataspace.
Returns
Returns a non-negative value if successful; otherwise, returns a negative value.

H5LTset_attribute_ushort() creates and writes a numerical attribute named attr_name and attaches it to the object specified by the name obj_name. The attribute has a dimensionality of 1. The HDF5 datatype of the attribute is H5T_NATIVE_USHORT.

◆ H5LTtext_to_dtype()

H5_HLDLL hid_t H5LTtext_to_dtype ( const char *  text,
H5LT_lang_t  lang_type 
)

Creates an HDF5 datatype given a text description.


Parameters
[in]textA character string containing a DDL definition of the datatype to be created
[in]lang_typeThe language used to describe the datatype. The only currently supported language is H5LT_DDL.
Returns
Returns the datatype identifier(non-negative) if successful; otherwise returns a negative value.

Given a text description of a datatype, this function creates an HDF5 datatype and returns the datatype identifier. The text description of the datatype has to comply with the lang_type definition of HDF5 datatypes. Currently, only the DDL(H5LT_DDL) is supported. The complete DDL definition of HDF5 datatypes can be found in the specifications chapter of the HDF5 User's Guide.

Example
An example of DDL definition of enum type is shown as follows.
“H5T_ENUM
{
“Bob” 0;
“Elena” 1;
“Quincey” 2;
“Frank” 3;
}