这篇教程C++ HDstrlen函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HDstrlen函数的典型用法代码示例。如果您正苦于以下问题:C++ HDstrlen函数的具体用法?C++ HDstrlen怎么用?C++ HDstrlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HDstrlen函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: HDc2fstr/*NAME HDc2fstr -- convert a C string into a Fortran string IN PLACEUSAGE intn HDc2fstr(str, len) char * str; IN: string to convert intn len; IN: length of Fortran stringRETURNS SUCCEEDDESCRIPTION Change a C string (NULL terminated) into a Fortran string. Basically, all that is done is that the NULL is ripped out and the string is padded with spaces---------------------------------------------------------------------------*/intn HDc2fstr(char *str, intn len){ int i; i=(int)HDstrlen(str); for (; i < len; i++) str[i] = ' '; return SUCCEED;} /* HDc2fstr */
开发者ID:schwehr,项目名称:hdf4,代码行数:25,
示例2: h5_cleanup/*------------------------------------------------------------------------- * Function: h5_cleanup * * Purpose: Cleanup temporary test files. * base_name contains the list of test file names. * The file access property list is also closed. * * Return: Non-zero if cleanup actions were performed; zero otherwise. * * Programmer: Albert Cheng * May 28, 1998 * * Modifications: * Albert Cheng, 2000-09-09 * Added the explicite base_name argument to replace the * global variable FILENAME. * *------------------------------------------------------------------------- */inth5_cleanup(const char *base_name[], hid_t fapl){ char filename[1024]; char temp[2048]; int i, j; int retval=0; hid_t driver; if (GetTestCleanup()){ for (i = 0; base_name[i]; i++) { if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) continue; driver = H5Pget_driver(fapl); if (driver == H5FD_FAMILY) { for (j = 0; /*void*/; j++) { HDsnprintf(temp, sizeof temp, filename, j); if (HDaccess(temp, F_OK) < 0) break; HDremove(temp); } } else if (driver == H5FD_CORE) { hbool_t backing; /* Whether the core file has backing store */ H5Pget_fapl_core(fapl,NULL,&backing); /* If the file was stored to disk with bacing store, remove it */ if(backing) HDremove(filename); } else if (driver == H5FD_MULTI) { H5FD_mem_t mt; assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); HDremove(temp); /*don't care if it fails*/ } } else { HDremove(filename); } } retval = 1; } H5Pclose(fapl); return retval;}
开发者ID:herr-biber,项目名称:hdf5,代码行数:73,
示例3: AddTest/* * Setup a test function and add it to the list of tests. * It must have no parameters and returns void. * TheName--short test name. * If the name starts with '-', do not run it by default. * TheCall--the test routine. * Cleanup--the cleanup routine for the test. * TheDescr--Long description of the test. * Parameters--pointer to extra parameters. Use NULL if none used. * Since only the pointer is copied, the contents should not change. * Return: Void * exit EXIT_FAILURE if error is encountered. */voidAddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr, const void *Parameters){ /* Sanity checking */ if (Index >= MAXNUMOFTESTS) { printf("Too many tests added, increase MAXNUMOFTESTS(%d)./n", MAXNUMOFTESTS); exit(EXIT_FAILURE); } /* end if */ if (HDstrlen(TheDescr) >= MAXTESTDESC) { printf("Test description too long, increase MAXTESTDESC(%d)./n", MAXTESTDESC); exit(EXIT_FAILURE); } /* end if */ if (HDstrlen(TheName) >= MAXTESTNAME) { printf("Test name too long, increase MAXTESTNAME(%d)./n", MAXTESTNAME); exit(EXIT_FAILURE); } /* end if */ /* Set up test function */ HDstrcpy(Test[Index].Description, TheDescr); if (*TheName != '-'){ HDstrcpy(Test[Index].Name, TheName); Test[Index].SkipFlag = 0; } else { /* skip test by default */ HDstrcpy(Test[Index].Name, TheName+1); Test[Index].SkipFlag = 1; } Test[Index].Call = TheCall; Test[Index].Cleanup = Cleanup; Test[Index].NumErrors = -1; Test[Index].Parameters = Parameters; /* Increment test count */ Index++;}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:51,
示例4: test_vl_string/* * test_vl_string * Tests variable-length string datatype with UTF-8 strings. */void test_vl_string(hid_t fid, const char *string){ hid_t type_id, space_id, dset_id; hsize_t dims = 1; hsize_t size; /* Number of bytes used */ char *read_buf[1]; herr_t ret; /* Create dataspace for datasets */ space_id = H5Screate_simple(RANK, &dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); /* Create a datatype to refer to */ type_id = H5Tcopy(H5T_C_S1); CHECK(type_id, FAIL, "H5Tcopy"); ret = H5Tset_size(type_id, H5T_VARIABLE); CHECK(ret, FAIL, "H5Tset_size"); /* Create a dataset */ dset_id = H5Dcreate2(fid, VL_DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); /* Write dataset to disk */ ret = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string); CHECK(ret, FAIL, "H5Dwrite"); /* Make certain the correct amount of memory will be used */ ret = H5Dvlen_get_buf_size(dset_id, type_id, space_id, &size); CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); VERIFY(size, (hsize_t)HDstrlen(string) + 1, "H5Dvlen_get_buf_size"); /* Read dataset from disk */ ret = H5Dread(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ VERIFY(HDstrcmp(string, read_buf[0]), 0, "strcmp"); /* Reclaim the read VL data */ ret = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, read_buf); CHECK(ret, FAIL, "H5Dvlen_reclaim"); /* Close all */ ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); ret = H5Tclose(type_id); CHECK(ret, FAIL, "H5Tclose"); ret = H5Sclose(space_id); CHECK(ret, FAIL, "H5Sclose");}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:54,
示例5: H5O_attr_size/*-------------------------------------------------------------------------- NAME H5O_attr_size PURPOSE Return the raw message size in bytes USAGE size_t H5O_attr_size(f, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source attribute struct RETURNS Size of message on success, 0 on failure DESCRIPTION This function returns the size of the raw attribute message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. * * Modified: * Robb Matzke, 17 Jul 1998 * Added padding between message parts for alignment.--------------------------------------------------------------------------*/static size_tH5O_attr_size(const H5F_t UNUSED *f, const void *_mesg){ const H5A_t *attr = (const H5A_t *)_mesg; size_t name_len; unsigned version; /* Attribute version */ hbool_t type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_size); assert(attr); name_len = HDstrlen(attr->name)+1; /* Check whether datatype is shared */ if(H5T_committed(attr->dt)) type_shared = TRUE; else type_shared = FALSE; /* Check which version to write out */ if(type_shared) version = H5O_ATTR_VERSION_NEW; /* Write out new version if shared datatype */ else version = H5O_ATTR_VERSION; if(version < H5O_ATTR_VERSION_NEW) ret_value = 1 + /*version */ 1 + /*reserved */ 2 + /*name size inc. null */ 2 + /*type size */ 2 + /*space size */ H5O_ALIGN(name_len) + /*attribute name */ H5O_ALIGN(attr->dt_size) + /*data type */ H5O_ALIGN(attr->ds_size) + /*data space */ attr->data_size; /*the data itself */ else ret_value = 1 + /*version */ 1 + /*flags */ 2 + /*name size inc. null */ 2 + /*type size */ 2 + /*space size */ name_len + /*attribute name */ attr->dt_size + /*data type */ attr->ds_size + /*data space */ attr->data_size; /*the data itself */ FUNC_LEAVE_NOAPI(ret_value);}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:70,
示例6: H5L_build_name/*-------------------------------------------------------------------------- * Function: H5L_build_name * * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME * * Return: Non-negative on success/Negative on failure * * Programmer: Vailin Choi, April 2, 2008 * * Modification: Raymond Lu, 14 Jan. 2009 * Added support for OpenVMS pathname--------------------------------------------------------------------------*/static herr_tH5L_build_name(char *prefix, char *file_name, char **full_name/*out*/){ size_t prefix_len; /* length of prefix */ size_t fname_len; /* Length of external link file name */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT prefix_len = HDstrlen(prefix); fname_len = HDstrlen(file_name); /* Allocate a buffer to hold the filename + prefix + possibly the delimiter + terminating null byte */ if(NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer") /* Compose the full file name */ HDsnprintf(*full_name, (prefix_len + fname_len + 2), "%s%s%s", prefix, (H5_CHECK_DELIMITER(prefix[prefix_len - 1]) ? "" : H5_DIR_SEPS), file_name);done: FUNC_LEAVE_NOAPI(ret_value)} /* H5L_build_name() */
开发者ID:MichaelToal,项目名称:hdf5,代码行数:35,
示例7: test_refstr_own/******************************************************************** test_refstr_own(): Test basic H5RS (ref-counted strings) code.** Tests transferring ownership of dynamically allocated strings** to ref-counted strings.******************************************************************/static voidtest_refstr_own(void){ H5RS_str_t *rs; /* Ref-counted string created */ char *s; /* Pointer to string to transfer */ const char *t; /* Temporary pointers to string */ int cmp; /* Comparison value */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Transferring Ref-Counted Strings/n")); /* Initialize buffer */ s = (char *)H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1); CHECK(s, NULL, "H5FL_BLK_MALLOC"); HDstrcpy(s, "foo"); /* Transfer ownership of dynamically allocated string to ref-counted string */ rs=H5RS_own(s); CHECK(rs, NULL, "H5RS_own"); /* Get pointer to raw string in ref-counted string */ t=H5RS_get_str(rs); CHECK(t, NULL, "H5RS_get_str"); VERIFY(t, s, "transferring"); cmp=HDstrcmp(s,t); VERIFY(cmp, 0, "HDstrcmp"); /* Increment reference count (should NOT duplicate string) */ ret=H5RS_incr(rs); CHECK(ret, FAIL, "H5RS_incr"); /* Change the buffer initially wrapped */ *s='F'; /* Get pointer to raw string in ref-counted string */ t=H5RS_get_str(rs); CHECK(t, NULL, "H5RS_get_str"); VERIFY(t, s, "transferring"); cmp=HDstrcmp(t,s); VERIFY(cmp, 0, "HDstrcmp"); /* Decrement reference count for string */ ret=H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); ret=H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr");} /* end test_refstr_own() */
开发者ID:Vertexwahn,项目名称:appleseed-deps,代码行数:56,
示例8: H5MM_strdup/*------------------------------------------------------------------------- * Function: H5MM_strdup * * Purpose: Duplicates a string. If the string to be duplicated is the * null pointer, then return null. If the string to be duplicated * is the empty string then return a new empty string. * * Return: Success: Ptr to a new string (or null if no string). * * Failure: abort() * * Programmer: Robb Matzke * [email C++ HEADER函数代码示例 C++ HDstrcmp函数代码示例
|