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 17 of file JSONReadersHelper.h.
References max(), and min().
19 if (tree.size() != 2) {
20 throw std::range_error(
"Expected two values e.g min/max not " + std::to_string(tree.size()));
23 auto it = tree.begin();
24 double min = it->second.get_value<
double>();
26 double max = it->second.get_value<
double>();
27 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 30 of file JSONReadersHelper.h.
32 if (tree.size() != 2) {
33 throw std::range_error(
"Expected two values e.g min/max not " + std::to_string(tree.size()));
36 auto it = tree.begin();
37 std::string first = it->second.data();
39 std::string second = it->second.data();
40 return std::make_pair(first, second);
◆ readTriplet()
std::array<double, 3> JSONReaders::readTriplet |
( |
pt::ptree & |
tree | ) |
|
|
inline |
Definition at line 43 of file JSONReadersHelper.h.
45 if (tree.size() != 3) {
46 throw std::range_error(
"Expected three values e.g x/y/z not " + std::to_string(tree.size()));
49 std::array<double, 3> xyz;
51 for (
auto val : tree) {
52 xyz[index++] = val.second.get_value<
double>();
◆ readVector()
std::vector<double> JSONReaders::readVector |
( |
pt::ptree & |
tree | ) |
|
|
inline |
Definition at line 57 of file JSONReadersHelper.h.
59 std::vector<double> result;
60 for (
auto val : tree) {
61 result.push_back(val.second.get_value<
double>());