• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ H5Aget_type函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了H5Aget_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:Citcoms_Hdf2Vtk.c


示例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,代码来源:h5Dataset.c


示例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,代码来源:attribute.cpp


示例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,代码来源:ah5_attribute.c


示例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,代码来源:VsH5Attribute.C


示例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,代码来源:Citcoms_Hdf2Vtk.c


示例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,代码来源:hdf5internals.cpp


示例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,代码来源:nxvgroup.c


示例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,代码来源:file.c


示例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,代码来源:genomedata_load_data.c


示例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,代码来源:nxvgroup.c


示例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,代码来源:H5Attribute.cpp


示例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,代码来源:Citcoms_Hdf2Vtk.c


示例14: H5Aget_type

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Aget_type
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL
Java_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,代码来源:h5aImp.c


示例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,代码来源:Citcoms_Hdf2Vtk.c


示例16: ReadStringsT

void
ReadStringsT( 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,代码来源:StringReadUtil.cpp


示例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,代码来源:make_raw_csk.c


示例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_f
nh5aget_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,代码来源:H5Af.c


示例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,代码来源:gh5_convenience.cpp


示例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,代码来源:AbstractHdf5Access.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ H5Aopen函数代码示例发布时间:2022-05-30
下一篇:
C++ H2W_DBG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap