51 m_regex =
"^L 2 error\\s*(?:\\(variable "
52 "(\\w+)\\))?\\s*:\\s*([+-]?\\d.+\\d|-?\\d|[+-]?nan|[+-]?inf).*";
55 TiXmlElement *value = metric->FirstChildElement(
"value");
62 ASSERTL0(value->Attribute(
"tolerance"),
63 "Missing tolerance in L2 metric");
67 if (value->Attribute(
"variable"))
69 var.
m_value = value->Attribute(
"variable");
75 val.
m_tolerance = atof(value->Attribute(
"tolerance"));
79 std::vector<MetricRegexFieldValue> tmp(2);
89 value = value->NextSiblingElement(
"value");
102 for (
int i = 0; i <
m_matches.size(); ++i)
105 "Wrong number of matches for regular expression.");
109 TiXmlElement *value =
new TiXmlElement(
"value");
113 std::map<std::string, std::string>::iterator it =
124 value->SetAttribute(
"variable",
m_matches[i][0].m_value);
126 if (
m_matches[i][0].m_value ==
"p" && !tolSet)
135 value->SetAttribute(
"tolerance", tol);
136 value->LinkEndChild(
new TiXmlText(
m_matches[i][1].m_value));
#define ASSERTL0(condition, msg)
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.
void v_Generate(std::istream &pStdout, std::istream &pStderr) override
Virtual function to generate the metric. Should be redefined in derived classes.
static MetricSharedPtr create(TiXmlElement *metric, bool generate)
MetricL2(TiXmlElement *metric, bool generate)
std::map< std::string, std::string > m_varTolerance
static std::string defaultTolerance
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.