Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/qi/directive/matches.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 Hartmut Kaiser | |
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(SPIRIT_MATCHES_JAN_07_2010_0745PM) | |
8 #define SPIRIT_MATCHES_JAN_07_2010_0745PM | |
9 | |
10 #if defined(_MSC_VER) | |
11 #pragma once | |
12 #endif | |
13 | |
14 #include <boost/spirit/home/qi/meta_compiler.hpp> | |
15 #include <boost/spirit/home/qi/parser.hpp> | |
16 #include <boost/spirit/home/qi/detail/assign_to.hpp> | |
17 #include <boost/spirit/home/support/unused.hpp> | |
18 #include <boost/spirit/home/support/info.hpp> | |
19 #include <boost/spirit/home/support/common_terminals.hpp> | |
20 #include <boost/spirit/home/support/has_semantic_action.hpp> | |
21 #include <boost/spirit/home/support/handles_container.hpp> | |
22 | |
23 namespace boost { namespace spirit | |
24 { | |
25 /////////////////////////////////////////////////////////////////////////// | |
26 // Enablers | |
27 /////////////////////////////////////////////////////////////////////////// | |
28 template <> | |
29 struct use_directive<qi::domain, tag::matches> // enables matches | |
30 : mpl::true_ {}; | |
31 }} | |
32 | |
33 namespace boost { namespace spirit { namespace qi | |
34 { | |
35 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS | |
36 using spirit::matches; | |
37 #endif | |
38 using spirit::matches_type; | |
39 | |
40 /////////////////////////////////////////////////////////////////////////// | |
41 // matches_directive returns whether the embedded parser matched | |
42 /////////////////////////////////////////////////////////////////////////// | |
43 template <typename Subject> | |
44 struct matches_directive : unary_parser<matches_directive<Subject> > | |
45 { | |
46 typedef Subject subject_type; | |
47 matches_directive(Subject const& subject_) | |
48 : subject(subject_) {} | |
49 | |
50 template <typename Context, typename Iterator> | |
51 struct attribute | |
52 { | |
53 typedef bool type; | |
54 }; | |
55 | |
56 template <typename Iterator, typename Context | |
57 , typename Skipper, typename Attribute> | |
58 bool parse(Iterator& first, Iterator const& last | |
59 , Context& context, Skipper const& skipper, Attribute& attr_) const | |
60 { | |
61 bool result = subject.parse(first, last, context, skipper, unused); | |
62 spirit::traits::assign_to(result, attr_); | |
63 return true; | |
64 } | |
65 | |
66 template <typename Context> | |
67 info what(Context& context) const | |
68 { | |
69 return info("matches", subject.what(context)); | |
70 } | |
71 | |
72 Subject subject; | |
73 | |
74 private: | |
75 // silence MSVC warning C4512: assignment operator could not be generated | |
76 matches_directive& operator= (matches_directive const&); | |
77 }; | |
78 | |
79 /////////////////////////////////////////////////////////////////////////// | |
80 // Parser generators: make_xxx function (objects) | |
81 /////////////////////////////////////////////////////////////////////////// | |
82 template <typename Subject, typename Modifiers> | |
83 struct make_directive<tag::matches, Subject, Modifiers> | |
84 { | |
85 typedef matches_directive<Subject> result_type; | |
86 result_type operator()(unused_type, Subject const& subject, unused_type) const | |
87 { | |
88 return result_type(subject); | |
89 } | |
90 }; | |
91 }}} | |
92 | |
93 namespace boost { namespace spirit { namespace traits | |
94 { | |
95 /////////////////////////////////////////////////////////////////////////// | |
96 template <typename Subject> | |
97 struct has_semantic_action<qi::matches_directive<Subject> > | |
98 : unary_has_semantic_action<Subject> {}; | |
99 | |
100 /////////////////////////////////////////////////////////////////////////// | |
101 template <typename Subject, typename Attribute, typename Context | |
102 , typename Iterator> | |
103 struct handles_container<qi::matches_directive<Subject>, Attribute | |
104 , Context, Iterator> | |
105 : unary_handles_container<Subject, Attribute, Context, Iterator> {}; | |
106 }}} | |
107 | |
108 #endif |