// 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_STARTSWITHCONSTRAINT_H #define IGLOO_STARTSWITHCONSTRAINT_H #include "./expressions/expression.h" namespace snowhouse { template struct StartsWithConstraint : Expression< StartsWithConstraint > { StartsWithConstraint(const ExpectedType& expected) : m_expected(expected) {} bool operator()(const std::string& actual) const { return actual.find(m_expected) == 0; } ExpectedType m_expected; }; template< typename ExpectedType > inline StartsWithConstraint StartsWith(const ExpectedType& expected) { return StartsWithConstraint(expected); } inline StartsWithConstraint StartsWith(const char* expected) { return StartsWithConstraint(expected); } template< typename ExpectedType > struct Stringizer< StartsWithConstraint< ExpectedType > > { static std::string ToString(const StartsWithConstraint& constraint) { std::ostringstream builder; builder << "starts with " << snowhouse::Stringize(constraint.m_expected); return builder.str(); } }; } #endif