本文整理汇总了C++中H5Location::attrExists方法的典型用法代码示例。如果您正苦于以下问题:C++ H5Location::attrExists方法的具体用法?C++ H5Location::attrExists怎么用?C++ H5Location::attrExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类H5Location
的用法示例。
在下文中一共展示了H5Location::attrExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setAttributeAsArray
//Create array of type TYPE, versus setAttributeArray that creates a scalar of type array
int ArfFileBase::setAttributeAsArray(DataTypes type, void* data, int size, String path, String name)
{
H5Location* loc;
Group gloc;
DataSet dloc;
Attribute attr;
DataType H5type;
DataType origType;
if (!opened) return -1;
try
{
try
{
gloc = file->openGroup(path.toUTF8());
loc = &gloc;
}
catch (FileIException error) //If there is no group with that path, try a dataset
{
dloc = file->openDataSet(path.toUTF8());
loc = &dloc;
}
H5type = getH5Type(type);
origType = getNativeType(type);
hsize_t dims = size;
if (loc->attrExists(name.toUTF8()))
{
attr = loc->openAttribute(name.toUTF8());
}
else
{
DataSpace attr_dataspace(1, &dims); //create a 1d simple dataspace of len SIZE
attr = loc->createAttribute(name.toUTF8(),H5type,attr_dataspace);
}
attr.write(origType,data);
}
catch (GroupIException error)
{
PROCESS_ERROR;
}
catch (AttributeIException error)
{
PROCESS_ERROR;
}
catch (DataSetIException error)
{
PROCESS_ERROR;
}
catch (FileIException error)
{
PROCESS_ERROR;
}
return 0;
}
示例2: type
int HDF5FileBase::setAttributeStr(String value, String path, String name)
{
H5Location* loc;
Group gloc;
DataSet dloc;
Attribute attr;
if (!opened) return -1;
StrType type(PredType::C_S1, value.length());
try
{
try
{
gloc = file->openGroup(path.toUTF8());
loc = &gloc;
}
catch (FileIException error) //If there is no group with that path, try a dataset
{
dloc = file->openDataSet(path.toUTF8());
loc = &dloc;
}
if (loc->attrExists(name.toUTF8()))
{
//attr = loc.openAttribute(name.toUTF8());
return -1; //string attributes cannot change size easily, better not allow overwritting.
}
else
{
DataSpace attr_dataspace(H5S_SCALAR);
attr = loc->createAttribute(name.toUTF8(), type, attr_dataspace);
}
attr.write(type,value.toUTF8());
}
catch (GroupIException error)
{
PROCESS_ERROR;
}
catch (AttributeIException error)
{
PROCESS_ERROR;
}
catch (FileIException error)
{
PROCESS_ERROR;
}
catch (DataSetIException error)
{
PROCESS_ERROR;
}
return 0;
}
示例3: type
int HDF5FileBase::setAttributeStrArray(Array<const char*>& data, int maxSize, String path, String name)
{
H5Location* loc;
Group gloc;
DataSet dloc;
Attribute attr;
hsize_t dims[1];
if (!opened) return -1;
StrType type(PredType::C_S1, maxSize + 1);
type.setSize(H5T_VARIABLE);
try
{
try
{
gloc = file->openGroup(path.toUTF8());
loc = &gloc;
}
catch (FileIException error) //If there is no group with that path, try a dataset
{
dloc = file->openDataSet(path.toUTF8());
loc = &dloc;
}
if (loc->attrExists(name.toUTF8()))
{
//attr = loc.openAttribute(name.toUTF8());
return -1; //string attributes cannot change size easily, better not allow overwritting.
}
else
{
DataSpace attr_dataspace;
int nStrings = data.size();
if (nStrings > 1)
{
dims[0] = nStrings;
attr_dataspace = DataSpace(1, dims);
}
else
attr_dataspace = DataSpace(H5S_SCALAR);
attr = loc->createAttribute(name.toUTF8(), type, attr_dataspace);
}
attr.write(type, data.getRawDataPointer());
}
catch (GroupIException error)
{
PROCESS_ERROR;
}
catch (AttributeIException error)
{
PROCESS_ERROR;
}
catch (FileIException error)
{
PROCESS_ERROR;
}
catch (DataSetIException error)
{
PROCESS_ERROR;
}
return 0;
}