From 2c850612ab0abf0429aba1bea606647fc286b95f Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 29 Mar 2016 17:49:32 +0200 Subject: [PATCH] functions added to query existence of file-, step-. field-attributes amd to get information by name --- src/h5core/h5_attribs.c | 505 ++++++++++++++++--------------- src/h5core/h5b_attribs.c | 58 ++++ src/include/H5Block_attribs.f90 | 2 +- src/include/H5Block_attribs.h | 77 ++++- src/include/H5_file_attribs.h | 81 +++-- src/include/h5core/h5_attribs.h | 60 ++-- src/include/h5core/h5b_attribs.h | 14 + 7 files changed, 490 insertions(+), 307 deletions(-) diff --git a/src/h5core/h5_attribs.c b/src/h5core/h5_attribs.c index fe4b9bd..3da8aaa 100644 --- a/src/h5core/h5_attribs.c +++ b/src/h5core/h5_attribs.c @@ -14,203 +14,6 @@ #include "h5_readwrite_private.h" #include "h5_hdf5_private.h" -h5_err_t -h5priv_read_attrib ( - 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 */ - ) { - H5_PRIV_API_ENTER (h5_err_t, - "id=%d, attrib_name='%s', attrib_type=%d, attrib_value=%p", - id, - attrib_name, - attrib_type, - attrib_value); - hid_t attrib_id; - hid_t type_id; - hid_t space_id; - TRY (attrib_id = hdf5_open_attribute (id, attrib_name)); - TRY (type_id = hdf5_get_attribute_type (attrib_id)); - - hid_t h5type_id; - TRY (h5type_id = h5priv_normalize_h5_type (type_id)); - if (h5type_id != attrib_type) - H5_PRIV_API_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Attribute '%s' has type '%s' but was requested as '%s'.", - attrib_name, - hdf5_get_type_name (h5type_id), - hdf5_get_type_name (attrib_type))); - - TRY (space_id = hdf5_get_attribute_dataspace (attrib_id)); - TRY (hdf5_read_attribute (attrib_id, type_id, attrib_value)); - TRY (hdf5_close_dataspace(space_id)); - TRY (hdf5_close_type (type_id)); - TRY (hdf5_close_attribute (attrib_id)); - H5_PRIV_API_RETURN (H5_SUCCESS); -} - -h5_err_t -h5_read_file_attrib ( - const h5_file_t f_, - const char *attrib_name, - const hid_t attrib_type, - void *attrib_value - ) { - h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_err_t, - "f=%p, attrib_name='%s', attrib_type=%d, " - "attrib_value=%p", - f, - attrib_name, - attrib_type, - attrib_value); - CHECK_FILEHANDLE (f); - H5_CORE_API_RETURN (h5priv_read_attrib ( - f->root_gid, - attrib_name, - attrib_type, - attrib_value)); -} - -h5_err_t -h5_read_step_attrib ( - const h5_file_t f_, - const char *attrib_name, - const hid_t attrib_type, - void *attrib_value - ) { - h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_err_t, - "f=%p, attrib_name='%s', attrib_type=%d, " - "attrib_value=%p", - f, - attrib_name, - attrib_type, - attrib_value); - CHECK_FILEHANDLE (f); - CHECK_TIMEGROUP (f); - H5_CORE_API_RETURN (h5priv_read_attrib ( - f->step_gid, - attrib_name, - attrib_type, - attrib_value)); -} - -h5_err_t -h5priv_write_attrib ( - 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) */ - const int overwrite - ) { - H5_PRIV_API_ENTER (h5_err_t, - "id=%d, attrib_name='%s', attrib_type=%d, " - "attrib_value=%p, attrib_nelem=%llu, overwrite=%d", - id, - attrib_name, - attrib_type, - attrib_value, - attrib_nelem, - overwrite); - hid_t space_id; - hid_t attrib_id; - hid_t type_id; - if ( attrib_type == H5T_NATIVE_CHAR ) { - TRY (type_id = hdf5_create_string_type (attrib_nelem)); - TRY (space_id = hdf5_create_dataspace_scalar ()); - } else { - type_id = attrib_type; - TRY (space_id = hdf5_create_dataspace (1, &attrib_nelem, NULL)); - } - h5_err_t exists; - TRY (exists = hdf5_attribute_exists (id, attrib_name)); - if (exists) { - if (overwrite) { - TRY (hdf5_delete_attribute (id, attrib_name)); - } else { - H5_PRIV_API_LEAVE ( - h5_error (H5_ERR_H5, "Cannot overwrite attribute %s/%s", - hdf5_get_objname (id), attrib_name)); - } - } - TRY (attrib_id = hdf5_create_attribute ( - id, - attrib_name, - type_id, - space_id, - H5P_DEFAULT, H5P_DEFAULT)); - - TRY (hdf5_write_attribute (attrib_id, type_id, attrib_value)); - TRY (hdf5_close_attribute (attrib_id)); - TRY (hdf5_close_dataspace (space_id)); - - if (attrib_type == H5T_NATIVE_CHAR) - TRY (hdf5_close_type (type_id)); - - H5_PRIV_API_RETURN (H5_SUCCESS); -} - -h5_err_t -h5_write_file_attrib ( - const h5_file_t f_, - const char *attrib_name, - const hid_t attrib_type, - const void *attrib_value, - const hsize_t attrib_nelem - ) { - h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_err_t, - "f=%p, attrib_name='%s', attrib_type=%d, " - "attrib_value=%p, attrib_nelem=%llu", - f, - attrib_name, - attrib_type, - attrib_value, - attrib_nelem); - CHECK_FILEHANDLE (f); - CHECK_WRITABLE_MODE (f); - H5_CORE_API_RETURN (h5priv_write_attrib ( - f->root_gid, - attrib_name, - attrib_type, - attrib_value, - attrib_nelem, - !is_appendonly (f))); -} - -h5_err_t -h5_write_step_attrib ( - const h5_file_t f_, - const char *attrib_name, - const hid_t attrib_type, - const void *attrib_value, - const hsize_t attrib_nelem - ) { - h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_err_t, - "f=%p, attrib_name='%s', attrib_type=%d, " - "attrib_value=%p, attrib_nelem=%llu", - f, - attrib_name, - attrib_type, - attrib_value, - attrib_nelem); - CHECK_FILEHANDLE (f); - CHECK_TIMEGROUP (f); - CHECK_WRITABLE_MODE (f); - H5_CORE_API_RETURN (h5priv_write_attrib ( - f->step_gid, - attrib_name, - attrib_type, - attrib_value, - attrib_nelem, - !is_appendonly (f))); -} static inline h5_err_t get_attrib_info ( @@ -297,13 +100,130 @@ h5priv_get_attrib_info_by_idx ( H5_PRIV_API_RETURN (get_attrib_info (attrib_id, attrib_type, attrib_nelem)); } -/*! - \ingroup h5_core_attrib +h5_err_t +h5priv_read_attrib ( + 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 */ + ) { + H5_PRIV_API_ENTER (h5_err_t, + "id=%d, attrib_name='%s', attrib_type=%d, attrib_value=%p", + id, + attrib_name, + attrib_type, + attrib_value); + hid_t attrib_id; + hid_t type_id; + hid_t space_id; + TRY (attrib_id = hdf5_open_attribute (id, attrib_name)); + TRY (type_id = hdf5_get_attribute_type (attrib_id)); - Get information about an attribute of a HDF5 object. + hid_t h5type_id; + TRY (h5type_id = h5priv_normalize_h5_type (type_id)); + if (h5type_id != attrib_type) + H5_PRIV_API_LEAVE ( + h5_error ( + H5_ERR_HDF5, + "Attribute '%s' has type '%s' but was requested as '%s'.", + attrib_name, + hdf5_get_type_name (h5type_id), + hdf5_get_type_name (attrib_type))); + + TRY (space_id = hdf5_get_attribute_dataspace (attrib_id)); + TRY (hdf5_read_attribute (attrib_id, type_id, attrib_value)); + TRY (hdf5_close_dataspace(space_id)); + TRY (hdf5_close_type (type_id)); + TRY (hdf5_close_attribute (attrib_id)); + H5_PRIV_API_RETURN (H5_SUCCESS); +} + +h5_err_t +h5priv_write_attrib ( + 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) */ + const int overwrite + ) { + H5_PRIV_API_ENTER (h5_err_t, + "id=%d, attrib_name='%s', attrib_type=%d, " + "attrib_value=%p, attrib_nelem=%llu, overwrite=%d", + id, + attrib_name, + attrib_type, + attrib_value, + attrib_nelem, + overwrite); + hid_t space_id; + hid_t attrib_id; + hid_t type_id; + if ( attrib_type == H5T_NATIVE_CHAR ) { + TRY (type_id = hdf5_create_string_type (attrib_nelem)); + TRY (space_id = hdf5_create_dataspace_scalar ()); + } else { + type_id = attrib_type; + TRY (space_id = hdf5_create_dataspace (1, &attrib_nelem, NULL)); + } + h5_err_t exists; + TRY (exists = hdf5_attribute_exists (id, attrib_name)); + if (exists) { + if (overwrite) { + TRY (hdf5_delete_attribute (id, attrib_name)); + } else { + H5_PRIV_API_LEAVE ( + h5_error (H5_ERR_H5, "Cannot overwrite attribute %s/%s", + hdf5_get_objname (id), attrib_name)); + } + } + TRY (attrib_id = hdf5_create_attribute ( + id, + attrib_name, + type_id, + space_id, + H5P_DEFAULT, H5P_DEFAULT)); + + TRY (hdf5_write_attribute (attrib_id, type_id, attrib_value)); + TRY (hdf5_close_attribute (attrib_id)); + TRY (hdf5_close_dataspace (space_id)); + + if (attrib_type == H5T_NATIVE_CHAR) + TRY (hdf5_close_type (type_id)); + + H5_PRIV_API_RETURN (H5_SUCCESS); +} + +h5_err_t +h5_has_file_attrib ( + const h5_file_t f_, + const char* const attrib_name + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, " + "attrib_name='%s'", + f, + attrib_name); + CHECK_FILEHANDLE (f); + H5_CORE_API_RETURN (hdf5_attribute_exists(f->root_gid, attrib_name)); +} + +h5_err_t +h5_has_step_attrib ( + const h5_file_t f_, + const char* const attrib_name + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, " + "attrib_name='%s'", + f, + attrib_name); + CHECK_FILEHANDLE (f); + H5_CORE_API_RETURN (hdf5_attribute_exists(f->step_gid, attrib_name)); +} - \return \c H5_SUCCESS or error code. -*/ h5_err_t h5_get_file_attrib_info_by_name ( const h5_file_t f_, /*!< IN: handle to open file */ @@ -327,6 +247,51 @@ h5_get_file_attrib_info_by_name ( H5_CORE_API_RETURN (H5_SUCCESS); } +h5_err_t +h5_get_step_attrib_info_by_name ( + const h5_file_t f_, /*!< handle to open file */ + char* attrib_name, /*!< OUT: name of attribute */ + h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */ + h5_size_t* attrib_nelem /*!< OUT: number of elements */ + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, " + "attrib_name=%p, " + "attrib_type=%p, attrib_nelem=%p", + f, + attrib_name, + attrib_type, attrib_nelem); + CHECK_FILEHANDLE (f); + CHECK_TIMEGROUP (f); + TRY (h5priv_get_attrib_info_by_name ( + f->step_gid, + attrib_name, + attrib_type, attrib_nelem)); + H5_CORE_API_RETURN (H5_SUCCESS); +} + +h5_ssize_t +h5_get_num_file_attribs ( + const h5_file_t f_ /*!< handle to open file */ + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); + CHECK_FILEHANDLE (f); + H5_CORE_API_RETURN (hdf5_get_num_attribute (f->root_gid)); +} + +h5_ssize_t +h5_get_num_step_attribs ( + const h5_file_t f_ /*!< handle to open file */ + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); + CHECK_FILEHANDLE (f); + CHECK_TIMEGROUP (f); + H5_CORE_API_RETURN (hdf5_get_num_attribute (f->step_gid)); +} + h5_err_t h5_get_file_attrib_info_by_idx ( const h5_file_t f_, /*!< handle to open file */ @@ -353,30 +318,6 @@ h5_get_file_attrib_info_by_idx ( H5_CORE_API_RETURN (H5_SUCCESS); } -h5_err_t -h5_get_step_attrib_info_by_name ( - const h5_file_t f_, /*!< handle to open file */ - char* attrib_name, /*!< OUT: name of attribute */ - h5_int64_t* attrib_type, /*!< OUT: H5 type of attribute */ - h5_size_t* attrib_nelem /*!< OUT: number of elements */ - ) { - h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_err_t, - "f=%p, " - "attrib_name=%p, " - "attrib_type=%p, attrib_nelem=%p", - f, - attrib_name, - attrib_type, attrib_nelem); - CHECK_FILEHANDLE (f); - CHECK_TIMEGROUP (f); - TRY (h5priv_get_attrib_info_by_name ( - f->step_gid, - attrib_name, - attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (H5_SUCCESS); -} - h5_err_t h5_get_step_attrib_info_by_idx ( const h5_file_t f_, /*!< handle to open file */ @@ -405,31 +346,109 @@ h5_get_step_attrib_info_by_idx ( H5_CORE_API_RETURN (H5_SUCCESS); } -/*! - \ingroup h5_core_attrib - - Get number of attributes of a HDF5 object. - - \return number of attributes or error code. -*/ -h5_ssize_t -h5_get_num_file_attribs ( - const h5_file_t f_ /*!< handle to open file */ +h5_err_t +h5_read_file_attrib ( + const h5_file_t f_, + const char* const attrib_name, + const hid_t attrib_type, + void* attrib_value ) { h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); + H5_CORE_API_ENTER (h5_err_t, + "f=%p, attrib_name='%s', attrib_type=%d, " + "attrib_value=%p", + f, + attrib_name, + attrib_type, + attrib_value); CHECK_FILEHANDLE (f); - H5_CORE_API_RETURN (hdf5_get_num_attribute (f->root_gid)); + H5_CORE_API_RETURN (h5priv_read_attrib ( + f->root_gid, + attrib_name, + attrib_type, + attrib_value)); } -h5_ssize_t -h5_get_num_step_attribs ( - const h5_file_t f_ /*!< handle to open file */ +h5_err_t +h5_read_step_attrib ( + const h5_file_t f_, + const char *attrib_name, + const hid_t attrib_type, + void *attrib_value ) { h5_file_p f = (h5_file_p)f_; - H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); + H5_CORE_API_ENTER (h5_err_t, + "f=%p, attrib_name='%s', attrib_type=%d, " + "attrib_value=%p", + f, + attrib_name, + attrib_type, + attrib_value); CHECK_FILEHANDLE (f); CHECK_TIMEGROUP (f); - H5_CORE_API_RETURN (hdf5_get_num_attribute (f->step_gid)); + H5_CORE_API_RETURN (h5priv_read_attrib ( + f->step_gid, + attrib_name, + attrib_type, + attrib_value)); } + +h5_err_t +h5_write_file_attrib ( + const h5_file_t f_, + const char *attrib_name, + const hid_t attrib_type, + const void *attrib_value, + const hsize_t attrib_nelem + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, attrib_name='%s', attrib_type=%d, " + "attrib_value=%p, attrib_nelem=%llu", + f, + attrib_name, + attrib_type, + attrib_value, + attrib_nelem); + CHECK_FILEHANDLE (f); + CHECK_WRITABLE_MODE (f); + H5_CORE_API_RETURN (h5priv_write_attrib ( + f->root_gid, + attrib_name, + attrib_type, + attrib_value, + attrib_nelem, + !is_appendonly (f))); +} + +h5_err_t +h5_write_step_attrib ( + const h5_file_t f_, + const char *attrib_name, + const hid_t attrib_type, + const void *attrib_value, + const hsize_t attrib_nelem + ) { + h5_file_p f = (h5_file_p)f_; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, attrib_name='%s', attrib_type=%d, " + "attrib_value=%p, attrib_nelem=%llu", + f, + attrib_name, + attrib_type, + attrib_value, + attrib_nelem); + CHECK_FILEHANDLE (f); + CHECK_TIMEGROUP (f); + CHECK_WRITABLE_MODE (f); + H5_CORE_API_RETURN (h5priv_write_attrib ( + f->step_gid, + attrib_name, + attrib_type, + attrib_value, + attrib_nelem, + !is_appendonly (f))); +} + + diff --git a/src/h5core/h5b_attribs.c b/src/h5core/h5b_attribs.c index 13299ad..601cac8 100644 --- a/src/h5core/h5b_attribs.c +++ b/src/h5core/h5b_attribs.c @@ -87,6 +87,64 @@ h5b_read_field_attrib ( H5_CORE_API_RETURN (H5_SUCCESS); } +h5_err_t +h5b_has_field_attrib ( + const h5_file_t fh, /*!< IN: file handle */ + const char* const field_name, /*!< IN: field name */ + const char* const attrib_name /*!< IN: attribute name */ + ) { + h5_file_p f = (h5_file_p)fh; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, " + "field_name='%s', " + "attrib_name=%s, ", + f, + field_name, + attrib_name); + CHECK_FILEHANDLE (f); + CHECK_TIMEGROUP (f); + + TRY (h5bpriv_open_field_group(f, field_name)); + + H5_CORE_API_RETURN ( + hdf5_attribute_exists ( + f->b->field_gid, + attrib_name) ); +} + +h5_err_t +h5b_get_field_attrib_info_by_name ( + const h5_file_t fh, /*!< IN: file handle */ + const char* const field_name, /*!< IN: field name */ + const char* const attrib_name, /*!< IN: attribute name */ + h5_int64_t* attrib_type, /*!< OUT: attribute type */ + h5_size_t* attrib_nelem /*!< OUT: number of elements */ + ) { + h5_file_p f = (h5_file_p)fh; + H5_CORE_API_ENTER (h5_err_t, + "f=%p, " + "field_name='%s', " + "attrib_name=%s, " + "attrib_type=%p, " + "attrib_nelem=%p", + f, + field_name, + attrib_name, + attrib_type, + attrib_nelem); + CHECK_FILEHANDLE (f); + CHECK_TIMEGROUP (f); + + TRY (h5bpriv_open_field_group(f, field_name)); + + H5_CORE_API_RETURN ( + h5priv_get_attrib_info_by_name ( + f->b->field_gid, + attrib_name, + attrib_type, + attrib_nelem)); +} + h5_ssize_t h5b_get_num_field_attribs ( const h5_file_t fh, /*0) if atrribute exists + \return false (\c 0) if attribute does not exist + \return \c H5_FAILURE on error + */ +static inline h5_err_t +H5BlockHasFieldAttrib ( + const h5_file_t f, ///< [in] file handle + const char* const field_name, ///< [in] field name + const char* const attrib_name ///< [in] name of attribute to query + ) { + H5_API_ENTER (h5_err_t, + "f=%p field_name='%s', " + "attrib_name=%p, ", + (h5_file_p)f, + field_name, + attrib_name); + H5_API_RETURN ( + h5b_has_field_attrib ( + f, + field_name, + attrib_name)); +} + +/** + Get the type and number of elements of the field attribute + given by its name. + + \return \c H5_SUCCESS on success + \return \c H5_FAILURE on error +*/ +static inline h5_err_t +H5BlockGetFieldAttribInfoByName ( + const h5_file_t f, ///< [in] file handle + const char* const field_name, ///< [in] field name + const char* const attrib_name, ///< [in] name of attribute to query + h5_int64_t* attrib_type, ///< [out] type of value + h5_size_t* attrib_nelem ///< [out] number of elements + ) { + H5_API_ENTER (h5_err_t, + "f=%p field_name='%s', " + "attrib_name=%p, " + "attrib_type=%p, " + "attrib_nelem=%p", + (h5_file_p)f, + field_name, + attrib_name, + attrib_type, + attrib_nelem); + H5_API_RETURN ( + h5b_get_field_attrib_info_by_name ( + f, + field_name, + attrib_name, + attrib_type, + attrib_nelem)); +} + /* ! _ __ _ _ ! (_) / /__ ___| |_ _ __(_)_ __ __ _ @@ -185,19 +245,18 @@ H5BlockReadFieldAttribString ( */ /** - Write float64 \c values as attribute \c attrib_name of field - \c field_name. + Attach an array of 64 bit floating point data as attribute to given field. \return \c H5_SUCCESS on success \return \c H5_FAILURE on error */ static inline h5_err_t H5BlockWriteFieldAttribFloat64 ( - const h5_file_t f, ///< [in] file handle. - const char* field_name, ///< [in] field name. - const char* attrib_name, ///< [in] attribute name. - const h5_float64_t* buffer, ///< [in] attribute values. - const h5_size_t nelems ///< [in] number of elements. + const h5_file_t f, ///< [in] file handle + const char* field_name, ///< [in] attach attribute to field with this name + const char* attrib_name, ///< [in] attribute name + const h5_float64_t* buffer, ///< [in] pointer to attribute data + const h5_size_t nelems ///< [in] number of elements to write ) { H5_API_ENTER (h5_err_t, diff --git a/src/include/H5_file_attribs.h b/src/include/H5_file_attribs.h index 11fb947..8bdc477 100644 --- a/src/include/H5_file_attribs.h +++ b/src/include/H5_file_attribs.h @@ -40,11 +40,63 @@ extern "C" { |_| |___/ */ +/** + Determines whether a file attribute with a given name exists. + + \return true (value \c >0) if atrribute exists + \return false (\c 0) if attribute does not exist + \return \c H5_FAILURE on error + */ +static inline h5_err_t +H5HasFileAttrib ( + const h5_file_t f, ///< [in] file handle + const char* const name ///< [in] name of attribute to query + ) { + H5_API_ENTER (h5_err_t, + "f=%p, " + "name=%p", + (h5_file_p)f, + name); + H5_API_RETURN ( + h5_has_file_attrib ( + f, + name)); +} + +/** + Get the type and number of elements of the file attribute + given by its name. + + \return \c H5_SUCCESS on success + \return \c H5_FAILURE on error +*/ +static inline h5_err_t +H5GetFileAttribInfoByName ( + const h5_file_t f, ///< [in] file handle. + const char* const name, ///< [in] name of attribute. + h5_int64_t* type, ///< [out] type of value.. + h5_size_t* nelems ///< [out] number of elements. + ) { + H5_API_ENTER (h5_err_t, + "f=%p, " + "name=%s, " + "type=%p, nelems=%p", + (h5_file_p)f, + name, + type, nelems); + H5_API_RETURN (h5_get_file_attrib_info_by_name ( + f, + name, + type, nelems)); +} + /** Gets the number of attributes in the file's root ("/"). \return Number of attributes \return \c H5_FAILURE on error + + \see H5GetFileAttribInfo() */ static inline h5_int64_t H5GetNumFileAttribs ( @@ -58,7 +110,7 @@ H5GetNumFileAttribs ( /** Gets the name, type and number of elements of the file attribute - specified by its index. + given by its index. This function can be used to retrieve all attributes bound to the file \c f by looping from \c 0 to the number of attribute minus @@ -95,33 +147,6 @@ H5GetFileAttribInfo ( nelems)); } -/** - Get the type and number of elements of the file attribute - specified by its name. - - \return \c H5_SUCCESS on success - \return \c H5_FAILURE on error -*/ -static inline h5_err_t -H5GetFileAttribInfoByName ( - const h5_file_t f, ///< [in] file handle. - const char* const name, ///< [in] name of attribute. - h5_int64_t* type, ///< [out] type of value.. - h5_size_t* nelems ///< [out] number of elements. - ) { - H5_API_ENTER (h5_err_t, - "f=%p, " - "name=%s, " - "type=%p, nelems=%p", - (h5_file_p)f, - name, - type, nelems); - H5_API_RETURN (h5_get_file_attrib_info_by_name ( - f, - name, - type, nelems)); -} - /* __ _ _ _ _ _ _ _ / _(_) | ___ __ _| |_| |_ _ __(_) |__ _ _| |_ ___ ___ diff --git a/src/include/h5core/h5_attribs.h b/src/include/h5core/h5_attribs.h index f656483..ad6568a 100644 --- a/src/include/h5core/h5_attribs.h +++ b/src/include/h5core/h5_attribs.h @@ -15,6 +15,40 @@ #ifdef __cplusplus extern "C" { #endif + +h5_err_t +h5_has_file_attrib ( + const h5_file_t, const char* const); + +h5_err_t +h5_has_step_attrib ( + const h5_file_t, const char* const); + +h5_err_t +h5_get_file_attrib_info_by_name ( + const h5_file_t, const char* const, h5_int64_t* const, h5_size_t*); + +h5_err_t +h5_get_step_attrib_info_by_name ( + const h5_file_t, const char* const, h5_int64_t*, h5_size_t*); + +h5_ssize_t +h5_get_num_file_attribs ( + const h5_file_t); + +h5_ssize_t +h5_get_num_step_attribs ( + const h5_file_t); + +h5_err_t +h5_get_file_attrib_info_by_idx ( + const h5_file_t, const h5_size_t, char*, const h5_size_t, h5_int64_t* const, + h5_size_t*); + +h5_err_t +h5_get_step_attrib_info_by_idx ( + const h5_file_t, const h5_size_t, char*, const h5_size_t, h5_int64_t*, + h5_size_t*); h5_err_t h5_read_file_attrib ( @@ -32,32 +66,6 @@ h5_err_t h5_write_step_attrib ( const h5_file_t, const char*, const hid_t, const void*, const hsize_t); -h5_err_t -h5_get_file_attrib_info_by_name ( - const h5_file_t, const char* const, h5_int64_t* const, h5_size_t*); - -h5_err_t -h5_get_file_attrib_info_by_idx ( - const h5_file_t, const h5_size_t, char*, const h5_size_t, h5_int64_t* const, - h5_size_t*); - -h5_err_t -h5_get_step_attrib_info_by_name ( - const h5_file_t, const char* const, h5_int64_t*, h5_size_t*); - -h5_err_t -h5_get_step_attrib_info_by_idx ( - const h5_file_t, const h5_size_t, char*, const h5_size_t, h5_int64_t*, - h5_size_t*); - -h5_ssize_t -h5_get_num_file_attribs ( - const h5_file_t); - -h5_ssize_t -h5_get_num_step_attribs ( - const h5_file_t); - #ifdef __cplusplus } #endif diff --git a/src/include/h5core/h5b_attribs.h b/src/include/h5core/h5b_attribs.h index 6223771..ff40183 100644 --- a/src/include/h5core/h5b_attribs.h +++ b/src/include/h5core/h5b_attribs.h @@ -35,6 +35,20 @@ h5b_read_field_attrib ( const h5_file_t, const char*, const char*, const h5_int64_t, void* const); +h5_err_t +h5b_has_field_attrib ( + const h5_file_t fh, + const char* const field_name, + const char* const attrib_name); + +h5_err_t +h5b_get_field_attrib_info_by_name ( + const h5_file_t, + const char* const, + const char* const, + h5_int64_t*, + h5_size_t*); + h5_ssize_t h5b_get_num_field_attribs ( const h5_file_t,