7 #ifndef IGLOO_COLLECTIONCONSTRAINTEVALUATOR_H 8 #define IGLOO_COLLECTIONCONSTRAINTEVALUATOR_H 11 #include "../../../assertionexception.h" 16 template<
typename Constra
intListType,
typename ActualType>
20 ConstraintListType& expression, ResultStack& result,
21 OperatorStack& operators,
const ActualType& actual)
23 ConstraintOperator::EvaluateOperatorsWithLessOrEqualPrecedence(op,
26 unsigned int passed_elements = 0;
27 typename ActualType::const_iterator it;
28 for(it = actual.begin(); it != actual.end(); it++)
30 if(ConstraintOperator::EvaluateElementAgainstRestOfExpression(expression,
37 return passed_elements;
43 static void Parse(
const std::string& str, std::vector<std::string>& res)
46 size_t newline = FindNewline(str, start);
48 while(newline != std::string::npos)
50 StoreLine(str, start, newline, res);
51 start = MoveToNextLine(str, newline);
52 newline = FindNewline(str, start);
55 if(start < str.size())
57 StoreLine(str, start, std::string::npos, res);
62 static size_t FindNewline(
const std::string& str,
size_t start)
64 return str.find_first_of(
"\r\n", start);
67 static void StoreLine(
const std::string& str,
size_t start,
size_t end,
68 std::vector<std::string>& res)
70 std::string line = str.substr(start, end - start);
74 static size_t MoveToNextLine(
const std::string& str,
size_t newline)
76 if(str.find(
"\r\n", newline) == newline)
81 if(str.find(
"\n", newline) == newline)
86 if(str.find(
"\r", newline) == newline)
91 std::ostringstream stm;
92 stm <<
"This string seems to contain an invalid line ending at position " 93 << newline <<
":\n" << str << std::endl;
98 template<
typename Constra
intListType>
102 ConstraintListType& expression, ResultStack& result,
103 OperatorStack& operators,
const std::string& actual)
105 std::vector<std::string> lines;
106 StringLineParser::Parse(actual, lines);
Definition: constraintoperator.h:26
Definition: assertionexception.h:11
Definition: collectionconstraintevaluator.h:17
Definition: collectionconstraintevaluator.h:41