- more generic private functions added to attrib API
This commit is contained in:
@@ -394,6 +394,7 @@ src/Fortran/TestUnderscoreC.c -text
|
||||
src/Makefile.am -text
|
||||
src/h5core/Makefile.am -text
|
||||
src/h5core/h5_attribs.c -text
|
||||
src/h5core/h5_attribs_private.h -text
|
||||
src/h5core/h5_core_private.h -text
|
||||
src/h5core/h5_errorhandling.c -text
|
||||
src/h5core/h5_errorhandling_private.h -text
|
||||
|
||||
+90
-58
@@ -2,7 +2,7 @@
|
||||
#include "h5_core_private.h"
|
||||
|
||||
static h5_err_t
|
||||
_get_hdf5_obj_id(
|
||||
get_hdf5_obj_id(
|
||||
h5_file_t *const f,
|
||||
const char mode,
|
||||
hid_t *id
|
||||
@@ -14,6 +14,39 @@ _get_hdf5_obj_id(
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5priv_read_attrib (
|
||||
h5_file_t* const f, /*!< handle to open file */
|
||||
const hid_t id, /*!< HDF5 object ID */
|
||||
const char* attrib_name, /*!< name of HDF5 attribute to read */
|
||||
const hid_t attrib_type, /*!< HDF5 type of attribute */
|
||||
void* const attrib_value /*!< OUT: attribute value */
|
||||
) {
|
||||
hid_t attrib_id;
|
||||
hid_t type_id;
|
||||
hid_t space_id;
|
||||
TRY( attrib_id = h5priv_open_hdf5_attribute (f, id, attrib_name) );
|
||||
TRY( type_id = h5priv_get_hdf5_attribute_type (f, attrib_id) );
|
||||
|
||||
hid_t h5type_id;
|
||||
TRY( h5type_id = h5_normalize_h5_type(f, type_id) );
|
||||
if ( h5type_id != attrib_type )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Attribute '%s' has type '%s' but was requested as '%s'.",
|
||||
attrib_name,
|
||||
h5priv_get_base_type_name(f, h5type_id),
|
||||
h5priv_get_base_type_name(f, attrib_type) );
|
||||
|
||||
TRY( space_id = h5priv_get_hdf5_attribute_dataspace (f, attrib_id) );
|
||||
TRY( h5priv_read_hdf5_attribute (f, attrib_id, type_id, attrib_value) );
|
||||
TRY( h5priv_close_hdf5_dataspace(f, space_id) );
|
||||
TRY( h5priv_close_hdf5_type(f, type_id) );
|
||||
TRY( h5priv_close_hdf5_attribute (f, attrib_id) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_core_attrib
|
||||
|
||||
@@ -31,66 +64,28 @@ h5_read_attrib (
|
||||
const hid_t attrib_type, /*!< HDF5 type of attribute */
|
||||
void* const attrib_value /*!< OUT: attribute value */
|
||||
) {
|
||||
|
||||
if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f );
|
||||
|
||||
hid_t attrib_id;
|
||||
hid_t space_id;
|
||||
hid_t type_id;
|
||||
|
||||
hid_t id;
|
||||
TRY( _get_hdf5_obj_id(f, mode, &id) );
|
||||
|
||||
TRY( attrib_id = h5priv_open_hdf5_attribute (f, id, attrib_name) );
|
||||
TRY( type_id = h5priv_get_hdf5_attribute_type (f, attrib_id) );
|
||||
|
||||
hid_t h5type_id;
|
||||
TRY( h5type_id = h5_normalize_h5_type(f, type_id) );
|
||||
if ( h5type_id != attrib_type )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Attribute '%s' has type '%s' but was requested as '%s'.",
|
||||
attrib_name,
|
||||
h5priv_get_base_type_name(f, h5type_id),
|
||||
h5priv_get_base_type_name(f, attrib_type) );
|
||||
|
||||
TRY( space_id = h5priv_get_hdf5_attribute_dataspace (f, attrib_id) );
|
||||
TRY( h5priv_read_hdf5_attribute (f, attrib_id, type_id, attrib_value) );
|
||||
TRY( h5priv_close_hdf5_dataspace(f, space_id) );
|
||||
TRY( h5priv_close_hdf5_type(f, type_id) );
|
||||
TRY( h5priv_close_hdf5_attribute (f, attrib_id) );
|
||||
TRY( get_hdf5_obj_id(f, mode, &id) );
|
||||
TRY( h5priv_read_attrib (f, id, attrib_name, attrib_type, attrib_value) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_core_attrib
|
||||
|
||||
Write attribute to HDF5 object.
|
||||
|
||||
\return \c H5_SUCCESS or error code.
|
||||
*/
|
||||
h5_err_t
|
||||
h5_write_attrib (
|
||||
h5priv_write_attrib (
|
||||
h5_file_t* const f, /*!< handle to open file */
|
||||
const char mode, /*!< FILE or STEP flag */
|
||||
const hid_t id, /*!< HDF5 object ID */
|
||||
const char* attrib_name, /*!< name of HDF5 attribute to write */
|
||||
const hid_t attrib_type, /*!< HDF5 type of attribute */
|
||||
const void* attrib_value, /*!< value of attribute */
|
||||
const hsize_t attrib_nelem /*!< number of elements (dimension) */
|
||||
) {
|
||||
|
||||
if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f );
|
||||
CHECK_WRITABLE_MODE( f );
|
||||
|
||||
hid_t space_id;
|
||||
hid_t attrib_id;
|
||||
hid_t type_id;
|
||||
|
||||
hid_t id;
|
||||
TRY( _get_hdf5_obj_id(f, mode, &id) );
|
||||
|
||||
if ( attrib_type == H5T_NATIVE_CHAR ) {
|
||||
TRY( type_id = h5priv_create_hdf5_string_type(f,
|
||||
attrib_nelem) );
|
||||
@@ -123,30 +118,42 @@ h5_write_attrib (
|
||||
/*!
|
||||
\ingroup h5_core_attrib
|
||||
|
||||
Get information about an attribute of a HDF5 object.
|
||||
Write attribute to HDF5 object.
|
||||
|
||||
\return \c H5_SUCCESS or error code.
|
||||
*/
|
||||
h5_err_t
|
||||
h5_get_attrib_info (
|
||||
h5_file_t* const f, /*!< handle to open file */
|
||||
const char mode, /*!< FILE or STEP flag */
|
||||
const h5_size_t attrib_idx, /*!< index of attribute */
|
||||
char* attrib_name, /*!< OUT: name of attribute */
|
||||
const h5_size_t len_attrib_name, /*!< buffer length */
|
||||
h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */
|
||||
h5_size_t* attrib_nelem /*!< OUT: number of elements */
|
||||
h5_write_attrib (
|
||||
h5_file_t* const f, /*!< handle to open file */
|
||||
const char mode, /*!< FILE or STEP flag */
|
||||
const char* attrib_name, /*!< name of HDF5 attribute to write */
|
||||
const hid_t attrib_type, /*!< HDF5 type of attribute */
|
||||
const void* attrib_value, /*!< value of attribute */
|
||||
const hsize_t attrib_nelem /*!< number of elements (dimension) */
|
||||
) {
|
||||
|
||||
if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f );
|
||||
CHECK_WRITABLE_MODE( f );
|
||||
|
||||
hid_t id;
|
||||
TRY( get_hdf5_obj_id(f, mode, &id) );
|
||||
TRY( h5priv_write_attrib (f, id, attrib_name, attrib_type,
|
||||
attrib_value, attrib_nelem) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5priv_get_attrib_info (
|
||||
h5_file_t* const f, /*!< handle to open file */
|
||||
const hid_t id, /*!< HDF5 object ID */
|
||||
const h5_size_t attrib_idx, /*!< index of attribute */
|
||||
char* attrib_name, /*!< OUT: name of attribute */
|
||||
const h5_size_t len_attrib_name,/*!< buffer length */
|
||||
h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */
|
||||
h5_size_t* attrib_nelem /*!< OUT: number of elements */
|
||||
) {
|
||||
hid_t attrib_id;
|
||||
hid_t mytype;
|
||||
hid_t space_id;
|
||||
|
||||
hid_t id;
|
||||
TRY( _get_hdf5_obj_id(f, mode, &id) );
|
||||
|
||||
TRY( attrib_id = h5priv_open_hdf5_attribute_idx (
|
||||
f,
|
||||
id,
|
||||
@@ -171,7 +178,32 @@ h5_get_attrib_info (
|
||||
TRY( h5priv_close_hdf5_type(f, mytype) );
|
||||
}
|
||||
TRY( h5priv_close_hdf5_attribute (f, attrib_id) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_core_attrib
|
||||
|
||||
Get information about an attribute of a HDF5 object.
|
||||
|
||||
\return \c H5_SUCCESS or error code.
|
||||
*/
|
||||
h5_err_t
|
||||
h5_get_attrib_info (
|
||||
h5_file_t* const f, /*!< handle to open file */
|
||||
const char mode, /*!< FILE or STEP flag */
|
||||
const h5_size_t attrib_idx, /*!< index of attribute */
|
||||
char* attrib_name, /*!< OUT: name of attribute */
|
||||
const h5_size_t len_attrib_name, /*!< buffer length */
|
||||
h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */
|
||||
h5_size_t* attrib_nelem /*!< OUT: number of elements */
|
||||
) {
|
||||
if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f );
|
||||
|
||||
hid_t id;
|
||||
TRY( get_hdf5_obj_id(f, mode, &id) );
|
||||
TRY( h5priv_get_attrib_info (f, id, attrib_idx, attrib_name, len_attrib_name,
|
||||
attrib_type, attrib_nelem) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -189,7 +221,7 @@ h5_get_num_attribs (
|
||||
) {
|
||||
if (mode != H5_ATTRIB_FILE) CHECK_TIMEGROUP( f );
|
||||
hid_t id;
|
||||
TRY( _get_hdf5_obj_id(f, mode, &id) );
|
||||
TRY( get_hdf5_obj_id(f, mode, &id) );
|
||||
return h5priv_get_num_hdf5_attribute (f, id);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef __H5_ATTRIBS_PRIVATE_H
|
||||
#define __H5_ATTRIBS_PRIVATE_H
|
||||
|
||||
h5_err_t
|
||||
h5priv_read_attrib (
|
||||
h5_file_t* const f,
|
||||
const hid_t id,
|
||||
const char* attrib_name,
|
||||
const hid_t attrib_type,
|
||||
void* const attrib_value
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5priv_write_attrib (
|
||||
h5_file_t* const f,
|
||||
const hid_t id,
|
||||
const char* attrib_name,
|
||||
const hid_t attrib_type,
|
||||
const void* attrib_value,
|
||||
const hsize_t attrib_nelem
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5priv_get_attrib_info (
|
||||
h5_file_t* const f,
|
||||
const hid_t id,
|
||||
const h5_size_t attrib_idx,
|
||||
char* attrib_name,
|
||||
const h5_size_t len_attrib_name,
|
||||
h5_int64_t* attrib_type,
|
||||
h5_size_t* attrib_nelem
|
||||
);
|
||||
#endif
|
||||
Reference in New Issue
Block a user