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

Method ParseId

IO/Infovis/vtkBiomTableReader.cxx:578–617  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

576
577//------------------------------------------------------------------------------
578void vtkBiomTableReader::ParseId()
579{
580 bool done = false;
581 size_t pos_start = 0;
582 while (!done)
583 {
584 size_t pos_id = this->FileContents.find("\"id\":", pos_start);
585 if (pos_id == std::string::npos)
586 {
587 vtkErrorMacro(<< "top-level id not found in input file");
588 return;
589 }
590
591 // check that this is the toplevel id by matching preceding brackets
592 std::string substring = this->FileContents.substr(0, pos_id);
593 int numOpenBrackets = std::count(substring.begin(), substring.end(), '[');
594 int numClosedBrackets = std::count(substring.begin(), substring.end(), ']');
595
596 if (numOpenBrackets == numClosedBrackets)
597 {
598 size_t pos_comma = this->FileContents.find(',', pos_id + 1);
599 if (pos_comma == std::string::npos)
600 {
601 vtkErrorMacro(<< "top-level id field not formatted properly");
602 return;
603 }
604 std::string name = this->FileContents.substr(pos_id + 5, pos_comma - pos_id - 5);
605 // remove trailing whitespace in our captured name
606 size_t pos_id_begin = name.find_first_not_of(" \t");
607 name = name.substr(pos_id_begin);
608 // remove double quotes in the name
609 name.erase(remove(name.begin(), name.end(), '\"'), name.end());
610 done = true;
611 }
612 else
613 {
614 pos_start = pos_id + 5;
615 }
616 }
617}
618
619//------------------------------------------------------------------------------
620int vtkBiomTableReader::FillOutputPortInformation(int, vtkInformation* info)

Callers 1

ReadMeshSimpleMethod · 0.95

Calls 6

countFunction · 0.50
removeFunction · 0.50
findMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected