summaryrefslogtreecommitdiff
path: root/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/oroperator.h
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/oroperator.h')
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/oroperator.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/oroperator.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/oroperator.h
new file mode 100644
index 00000000..5a307ff6
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/oroperator.h
@@ -0,0 +1,55 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef IGLOO_OROPERATOR_H
+#define IGLOO_OROPERATOR_H
+
+namespace snowhouse {
+
+ struct OrOperator : public ConstraintOperator
+ {
+ template <typename ConstraintListType, typename ActualType>
+ void Evaluate(ConstraintListType& list, ResultStack& result, OperatorStack& operators, const ActualType& actual)
+ {
+ EvaluateOperatorsWithLessOrEqualPrecedence(*this, operators, result);
+
+ operators.push(this);
+
+ EvaluateConstraintList(list.m_tail, result, operators, actual);
+ }
+
+ void PerformOperation(ResultStack& result)
+ {
+ if(result.size() < 2)
+ {
+ throw InvalidExpressionException("The expression contains an or operator with too few operands");
+ }
+
+ bool right = result.top();
+ result.pop();
+ bool left = result.top();
+ result.pop();
+
+ result.push(left || right);
+ }
+
+ int Precedence() const
+ {
+ return 4;
+ }
+ };
+
+ template<>
+ struct Stringizer<OrOperator>
+ {
+ static std::string ToString(const OrOperator&)
+ {
+ return "or";
+ }
+ };
+}
+
+#endif