7 #ifndef IGLOO_EXPRESSIONBUILDER_H 8 #define IGLOO_EXPRESSIONBUILDER_H 14 template <
typename Constra
intListType,
typename ActualType>
15 inline void EvaluateConstraintList(ConstraintListType& constraint_list, ResultStack& result, OperatorStack& operators,
const ActualType& actual)
17 constraint_list.m_head.Evaluate(constraint_list, result, operators, actual);
20 template <
typename ActualType>
21 inline void EvaluateConstraintList(Nil&, ResultStack&, OperatorStack&,
const ActualType&) {}
24 template <
typename Constra
intListType>
31 template <
typename ExpectedType>
33 EqualTo(
const ExpectedType& expected)
38 ConstraintAdapterType constraint(expected);
41 return BuilderType(Concatenate(m_constraint_list, node));
44 template <
typename ExpectedType,
typename DeltaType>
46 EqualToWithDelta(
const ExpectedType& expected,
const DeltaType& delta)
54 return BuilderType(Concatenate(m_constraint_list, node));
57 template <
typename MatcherType>
59 Fulfilling(
const MatcherType& matcher)
64 ConstraintAdapterType constraint(matcher);
67 return BuilderType(Concatenate(m_constraint_list, node));
73 return EqualTo<bool>(
false);
79 return EqualTo<bool>(
true);
83 EqualTo(
const char* expected)
85 return EqualTo<std::string>(std::string(expected));
88 template <
typename ExpectedType>
90 GreaterThan(
const ExpectedType& expected)
95 ConstraintAdapterType constraint(expected);
97 return BuilderType(Concatenate(m_constraint_list, node));
100 template <
typename ExpectedType>
102 LessThan(
const ExpectedType& expected)
107 ConstraintAdapterType constraint(expected);
109 return BuilderType(Concatenate(m_constraint_list, node));
112 template <
typename ExpectedType>
114 Containing(
const ExpectedType& expected)
119 ConstraintAdapterType constraint(expected);
121 return BuilderType(Concatenate(m_constraint_list, node));
125 Containing(
const char* expected)
127 return Containing<std::string>(std::string(expected));
130 template <
typename ExpectedType>
132 EndingWith(
const ExpectedType& expected)
137 ConstraintAdapterType constraint(expected);
139 return BuilderType(Concatenate(m_constraint_list, node));
143 EndingWith(
const char* expected)
145 return EndingWith(std::string(expected));
148 template <
typename ExpectedType>
150 StartingWith(
const ExpectedType& expected)
155 ConstraintAdapterType constraint(expected);
157 return BuilderType(Concatenate(m_constraint_list, node));
161 StartingWith(
const char* expected)
163 return StartingWith(std::string(expected));
166 template <
typename ExpectedType>
168 OfLength(
const ExpectedType& expected)
173 ConstraintAdapterType constraint(expected);
175 return BuilderType(Concatenate(m_constraint_list, node));
184 ConstraintAdapterType constraint(0);
186 return BuilderType(Concatenate(m_constraint_list, node));
189 template <
typename ExpectedType>
191 EqualToContainer(
const ExpectedType& expected)
193 typedef bool (*DefaultBinaryPredivateType)(
const typename ExpectedType::value_type&,
const typename ExpectedType::value_type&);
199 return BuilderType(Concatenate(m_constraint_list, node));
202 template <
typename ExpectedType,
typename BinaryPredicate>
204 EqualToContainer(
const ExpectedType& expected,
const BinaryPredicate predicate)
211 return BuilderType(Concatenate(m_constraint_list, node));
227 AllOperatorNode node(op,
Nil());
228 return BuilderType(Concatenate(m_constraint_list, node));
235 AtLeastOperatorNode node(op,
Nil());
236 return BuilderType(Concatenate(m_constraint_list, node));
243 ExactlyOperatorNode node(op,
Nil());
244 return BuilderType(Concatenate(m_constraint_list, node));
251 AtMostOperatorNode node(op,
Nil());
252 return BuilderType(Concatenate(m_constraint_list, node));
259 NoneOperatorNode node(op,
Nil());
260 return BuilderType(Concatenate(m_constraint_list, node));
267 AndOperatorNode node(op,
Nil());
268 return BuilderType(Concatenate(m_constraint_list, node));
275 OrOperatorNode node(op,
Nil());
276 return BuilderType(Concatenate(m_constraint_list, node));
283 NotOperatorNode node(op,
Nil());
284 return BuilderType(Concatenate(m_constraint_list, node));
287 template <
typename ActualType>
288 void Evaluate(ResultStack& result, OperatorStack& operators,
const ActualType& actual)
290 EvaluateConstraintList(m_constraint_list, result, operators, actual);
293 ConstraintListType m_constraint_list;
296 template <
typename T>
297 inline void StringizeConstraintList(
const T& list, std::ostringstream& stm)
302 stm << snowhouse::Stringize(list.m_head);
303 StringizeConstraintList(list.m_tail, stm);
306 inline void StringizeConstraintList(
const Nil&, std::ostringstream&)
310 template<
typename Constra
intListType>
315 std::ostringstream stm;
316 StringizeConstraintList(builder.m_constraint_list, stm);
Definition: notoperator.h:12
Definition: expressionbuilder.h:25
Definition: andoperator.h:12
Definition: constraintadapter.h:13
Definition: alloperator.h:14
Definition: constraintlist.h:17
Definition: exactlyoperator.h:12
Definition: equalswithdeltaconstraint.h:15
Definition: stringize.h:71
Definition: equalscontainerconstraint.h:21
Definition: noneoperator.h:12
Definition: atleastoperator.h:14
Definition: constraintlist.h:31
Definition: oroperator.h:12
Definition: atmostoperator.h:12