Please, help us to better know about our user community by answering the following short survey: https://www.hdfgroup.org/website-survey/
HDF5  1.10.9-1
C-API Reference
Enumeration Datatypes

Detailed Description

Functions

hid_t H5Tenum_create (hid_t base_id)
 Creates a new enumeration datatype. More...
 
herr_t H5Tenum_insert (hid_t type, const char *name, const void *value)
 Inserts a new enumeration datatype member. More...
 
herr_t H5Tenum_nameof (hid_t type, const void *value, char *name, size_t size)
 Returns the symbol name corresponding to a specified member of an enumeration datatype. More...
 
herr_t H5Tenum_valueof (hid_t type, const char *name, void *value)
 Returns the value corresponding to a specified member of an enumeration datatype. More...
 
int H5Tget_nmembers (hid_t type_id)
 Retrieves the number of elements in a compound or enumeration datatype. More...
 
char * H5Tget_member_name (hid_t type_id, unsigned membno)
 Retrieves the name of a compound or enumeration datatype member. More...
 
int H5Tget_member_index (hid_t type_id, const char *name)
 Retrieves the index of a compound or enumeration datatype member. More...
 
herr_t H5Tget_member_value (hid_t type_id, unsigned membno, void *value)
 Returns the value of an enumeration datatype member. More...
 

Function Documentation

◆ H5Tenum_create()

hid_t H5Tenum_create ( hid_t  base_id)

Creates a new enumeration datatype.

Parameters
[in]base_idDatatype identifier for the base datatype. Must be an integer datatype
Returns
Returns a enumeration datatype identifier if successful; otherwise returns H5I_INVALID_HID.

H5Tenum_create() creates a new enumeration datatype based on the specified base datatype, dtype_id, which must be an integer datatype.

If a particular architecture datatype is required, a little endian or big endian datatype for example, use a native datatype as the base datatype and use H5Tconvert() on values as they are read from or written to a dataset.

Since
1.2.0

◆ H5Tenum_insert()

herr_t H5Tenum_insert ( hid_t  type,
const char *  name,
const void *  value 
)

Inserts a new enumeration datatype member.

Parameters
[in]typeDatatype identifier
[in]nameName of the new member
[in]valuePointer to the value of the new member
Returns
Returns a non-negative value if successful; otherwise returns a negative value.

H5Tenum_insert() inserts a new enumeration datatype member into an enumeration datatype.

type_id is the datatype identifier for the enumeration datatype, name is the name of the new member, and value points to the value of the new member.

name and value must both be unique within dtype_id.

value points to data which must be of the integer base datatype used when the enumeration datatype was created. If a particular architecture datatype is required, a little endian or big endian datatype for example, use a native datatype as the base datatype and use H5Tconvert() on values as they are read from or written to a dataset.

Since
1.2.0

◆ H5Tenum_nameof()

herr_t H5Tenum_nameof ( hid_t  type,
const void *  value,
char *  name,
size_t  size 
)

Returns the symbol name corresponding to a specified member of an enumeration datatype.

Parameters
[in]typeDatatype identifier
[in]valueValue of the enumeration datatype
[out]nameBuffer for output of the symbol name
[in]sizeAnticipated size of the symbol name, in bytes
Returns
Returns a non-negative value if successful. Otherwise returns a negative value

H5Tenum_nameof() finds the symbol name that corresponds to the specified value of the enumeration datatype type.

At most size characters of the symbol name are copied into the name buffer. If the entire symbol name and null terminator do not fit in the name buffer, then as many characters as possible are copied (not null terminated) and the function fails.

Since
1.2.0

◆ H5Tenum_valueof()

herr_t H5Tenum_valueof ( hid_t  type,
const char *  name,
void *  value 
)

Returns the value corresponding to a specified member of an enumeration datatype.

Parameters
[in]typeDatatype identifier
[in]nameSymbol name of the enumeration datatype
[out]valueBuffer for the value of the enumeration datatype
Returns
Returns a non-negative value if successful; otherwise returns a negative value.

H5Tenum_valueof() finds the value that corresponds to the specified name of the enumeration datatype dtype_id.

Values returned in value will be of the enumerated type’s base type, that is, the datatype used by H5Tenum_create() when the enumerated type was created.

The value buffer must be at least large enough to hold a value of that base type. If the size is unknown, you can determine it with H5Tget_size().

Since
1.2.0

◆ H5Tget_member_index()

int H5Tget_member_index ( hid_t  type_id,
const char *  name 
)

Retrieves the index of a compound or enumeration datatype member.

Parameters
[in]type_idDatatype identifier
[in]nameName of the field or member
Returns
Returns a non-negative value if successful; otherwise returns a negative value.

H5Tget_member_index() retrieves the index of a field of a compound datatype or an element of an enumeration datatype.

The name of the target field or element is specified by name.

Fields are stored in no particular order with index values of 0 through N-1, where N is the value returned by H5Tget_nmembers() .

Since
1.2.0

◆ H5Tget_member_name()

char* H5Tget_member_name ( hid_t  type_id,
unsigned  membno 
)

Retrieves the name of a compound or enumeration datatype member.

Parameters
[in]type_idDatatype identifier
[in]membnoZero-based index of the field or element
Returns
Returns a valid pointer to a string allocated with malloc() if successful; otherwise returns NULL.

H5Tget_member_name() retrieves the name of a field of a compound datatype or an element of an enumeration datatype.

The index of the target field or element is specified in member_no. Compound datatype fields and enumeration datatype elements are stored in no particular order with index values of 0 through N-1, where N is the value returned by H5Tget_nmembers().

The HDF5 library allocates a buffer to receive the name of the field. The caller must subsequently free the buffer with H5free_memory().

Since
1.2.0

◆ H5Tget_member_value()

herr_t H5Tget_member_value ( hid_t  type_id,
unsigned  membno,
void *  value 
)

Returns the value of an enumeration datatype member.

Parameters
[in]type_idDatatype identifier
[in]membnoNumber of the enumeration datatype member
[out]valueBuffer for the value of the enumeration datatype member
Returns
Returns a non-negative value if successful; otherwise returns a negative value.

H5Tget_member_value() returns the value of the enumeration datatype member member_no.

The member value is returned in a user-supplied buffer pointed to by value. Values returned in value will be of the enumerated type’s base type, that is, the datatype used by H5Tenum_create() when the enumerated type was created.

The value buffer must be at least large enough to hold a value of that base type. If the size is unknown, you can determine it with H5Tget_size().

Since
1.2.0

◆ H5Tget_nmembers()

int H5Tget_nmembers ( hid_t  type_id)

Retrieves the number of elements in a compound or enumeration datatype.

Parameters
[in]type_idDatatype identifier
Returns
Returns the number of elements if successful; otherwise returns a negative value.

H5Tget_nmembers() retrieves the number of fields in a compound datatype or the number of members of an enumeration datatype.

Since
1.2.0