24 #include "openPMD/config.hpp"
26 #include <nlohmann/json.hpp>
42 enum class SupportedLanguages
50 nlohmann::json config;
51 SupportedLanguages originallySpecifiedAs{SupportedLanguages::JSON};
79 inline nlohmann::json &
json()
81 return *m_positionInOriginal;
84 template <
typename Key>
113 SupportedLanguages originallySpecifiedAs{SupportedLanguages::JSON};
122 std::shared_ptr<nlohmann::json> m_originalJSON;
132 std::shared_ptr<nlohmann::json> m_shadow;
138 nlohmann::json *m_positionInOriginal;
144 nlohmann::json *m_positionInShadow;
148 nlohmann::json &result, nlohmann::json
const &shadow)
const;
151 std::shared_ptr<nlohmann::json> originalJSON,
152 std::shared_ptr<nlohmann::json> shadow,
153 nlohmann::json *positionInOriginal,
154 nlohmann::json *positionInShadow,
155 SupportedLanguages originallySpecifiedAs,
159 template <
typename Key>
160 TracingJSON TracingJSON::operator[](Key &&key)
162 nlohmann::json *newPositionInOriginal =
163 &m_positionInOriginal->operator[](key);
166 static nlohmann::json nullvalue;
167 nlohmann::json *newPositionInShadow = &nullvalue;
168 if (m_trace && m_positionInOriginal->is_object())
170 newPositionInShadow = &m_positionInShadow->operator[](key);
172 bool traceFurther = newPositionInOriginal->is_object();
176 newPositionInOriginal,
178 originallySpecifiedAs,
182 nlohmann::json tomlToJson(toml::value
const &val);
183 toml::value jsonToToml(nlohmann::json
const &val);
194 ParsedConfig parseOptions(std::string
const &options,
bool considerFiles);
202 parseOptions(std::string
const &options, MPI_Comm comm,
bool considerFiles);
215 nlohmann::json &lowerCase(nlohmann::json &);
224 std::optional<std::string> asStringDynamic(nlohmann::json
const &);
229 std::optional<std::string> asLowerCaseStringDynamic(nlohmann::json
const &);
235 extern std::vector<std::string> backendKeys();
243 void warnGlobalUnusedOptions(TracingJSON
const &config);
250 merge(nlohmann::json &defaultVal, nlohmann::json
const &overwrite);
252 nlohmann::json &filterByTemplate(
253 nlohmann::json &defaultVal, nlohmann::json
const &positiveMask);
Extend nlohmann::json with tracing of which keys have been accessed by operator[]().
Definition: JSON_internal.hpp:68
nlohmann::json & json()
Access the underlying JSON value.
Definition: JSON_internal.hpp:79
void declareFullyRead()
Declare all keys of the current object read.
Definition: JSON.cpp:114
nlohmann::json invertShadow() const
Invert the "shadow", i.e.
Definition: JSON.cpp:71
nlohmann::json const & getShadow() const
Get the "shadow", i.e.
Definition: JSON.cpp:61
Public definitions of openPMD-api.
Definition: Date.cpp:29
Definition: JSON_internal.hpp:49