From 05a0f6c868087de660105522e427b75a1644e9b7 Mon Sep 17 00:00:00 2001 From: f0reachARR Date: Thu, 26 Sep 2024 18:09:57 +0900 Subject: [PATCH] Use allocator from parent --- .../src/openscenario_interpreter.cpp | 4 ++-- openscenario/openscenario_interpreter/src/syntax/act.cpp | 2 +- .../openscenario_interpreter/src/syntax/condition_group.cpp | 2 +- openscenario/openscenario_interpreter/src/syntax/event.cpp | 2 +- .../openscenario_interpreter/src/syntax/init_actions.cpp | 6 +++--- .../openscenario_interpreter/src/syntax/maneuver.cpp | 2 +- .../openscenario_interpreter/src/syntax/maneuver_group.cpp | 2 +- .../openscenario_interpreter/src/syntax/private.cpp | 2 +- openscenario/openscenario_interpreter/src/syntax/story.cpp | 2 +- .../openscenario_interpreter/src/syntax/storyboard.cpp | 2 +- .../openscenario_interpreter/src/syntax/trigger.cpp | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openscenario/openscenario_interpreter/src/openscenario_interpreter.cpp b/openscenario/openscenario_interpreter/src/openscenario_interpreter.cpp index 7a45d02711d..188c94816c0 100644 --- a/openscenario/openscenario_interpreter/src/openscenario_interpreter.cpp +++ b/openscenario/openscenario_interpreter/src/openscenario_interpreter.cpp @@ -288,8 +288,8 @@ auto Interpreter::publishCurrentContext() const -> void { Context context; { - nlohmann::json json; - boost::json::object json; + boost::json::monotonic_resource mr; + boost::json::object json(&mr); context.stamp = now(); if (publish_empty_context) { context.data = ""; diff --git a/openscenario/openscenario_interpreter/src/syntax/act.cpp b/openscenario/openscenario_interpreter/src/syntax/act.cpp index 8cb3fde1e6e..5ad07cf8ac8 100644 --- a/openscenario/openscenario_interpreter/src/syntax/act.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/act.cpp @@ -55,7 +55,7 @@ auto operator<<(boost::json::object & json, const Act & datum) -> boost::json::o auto & maneuver_groups = json["ManeuverGroup"].emplace_array(); for (auto && maneuver_group : datum.elements) { - boost::json::object act; + boost::json::object act(json.storage()); act << maneuver_group.as(); maneuver_groups.push_back(std::move(act)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/condition_group.cpp b/openscenario/openscenario_interpreter/src/syntax/condition_group.cpp index 88f5209355d..37567915a9b 100644 --- a/openscenario/openscenario_interpreter/src/syntax/condition_group.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/condition_group.cpp @@ -42,7 +42,7 @@ auto operator<<(boost::json::object & json, const ConditionGroup & datum) -> boo auto & conditions = json["Condition"].emplace_array(); for (const auto & each : datum) { - boost::json::object condition; + boost::json::object condition(json.storage()); condition << each; conditions.push_back(std::move(condition)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/event.cpp b/openscenario/openscenario_interpreter/src/syntax/event.cpp index 6cf85013a78..9b9ffc19dd4 100644 --- a/openscenario/openscenario_interpreter/src/syntax/event.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/event.cpp @@ -79,7 +79,7 @@ auto operator<<(boost::json::object & json, const Event & datum) -> boost::json: auto & actions = json["Action"].emplace_array(); for (const auto & each : datum.elements) { - boost::json::object action; + boost::json::object action(json.storage()); action << each.as(); actions.push_back(std::move(action)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/init_actions.cpp b/openscenario/openscenario_interpreter/src/syntax/init_actions.cpp index 02e01257b1c..d3fa0b4268a 100644 --- a/openscenario/openscenario_interpreter/src/syntax/init_actions.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/init_actions.cpp @@ -160,7 +160,7 @@ auto operator<<(boost::json::object & json, const InitActions & init_actions) auto & global_actions = json["GlobalAction"].emplace_array(); for (const auto & init_action : init_actions.global_actions) { - boost::json::object action; + boost::json::object action(json.storage()); action["type"] = makeTypename(init_action.as().type()); global_actions.push_back(std::move(action)); } @@ -168,7 +168,7 @@ auto operator<<(boost::json::object & json, const InitActions & init_actions) auto & user_defined_actions = json["UserDefinedAction"].emplace_array(); for (const auto & init_action : init_actions.user_defined_actions) { - boost::json::object action; + boost::json::object action(json.storage()); action["type"] = makeTypename(init_action.as().type()); user_defined_actions.push_back(std::move(action)); } @@ -176,7 +176,7 @@ auto operator<<(boost::json::object & json, const InitActions & init_actions) auto & privates = json["Private"].emplace_array(); for (const auto & init_action : init_actions.privates) { - boost::json::object action; + boost::json::object action(json.storage()); action << init_action.as(); privates.push_back(std::move(action)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/maneuver.cpp b/openscenario/openscenario_interpreter/src/syntax/maneuver.cpp index 1d3e009b4fa..8bd3fc45a81 100644 --- a/openscenario/openscenario_interpreter/src/syntax/maneuver.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/maneuver.cpp @@ -73,7 +73,7 @@ auto operator<<(boost::json::object & json, const Maneuver & maneuver) -> boost: auto & events = json["Event"].emplace_array(); for (const auto & event : maneuver.elements) { - boost::json::object json_event; + boost::json::object json_event(json.storage()); json_event << event.as(); events.push_back(std::move(json_event)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/maneuver_group.cpp b/openscenario/openscenario_interpreter/src/syntax/maneuver_group.cpp index 5bc79a3aae8..2a51dd8e0da 100644 --- a/openscenario/openscenario_interpreter/src/syntax/maneuver_group.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/maneuver_group.cpp @@ -72,7 +72,7 @@ auto operator<<(boost::json::object & json, const ManeuverGroup & maneuver_group auto & maneuvers = json["Maneuver"].emplace_array(); for (auto && maneuver : maneuver_group.elements) { - boost::json::object json_maneuver; + boost::json::object json_maneuver(json.storage()); json_maneuver << maneuver.as(); maneuvers.push_back(std::move(json_maneuver)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/private.cpp b/openscenario/openscenario_interpreter/src/syntax/private.cpp index cf68437b37b..998023be639 100644 --- a/openscenario/openscenario_interpreter/src/syntax/private.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/private.cpp @@ -92,7 +92,7 @@ auto operator<<(boost::json::object & json, const Private & datum) -> boost::jso auto & private_actions = json["PrivateAction"].emplace_array(); for (const auto & private_action : datum.private_actions) { - boost::json::object action; + boost::json::object action(json.storage()); action["type"] = makeTypename(private_action.type()); private_actions.push_back(std::move(action)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/story.cpp b/openscenario/openscenario_interpreter/src/syntax/story.cpp index 6ad46132c07..416320742df 100644 --- a/openscenario/openscenario_interpreter/src/syntax/story.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/story.cpp @@ -58,7 +58,7 @@ auto operator<<(boost::json::object & json, const Story & story) -> boost::json: auto & acts = json["Act"].emplace_array(); for (auto && act : story.elements) { - boost::json::object json_act; + boost::json::object json_act(json.storage()); json_act << act.as(); acts.push_back(std::move(json_act)); } diff --git a/openscenario/openscenario_interpreter/src/syntax/storyboard.cpp b/openscenario/openscenario_interpreter/src/syntax/storyboard.cpp index 4c1c86e88d7..71b6b3aed65 100644 --- a/openscenario/openscenario_interpreter/src/syntax/storyboard.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/storyboard.cpp @@ -67,7 +67,7 @@ auto operator<<(boost::json::object & json, const Storyboard & datum) -> boost:: auto & stories = json["Story"].emplace_array(); for (const auto & story : datum.elements) { - boost::json::object each; + boost::json::object each(json.storage()); if (story.is()) { continue; } diff --git a/openscenario/openscenario_interpreter/src/syntax/trigger.cpp b/openscenario/openscenario_interpreter/src/syntax/trigger.cpp index 65d3cffaf76..51ea2dd41b6 100644 --- a/openscenario/openscenario_interpreter/src/syntax/trigger.cpp +++ b/openscenario/openscenario_interpreter/src/syntax/trigger.cpp @@ -70,7 +70,7 @@ auto operator<<(boost::json::object & json, const Trigger & datum) -> boost::jso auto & condition_groups = json["ConditionGroup"].emplace_array(); for (const auto & each : datum) { - boost::json::object condition_group; + boost::json::object condition_group(json.storage()); condition_group << each; condition_groups.push_back(std::move(condition_group)); }