diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-30 18:13:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-30 18:13:48 (GMT) |
commit | 0e06a92d0e1e129c46f27115f2b15ca2995ac59e (patch) | |
tree | d1d035c68ed9725b7c74b5dcb5c1b3b9625258dd /src/H5A.c | |
parent | dbff4af21c57cfd14f7f35a6799faad5087c0867 (diff) | |
download | hdf5-0e06a92d0e1e129c46f27115f2b15ca2995ac59e.zip hdf5-0e06a92d0e1e129c46f27115f2b15ca2995ac59e.tar.gz hdf5-0e06a92d0e1e129c46f27115f2b15ca2995ac59e.tar.bz2 |
[svn-r14218] Description:
Changed H5Acreate2 -> H5Acreate_by_name, to be more consistent with
other new API routines.
Re-added simpler form of H5Acreate2, which creates attributes directly
on an object.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src/H5A.c')
-rw-r--r-- | src/H5A.c | 73 |
1 files changed, 69 insertions, 4 deletions
@@ -190,7 +190,72 @@ H5A_term_interface(void) PURPOSE Creates an attribute on an object USAGE - hid_t H5Acreate2(loc_id, obj_name, attr_name, type_id, space_id, acpl_id, + hid_t H5Acreate2(loc_id, attr_name, type_id, space_id, acpl_id, + aapl_id) + hid_t loc_id; IN: Object (dataset or group) to be attached to + const char *attr_name; IN: Name of attribute to locate and open + hid_t type_id; IN: ID of datatype for attribute + hid_t space_id; IN: ID of dataspace for attribute + hid_t acpl_id; IN: ID of creation property list (currently not used) + hid_t aapl_id; IN: Attribute access property list + RETURNS + Non-negative on success/Negative on failure + + DESCRIPTION + This function creates an attribute which is attached to the object + specified with 'loc_id'. The name specified with 'attr_name' for + each attribute for an object must be unique for that object. The 'type_id' + and 'space_id' are created with the H5T and H5S interfaces respectively. + The 'aapl_id' property list is currently unused, but will be used in the + future for optional attribute access properties. The attribute ID returned + from this function must be released with H5Aclose or resource leaks will + develop. + +--------------------------------------------------------------------------*/ +/* ARGSUSED */ +hid_t +H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, + hid_t acpl_id, hid_t UNUSED aapl_id) +{ + H5G_loc_t loc; /* Object location */ + H5T_t *type; /* Datatype to use for attribute */ + H5S_t *space; /* Dataspace to use for attribute */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5Acreate2, FAIL) + H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, + acpl_id, aapl_id); + + /* check arguments */ + if(H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") + if(!attr_name || !*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* Go do the real work for attaching the attribute to the dataset */ + if((ret_value = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Acreate2() */ + + +/*-------------------------------------------------------------------------- + NAME + H5Acreate_by_name + PURPOSE + Creates an attribute on an object + USAGE + hid_t H5Acreate_by_name(loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id) hid_t loc_id; IN: Object (dataset or group) to be attached to const char *obj_name; IN: Name of object relative to location @@ -216,7 +281,7 @@ H5A_term_interface(void) --------------------------------------------------------------------------*/ /* ARGSUSED */ hid_t -H5Acreate2(hid_t loc_id, const char *obj_name, const char *attr_name, +H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t UNUSED aapl_id, hid_t lapl_id) { @@ -229,7 +294,7 @@ H5Acreate2(hid_t loc_id, const char *obj_name, const char *attr_name, H5S_t *space; /* Dataspace to use for attribute */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Acreate2, FAIL) + FUNC_ENTER_API(H5Acreate_by_name, FAIL) H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id); @@ -269,7 +334,7 @@ done: HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) -} /* H5Acreate2() */ +} /* H5Acreate_by_name() */ /*------------------------------------------------------------------------- |