当前位置: 首页>>代码示例>>C++>>正文


C++ H5Aget_type函数代码示例

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


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


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