/* * Class: hdf_hdf5lib_H5 * Method: H5Oset_comment * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment (JNIEnv *env, jclass clss, jlong loc_id, jstring comment) { herr_t status = -1; const char *oComment = NULL; jboolean isCopy; if (comment == NULL) { status = H5Oset_comment((hid_t)loc_id, oComment); } /* end if */ else { oComment = ENVPTR->GetStringUTFChars(ENVPAR comment, &isCopy); if (oComment != NULL) { status = H5Oset_comment((hid_t)loc_id, oComment); ENVPTR->ReleaseStringUTFChars(ENVPAR comment, oComment); } } /* end else */ if (status < 0) h5libraryError(env); } /* end Java_hdf_hdf5lib_H5_H5Oset_1comment */
/* * Class: hdf_hdf5lib_H5 * Method: H5Oset_comment * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment (JNIEnv *env, jclass clss, jlong loc_id, jstring comment) { const char *oComment = NULL; herr_t status = FAIL; UNUSED(clss); if (NULL != comment) PIN_JAVA_STRING(ENVONLY, comment, oComment, NULL, "H5Oset_comment: object comment not pinned"); if ((status = H5Oset_comment((hid_t)loc_id, oComment)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: if (oComment) UNPIN_JAVA_STRING(ENVONLY, comment, oComment); } /* end Java_hdf_hdf5lib_H5_H5Oset_1comment */
/*------------------------------------------------------------------------- * Function: test_misc * * Purpose: Test miscellaneous group stuff. * * Return: Success: 0 * * Failure: number of errors * * Programmer: Robb Matzke * Tuesday, November 24, 1998 * *------------------------------------------------------------------------- */ static int test_misc(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t g1 = (-1), g2 = (-1), g3 = (-1); char filename[NAME_BUF_SIZE]; char comment[64]; if(new_format) TESTING("miscellaneous group tests (w/new group format)") else TESTING("miscellaneous group tests") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create initial groups for testing, then close */ if((g1 = H5Gcreate2(fid, "test_1a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if((g2 = H5Gcreate2(g1, "sub_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if((g3 = H5Gcreate2(fid, "test_1b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Oset_comment(g3, "hello world") < 0) TEST_ERROR if(H5Gclose(g1) < 0) TEST_ERROR if(H5Gclose(g2) < 0) TEST_ERROR if(H5Gclose(g3) < 0) TEST_ERROR /* Open all groups with absolute names to check for exsistence */ if((g1 = H5Gopen2(fid, "/test_1a", H5P_DEFAULT)) < 0) TEST_ERROR if((g2 = H5Gopen2(fid, "/test_1a/sub_1", H5P_DEFAULT)) < 0) TEST_ERROR if((g3 = H5Gopen2(fid, "/test_1b", H5P_DEFAULT)) < 0) TEST_ERROR if(H5Oget_comment_by_name(g3, "././.", comment, sizeof comment, H5P_DEFAULT) < 0) TEST_ERROR if(HDstrcmp(comment, "hello world")) { H5_FAILED(); puts(" Read the wrong comment string from the group."); printf(" got: \"%s\"\n ans: \"hello world\"\n", comment); TEST_ERROR }
/****if* H5Of/h5oset_comment_c * NAME * h5oset_comment_c * PURPOSE * Calls H5Oset_comment * INPUTS * object_id - Identifier of the target object. * comment - The new comment. * commentlen - Length of the comment. * RETURNS * 0 on success, -1 on failure * AUTHOR * M. Scot Breitenfeld * May 17, 2012 * SOURCE */ int_f nh5oset_comment_c (hid_t_f *object_id, _fcd comment, size_t_f *commentlen) /******/ { char *c_comment = NULL; /* Buffer to hold C string */ int_f ret_value = 0; /* Return value */ /* * Convert FORTRAN string to C string */ if((c_comment = HD5f2cstring(comment, (size_t)*commentlen)) == NULL) HGOTO_DONE(FAIL); /* * Call H5Oset_comment function. */ if((hid_t_f)H5Oset_comment((hid_t)*object_id, c_comment) < 0) HGOTO_DONE(FAIL); done: if(c_comment) HDfree(c_comment); return ret_value; }
void Object::setComment(char const* comment) const { // {{{ assertSuccess( "setting object comment", H5Oset_comment(getId(),comment) ); } // }}}