| 584 | } |
| 585 | |
| 586 | bool cfg::node::from_json(const nlohmann::json& json, bool dynamic) |
| 587 | { |
| 588 | if (!json.is_object()) |
| 589 | { |
| 590 | return false; |
| 591 | } |
| 592 | |
| 593 | auto find_node = [this](std::string_view name) -> _base* |
| 594 | { |
| 595 | for (const auto& node : get_nodes()) |
| 596 | { |
| 597 | if (node->get_name() == name) |
| 598 | { |
| 599 | return node; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | return nullptr; |
| 604 | }; |
| 605 | |
| 606 | for (auto& [key, value] : json.get<nlohmann::json::object_t>()) |
| 607 | { |
| 608 | auto keyNode = find_node(key); |
| 609 | |
| 610 | if (keyNode == nullptr || (dynamic && !keyNode->get_is_dynamic())) |
| 611 | { |
| 612 | continue; |
| 613 | } |
| 614 | |
| 615 | keyNode->from_json(value, dynamic); |
| 616 | } |
| 617 | |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | bool cfg::node::from_string(std::string_view value, bool dynamic) |
| 622 | { |
no test coverage detected