【发布时间】:2014-05-15 13:42:47
【问题描述】:
我尝试读取属性的内容。我使用 C++ 和 HDF5 API。 我的脚本如下所示:
#include <iostream>
#include <string>
#ifndef H5_NO_NAMESPACE
#ifndef H5_NO_STD
using std::cout;
using std::endl;
#endif // H5_NO_STD
#endif
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
const H5std_string FILE_NAME ("file.h5");
const H5std_string GROUP_NAME_what ("here/where");
int main (void)
{
H5File file( FILE_NAME, H5F_ACC_RDONLY );
/*
* open Group and Attribute
*/
Group what= file.openGroup( GROUP_NAME_what );
Attribute attr = what.openAttribute("lat");
H5std_string test;
DataType type = attr.getDataType();
attr.read(type,test);
cout << test << endl;
return 0;
}
test应该写的是:
ATTRIBUTE "lat" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SCALAR
DATA {
(0): 48.3515
}
}
但我得到的是:
lÐÞþ,H@
谁能告诉我我做错了什么?
坦克很多!
【问题讨论】:
标签: c++ attributes hdf5