24#include "openPMD/config.hpp"
27#include <nlohmann/json.hpp>
43 enum class SupportedLanguages
51 nlohmann::json config = nlohmann::json::object();
52 SupportedLanguages originallySpecifiedAs{SupportedLanguages::JSON};
72 TracingJSON(nlohmann::json, SupportedLanguages);
80 nlohmann::json &
json();
91 nlohmann::json &
json(std::vector<std::string> path);
93 template <
typename Key>
94 TracingJSON operator[](Key &&key);
122 SupportedLanguages originallySpecifiedAs{SupportedLanguages::JSON};
131 std::shared_ptr<nlohmann::json> m_originalJSON;
141 std::shared_ptr<nlohmann::json> m_shadow;
147 nlohmann::json *m_positionInOriginal;
153 nlohmann::json *m_positionInShadow;
158 std::deque<std::string> m_positionForErrorMessages;
162 nlohmann::json &result, nlohmann::json
const &shadow)
const;
165 std::shared_ptr<nlohmann::json> originalJSON,
166 std::shared_ptr<nlohmann::json> shadow,
167 nlohmann::json *positionInOriginal,
168 nlohmann::json *positionInShadow,
169 std::deque<std::string> positionForErrorMessages,
170 SupportedLanguages originallySpecifiedAs,
180 nlohmann::json
const &original,
181 nlohmann::json &shadow,
182 std::deque<std::string> &positionForErrorMessages);
185 template <
typename Key>
188 nlohmann::json *newPositionInOriginal =
189 &m_positionInOriginal->operator[](key);
192 static nlohmann::json nullvalue;
193 nlohmann::json *newPositionInShadow = &nullvalue;
194 if (m_trace && m_positionInOriginal->is_object())
196 newPositionInShadow = &m_positionInShadow->operator[](key);
198 bool traceFurther = newPositionInOriginal->is_object();
199 auto new_path = m_positionForErrorMessages;
200 new_path.push_back(std::forward<Key>(key));
204 newPositionInOriginal,
207 originallySpecifiedAs,
211 nlohmann::json tomlToJson(toml::value
const &val);
212 toml::value jsonToToml(nlohmann::json
const &val);
226 ParsedConfig parseOptions(
227 std::string
const &options,
229 bool convertLowercase =
true);
236 ParsedConfig parseOptions(
237 std::string
const &options,
240 bool convertLowercase =
true);
253 nlohmann::json &lowerCase(nlohmann::json &);
262 std::optional<std::string> asStringDynamic(nlohmann::json
const &);
267 std::optional<std::string> asLowerCaseStringDynamic(nlohmann::json
const &);
273 constexpr std::array<char const *, 4> backendKeys{
274 "adios2",
"json",
"toml",
"hdf5"};
282 void warnGlobalUnusedOptions(
TracingJSON const &config);
288 nlohmann::json &merge_internal(
289 nlohmann::json &defaultVal,
290 nlohmann::json
const &overwrite,
293 nlohmann::json &filterByTemplate(
294 nlohmann::json &defaultVal, nlohmann::json
const &positiveMask);
296 template <
typename toml_t>
297 std::string format_toml(toml_t &&);
Extend nlohmann::json with tracing of which keys have been accessed by operator[]().
Definition JSON_internal.hpp:69
void declareFullyRead()
Declare all keys of the current object read.
Definition JSON.cpp:141
nlohmann::json invertShadow() const
Invert the "shadow", i.e.
Definition JSON.cpp:98
nlohmann::json const & getShadow() const
Get the "shadow", i.e.
Definition JSON.cpp:88
nlohmann::json & json()
Access the underlying JSON value.
Definition JSON.cpp:65
Public definitions of openPMD-api.
Definition Date.cpp:29
Definition JSON_internal.hpp:50