您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ H5Aget_type函数代码示例

51自学网 2021-06-01 21:19:55
  C++
这篇教程C++ H5Aget_type函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中H5Aget_type函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Aget_type函数的具体用法?C++ H5Aget_type怎么用?C++ H5Aget_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了H5Aget_type函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_attribute_disk

static herr_t get_attribute_disk(hid_t loc_id,                                 const char *attr_name,                                 void *attr_out){    hid_t attr_id;    hid_t attr_type;    herr_t status;    attr_id = H5Aopen_name(loc_id, attr_name);    if (attr_id < 0)        return -1;    attr_type = H5Aget_type(attr_id);    if (attr_type < 0)        goto out;    status = H5Aread(attr_id, attr_type, attr_out);    if (status < 0)        goto out;    status = H5Tclose(attr_type);    if (status < 0)        goto out;    status = H5Aclose(attr_id);    if (status < 0)        return -1;    return 0;out:    H5Tclose(attr_type);    H5Aclose(attr_id);    return -1;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:34,


示例2: H5Dataset_read_attr_value

/* read attribute value */char* H5Dataset_read_attr_value(hid_t aid){    hid_t asid=-1, atid=-1;    int i, rank;    hsize_t *dims;    size_t size=1;    char *attr_buf=NULL;      asid = H5Aget_space(aid);    atid = H5Aget_type(aid);    rank = H5Sget_simple_extent_ndims(asid);    if (rank > 0) {        dims = (hsize_t *)malloc(rank * sizeof(hsize_t));        H5Sget_simple_extent_dims(asid, dims, NULL);        for (i=0; i<rank; i++) {            size *= (size_t)dims[i];            free(dims);        }        size *= H5Tget_size(atid);        attr_buf = (char *)malloc(size);        if (H5Aread( aid, atid, attr_buf) < 0) {            free(attr_buf);            attr_buf = NULL;        }    }        if( atid > 0) H5Tclose(atid);    if (asid > 0) H5Sclose(asid);     return attr_buf;}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:35,


示例3: write

void write(const hid_attribute_adaptor& attrib, const std::string& value){	hid_t attr_type_id = H5CPP_ERR_ON_NEG(H5Aget_type(attrib.id()));	if(H5Tget_class(attr_type_id) != H5T_STRING)		H5CPP_THROW("Attempted to set string value on non-string attribute '"			<< object::get_name(attrib.id()) << '/'');	const char* cstr = value.c_str();	if(H5Tis_variable_str(attr_type_id))		H5CPP_ERR_ON_NEG(H5Awrite(attrib.id(), attr_type_id, &cstr));	else	{		std::size_t attriblen = H5Aget_storage_size(attrib.id());		if(attriblen > value.length())		{			// avoid reading past end of value into unalloc'd mem			std::vector<char> buf(attriblen,'/0');			std::copy(cstr, cstr+value.length(), &buf[0]);			H5CPP_ERR_ON_NEG(H5Awrite(attrib.id(), attr_type_id, &buf[0]));		}		else			H5CPP_ERR_ON_NEG(H5Awrite(attrib.id(), attr_type_id, cstr));	}}
开发者ID:achayan,项目名称:anim-studio-tools,代码行数:25,


示例4: AH5_read_str_attr

// Read string attribute <attr_name> given by address <path>char AH5_read_str_attr(hid_t loc_id, const char *path, char *attr_name, char **rdata){    hid_t attr_id, filetype, memtype;    size_t sdim;    char success = AH5_FALSE;    if (AH5_path_valid(loc_id, path) || strcmp(path, ".") == 0)        if (H5Aexists_by_name(loc_id, path, attr_name, H5P_DEFAULT) > 0)        {            attr_id = H5Aopen_by_name(loc_id, path, attr_name, H5P_DEFAULT, H5P_DEFAULT);            filetype = H5Aget_type(attr_id);            sdim = H5Tget_size(filetype);            sdim++;  // make a space for null terminator            *rdata = (char *) malloc(sdim * sizeof(char));            memtype = H5Tcopy(H5T_C_S1);            H5Tset_size(memtype, sdim);            if (H5Aread(attr_id, memtype, *rdata) >= 0)                success = AH5_TRUE;            else                free(*rdata);            H5Tclose(memtype);            H5Tclose(filetype);            H5Aclose(attr_id);        }    if (!success)        *rdata = NULL;    return success;}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:29,


示例5: H5Aget_type

// JRC: This fat interface may not scale?  What about// scalar attributes?herr_t VsH5Attribute::getDoubleVectorValue(std::vector<double>* dvals) {  herr_t err = 0;  size_t npoints;  hid_t atype = H5Aget_type(getId());  H5T_class_t type = H5Tget_class(atype);  hid_t aspace = H5Aget_space(getId());  size_t rank = H5Sget_simple_extent_ndims(aspace);  if (type != H5T_FLOAT) {    VsLog::warningLog() <<"VsH5Attribute::getDoubleVectorValue() - Requested attribute " <<getShortName()         <<" is not a floating point vector." <<std::endl;    dvals->resize(0);    return -1;  }    if (rank == 0) {    dvals->resize(1);    double v;    err = H5Aread(getId(), H5T_NATIVE_DOUBLE, &v);    (*dvals)[0] = v;    return err;  }    // rank>0  npoints = H5Sget_simple_extent_npoints(aspace);  double* v = new double[npoints];  err = H5Aread(getId(), H5T_NATIVE_DOUBLE, v);  dvals->resize(npoints);  for (size_t i = 0; i<npoints; ++i) {    (*dvals)[i] = v[i];  }  delete [] v;    return err;}
开发者ID:HarinarayanKrishnan,项目名称:VisIt26RC_Trunk,代码行数:37,


示例6: get_attribute_float

static herr_t get_attribute_float(hid_t input, const char *name, float *val){    hid_t attr_id;    hid_t type_id;    H5T_class_t type_class;    size_t type_size;    herr_t status;    char *strval;    attr_id = H5Aopen_name(input, name);    type_id = H5Aget_type(attr_id);    type_class = H5Tget_class(type_id);    type_size = H5Tget_size(type_id);    H5Tclose(type_id);    H5Aclose(attr_id);    switch(type_class)    {        case H5T_STRING:            status = get_attribute_str(input, name, &strval);            if (status < 0) return -1;                *val = atof(strval);            free(strval);            return 0;        case H5T_FLOAT:            status = get_attribute(input, name, H5T_NATIVE_FLOAT, val);            if (status < 0) return -1;            return 0;    }    return -1;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:34,


示例7: H5Aopen

hdf5attribute::hdf5attribute(hdf5dataset& hdataset, const std::string& name){	_attribute_id = H5Aopen(hdataset.handle(), name.c_str(), H5P_DEFAULT);	if(_attribute_id < 0)		throw std::runtime_error("Failed to open attribute (" + name + ") in dataset (" + "not available" + ") file (" + "not available" + ")");	_type_id = H5Aget_type(_attribute_id);}
开发者ID:klindworth,项目名称:cvwidgets,代码行数:8,


示例8: validateFloat3Attribute

/*-------------------------------------------------------------*/static void validateFloat3Attribute(pNXVcontext self,	hid_t dpField, char *name){	hid_t attID, attType, attSpace;	H5T_class_t h5class;	hsize_t dims[2], maxDims[2];	char fname[512];	memset(fname,0,sizeof(fname));	H5Iget_name(dpField,fname,sizeof(fname));	if(!H5LTfind_attribute(dpField,name)){			NXVsetLog(self,"sev","error");			NXVprintLog(self,"message",				"Missing attribute %s on %s",				name, fname);			NXVlog(self);			self->errCount++;	} else {		attID = H5Aopen(dpField,name,H5P_DEFAULT);		assert(attID >= 0);		attType = H5Aget_type(attID);		assert(attType >= 0);		h5class = H5Tget_class(attType);		if(h5class != H5T_FLOAT){			NXVsetLog(self,"sev","error");			NXVprintLog(self,"message",				"%s attribute on %s is of wrong type, expected float",				name, fname);			NXVlog(self);			self->errCount++;		} else {			attSpace = H5Aget_space(attID);			if(H5Sget_simple_extent_ndims(attSpace) != 1){				NXVsetLog(self,"sev","error");				NXVprintLog(self,"message",					"%s attribute on %s is of wrong rank, expected 1",					name, fname);				NXVlog(self);				self->errCount++;			} else {				H5Sget_simple_extent_dims(attSpace,dims,maxDims);				if(dims[0] != 3){					NXVsetLog(self,"sev","error");					NXVprintLog(self,"message",						"%s attribute on %s is of wrong size, expected 3",						name, fname);					NXVlog(self);					self->errCount++;				}			}			H5Sclose(attSpace);		}		H5Tclose(attType);		H5Aclose(attID);	}}
开发者ID:nexusformat,项目名称:cnxvalidate,代码行数:59,


示例9: mhdf_getElemTypeName

void mhdf_getElemTypeName( mhdf_FileHandle file_handle,                      const char* elem_handle,                      char* buffer, size_t buf_len,                      mhdf_Status* status ){  FileHandle* file_ptr;  hid_t elem_id, type_id, attr_id;  char bytes[16];  herr_t rval;  API_BEGIN;   if (NULL == buffer || buf_len < 2)  {    mhdf_setFail( status, "invalid input" );    return;  }  buffer[0] = '/0';    file_ptr = (FileHandle*)(file_handle);  if (!mhdf_check_valid_file( file_ptr, status ))    return;    elem_id = mhdf_elem_group_from_handle( file_ptr, elem_handle, status );  if (elem_id < 0) return;    attr_id = H5Aopen_name( elem_id, ELEM_TYPE_ATTRIB );  H5Gclose( elem_id );  if (attr_id < 0)  {    mhdf_setFail( status, "Missing element type attribute.  Invalid file." );    return;  }    type_id = H5Aget_type( attr_id );  assert( type_id > 0 );    rval = H5Aread( attr_id, type_id, bytes );  H5Aclose( attr_id );  if (rval < 0)  {    H5Tclose( type_id );    mhdf_setFail( status, "Failed to read element type attribute.  Invalid file." );    return;  }    rval = H5Tenum_nameof( type_id, bytes, buffer, buf_len );  H5Tclose( type_id );  if (rval < 0)  {    mhdf_setFail( status, "Invalid datatype for element type attribute.  Invalid file." );    return;  }    mhdf_setOkay( status );    API_END;  return ;}
开发者ID:chrismullins,项目名称:moab,代码行数:58,


示例10: get_cols

/* fetch num_cols and the col for a particular trackname */void get_cols(chromosome_t *chromosome, char *trackname, hsize_t *num_cols,              hsize_t *col) {  hid_t attr, root, dataspace, datatype;  hsize_t data_size, cell_size, num_cells;  char *attr_data;  /* Tracknames are stored in the attributes of the root group of each file */  root = H5Gopen(chromosome->h5group, "/", H5P_DEFAULT);  assert(root >= 0);  attr = H5Aopen_name(root, "tracknames");  assert(attr >= 0);  dataspace = H5Aget_space(attr);  assert(dataspace >= 0);  assert(H5Sget_simple_extent_dims(dataspace, num_cols, NULL) == 1);  assert(H5Sclose(dataspace) >= 0);  if (trackname && col) {    datatype = H5Aget_type(attr);    assert(datatype >= 0);    assert(H5Tget_class(datatype) == H5T_STRING);    cell_size = H5Tget_size(datatype);    assert(cell_size > 0);    data_size = H5Aget_storage_size(attr);    assert(data_size > 0);    num_cells = data_size / cell_size;    /* allocate room for tracknames */    attr_data = xmalloc(data_size);    assert(attr_data);    assert(H5Aread(attr, datatype, attr_data) >= 0);    *col = 0;    for (*col = 0; *col <= num_cells; (*col)++) {      if (*col == num_cells) {        fprintf(stderr, "can't find trackname: %s/n", trackname);        free(attr_data);        exit(EXIT_FAILURE);      } else {        if (!strncmp(attr_data + (*col * cell_size), trackname, cell_size)) {          break;        }      }    }    /* clean up read tracknames */    free(attr_data);  }  assert(H5Aclose(attr) >= 0);}
开发者ID:weallen,项目名称:Seqwill,代码行数:58,


示例11: validateDependsOnAttributes

/*--------------------------------------------------------------	This validates the lesser depends_on chain fields like	vector, offset and transformation_type----------------------------------------------------------------*/static void validateDependsOnAttributes(pNXVcontext self,hid_t dpField){	char fname[512], transData[512];	hid_t attID, attType, attSpace;	H5T_class_t h5class;	memset(fname,0,sizeof(fname));	memset(transData,0,sizeof(transData));	H5Iget_name(dpField,fname,sizeof(fname));	/*		deal with transformation_type	*/	if(!H5LTfind_attribute(dpField,"transformation_type")){			NXVsetLog(self,"sev","error");			NXVprintLog(self,"message",				"Missing attribute transformation_type on %s",				fname);			NXVlog(self);			self->errCount++;	} else {		attID = H5Aopen(dpField,"transformation_type",H5P_DEFAULT);		assert(attID >= 0);		attType = H5Aget_type(attID);		assert(attType >= 0);		h5class = H5Tget_class(attType);		if(h5class != H5T_STRING){			NXVsetLog(self,"sev","error");			NXVprintLog(self,"message",				"transformation_type on %s is of wrong type, expected string",				fname);			NXVlog(self);			self->errCount++;		} else {			H5NXget_attribute_string(self->fileID, fname,					"transformation_type",transData);			if(strcmp(transData,"translation") != 0				&& strcmp(transData,"rotation") != 0){					NXVsetLog(self,"sev","error");					NXVprintLog(self,"message",						"transformation_type on %s contains bad data: %s",						fname,						"expected rotation or translation");					NXVlog(self);					self->errCount++;				}		}		H5Tclose(attType);		H5Aclose(attID);	}	validateFloat3Attribute(self,dpField,"offset");	validateFloat3Attribute(self,dpField,"vector");}
开发者ID:nexusformat,项目名称:cnxvalidate,代码行数:60,


示例12: H5Aget_type

H5Type & H5Attribute::getDataType(){    hid_t type = H5Aget_type(attr);    if (type < 0)    {        throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute type"));    }    return *new H5Type(*this, type);}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:10,


示例13: get_attribute_str

static herr_t get_attribute_str(hid_t obj_id,                                const char *attr_name,                                char **data){    hid_t attr_id;    hid_t attr_type;    size_t type_size;    herr_t status;    *data = NULL;    attr_id = H5Aopen_name(obj_id, attr_name);    if (attr_id < 0)        return -1;    attr_type = H5Aget_type(attr_id);    if (attr_type < 0)        goto out;    /* Get the size */    type_size = H5Tget_size(attr_type);    if (type_size < 0)        goto out;    /* malloc enough space for the string, plus 1 for trailing '/0' */    *data = (char *)malloc(type_size + 1);    status = H5Aread(attr_id, attr_type, *data);    if (status < 0)        goto out;    /* Set the last character to '/0' in case we are dealing with     * null padded or space padded strings     */    (*data)[type_size] = '/0';    status = H5Tclose(attr_type);    if (status < 0)        goto out;    status = H5Aclose(attr_id);    if (status < 0)        return -1;    return 0;out:    H5Tclose(attr_type);    H5Aclose(attr_id);    if (*data)        free(*data);    return -1;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:53,


示例14: H5Aget_type

/* * Class:     hdf_hdf5lib_H5 * Method:    H5Aget_type * Signature: (J)J */JNIEXPORT jlong JNICALLJava_hdf_hdf5lib_H5__1H5Aget_1type    (JNIEnv *env, jclass clss, jlong attr_id){    hid_t retVal = -1;    retVal = H5Aget_type((hid_t)attr_id);    if (retVal < 0)        h5libraryError(env);    return (jlong)retVal;} /* end Java_hdf_hdf5lib_H5__1H5Aget_1type */
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:17,


示例15: get_attribute_info

static herr_t get_attribute_info(hid_t obj_id,                                 const char *attr_name,                                 hsize_t *dims,                                 H5T_class_t *type_class,                                 size_t *type_size,                                 hid_t *type_id){    hid_t attr_id;    hid_t space_id;    herr_t status;    int rank;    /* Open the attribute. */    attr_id = H5Aopen_name(obj_id, attr_name);    if (attr_id < 0)        return -1;    /* Get an identifier for the datatype. */    *type_id = H5Aget_type(attr_id);    /* Get the class. */    *type_class = H5Tget_class(*type_id);    /* Get the size. */    *type_size = H5Tget_size(*type_id);    /* Get the dataspace handle */    space_id = H5Aget_space(attr_id);    if (space_id < 0)        goto out;    /* Get dimensions */    rank = H5Sget_simple_extent_dims(space_id, dims, NULL);    if (rank < 0)        goto out;    /* Terminate access to the dataspace */    status = H5Sclose(space_id);    if (status < 0)        goto out;    /* End access to the attribute */    status = H5Aclose(attr_id);    if (status < 0)        goto out;    return 0;out:    H5Tclose(*type_id);    H5Aclose(attr_id);    return -1;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:52,


示例16: ReadStringsT

voidReadStringsT( hid_t iParent,              const std::string &iAttrName,              size_t iNumStrings,              StringT *oStrings ){    ABCA_ASSERT( iParent >= 0, "Invalid parent in ReadStringsT" );    // Open the attribute.    hid_t attrId = H5Aopen( iParent, iAttrName.c_str(), H5P_DEFAULT );    ABCA_ASSERT( attrId >= 0,                 "Couldn't open attribute named: " << iAttrName );    AttrCloser attrCloser( attrId );    // Checking code.    {        hid_t attrFtype = H5Aget_type( attrId );        DtypeCloser dtypeCloser( attrFtype );        hid_t nativeDtype = GetNativeDtype<CharT>();        ABCA_ASSERT( H5Tget_class( attrFtype ) ==                     H5Tget_class( nativeDtype ) &&                     H5Tget_sign( attrFtype ) ==                     H5Tget_sign( nativeDtype ),                     "Invalid datatype for stringT" );    }    hid_t attrSpace = H5Aget_space( attrId );    ABCA_ASSERT( attrSpace >= 0,                 "Couldn't get dataspace for attribute: " << iAttrName );    DspaceCloser dspaceCloser( attrSpace );    hssize_t numPoints = H5Sget_simple_extent_npoints( attrSpace );    ABCA_ASSERT( numPoints > 0,                 "Degenerate string dimensions in ReadStringsT" );    // Create temporary char storage buffer.    std::vector<CharT> charStorage( ( size_t )( 1 + numPoints ),                                    ( CharT )0 );    // Read into it.    herr_t status = H5Aread( attrId, GetNativeDtype<CharT>(),                             ( void * )&charStorage.front() );    ABCA_ASSERT( status >= 0, "Couldn't read from attribute: " << iAttrName );    // Extract 'em.    ExtractStrings( oStrings, ( const CharT * )&charStorage.front(),                    1 + numPoints, iNumStrings );}
开发者ID:ryutaro765,项目名称:Alembic,代码行数:51,


示例17: hdf5_read

int hdf5_read(void *output, hid_t file, char *n_group, char *n_dset, char *n_attr, int c){    hid_t memtype, type, group=-1, dset=-1, attr=-1, tmp_id, space;    herr_t status;    size_t sdim;    int ndims;        tmp_id = file;    if(strlen(n_group)>0){        group = H5Gopen(tmp_id, n_group, H5P_DEFAULT);        tmp_id = group;    }    if(strlen(n_dset)>0){        dset = H5Dopen(tmp_id, n_dset, H5P_DEFAULT);        tmp_id = dset;    }    if(strlen(n_attr)>0){        attr = H5Aopen(tmp_id, n_attr, H5P_DEFAULT);        tmp_id = attr;    }        if(c == 'c'){        memtype = H5Tcopy (H5T_C_S1);        type = H5Aget_type (tmp_id);        sdim = H5Tget_size (type);        sdim++;        status = H5Tset_size (memtype, sdim);    }    else if(c == 'd'){        memtype = H5T_NATIVE_DOUBLE;    }    else if(c == 'i' || c == 'n'){        memtype = H5T_NATIVE_INT;    }    else if(c == 'f'){        memtype = H5T_NATIVE_FLOAT;    }        if (tmp_id == attr){        status = H5Aread(tmp_id, memtype, output);    }    else if(tmp_id == dset && c == 'n'){        space = H5Dget_space (dset);        ndims = H5Sget_simple_extent_dims (space, output, NULL);    }    else{        return(-1);    }        return(1);}
开发者ID:duanuys,项目名称:GMT5SAR,代码行数:50,


示例18: nh5aget_type_c

/*---------------------------------------------------------------------------- * Name:        h5aget_type_c * Purpose:     Call H5Aget_space to get attribute's datatype * Inputs:      attr_id - attribute identifier * Outputs:     type_id - datatype identifier * Returns:     0 on success, -1 on failure * Programmer:  Elena Pourmal *              Thursday, August 12, 1999 * Modifications: *---------------------------------------------------------------------------*/int_fnh5aget_type_c (hid_t_f *attr_id, hid_t_f *type_id){    int_f ret_value=0;          /* Return value */     /*      * Call H5Aget_type function.      */     if ((*type_id = (hid_t_f)H5Aget_type((hid_t)*attr_id)) < 0)         HGOTO_DONE(FAIL);done:     return ret_value;}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:24,


示例19: GH5_FetchAttribute

bool GH5_FetchAttribute( hid_t loc_id, const char *pszAttrName,                         CPLString &osResult, bool bReportError ){    bool retVal = false;    hid_t hAttr = H5Aopen_name( loc_id, pszAttrName );    osResult.clear();    if( hAttr < 0 )    {        if( bReportError )            CPLError( CE_Failure, CPLE_AppDefined,                      "Attempt to read attribute %s failed, not found.",                      pszAttrName );        return false;    }    hid_t hAttrTypeID      = H5Aget_type( hAttr );    hid_t hAttrNativeType  = H5Tget_native_type( hAttrTypeID, H5T_DIR_DEFAULT );    if( H5Tget_class( hAttrNativeType ) == H5T_STRING )    {        int nAttrSize = H5Tget_size( hAttrTypeID );        char *pachBuffer = (char *) CPLCalloc(nAttrSize+1,1);        H5Aread( hAttr, hAttrNativeType, pachBuffer );        osResult = pachBuffer;        CPLFree( pachBuffer );        retVal = true;    }    else    {        if( bReportError )            CPLError( CE_Failure, CPLE_AppDefined,                      "Attribute %s of unsupported type for conversion to string.",                      pszAttrName );        retVal = false;    }    H5Tclose( hAttrNativeType );    H5Tclose( hAttrTypeID );    H5Aclose( hAttr );    return retVal;}
开发者ID:TUW-GEO,项目名称:OGRSpatialRef3D,代码行数:49,


示例20: H5Dopen

void AbstractHdf5Access::SetUnlimitedDatasetId(){    // Now deal with the unlimited dimension    // In terms of an Unlimited dimension dataset:    // * Files pre - r16738 (inc. Release 3.1 and earlier) use simply "Time" for "Data"'s unlimited variable.    // * Files generated by r16738 - r18257 used "<DatasetName>_Time" for "<DatasetName>"'s unlimited variable,    //   - These are not to be used and there is no backwards compatibility for them, since they weren't in a release.    // * Files post r18257 (inc. Release 3.2 onwards) use "<DatasetName>_Unlimited" for "<DatasetName>"'s    //   unlimited variable,    //   - a new attribute "Name" has been added to the Unlimited Dataset to allow it to assign    //     any name to the unlimited variable. Which can then be easily read by Hdf5DataReader.    //   - if this dataset is missing we look for simply "Time" to remain backwards compatible with Releases <= 3.1    if (DoesDatasetExist(mDatasetName + "_Unlimited"))    {        mUnlimitedDatasetId = H5Dopen(mFileId, (mDatasetName + "_Unlimited").c_str());        hid_t name_attribute_id = H5Aopen_name(mUnlimitedDatasetId, "Name");        hid_t unit_attribute_id = H5Aopen_name(mUnlimitedDatasetId, "Unit");        hid_t attribute_type  = H5Aget_type(name_attribute_id);        // Read into it.        char* string_array = (char *)malloc(sizeof(char)*MAX_STRING_SIZE);        H5Aread( name_attribute_id, attribute_type, string_array);        std::string name_string(&string_array[0]);        mUnlimitedDimensionName = name_string;        H5Aread( unit_attribute_id, attribute_type, string_array);        std::string unit_string(&string_array[0]);        mUnlimitedDimensionUnit = unit_string;        free(string_array);        H5Tclose(attribute_type);        H5Aclose(name_attribute_id);        H5Aclose(unit_attribute_id);    }    else if (DoesDatasetExist("Time"))    {        mUnlimitedDimensionName = "Time";        mUnlimitedDimensionUnit = "msec";        mUnlimitedDatasetId = H5Dopen(mFileId, mUnlimitedDimensionName.c_str());    }    else    {        NEVER_REACHED;    }    mIsUnlimitedDimensionSet = true;}
开发者ID:getshameer,项目名称:Chaste,代码行数:49,


示例21: e5_read_attr_list

estatus_te5_read_attr_list(    hid_t e5_group_id, e5_attr* e5_attr_list){    int i;    estatus_t status = E5_SUCCESS;    hid_t h5_type;    hid_t h5_native_type;    hid_t h5_space;    hid_t e5_attribute_id;    for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)    {        e5_attr *attr = &e5_attr_list[i];        if(attr->name == 0 || strlen(attr->name) < 1)            continue;        e5_info(e5_group_id, "Reading attribute [name='%s']/n", attr->name);        if(H5Aexists(e5_group_id, attr->name) <= 0)        {            status = E5_INVALID_ATTRIBUTE;            e5_error(e5_group_id, status, "Invalid name requested for attribute [type='%d', name='%s', value='%p']/n",  attr->type, attr->name, attr->value);            continue;        }        e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);        h5_type = H5Aget_type(e5_attribute_id);        h5_space = H5Aget_space(e5_attribute_id);        h5_native_type = e5_get_native_h5_type(h5_type);        attr->type = e5_convert_hdf_type(h5_type);        if(e5_is_valid_type(attr->type) != E5_TRUE)        {            status = E5_INVALID_TYPE;            e5_error(e5_group_id, status, "Invalid type requested for attribute [type='%d', name='%s', value='%p']/n",  attr->type, attr->name, attr->value);            continue;        }        H5Aread(e5_attribute_id, h5_native_type, attr->value);        H5Aclose(e5_attribute_id);        e5_info(e5_group_id, "Read attribute [type='%s', name='%s', value='%p']/n",            e5_typename(attr->type), attr->name, attr->value);    }    return status;}
开发者ID:voidcycles,项目名称:void,代码行数:49,


示例22: ABCA_ASSERT

voidReadStringT<std::string,char>( hid_t iParent,                               const std::string &iAttrName,                               std::string &oString ){    ABCA_ASSERT( iParent >= 0, "Invalid parent in ReadStringT" );    // Open the attribute.    hid_t attrId = H5Aopen( iParent, iAttrName.c_str(), H5P_DEFAULT );    ABCA_ASSERT( attrId >= 0,                 "Couldn't open attribute named: " << iAttrName );    AttrCloser attrCloser( attrId );    // Checking code.    hid_t attrFtype = H5Aget_type( attrId );    DtypeCloser dtypeCloser( attrFtype );    ssize_t numChars = H5Tget_size( attrFtype );    ABCA_ASSERT( numChars >= 0,                 "ReadStringT() H5Aget_size() failed" );    // Read and check space    {        hid_t attrSpace = H5Aget_space( attrId );        ABCA_ASSERT( attrSpace >= 0,                     "Couldn't get dataspace for attribute: " << iAttrName );        DspaceCloser dspaceCloser( attrSpace );                H5S_class_t attrSpaceClass = H5Sget_simple_extent_type( attrSpace );        ABCA_ASSERT( attrSpaceClass == H5S_SCALAR,                     "Tried to read non-scalar attribute: " << iAttrName                     << " as scalar" );    }    // Create temporary char storage buffer.    std::vector<char> charStorage( ( size_t )( 1 + numChars ),                                   ( char )0 );    // Read into it.    herr_t status = H5Aread( attrId, attrFtype,                             ( void * )&charStorage.front() );    ABCA_ASSERT( status >= 0, "Couldn't read from attribute: " << iAttrName );    // Return it.    oString = ( const char * )&charStorage.front();}
开发者ID:ryutaro765,项目名称:Alembic,代码行数:46,


示例23: NC4_get_propattr

static intNC4_get_propattr(NC_HDF5_FILE_INFO_T* h5){    int ncstat = NC_NOERR;    size_t size;    H5T_class_t t_class;    hid_t grp = -1;    hid_t attid = -1;    hid_t aspace = -1;    hid_t atype = -1;    hid_t ntype = -1;    herr_t herr = 0;    char* text = NULL;    /* Get root group */    grp = h5->root_grp->hdf_grpid; /* get root group */    /* Try to extract the NCPROPS attribute */    if(H5Aexists(grp,NCPROPS) > 0) { /* Does exist */        attid = H5Aopen_name(grp, NCPROPS);	herr = -1;	aspace = H5Aget_space(attid); /* dimensions of attribute data */        atype = H5Aget_type(attid);	/* Verify that atype and size */	t_class = H5Tget_class(atype);	if(t_class != H5T_STRING) {ncstat = NC_EATTMETA; goto done;}        size = H5Tget_size(atype);	if(size == 0) goto done;	text = (char*)malloc(size+1);	if(text == NULL)	    {ncstat = NC_ENOMEM; goto done;}        HCHECK((ntype = H5Tget_native_type(atype, H5T_DIR_ASCEND)));        HCHECK((H5Aread(attid, ntype, text)));	/* Make sure its null terminated */	text[size] = '/0';	/* Try to parse text */	ncstat = NC4_properties_parse(&h5->fileinfo->propattr,text);	herr = 0;    }done:    if(attid >= 0) HCHECK((H5Aclose(attid)));    if(aspace >= 0) HCHECK((H5Sclose(aspace)));    if(ntype >= 0) HCHECK((H5Tclose(ntype)));    if(atype >= 0) HCHECK((H5Tclose(atype)));    if(text != NULL) free(text);    return ncstat;}
开发者ID:balborian,项目名称:libmesh,代码行数:46,


示例24: H5Aget_type

char HVLStringAttribute::read(std::string & str){		hid_t ftype = H5Aget_type(fObjectId);    H5T_class_t type_class = H5Tget_class (ftype);       if (type_class != H5T_STRING) {		std::cout<<"/n type class is not H5T_STRING";		return HStringAttribute::read(str);	}    	char * t[1];	herr_t status = H5Aread(fObjectId, dataType(), &t);	if(status < 0)		return 0;	str = std::string(t[0]);	free( t[0]);	return 1;}
开发者ID:spinos,项目名称:aphid,代码行数:18,


示例25: h5_att_str

void h5_att_str(hid_t file_id, char *group, char *name, char *value){  int ii, kk;  void *buf = NULL;  hid_t attr_id;  H5O_info_t object_info;  char *attr_name = (char *) MALLOC(sizeof(char)*50);  H5Oget_info_by_name(file_id, group, &object_info, H5P_DEFAULT);  for (ii=0; ii<object_info.num_attrs; ii++) {    attr_id = H5Aopen_by_idx(file_id, group, H5_INDEX_NAME, H5_ITER_NATIVE, ii,      H5P_DEFAULT, H5P_DEFAULT);    H5Aget_name(attr_id, 50, attr_name);    if (strcmp_case(name, attr_name) == 0) {      hid_t attr_type = H5Aget_type(attr_id);      H5T_class_t data_type = H5Tget_native_type(attr_type, H5T_DIR_DEFAULT);      size_t data_size = H5Tget_size(data_type);      hid_t attr_space = H5Aget_space(attr_id);      hsize_t dims[H5S_MAX_RANK];      int rank = H5Sget_simple_extent_dims(attr_space, dims, NULL);      hsize_t elements = 1;      for (kk=0; kk<rank; kk++)        elements *= dims[kk];      buf = (void *) MALLOC((unsigned)(elements*data_size));      H5Aread(attr_id, attr_type, buf);      H5Tclose(attr_type);      H5Tclose(data_type);      H5Sclose(attr_space);    }    else {      H5Aclose(attr_id);      continue;    }    H5Aclose(attr_id);  }  if (buf) {    strcpy(value, buf);    FREE(buf);  }  else    strcpy(value, "???");  FREE(attr_name);}
开发者ID:khogenso,项目名称:ASF_MapReady,代码行数:43,


示例26: NC4_get_propattr

static intNC4_get_propattr(NC_HDF5_FILE_INFO_T* h5){    int ncstat = NC_NOERR;    size_t size;    H5T_class_t t_class;	    char text[NCPROPS_LENGTH+1];    hid_t grp = -1;    hid_t attid = -1;    hid_t aspace = -1;    hid_t atype = -1;    hid_t ntype = -1;    herr_t herr = 0;    /* Get root group */    grp = h5->root_grp->hdf_grpid; /* get root group */    /* Try to extract the NCPROPS attribute */    attid = H5Aopen_name(grp, NCPROPS);    if(attid >= 0) {	herr = -1;	aspace = H5Aget_space(attid); /* dimensions of attribute data */        atype = H5Aget_type(attid);	/* Verify that atype and size */	t_class = H5Tget_class(atype);	if(t_class != H5T_STRING) {ncstat = NC_EATTMETA; goto done;}        size = H5Tget_size(atype);	if(size != NCPROPS_LENGTH) {ncstat = NC_EATTMETA; goto done;}        HCHECK((ntype = H5Tget_native_type(atype, H5T_DIR_ASCEND)));        HCHECK((H5Aread(attid, ntype, text)));	/* Try to parse text */	strncpy(h5->fileinfo->propattr.text,text,NCPROPS_LENGTH);	h5->fileinfo->propattr.text[NCPROPS_LENGTH-1] = '/0';	ncstat = NC4_properties_parse(&h5->fileinfo->propattr);	herr = 0;    }    done:    if(attid >= 0) HCHECK((H5Aclose(attid)));    if(aspace >= 0) HCHECK((H5Sclose(aspace)));    if(ntype >= 0) HCHECK((H5Tclose(ntype)));    if(atype >= 0) HCHECK((H5Tclose(atype)));    return ncstat;}
开发者ID:jarlela,项目名称:netcdf-c,代码行数:42,


示例27: hdf5_object

hdf5_datatype::hdf5_datatype(hdf5_annotation const& annotation)    :      hdf5_object(H5Aget_type(annotation.get_id())),      type_class_(H5Tget_class(get_id())){    if(annotation.get_id() < 0) {        boost::serialization::throw_exception(            hdf5_archive_exception(                hdf5_archive_exception::hdf5_archive_annotation_access_error            )        );    }    if(get_id() < 0) {        boost::serialization::throw_exception(            hdf5_archive_exception(                hdf5_archive_exception::hdf5_archive_datatype_access_error            )        );    }}
开发者ID:christoph-weinrich,项目名称:serialization,代码行数:20,


示例28: h5_read_attribute

 /// Return the attribute name of obj, and "" if the attribute does not exist. void h5_read_attribute(hid_t id, std::string const &name, std::string & s) {  s = "";  // if the attribute is not present, return 0  if (H5LTfind_attribute(id, name.c_str()) == 0) return; // not present  attribute attr = H5Aopen(id, name.c_str(), H5P_DEFAULT);  if (!attr.is_valid()) TRIQS_RUNTIME_ERROR << "Cannot open the attribute " << name;  dataspace space = H5Aget_space(attr);  int rank = H5Sget_simple_extent_ndims(space);  if (rank != 0) TRIQS_RUNTIME_ERROR << "Reading a string attribute and got rank !=0";  datatype strdatatype = H5Aget_type(attr);  std::vector<char> buf(H5Aget_storage_size(attr) + 1, 0x00);  auto err = H5Aread(attr, strdatatype, (void *)(&buf[0]));  if (err < 0) TRIQS_RUNTIME_ERROR << "Cannot read the attribute " << name;  s.append(&(buf.front())); }
开发者ID:JaksaVucicevic,项目名称:triqs,代码行数:23,


示例29: throw

 void DCAttribute::readAttribute(const char* name, hid_t parent, void* dst) throw (DCException) {     hid_t attr = H5Aopen(parent, name, H5P_DEFAULT);     if (attr < 0)         throw DCException(getExceptionString(name, "Attribute could not be opened for reading"));          hid_t attr_type = H5Aget_type(attr);     if (attr_type < 0)     {         H5Aclose(attr);         throw DCException(getExceptionString(name, "Could not get type of attribute"));     }          if (H5Aread(attr, attr_type, dst) < 0)     {         H5Aclose(attr);         throw DCException(getExceptionString(name, "Attribute could not be read"));     }          H5Aclose(attr); }
开发者ID:PrometheusPi,项目名称:libSplash,代码行数:22,



注:本文中的H5Aget_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ H5Aopen函数代码示例
C++ H2W_DBG函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。