15#ifndef PFC_TOML_TO_JSON_HPP
16#define PFC_TOML_TO_JSON_HPP
18#include <nlohmann/json.hpp>
19#include <toml++/toml.hpp>
39 for (
const auto &[
key, value] :
table) {
62 case toml::node_type::array: {
63 nlohmann::json
arr = nlohmann::json::array();
70 case toml::node_type::string: {
71 return std::string(
node_ref.as_string()->get());
77 return node_ref.as_floating_point()->get();
86 (
date.month < 10 ?
"0" :
"") +
87 std::to_string(
date.month) +
"-" +
88 (
date.day < 10 ?
"0" :
"") + std::to_string(
date.day);
95 (
time.hour < 10 ?
"0" :
"") + std::to_string(
time.hour) +
":" +
96 (
time.minute < 10 ?
"0" :
"") + std::to_string(
time.minute) +
":" +
97 (
time.second < 10 ?
"0" :
"") + std::to_string(
time.second);
98 if (
time.nanosecond > 0) {
107 std::to_string(
dt.date.year) +
"-" + (
dt.date.month < 10 ?
"0" :
"") +
108 std::to_string(
dt.date.month) +
"-" + (
dt.date.day < 10 ?
"0" :
"") +
109 std::to_string(
dt.date.day) +
"T" + (
dt.time.hour < 10 ?
"0" :
"") +
110 std::to_string(
dt.time.hour) +
":" + (
dt.time.minute < 10 ?
"0" :
"") +
111 std::to_string(
dt.time.minute) +
":" + (
dt.time.second < 10 ?
"0" :
"") +
112 std::to_string(
dt.time.second);
113 if (
dt.time.nanosecond > 0) {
114 dt_str +=
"." + std::to_string(
dt.time.nanosecond);
116 if (
dt.offset.has_value()) {
117 auto offset =
dt.offset.value();
131 return std::string(
node_ref.as_string()->get());
133 return nlohmann::json(
nullptr);
150 return nlohmann::json(
nullptr);
Represents the global simulation domain (the "world").
Definition world.hpp:91
World(const Int3 &lower, const Int3 &upper, const CoordinateSystem< T > &cs)
Constructs a World object.
nlohmann::json toml_to_json(const toml::node &node_ref)
Convert a TOML node to nlohmann::json.
Definition toml_to_json.hpp:57