----------------------------------------------------------------------------
| 2616 | |
| 2617 | //---------------------------------------------------------------------------- |
| 2618 | bool vtkSMStateVersionController::Process(vtkPVXMLElement* parent, vtkSMSession* session) |
| 2619 | { |
| 2620 | vtkPVXMLElement* root = parent; |
| 2621 | if (parent && strcmp(parent->GetName(), "ServerManagerState") != 0) |
| 2622 | { |
| 2623 | root = root->FindNestedElementByName("ServerManagerState"); |
| 2624 | } |
| 2625 | |
| 2626 | if (!root || strcmp(root->GetName(), "ServerManagerState") != 0) |
| 2627 | { |
| 2628 | vtkErrorMacro("Invalid root element. Expected \"ServerManagerState\""); |
| 2629 | return false; |
| 2630 | } |
| 2631 | |
| 2632 | vtkSMVersion version(0, 0, 0); |
| 2633 | if (const char* str_version = root->GetAttribute("version")) |
| 2634 | { |
| 2635 | auto result = vtk::scan<int, int, int>(std::string_view(str_version), "{:d}.{:d}.{:d}"); |
| 2636 | const auto& [major, minor, patch] = result->values(); |
| 2637 | version = vtkSMVersion(major, minor, patch); |
| 2638 | } |
| 2639 | |
| 2640 | bool status = true; |
| 2641 | if (version < vtkSMVersion(4, 2, 0)) |
| 2642 | { |
| 2643 | vtkWarningMacro( |
| 2644 | "State file version is less than 4.2.0. " |
| 2645 | "We will try to load the state file. It's recommended, however, " |
| 2646 | "that you load the state in ParaView 4.2.0 (up to 5.5.2) and save a newer version " |
| 2647 | "so that it can be loaded more faithfully. " |
| 2648 | "Loading state files generated from ParaView versions older than 4.2.0 " |
| 2649 | "is no longer supported."); |
| 2650 | |
| 2651 | version = vtkSMVersion(4, 2, 0); |
| 2652 | } |
| 2653 | |
| 2654 | // A little hackish for now, convert vtkPVXMLElement to string. |
| 2655 | std::ostringstream stream; |
| 2656 | root->PrintXML(stream, vtkIndent()); |
| 2657 | |
| 2658 | // parse using pugi. |
| 2659 | pugi::xml_document document; |
| 2660 | |
| 2661 | if (!document.load_string(stream.str().c_str())) |
| 2662 | { |
| 2663 | vtkErrorMacro("Failed to convert from vtkPVXMLElement to pugi::xml_document"); |
| 2664 | return false; |
| 2665 | } |
| 2666 | |
| 2667 | if (status && (version < vtkSMVersion(5, 1, 0))) |
| 2668 | { |
| 2669 | status = Process_4_2_to_5_1()(document); |
| 2670 | version = vtkSMVersion(5, 1, 0); |
| 2671 | } |
| 2672 | |
| 2673 | if (status && (version < vtkSMVersion(5, 4, 0))) |
| 2674 | { |
| 2675 | status = Process_5_1_to_5_4()(document); |
no test coverage detected