本文整理汇总了C++中nexus::File::getPath方法的典型用法代码示例。如果您正苦于以下问题:C++ File::getPath方法的具体用法?C++ File::getPath怎么用?C++ File::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nexus::File
的用法示例。
在下文中一共展示了File::getPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readMuonLogData
bool MuonNexusReader::readMuonLogData(NeXus::File &handle) {
const string NAME("name");
const string VALUES("values");
const string TIME("time");
// read name of Log data
string dataName;
handle.readData(NAME, dataName);
// read data values
try {
handle.openData(VALUES);
} catch (NeXus::Exception &) {
g_log.warning() << "No " << VALUES << " set in " << handle.getPath()
<< "\n";
return false;
}
std::vector<float> values;
std::vector<std::string> stringValues;
bool isNumeric(false);
NeXus::Info info = handle.getInfo();
if (info.type == NX_FLOAT32 && info.dims.size() == 1) {
isNumeric = true;
boost::scoped_array<float> dataVals(new float[info.dims[0]]);
handle.getData(dataVals.get());
values.assign(dataVals.get(), dataVals.get() + info.dims[0]);
stringValues.resize(info.dims[0]); // Leave empty
} else if (info.type == NX_CHAR && info.dims.size() == 2) {
boost::scoped_array<char> dataVals(
new char[info.dims[0] * info.dims[1] + 1]);
handle.getData(dataVals.get());
dataVals[info.dims[0] * info.dims[1]] = 0;
for (int i = 0; i < info.dims[0]; ++i) {
std::string str(&dataVals[i * info.dims[1]],
&dataVals[(i + 1) * info.dims[1]]);
stringValues.push_back(str);
}
values.resize(info.dims[0]); // Leave empty
} else {
// Leave both empty
values.resize(info.dims[0]);
stringValues.resize(info.dims[0]);
}
handle.closeData();
// read time values
try {
handle.openData(TIME);
} catch (NeXus::Exception &) {
g_log.warning() << "No " << TIME << " set in " << handle.getPath() << "\n";
return false;
}
info = handle.getInfo();
boost::scoped_array<float> timeVals(new float[info.dims[0]]);
if (info.type == NX_FLOAT32 && info.dims.size() == 1) {
handle.getData(timeVals.get());
} else {
throw std::runtime_error(
"Error in MuonNexusReader: expected float array for log times");
}
handle.closeData();
// Add loaded values to vectors
logNames.push_back(dataName);
std::vector<float> tmp(timeVals.get(), timeVals.get() + info.dims[0]);
logTimes.push_back(tmp);
logType.push_back(isNumeric);
logValues.push_back(values);
logStringValues.push_back(stringValues);
return true;
}