本文整理汇总了C++中HDF5Dataset::CreateAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ HDF5Dataset::CreateAttribute方法的具体用法?C++ HDF5Dataset::CreateAttribute怎么用?C++ HDF5Dataset::CreateAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HDF5Dataset
的用法示例。
在下文中一共展示了HDF5Dataset::CreateAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteAttribute
// writing attribute to the file
void WriteAttribute( RString& rFilename,
RString& rPath,
RVector<int> rIntdata,
RVector<double> rDoubledata,
RString rStrdata,
vector<STLTypes::NameValuePair>& inAttributes, SEXP& results)
{
HDF5DA da(rFilename.Data(0),StringUtils::CompareNoCase(ExtractAttribute(inAttributes,NEWFILE),"true"));
HDF5OutputConverter oc;
string strPath(rPath.Data(0));
// read the compress level
string compressStr = ExtractAttribute(inAttributes,COMPRESSLEVEL);
int compressedLevel = 0;
if ((compressStr.size()>0))
compressedLevel = atoi(compressStr.c_str());
// the dimension of the data to be read
string strRow = ExtractAttribute(inAttributes,ROW);
string strCol = ExtractAttribute(inAttributes,COL);
size_t row=0;
size_t col=0;
if ((strRow.size()>0) && (strCol.size()>0))
{
row = atoi(strRow.c_str());
col = atoi(strCol.c_str());
}
string::size_type index = strPath.find_last_of('/');
if((index == string::npos )||(index==0))
throw RException("Attribute can only be directly under an existing dataset or group.");
string parent = strPath.substr(0,index);
string attr = strPath.substr(index+1,string::npos);
// are we going to overwrite an existing attribute
bool overwrite = StringUtils::CompareNoCase(ExtractAttribute(inAttributes,OVERWRITE),"true");
if(rIntdata.Size()>0)
{
// obtain the data from input
rIntdata.Dimensions(row,col);
Matrix<int> intdata;
rIntdata.Extract(intdata);
if(CheckDataset(da,parent))
{
HDF5Dataset ds = da.OpenDatasetByFullPath(parent);
if (overwrite)
ds.DeleteAttribute(attr);
ds.CreateAttribute(attr,intdata, compressedLevel);
}
else if(CheckGroup(da,parent))
{
HDF5Group gp = da.OpenGroupByFullPath(parent);
if (overwrite)
gp.DeleteAttribute(attr);
gp.CreateAttribute(attr,intdata, compressedLevel);
}
else
throw RException("Attribute can only be directly under an existing dataset or group.");
}
else if(rDoubledata.Size()>0)
{
// obtain the data from input
rDoubledata.Dimensions(row,col);
Matrix<double> doubledata;
rDoubledata.Extract(doubledata);
if(CheckDataset(da,parent))
{
HDF5Dataset ds = da.OpenDatasetByFullPath(parent);
if (overwrite)
ds.DeleteAttribute(attr);
ds.CreateAttribute(attr,doubledata, compressedLevel);
}
else if(CheckGroup(da,parent))
{
HDF5Group gp = da.OpenGroupByFullPath(parent);
if (overwrite)
gp.DeleteAttribute(attr);
gp.CreateAttribute(attr,doubledata, compressedLevel);
}
else
throw RException("Attribute can only be directly under an existing dataset or group.");
}
else if(rStrdata.Size()>0)
{
// obtain the data from input
rStrdata.Dimensions(row,col);
Matrix<string> strdata;
rStrdata.Extract(strdata,row,col);
if(CheckDataset(da,parent))
{
HDF5Dataset ds = da.OpenDatasetByFullPath(parent);
if (overwrite)
ds.DeleteAttribute(attr);
//.........这里部分代码省略.........