------------------------------------------------------------------------------
| 534 | |
| 535 | //------------------------------------------------------------------------------ |
| 536 | void vtkBiomTableReader::ParseRows() |
| 537 | { |
| 538 | // find "rows": |
| 539 | size_t pos_start = this->FileContents.find("\"rows\":"); |
| 540 | if (pos_start == std::string::npos) |
| 541 | { |
| 542 | vtkErrorMacro(<< "rows not found in input file"); |
| 543 | return; |
| 544 | } |
| 545 | |
| 546 | for (int currentRow = 0; currentRow < this->NumberOfRows; ++currentRow) |
| 547 | { |
| 548 | // find id for this row |
| 549 | size_t pos_row_1 = this->FileContents.find("\"id\":", pos_start); |
| 550 | if (pos_row_1 == std::string::npos) |
| 551 | { |
| 552 | vtkErrorMacro(<< "rows field not formatted properly"); |
| 553 | return; |
| 554 | } |
| 555 | size_t pos_row_2 = this->FileContents.find("\", \"metadata\":", pos_row_1); |
| 556 | if (pos_row_2 == std::string::npos) |
| 557 | { |
| 558 | vtkErrorMacro(<< "rows field not formatted properly"); |
| 559 | return; |
| 560 | } |
| 561 | std::string name = this->FileContents.substr(pos_row_1 + 5, pos_row_2 - pos_row_1 - 5); |
| 562 | // remove quotes |
| 563 | name.erase(remove(name.begin(), name.end(), '\"'), name.end()); |
| 564 | // trim whitespace |
| 565 | const size_t beginStr = name.find_first_not_of(" \t"); |
| 566 | const size_t endStr = name.find_last_not_of(" \t"); |
| 567 | const size_t range = endStr - beginStr + 1; |
| 568 | name = name.substr(beginStr, range); |
| 569 | |
| 570 | this->GetOutput()->SetValue(currentRow, 0, vtkVariant(name)); |
| 571 | pos_start = pos_row_2; |
| 572 | |
| 573 | // this is where we would capture the metadata for this row |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | //------------------------------------------------------------------------------ |
| 578 | void vtkBiomTableReader::ParseId() |
no test coverage detected