PageRenderTime 36ms CodeModel.GetById 18ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/spirit/home/karma/detail/string_compare.hpp

http://hadesmem.googlecode.com/
C++ Header | 76 lines | 56 code | 16 blank | 4 comment | 10 complexity | b46c288273c0c01913e138f9a36d77bf MD5 | raw file
 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 <string>
14#include <boost/spirit/home/support/char_class.hpp>
15#include <boost/spirit/home/karma/detail/generate_to.hpp>
16#include <boost/range/iterator_range.hpp>
17
18namespace boost { namespace spirit { namespace karma { namespace detail
19{
20    template <typename Char>
21    bool string_compare(Char const* attr, Char const* lit)
22    {
23        Char ch_attr = *attr;
24        Char ch_lit = *lit;
25
26        while (!!ch_lit && !!ch_attr)
27        {
28            if (ch_attr != ch_lit)
29                return false;
30
31            ch_attr = *++attr;
32            ch_lit = *++lit;
33        }
34
35        return !ch_lit && !ch_attr;
36    }
37
38    template <typename Char>
39    bool string_compare(Char const* attr, Char const* lit, unused_type, unused_type)
40    {
41        return string_compare(attr, lit);
42    }
43
44    template <typename Char>
45    bool string_compare(unused_type, Char const*, unused_type, unused_type)
46    {
47        return true;
48    }
49
50    template <typename Char, typename CharEncoding, typename Tag>
51    bool string_compare(Char const* attr, Char const* lit, CharEncoding, Tag)
52    {
53        Char ch_attr = *attr;
54        Char ch_lit = spirit::char_class::convert<CharEncoding>::to(Tag(), *lit);
55
56        while (!!ch_lit && !!ch_attr)
57        {
58            if (ch_attr != ch_lit)
59                return false;
60
61            ch_attr = *++attr;
62            ch_lit = spirit::char_class::convert<CharEncoding>::to(Tag(), *++lit);
63        }
64
65        return !ch_lit && !ch_attr;
66    }
67
68    template <typename Char, typename CharEncoding, typename Tag>
69    bool string_compare(unused_type, Char const*, CharEncoding, Tag)
70    {
71        return true;
72    }
73
74}}}}
75
76#endif