------------------------------------------------------------------------------ Read an integer value
| 289 | //------------------------------------------------------------------------------ |
| 290 | // Read an integer value |
| 291 | int 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 | //------------------------------------------------------------------------------ |
| 336 | int vtkMNIObjectReader::ReadProperty(vtkProperty* property) |
no test coverage detected