------------------------------------------------------------------------------
| 373 | |
| 374 | //------------------------------------------------------------------------------ |
| 375 | bool vtkHDRReader::ReadHeaderData() |
| 376 | { |
| 377 | vtkResourceStream* stream = this->GetStream(); |
| 378 | vtkNew<vtkFileResourceStream> fileStream; |
| 379 | if (!stream) |
| 380 | { |
| 381 | if (!fileStream->Open(this->InternalFileName)) |
| 382 | { |
| 383 | vtkErrorMacro("Could not open file " << this->InternalFileName); |
| 384 | return false; |
| 385 | } |
| 386 | stream = fileStream; |
| 387 | } |
| 388 | stream->Seek(0, vtkResourceStream::SeekDirection::Begin); |
| 389 | |
| 390 | int headersize = 0; |
| 391 | |
| 392 | vtkNew<vtkResourceParser> parser; |
| 393 | parser->SetStream(stream); |
| 394 | |
| 395 | std::string str; |
| 396 | vtkTypeInt64 cur = parser->Tell(); |
| 397 | vtkParseResult res = parser->ReadLine(str); |
| 398 | if (res == vtkParseResult::Error) |
| 399 | { |
| 400 | vtkErrorMacro("Error reading program type"); |
| 401 | return false; |
| 402 | } |
| 403 | headersize += parser->Tell() - cur; |
| 404 | |
| 405 | this->ProgramType = str.substr(2); |
| 406 | |
| 407 | // Read header |
| 408 | while (true) |
| 409 | { |
| 410 | cur = parser->Tell(); |
| 411 | res = parser->ReadLine(str); |
| 412 | if (res == vtkParseResult::Error) |
| 413 | { |
| 414 | vtkErrorMacro("Error reading program type"); |
| 415 | return false; |
| 416 | } |
| 417 | headersize += parser->Tell() - cur; |
| 418 | |
| 419 | // EOL |
| 420 | if (str.empty()) |
| 421 | { |
| 422 | break; |
| 423 | } |
| 424 | |
| 425 | // skip comments |
| 426 | if (str.front() == '#') |
| 427 | { |
| 428 | continue; |
| 429 | } |
| 430 | |
| 431 | // Split by '=' |
| 432 | std::string::size_type equalChar = str.find_first_of('='); |