35#include <boost/algorithm/string.hpp>
54 std::string fp = R
"(-?\d+\.?\d*(?:e[+-]\d+)?|-?nan)";
60 m_regex = R
"(^EV:\s+\d+\s+()" + fp + ")\\s+(" + fp +
").*";
63 TiXmlElement *value = metric->FirstChildElement(
"value");
68 ASSERTL0(value->Attribute(
"tolerance"),
69 "Missing tolerance in eigenvalue metric");
71 "Missing value in preconditioner metric.");
76 std::string cmplx = value->GetText();
77 std::vector<std::string> cmpts;
78 boost::split(cmpts, cmplx, boost::is_any_of(
","));
80 "Value should be magnitude and angle, separated by comma");
84 mag.
m_tolerance = atof(value->Attribute(
"tolerance"));
88 angle.
m_tolerance = atof(value->Attribute(
"tolerance"));
92 std::vector<MetricRegexFieldValue> tmp(2);
102 value = value->NextSiblingElement(
"value");
115 for (
int i = 0; i <
m_matches.size(); ++i)
118 "Wrong number of matches for regular expression.");
121 TiXmlElement *value =
new TiXmlElement(
"value");
128 value->SetAttribute(
"index",
m_matches[i][0].m_value);
129 value->SetAttribute(
"tolerance", tol);
130 value->LinkEndChild(
new TiXmlText(
m_matches[i][1].m_value +
"," +
#define ASSERTL0(condition, msg)
static MetricSharedPtr create(TiXmlElement *metric, bool generate)
static std::string defaultTolerance
std::string m_varTolerance
MetricEigenvalue(TiXmlElement *metric, bool generate)
void v_Generate(std::istream &pStdout, std::istream &pStderr) override
Virtual function to generate the metric. Should be redefined in derived classes.
std::string RegisterCreatorFunction(std::string key, CreatorFunction func)
TiXmlElement * m_metric
Pointer to XML structure containing metric definition.
bool m_generate
Determines whether to generate this metric or not.
bool m_unordered
If true, regex matches may be in any order in output.
void v_Generate(std::istream &pStdout, std::istream &pStderr) override
Test output against a regex expression and set of matches.
std::vector< std::vector< MetricRegexFieldValue > > m_matches
Stores the multiple matches defined in each <MATCH> tag.
std::regex m_regex
Storage for the boost regex.
bool EmptyString(const char *s)
Check to see whether the given string s is empty (or null).
MetricFactory & GetMetricFactory()
Data structure for a Regex value to match.