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

C++ H5Aopen函数代码示例

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

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



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

示例1: fname

AccessTraceReader::AccessTraceReader(std::string _fname) : fname(_fname.c_str()) {
    hid_t fid = H5Fopen(fname.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
    if (fid == H5I_INVALID_HID) panic("Could not open HDF5 file %s", fname.c_str());

    // Check that the trace finished
    hid_t fAttr = H5Aopen(fid, "finished", H5P_DEFAULT);
    uint32_t finished;
    H5Aread(fAttr, H5T_NATIVE_UINT, &finished);
    H5Aclose(fAttr);

    if (!finished) panic("Trace file %s unfinished (halted simulation?)", fname.c_str());

    // Populate numRecords & numChildren
    hsize_t nPackets;
    hid_t table = H5PTopen(fid, "accs");
    if (table == H5I_INVALID_HID) panic("Could not open HDF5 packet table");
    H5PTget_num_packets(table, &nPackets);
    numRecords = nPackets;

    hid_t ncAttr = H5Aopen(fid, "numChildren", H5P_DEFAULT);
    H5Aread(ncAttr, H5T_NATIVE_UINT, &numChildren);
    H5Aclose(ncAttr);

    curFrameRecord = 0;
    cur = 0;
    max = MIN(PT_CHUNKSIZE, numRecords);
    buf = max? gm_calloc<PackedAccessRecord>(max) : nullptr;

    if (max) {
        H5PTread_packets(table, 0, max, buf);
    }

    H5PTclose(table);
    H5Fclose(fid);
}
开发者ID:Luffy0011,项目名称:zsim,代码行数:35,代码来源:access_tracing.cpp


示例2: AH5_write_str_root_attr

char AH5_write_str_root_attr(hid_t loc_id, const char *attr_name, const char *wdata)
{
  char success = AH5_FALSE;

  hid_t aid = H5Screate(H5S_SCALAR);
  hid_t atype = H5Tcopy(H5T_C_S1);
  htri_t attr_exists = H5Aexists(loc_id, attr_name);
  hid_t attr = -1;

  H5Tset_size(atype, strlen(wdata));

  if (atype >= 0) {
    if (attr_exists == 0) {
      attr = H5Acreate(loc_id, attr_name, atype, aid, H5P_DEFAULT, H5P_DEFAULT);
    } else if (attr_exists > 0) {
      attr = H5Aopen(loc_id, attr_name, H5P_DEFAULT);
    }

    if (attr && H5Awrite(attr, atype, wdata) >= 0 && H5Aclose(attr) >= 0)
      success = AH5_TRUE;
  }

  success &= (H5Tclose(atype) >= 0);
  success &= (H5Sclose(aid) >= 0);

  return success;
}
开发者ID:axessim,项目名称:amelethdf-c,代码行数:27,代码来源:ah5_general.c


示例3: e5_write_attr_list_double

int
e5_write_attr_list_double(
    hid_t e5_group_id, e5_attr_double* e5_attr_list)
{
    int i;
    hid_t e5_attribute_id;
    hid_t e5_dataspace_id = H5Screate(H5S_SCALAR);
    for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)
    {
        e5_attr_double *attr = &e5_attr_list[i];
        if(attr->name == 0 || strlen(attr->name) < 1)
            continue;

        if(H5Aexists(e5_group_id, attr->name) <= 0)
            e5_attribute_id = H5Acreate(e5_group_id, attr->name, H5T_IEEE_F64LE, e5_dataspace_id, H5P_DEFAULT);
        else
            e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);

        e5_info(e5_group_id, "Adding attribute [type='double', name='%s', value='%f']\n",  attr->name, attr->value);

        H5Awrite(e5_attribute_id, H5T_NATIVE_DOUBLE, &(attr->value));
        H5Aclose(e5_attribute_id);
    }
    H5Sclose(e5_dataspace_id);
    return E5_SUCCESS;
}
开发者ID:voidcycles,项目名称:void,代码行数:26,代码来源:e5.c


示例4: readIntAttribute

static int readIntAttribute(int _iDatasetId, const char *_pstName)
{
    hid_t iAttributeId;
    herr_t status;
    int iVal = -1;
    hsize_t n = 0;

    if (H5Aiterate(_iDatasetId, H5_INDEX_NAME, H5_ITER_NATIVE, &n, find_attr_by_name, (void *)_pstName) > 0)
    {
        iAttributeId = H5Aopen(_iDatasetId, _pstName, H5P_DEFAULT);
        if (iAttributeId < 0)
        {
            return -1;
        }

        status = H5Aread(iAttributeId, H5T_NATIVE_INT, &iVal);
        if (status < 0)
        {
            return -1;
        }

        status = H5Aclose(iAttributeId);
        if (status < 0)
        {
            return -1;
        }
    }
    return iVal;
}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:29,代码来源:h5_readDataFromFile.c


示例5: e5_write_attr_list_str

estatus_t
e5_write_attr_list_str(
    hid_t e5_group_id, e5_attr_str* e5_attr_list)
{
    int i;
    hid_t e5_attribute_id;
    hid_t e5_dataspace_id = H5Screate(H5S_SCALAR);
    hid_t e5_string_type = H5Tcopy(H5T_C_S1);
    H5Tset_size(e5_string_type, E5_MAX_ATTR_STRING_LENGTH);
    for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)
    {
        e5_attr_str *attr = &e5_attr_list[i];
        if(attr->name == 0 || strlen(attr->name) < 1)
            continue;

        if(attr->value == 0 || strlen(attr->value) < 1)
            continue;

        if(H5Aexists(e5_group_id, attr->name) <= 0)
            e5_attribute_id = H5Acreate(e5_group_id, attr->name, e5_string_type, e5_dataspace_id, H5P_DEFAULT);
        else
            e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);

        e5_info(e5_group_id, "Adding attribute [type='string', name='%s', value='%s']\n",  attr->name, attr->value);

        H5Awrite(e5_attribute_id, e5_string_type, &(attr->value));
        H5Aclose(e5_attribute_id);
    }
    H5Sclose(e5_dataspace_id);
    return E5_SUCCESS;
}
开发者ID:voidcycles,项目名称:void,代码行数:31,代码来源:e5.c


示例6: throw

    void DCAttribute::writeAttribute(const char* name, const hid_t type, hid_t parent,
                                     uint32_t ndims, const Dimensions dims, const void* src)
    throw (DCException)
    {
        hid_t attr = -1;
        if (H5Aexists(parent, name))
            attr = H5Aopen(parent, name, H5P_DEFAULT);
        else
        {
            hid_t dsp;
            if( ndims == 1 && dims.getScalarSize() == 1 )
                dsp = H5Screate(H5S_SCALAR);
            else
                dsp = H5Screate_simple( ndims, dims.getPointer(), dims.getPointer() );

            attr = H5Acreate(parent, name, type, dsp, H5P_DEFAULT, H5P_DEFAULT);
            H5Sclose(dsp);
        }

        if (attr < 0)
            throw DCException(getExceptionString(name, "Attribute could not be opened or created"));

        if (H5Awrite(attr, type, src) < 0)
        {
            H5Aclose(attr);
            throw DCException(getExceptionString(name, "Attribute could not be written"));
        }

        H5Aclose(attr);
    }
开发者ID:Flamefire,项目名称:libSplash,代码行数:30,代码来源:DCAttribute.cpp


示例7: e5_read_attr_list_float

estatus_t
e5_read_attr_list_float(
    hid_t e5_group_id, e5_attr_float* e5_attr_list)
{
    int i;
    hid_t e5_attribute_id;
    estatus_t status = E5_SUCCESS;

    for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)
    {
        e5_attr_float *attr = &e5_attr_list[i];
        if(attr->name == 0 || strlen(attr->name) < 1)
            continue;

        if(H5Aexists(e5_group_id, attr->name) <= 0)
        {
            status = E5_INVALID_ATTRIBUTE;
            e5_error(e5_group_id, status, "Specified attribute '%s' does not exist\n", attr->name);
            continue;
        }

        e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);
        H5Aread(e5_attribute_id, H5T_NATIVE_FLOAT, &(attr->value));
        H5Aclose(e5_attribute_id);

        e5_info(e5_group_id, "Read attribute [type='float', name='%s', value='%f']\n",  attr->name, attr->value);
    }
    return status;
}
开发者ID:voidcycles,项目名称:void,代码行数:29,代码来源:e5.c


示例8: write_internal

	void write_internal(hdf5dataset& hdataset, const std::string& name, hid_t type_id, const void* buffer, bool overwrite)
	{
		bool exists = H5Aexists(hdataset.handle(), name.c_str());
		hid_t attribute_id = -1;
		if(exists && overwrite)
		{
			attribute_id = H5Aopen(hdataset.handle(), name.c_str(), H5P_DEFAULT);
			//H5Ldelete(_hfile.handle(), name.c_str(), H5P_DEFAULT);
		}
		else if(exists && !overwrite)
			throw std::runtime_error("Attribute already exists: (" + name + ")");
		else
		{
			hsize_t dims = 1;
			hid_t space_id = H5Screate_simple(1, &dims, NULL);

			attribute_id = H5Acreate(hdataset.handle(), name.c_str(), type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
			H5Sclose(space_id);
		}

		if(attribute_id < 0)
			throw std::runtime_error("Error creating or opening attribute () in file (" + name + ")");

		H5Awrite(attribute_id, type_id, buffer);
		H5Tclose(type_id);
		H5Aclose(attribute_id);
	}
开发者ID:klindworth,项目名称:cvwidgets,代码行数:27,代码来源:hdf5internals.cpp


示例9: utils_hdf5_check_attr

escdf_errno_t utils_hdf5_check_attr(hid_t loc_id, const char *name,
                                    hsize_t *dims, unsigned int ndims,
                                    hid_t *attr_pt)
{
    hid_t attr_id, dtspace_id;

    if ((attr_id = H5Aopen(loc_id, name, H5P_DEFAULT)) < 0)
        RETURN_WITH_ERROR(attr_id);

    /* Check space dimensions. */
    if ((dtspace_id = H5Aget_space(attr_id)) < 0) {
        DEFER_FUNC_ERROR(dtspace_id);
        goto cleanup_attr;
    }
    if (utils_hdf5_check_shape(dtspace_id, dims, ndims) != ESCDF_SUCCESS) {
        goto cleanup_dtspace;
    }
    H5Sclose(dtspace_id);
    if (attr_pt)
        *attr_pt = attr_id;
    else
        H5Aclose(attr_id);
    return ESCDF_SUCCESS;

    cleanup_dtspace:
    H5Sclose(dtspace_id);
    cleanup_attr:
    H5Aclose(attr_id);
    return ESCDF_ERROR;
}
开发者ID:thomas-ruh,项目名称:libescdf,代码行数:30,代码来源:utils_hdf5.c


示例10: e5_read_attr_list_str

estatus_t
e5_read_attr_list_str(
    hid_t e5_group_id, e5_attr_str* e5_attr_list)
{
    int i;
    estatus_t status = E5_SUCCESS;

    hid_t e5_attribute_id;
    hid_t e5_dataspace_id = H5Screate(H5S_SCALAR);
    hid_t e5_string_type = H5Tcopy(H5T_C_S1);
    H5Tset_size(e5_string_type, E5_MAX_ATTR_STRING_LENGTH);

    for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)
    {
        e5_attr_str *attr = &e5_attr_list[i];
        if(attr->name == 0 || strlen(attr->name) < 1)
            continue;

        if(H5Aexists(e5_group_id, attr->name) <= 0)
        {
            status = E5_INVALID_ATTRIBUTE;
            e5_error(e5_group_id, status, "Specified attribute '%s' does not exist\n", attr->name);
            continue;
        }

        e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);
        H5Aread(e5_attribute_id, e5_string_type, &(attr->value));
        H5Aclose(e5_attribute_id);

        e5_info(e5_group_id, "Read attribute [type='str', name='%s', value='%s']\n",  attr->name, attr->value);
    }
    H5Sclose(e5_dataspace_id);
    return status;
}
开发者ID:voidcycles,项目名称:void,代码行数:34,代码来源:e5.c


示例11: e5_write_attr_list

estatus_t
e5_write_attr_list(
    hid_t e5_group_id, e5_attr* e5_attr_list)
{
    int i;
    eid_t status = E5_SUCCESS;
    hid_t e5_attribute_id;
    hid_t e5_dataspace_id = H5Screate(H5S_SCALAR);
    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;

        if(e5_is_valid_type(e5_attr_list[i].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;
        }

        hid_t hdf_type = e5_convert_type_to_hdf(e5_attr_list[i].type);
        hid_t hdf_format = e5_convert_format_to_hdf(e5_attr_list[i].type);

        if(H5Aexists(e5_group_id, attr->name) <= 0)
            e5_attribute_id = H5Acreate(e5_group_id, attr->name, hdf_type, e5_dataspace_id, H5P_DEFAULT);

        e5_info(e5_group_id, "Adding attribute [type='integer', name='%s', value='%d']\n",  attr->name, attr->value);
        e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);
        H5Awrite(e5_attribute_id, hdf_format, &(attr->value));
        H5Aclose(e5_attribute_id);
    }
    H5Sclose(e5_dataspace_id);
    return E5_SUCCESS;
}
开发者ID:voidcycles,项目名称:void,代码行数:35,代码来源:e5.c


示例12: open

hid_t seissol::checkpoint::h5::Fault::initFile(int odd, const char* filename)
{
	hid_t h5file;

	if (loaded()) {
		// Open the file
		h5file = open(filename, false);
		checkH5Err(h5file);

		// Fault writer
		m_h5timestepFault[odd] = H5Aopen(h5file, "timestep_fault", H5P_DEFAULT);
		checkH5Err(m_h5timestepFault[odd]);

		// Data
		for (unsigned int i = 0; i < NUM_VARIABLES; i++) {
			m_h5data[odd][i] = H5Dopen(h5file, VAR_NAMES[i], H5P_DEFAULT);
			checkH5Err(m_h5data[odd][i]);
		}
	} else {
		// Create the file
		hid_t h5plist = H5Pcreate(H5P_FILE_ACCESS);
		checkH5Err(h5plist);
		checkH5Err(H5Pset_libver_bounds(h5plist, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST));
#ifdef USE_MPI
		checkH5Err(H5Pset_fapl_mpio(h5plist, comm(), MPI_INFO_NULL));
#endif // USE_MPI

		h5file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, h5plist);
		checkH5Err(h5file);
		checkH5Err(H5Pclose(h5plist));

		// Create scalar dataspace for attributes
		hid_t h5spaceScalar = H5Screate(H5S_SCALAR);
		checkH5Err(h5spaceScalar);

		// Fault writer
		m_h5timestepFault[odd] = H5Acreate(h5file, "timestep_fault",
				H5T_STD_I32LE, h5spaceScalar, H5P_DEFAULT, H5P_DEFAULT);
		checkH5Err(m_h5timestepFault[odd]);
		int t = 0;
		checkH5Err(H5Awrite(m_h5timestepFault[odd], H5T_NATIVE_INT, &t));

		checkH5Err(H5Sclose(h5spaceScalar));

		// Variables
		for (unsigned int i = 0; i < NUM_VARIABLES; i++) {
			h5plist = H5Pcreate(H5P_DATASET_CREATE);
			checkH5Err(h5plist);
			checkH5Err(H5Pset_layout(h5plist, H5D_CONTIGUOUS));
			checkH5Err(H5Pset_alloc_time(h5plist, H5D_ALLOC_TIME_EARLY));
			m_h5data[odd][i] = H5Dcreate(h5file, VAR_NAMES[i], H5T_IEEE_F64LE, m_h5fSpaceData,
				H5P_DEFAULT, h5plist, H5P_DEFAULT);
			checkH5Err(m_h5data[odd][i]);
			checkH5Err(H5Pclose(h5plist));
		}
	}

	return h5file;
}
开发者ID:fsimonis,项目名称:SeisSol,代码行数:59,代码来源:Fault.cpp


示例13: 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


示例14: 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


示例15: 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


示例16: H5Aopen

bool seissol::checkpoint::h5::Wavefield::validate(hid_t h5file) const
{
	// Turn of error printing
	H5ErrHandler errHandler;

	// Check #partitions
	hid_t h5attr = H5Aopen(h5file, "partitions", H5P_DEFAULT);
	if (h5attr < 0) {
		logWarning(rank()) << "Checkpoint does not have a partition attribute.";
		return false;
	}

	int p;
	herr_t err = H5Aread(h5attr, H5T_NATIVE_INT, &p);
	checkH5Err(H5Aclose(h5attr));
	if (err < 0 || p != partitions()) {
		logWarning(rank()) << "Partitions in checkpoint do not match.";
		return false;
	}

	// Check dimensions
	hid_t h5data = H5Dopen(h5file, "values", H5P_DEFAULT);
	if (h5data < 0) {
		logWarning(rank()) << "Checkpoint does not contains a data array.";
		return false;
	}

	hid_t h5space = H5Dget_space(h5data);
	checkH5Err(H5Dclose(h5data));
	if (h5space < 0) {
		logWarning(rank()) << "Could not get space identifier in checkpoint.";
		return false;
	}

	bool isValid = true;

	int dims = H5Sget_simple_extent_ndims(h5space);
	if (dims != 1) {
		isValid = false;
		logWarning(rank()) << "Number of dimensions in checkpoint does not match.";
	} else {
		hsize_t dimSize;
		if (H5Sget_simple_extent_dims(h5space, &dimSize, 0L) != 1) {
			isValid = false;
			logWarning(rank()) << "Could not get dimension sizes of checkpoint.";
		} else {
			if (dimSize != numTotalElems()) {
				isValid = false;
				logWarning(rank()) << "Number of elements in checkpoint does not match.";
			}
		}
	}
	checkH5Err(H5Sclose(h5space));

	return isValid;
}
开发者ID:jjww2015,项目名称:SeisSol,代码行数:56,代码来源:Wavefield.cpp


示例17: THROW

void 
HDF5Attribute::open(const HDF5Id location_id, const String &name)
{
    if (isValid()) {
        THROW(Iex::IoExc, "Tried to open attribute that has already "
                          "been opened or created");
    }
    
    m_id = H5Aopen(location_id, name.c_str(), H5P_DEFAULT);
}
开发者ID:papaver,项目名称:nkhive,代码行数:10,代码来源:HDF5Attribute.cpp


示例18: H5Object

H5Attribute::H5Attribute(H5Object & _parent, const std::string & _name) : H5Object(_parent, _name)
{
    if (H5Aexists(getParent().getH5Id(), name.c_str()) <= 0)
    {
        throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute: %s"), name.c_str());
    }

    attr = H5Aopen(getParent().getH5Id(), name.c_str(), H5P_DEFAULT);
    if (attr < 0)
    {
        throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute: %s"), name.c_str());
    }
}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:13,代码来源:H5Attribute.cpp


示例19: H5Aopen

//--------------------------------------------------------------------------
// Function:	H5Object::openAttribute
///\brief	Opens an attribute given its name.
///\param	name - IN: Name of the attribute
///\return	Attribute instance
///\exception	H5::AttributeIException
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Attribute H5Object::openAttribute( const char* name ) const
{
   hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT);
   if( attr_id > 0 )
   {
      Attribute attr( attr_id );
      return( attr );
   }
   else
   {
      throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed");
   }
}
开发者ID:VisBlank,项目名称:hdf5,代码行数:21,代码来源:H5Object.cpp


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ H5Aread函数代码示例发布时间:2022-05-30
下一篇:
C++ H5Aget_type函数代码示例发布时间: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