Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/qi/char/char_class.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2001-2011 Joel de Guzman | |
3 | |
4 Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 ==============================================================================*/ | |
7 #if !defined(BOOST_SPIRIT_CHAR_CLASS_APRIL_16_2006_1051AM) | |
8 #define BOOST_SPIRIT_CHAR_CLASS_APRIL_16_2006_1051AM | |
9 | |
10 #if defined(_MSC_VER) | |
11 #pragma once | |
12 #endif | |
13 | |
14 #include <boost/spirit/home/qi/char/char_parser.hpp> | |
15 #include <boost/spirit/home/qi/domain.hpp> | |
16 #include <boost/spirit/home/support/char_class.hpp> | |
17 #include <boost/spirit/home/support/common_terminals.hpp> | |
18 #include <boost/spirit/home/support/info.hpp> | |
19 #include <boost/spirit/home/support/modify.hpp> | |
20 #include <boost/spirit/home/support/detail/get_encoding.hpp> | |
21 #include <boost/mpl/eval_if.hpp> | |
22 | |
23 namespace boost { namespace spirit | |
24 { | |
25 /////////////////////////////////////////////////////////////////////////// | |
26 // Enablers | |
27 /////////////////////////////////////////////////////////////////////////// | |
28 // enables alnum, alpha, graph, etc. | |
29 template <typename CharClass, typename CharEncoding> | |
30 struct use_terminal<qi::domain, tag::char_code<CharClass, CharEncoding> > | |
31 : mpl::true_ {}; | |
32 }} | |
33 | |
34 namespace boost { namespace spirit { namespace qi | |
35 { | |
36 // hoist the char classification namespaces into qi sub-namespaces of the | |
37 // same name | |
38 namespace ascii { using namespace boost::spirit::ascii; } | |
39 namespace iso8859_1 { using namespace boost::spirit::iso8859_1; } | |
40 namespace standard { using namespace boost::spirit::standard; } | |
41 namespace standard_wide { using namespace boost::spirit::standard_wide; } | |
42 #if defined(BOOST_SPIRIT_UNICODE) | |
43 namespace unicode { using namespace boost::spirit::unicode; } | |
44 #endif | |
45 | |
46 // Import the standard namespace into the qi namespace. This allows | |
47 // for default handling of all character/string related operations if not | |
48 // prefixed with a character set namespace. | |
49 using namespace boost::spirit::standard; | |
50 | |
51 // Import encoding | |
52 using spirit::encoding; | |
53 | |
54 /////////////////////////////////////////////////////////////////////////// | |
55 // Generic char classification parser (for alnum, alpha, graph, etc.) | |
56 /////////////////////////////////////////////////////////////////////////// | |
57 template <typename Tag> | |
58 struct char_class | |
59 : char_parser<char_class<Tag>, typename Tag::char_encoding::char_type> | |
60 { | |
61 typedef typename Tag::char_encoding char_encoding; | |
62 typedef typename Tag::char_class classification; | |
63 | |
64 template <typename CharParam, typename Context> | |
65 bool test(CharParam ch, Context&) const | |
66 { | |
67 using spirit::char_class::classify; | |
68 return traits::ischar<CharParam, char_encoding>::call(ch) && | |
69 classify<char_encoding>::is(classification(), ch); | |
70 } | |
71 | |
72 template <typename Context> | |
73 info what(Context& /*context*/) const | |
74 { | |
75 typedef spirit::char_class::what<char_encoding> what_; | |
76 return info(what_::is(classification())); | |
77 } | |
78 }; | |
79 | |
80 namespace detail | |
81 { | |
82 template <typename Tag, bool no_case = false> | |
83 struct make_char_class : mpl::identity<Tag> {}; | |
84 | |
85 template <> | |
86 struct make_char_class<tag::lower, true> : mpl::identity<tag::alpha> {}; | |
87 | |
88 template <> | |
89 struct make_char_class<tag::upper, true> : mpl::identity<tag::alpha> {}; | |
90 } | |
91 | |
92 /////////////////////////////////////////////////////////////////////////// | |
93 // Parser generators: make_xxx function (objects) | |
94 /////////////////////////////////////////////////////////////////////////// | |
95 template <typename CharClass, typename CharEncoding, typename Modifiers> | |
96 struct make_primitive<tag::char_code<CharClass, CharEncoding>, Modifiers> | |
97 { | |
98 static bool const no_case = | |
99 has_modifier<Modifiers, tag::char_code_base<tag::no_case> >::value; | |
100 | |
101 typedef typename | |
102 spirit::detail::get_encoding<Modifiers, CharEncoding>::type | |
103 char_encoding; | |
104 | |
105 typedef tag::char_code< | |
106 typename detail::make_char_class<CharClass, no_case>::type | |
107 , char_encoding> | |
108 tag; | |
109 | |
110 typedef char_class<tag> result_type; | |
111 result_type operator()(unused_type, unused_type) const | |
112 { | |
113 return result_type(); | |
114 } | |
115 }; | |
116 }}} | |
117 | |
118 #endif |