collection of helper methods to load in pairs, triplets or vectors of doubles from JSON files
More...
|
std::pair< double, double > | readPair (pt::ptree &tree) |
|
std::pair< std::string, std::string > | readStringPair (pt::ptree &tree) |
|
std::array< double, 3 > | readTriplet (pt::ptree &tree) |
|
std::vector< double > | readVector (pt::ptree &tree) |
|
collection of helper methods to load in pairs, triplets or vectors of doubles from JSON files
JSONReadersHelper.h
- Date
- 21.09.2022
- Author
- Tobias Stockmanns t.sto.nosp@m.ckma.nosp@m.nns@f.nosp@m.z-ju.nosp@m.elich.nosp@m..de
◆ readPair()
std::pair<double, double> JSONReaders::readPair |
( |
pt::ptree & |
tree | ) |
|
|
inline |
Definition at line 29 of file JSONReadersHelper.h.
References max(), and min().
31 if (tree.size() != 2) {
32 throw std::range_error(
"Expected two values e.g min/max not " + std::to_string(tree.size()));
35 auto it = tree.begin();
36 double min = it->second.get_value<
double>();
38 double max = it->second.get_value<
double>();
39 return std::make_pair(min, max);
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
◆ readStringPair()
std::pair<std::string, std::string> JSONReaders::readStringPair |
( |
pt::ptree & |
tree | ) |
|
|
inline |
Definition at line 42 of file JSONReadersHelper.h.
44 if (tree.size() != 2) {
45 throw std::range_error(
"Expected two values e.g min/max not " + std::to_string(tree.size()));
48 auto it = tree.begin();
49 std::string first = it->second.data();
51 std::string second = it->second.data();
52 return std::make_pair(first, second);
◆ readTriplet()
std::array<double, 3> JSONReaders::readTriplet |
( |
pt::ptree & |
tree | ) |
|
|
inline |
Definition at line 55 of file JSONReadersHelper.h.
57 if (tree.size() != 3) {
58 throw std::range_error(
"Expected three values e.g x/y/z not " + std::to_string(tree.size()));
61 std::array<double, 3> xyz;
63 for (
auto val : tree) {
64 xyz[index++] = val.second.get_value<
double>();
◆ readVector()
std::vector<double> JSONReaders::readVector |
( |
pt::ptree & |
tree | ) |
|
|
inline |
Definition at line 69 of file JSONReadersHelper.h.
71 std::vector<double> result;
72 for (
auto val : tree) {
73 result.push_back(val.second.get_value<
double>());