60{
61 for (auto *file = metric->FirstChildElement("file"); file;
62 file = file->NextSiblingElement("file"))
63 {
64 Table table;
65 ASSERTL0(file->Attribute(
"filename"),
66 "Missing filename for TABLE metric file tag.");
67 ASSERTL0(file->Attribute(
"tolerance"),
68 "Missing tolerance for TABLE metric file tag.");
69 table.filename = file->Attribute("filename");
70 table.tolerance = std::stod(file->Attribute("tolerance"));
71 ASSERTL0(std::isfinite(table.tolerance) && table.tolerance >= 0.0,
72 "TABLE metric tolerance must be finite and non-negative.");
73
74 if (!generate)
75 {
76 auto *columns = file->FirstChildElement("columns");
78 "Missing columns for TABLE metric file " + table.filename);
79 const std::string columnText =
82 "Empty columns for TABLE metric file " + table.filename);
85
86 for (auto *row = file->FirstChildElement("row"); row;
87 row = row->NextSiblingElement("row"))
88 {
89 const std::string rowText =
91 ? std::string()
92 : StringUtils::
TrimCopy(row->GetText());
94 "Empty row for TABLE metric file " + table.filename);
95 std::vector<std::string> values;
99 values.size() == table.columns.size(),
100 "TABLE metric row has the wrong number of columns in " +
101 table.filename);
102 std::vector<double> parsed;
103 parsed.reserve(values.size());
104 for (const auto &value : values)
105 {
106 size_t used = 0;
107 double number = std::stod(value, &used);
108 ASSERTL0(used == value.size() && std::isfinite(number),
109 "TABLE metric rows must contain finite numbers.");
110 parsed.push_back(number);
111 }
112 table.rows.push_back(std::move(parsed));
113 }
115 "Missing rows for TABLE metric file " + table.filename);
116 }
117 m_tables.push_back(std::move(table));
118 }
120}
#define ASSERTL0(condition, msg)
Metric(TiXmlElement *metric, bool generate)
Constructor.
std::vector< Table > m_tables
std::string TrimCopy(std::string str)
Container & Split(Container &result, std::string_view input, Pred pred, TokenCompressMode mode=eTokenCompressOff)
Splits input at characters matching pred into result, which is cleared first. An empty input gives a ...
bool EmptyString(const char *s)
Check to see whether the given string s is empty (or null).