1 #ifndef PARSERS_CONNECTIONSPARSER_HPP 2 #define PARSERS_CONNECTIONSPARSER_HPP 4 #include <nlohmann/json.hpp> 7 #include "../QuantumSystem/Parameters.hpp" 8 #include "../QuantumSystem/Connections.hpp" 26 for (
auto element : connection)
28 if (element.is_array())
45 for (
auto el : jsonConnection)
48 connection = el.get<Connection>();
50 else if (el.is_number_float() or el.is_number_integer())
51 value = el.get<
double>();
55 connection = jsonConnection.get<Connection>();
67 Connections connections;
68 for (
auto jsonConnection : parameterConnections)
70 Connection connection;
71 double value{defaultValue};
73 connections.map[connection] = value;
88 static ParametersConnections
Parse(
json &jsonConnections, T ¶meters)
90 ParametersConnections parConn;
91 for (
auto parameterConnectionsItem : jsonConnections.items())
93 json ¶meterConnections = parameterConnectionsItem.value();
94 const std::string &key = parameterConnectionsItem.key();
95 double defaultValue = parameters[key];
nlohmann::json json
Definition: ConnectionsParser.hpp:5
static ParametersConnections Parse(json &jsonConnections, T ¶meters)
Parsing json object to ParametersConnetions.
Definition: ConnectionsParser.hpp:88
static Connections GetAllConnections(json ¶meterConnections, double defaultValue)
Get the all Connections objects from json object.
Definition: ConnectionsParser.hpp:65
parsing connections from JSON file
Definition: ConnectionsParser.hpp:14
static void GetConnection(json &jsonConnection, Connection &connection, double &value)
Get the Connection object.
Definition: ConnectionsParser.hpp:41
static bool HasArray(json &connection)
checks if one of the item in json is an array
Definition: ConnectionsParser.hpp:24