1 // Copyright (c) 2001-2011 Hartmut Kaiser 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #if !defined(BOOST_SPIRIT_KARMA_STRING_COMPARE_AUG_08_2009_0756PM) 7 #define BOOST_SPIRIT_KARMA_STRING_COMPARE_AUG_08_2009_0756PM 8 9 #if defined(_MSC_VER) 10 #pragma once 11 #endif 12 13 #include <boost/spirit/home/support/char_class.hpp> 14 #include <boost/spirit/home/karma/detail/generate_to.hpp> 15 16 namespace boost { namespace spirit { namespace karma { namespace detail 17 { 18 template <typename Char> string_compare(Char const * attr,Char const * lit)19 bool string_compare(Char const* attr, Char const* lit) 20 { 21 Char ch_attr = *attr; 22 Char ch_lit = *lit; 23 24 while (!!ch_lit && !!ch_attr) 25 { 26 if (ch_attr != ch_lit) 27 return false; 28 29 ch_attr = *++attr; 30 ch_lit = *++lit; 31 } 32 33 return !ch_lit && !ch_attr; 34 } 35 36 template <typename Char> string_compare(Char const * attr,Char const * lit,unused_type,unused_type)37 bool string_compare(Char const* attr, Char const* lit, unused_type, unused_type) 38 { 39 return string_compare(attr, lit); 40 } 41 42 template <typename Char> string_compare(unused_type,Char const *,unused_type,unused_type)43 bool string_compare(unused_type, Char const*, unused_type, unused_type) 44 { 45 return true; 46 } 47 48 template <typename Char, typename CharEncoding, typename Tag> string_compare(Char const * attr,Char const * lit,CharEncoding,Tag)49 bool string_compare(Char const* attr, Char const* lit, CharEncoding, Tag) 50 { 51 Char ch_attr = *attr; 52 Char ch_lit = spirit::char_class::convert<CharEncoding>::to(Tag(), *lit); 53 54 while (!!ch_lit && !!ch_attr) 55 { 56 if (ch_attr != ch_lit) 57 return false; 58 59 ch_attr = *++attr; 60 ch_lit = spirit::char_class::convert<CharEncoding>::to(Tag(), *++lit); 61 } 62 63 return !ch_lit && !ch_attr; 64 } 65 66 template <typename Char, typename CharEncoding, typename Tag> string_compare(unused_type,Char const *,CharEncoding,Tag)67 bool string_compare(unused_type, Char const*, CharEncoding, Tag) 68 { 69 return true; 70 } 71 72 }}}} 73 74 #endif 75