MCPcopy Create free account
hub / github.com/Kitware/VTK / ParseIdValue

Method ParseIdValue

IO/MINC/vtkMNIObjectReader.cxx:291–333  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Read an integer value

Source from the content-addressed store, hash-verified

289//------------------------------------------------------------------------------
290// Read an integer value
291int vtkMNIObjectReader::ParseIdValue(vtkIdType* value)
292{
293 if (this->FileType == VTK_BINARY)
294 {
295 int val;
296 this->InputStream->read((char*)(&val), sizeof(int));
297 *value = val;
298
299 return !this->InputStream->fail();
300 }
301
302 // The rest of the code is for ASCII files
303 if (!this->SkipWhitespace())
304 {
305 vtkErrorMacro("Unexpected end of file " << this->FileName << ":" << this->LineNumber);
306 return 0;
307 }
308
309 char* cp = this->CharPointer;
310
311 auto result = vtk::scan_int<long long>(std::string_view(cp));
312 auto lval = result ? result->value() : 0;
313 cp = const_cast<char*>(result->range().data());
314 if (lval > static_cast<long long>(VTK_INT_MAX) || lval < static_cast<long long>(VTK_INT_MIN))
315 {
316 vtkErrorMacro(
317 "Value " << lval << " is too large for int " << this->FileName << ":" << this->LineNumber);
318 return 0;
319 }
320
321 *value = static_cast<int>(lval);
322
323 // If no bytes were read, that means there was a syntax error
324 if (cp == this->CharPointer)
325 {
326 vtkErrorMacro("Syntax error " << this->FileName << ":" << this->LineNumber);
327 return 0;
328 }
329
330 this->CharPointer = cp;
331
332 return 1;
333}
334
335//------------------------------------------------------------------------------
336int vtkMNIObjectReader::ReadProperty(vtkProperty* property)

Callers 3

ReadNumberOfPointsMethod · 0.95
ReadNumberOfCellsMethod · 0.95
ReadColorsMethod · 0.95

Calls 5

SkipWhitespaceMethod · 0.95
readMethod · 0.45
valueMethod · 0.45
dataMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected