Commit 2c850612 authored by gsell's avatar gsell

functions added to query existence of file-, step-. field-attributes amd to get information by name

parent bc528f27
This diff is collapsed.
......@@ -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, /*<! IN: file handle */
......
......@@ -28,7 +28,7 @@
!! Query the number of attributes of field \c field_name.
!!
!! \return number of attributes
!!\return \c H5_FAILURE on error
!! \return \c H5_FAILURE on error
INTEGER*8 FUNCTION h5bl_getnfieldattribs (filehandle, field_name)
INTEGER*8, INTENT(IN) :: filehandle !< file handle
......
......@@ -58,12 +58,12 @@ H5BlockGetNumFieldAttribs (
}
/**
Gets the name, type and number of elements of the field attribute
Get the name, type and number of elements of the field attribute
specified by its index.
This function can be used to retrieve all attributes bound to the
specified field by looping from \c 0 to the number of attribute
minus one. The number of attributes bound to the
minus one. The number of attributes attached to the
field can be queried by calling \ref H5BlockGetNumFieldAttribs.
\return \c H5_SUCCESS on success
......@@ -102,6 +102,66 @@ H5BlockGetFieldAttribInfo (
attrib_nelem));
}
/**
Determines whether a field 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
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,
......
......@@ -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));
}
/*
__ _ _ _ _ _ _ _
/ _(_) | ___ __ _| |_| |_ _ __(_) |__ _ _| |_ ___ ___
......
......@@ -15,48 +15,56 @@
#ifdef __cplusplus
extern "C" {
#endif
h5_err_t
h5_read_file_attrib (
const h5_file_t, const char*, const hid_t, void*);
h5_has_file_attrib (
const h5_file_t, const char* const);
h5_err_t
h5_read_step_attrib (
const h5_file_t, const char*, const hid_t, void*);
h5_has_step_attrib (
const h5_file_t, const char* const);
h5_err_t
h5_write_file_attrib (
const h5_file_t, const char*, const hid_t, const void*, const hsize_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_write_step_attrib (
const h5_file_t, const char*, const hid_t, const void*, const hsize_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_file_attrib_info_by_name (
const h5_file_t, const char* const, h5_int64_t* const, 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_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_err_t
h5_read_file_attrib (
const h5_file_t, const char*, const hid_t, void*);
h5_ssize_t
h5_get_num_step_attribs (
const h5_file_t);
h5_err_t
h5_read_step_attrib (
const h5_file_t, const char*, const hid_t, void*);
h5_err_t
h5_write_file_attrib (
const h5_file_t, const char*, const hid_t, const void*, const hsize_t);
h5_err_t
h5_write_step_attrib (
const h5_file_t, const char*, const hid_t, const void*, const hsize_t);
#ifdef __cplusplus
}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment