本文整理汇总了C++中Var::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Var::getSize方法的具体用法?C++ Var::getSize怎么用?C++ Var::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Var
的用法示例。
在下文中一共展示了Var::getSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: C
void bi::InputNetCDFBuffer::readMask0(const VarType type,
Mask<ON_HOST>& mask) {
typedef temp_host_matrix<real>::type temp_matrix_type;
mask.resize(m.getNumVars(type), false);
Var* var;
int r;
long start, len;
/* sparse masks */
for (r = 0; r < int(recDims.size()); ++r) {
if (timeVars[r] < 0) {
BOOST_AUTO(range, modelVars.equal_range(r));
BOOST_AUTO(iter, range.first);
BOOST_AUTO(end, range.second);
start = 0;
len = nc_inq_dimlen(ncid, recDims[r]);
temp_matrix_type C(iter->second->getNumDims(), len);
readCoords(coordVars[r], start, len, C);
for (; iter != end; ++iter) {
var = iter->second;
if (var->getType() == type) {
mask.addSparseMask(var->getId(), C.size2());
serialiseCoords(var, C, mask.getIndices(var->getId()));
}
}
}
}
/* dense masks */
r = -1; // for those vars not associated with a record dimension
BOOST_AUTO(range, modelVars.equal_range(r));
BOOST_AUTO(iter, range.first);
BOOST_AUTO(end, range.second);
for (; iter != end; ++iter) {
var = iter->second;
if (var->getType() == type) {
mask.addDenseMask(var->getId(), var->getSize());
}
}
}
示例2: parseLogHeaders
//.........这里部分代码省略.........
/* <log_file_name> <data_type> <units> <param_name>
or
<log_file_name> byte_order is [lit|big]_endian
*/
if ( sscanf(line, "%s %s %s %s", str1, str2, str3, str4) == 4 ) {
// Byte order statement and top of a log group?
if (!strcmp(str2, "byte_order")) {
LogData *ld = new LogData;
log.push_back(ld);
currLogData = log[nGroups_];
nGroups_++;
// New binary file
currLogData->setBinaryFileName(str1);
// Set byte order
if (!strcmp(str4, "big_endian")) {
currLogData->dataByteOrder = 1;
} else {
currLogData->dataByteOrder = 0;
}
continue;
}
// Check for binary file name mismatches
if (strcmp(str1, currLogData->getBinaryFileName())) {
printf("ERROR: Parsing log header \"%s\".\n"
" Line %d. Binary file name "
"mismatch with \"%s\".\n"
" May need little/big endian "
"specification.\n\n",
headerName, lineNum,
currLogData->getBinaryFileName());
return (-1);
}
// New variable
Var *v = new Var;
currLogData->vars.push_back(v);
nVars = currLogData->getNumVars();
currVar = currLogData->vars[nVars];
nVars++;
currLogData->setNumVars(nVars);
// Set Type
if (currVar->setType(str2) < 0) {
printf("ERROR: In log header \"%s\".\n"
" Line %d. Type \"%s\" is "
"not supported.\n",
headerName, lineNum, str2);
return (-1);
}
// For Release-07 we need to convert the old unit specs by
// adding explicit asterisk for multiplication. )
{
char new_units_spec[100];
new_units_spec[0] = 0;
if ( convert_units_spec (str3, new_units_spec) != 0 ) {
printf (" ERROR: Attempt to convert old units-spec, \"%s\" failed.\n\n",str3);
return (-1);
}
delete [] str3;
len = strlen(new_units_spec);
str3 = new char[len + 1] ;
strcpy(str3, new_units_spec);
}
// Initialize Unit class
if ( ! strcmp(str3,"--")) {
currVar->setUnit(str3);
} else {
currVar->setUnit(map_trick_units_to_udunits(str3));
}
// Set Var Name
currVar->setVarName(str4) ;
if (currVar->getSize() < 0) {
printf("ERROR: In log header \"%s\".\n"
" Line %d. Problem with var "
"name \"%s\" . \n",
headerName, lineNum, str4);
return (-1);
}
}
}
fclose(fp_);
delete[]line;
delete[]str1;
delete[]str2;
delete[]str3;
delete[]str4;
delete[]headerName;
}
return 1;
}