annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/directive/matches.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 3
Chris@16 4 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 =============================================================================*/
Chris@16 7 #if !defined(SPIRIT_MATCHES_JAN_07_2010_0745PM)
Chris@16 8 #define SPIRIT_MATCHES_JAN_07_2010_0745PM
Chris@16 9
Chris@16 10 #if defined(_MSC_VER)
Chris@16 11 #pragma once
Chris@16 12 #endif
Chris@16 13
Chris@16 14 #include <boost/spirit/home/qi/meta_compiler.hpp>
Chris@16 15 #include <boost/spirit/home/qi/parser.hpp>
Chris@16 16 #include <boost/spirit/home/qi/detail/assign_to.hpp>
Chris@16 17 #include <boost/spirit/home/support/unused.hpp>
Chris@16 18 #include <boost/spirit/home/support/info.hpp>
Chris@16 19 #include <boost/spirit/home/support/common_terminals.hpp>
Chris@16 20 #include <boost/spirit/home/support/has_semantic_action.hpp>
Chris@16 21 #include <boost/spirit/home/support/handles_container.hpp>
Chris@16 22
Chris@16 23 namespace boost { namespace spirit
Chris@16 24 {
Chris@16 25 ///////////////////////////////////////////////////////////////////////////
Chris@16 26 // Enablers
Chris@16 27 ///////////////////////////////////////////////////////////////////////////
Chris@16 28 template <>
Chris@16 29 struct use_directive<qi::domain, tag::matches> // enables matches
Chris@16 30 : mpl::true_ {};
Chris@16 31 }}
Chris@16 32
Chris@16 33 namespace boost { namespace spirit { namespace qi
Chris@16 34 {
Chris@16 35 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
Chris@16 36 using spirit::matches;
Chris@16 37 #endif
Chris@16 38 using spirit::matches_type;
Chris@16 39
Chris@16 40 ///////////////////////////////////////////////////////////////////////////
Chris@16 41 // matches_directive returns whether the embedded parser matched
Chris@16 42 ///////////////////////////////////////////////////////////////////////////
Chris@16 43 template <typename Subject>
Chris@16 44 struct matches_directive : unary_parser<matches_directive<Subject> >
Chris@16 45 {
Chris@16 46 typedef Subject subject_type;
Chris@16 47 matches_directive(Subject const& subject_)
Chris@16 48 : subject(subject_) {}
Chris@16 49
Chris@16 50 template <typename Context, typename Iterator>
Chris@16 51 struct attribute
Chris@16 52 {
Chris@16 53 typedef bool type;
Chris@16 54 };
Chris@16 55
Chris@16 56 template <typename Iterator, typename Context
Chris@16 57 , typename Skipper, typename Attribute>
Chris@16 58 bool parse(Iterator& first, Iterator const& last
Chris@16 59 , Context& context, Skipper const& skipper, Attribute& attr_) const
Chris@16 60 {
Chris@16 61 bool result = subject.parse(first, last, context, skipper, unused);
Chris@16 62 spirit::traits::assign_to(result, attr_);
Chris@16 63 return true;
Chris@16 64 }
Chris@16 65
Chris@16 66 template <typename Context>
Chris@16 67 info what(Context& context) const
Chris@16 68 {
Chris@16 69 return info("matches", subject.what(context));
Chris@16 70 }
Chris@16 71
Chris@16 72 Subject subject;
Chris@16 73
Chris@16 74 private:
Chris@16 75 // silence MSVC warning C4512: assignment operator could not be generated
Chris@16 76 matches_directive& operator= (matches_directive const&);
Chris@16 77 };
Chris@16 78
Chris@16 79 ///////////////////////////////////////////////////////////////////////////
Chris@16 80 // Parser generators: make_xxx function (objects)
Chris@16 81 ///////////////////////////////////////////////////////////////////////////
Chris@16 82 template <typename Subject, typename Modifiers>
Chris@16 83 struct make_directive<tag::matches, Subject, Modifiers>
Chris@16 84 {
Chris@16 85 typedef matches_directive<Subject> result_type;
Chris@16 86 result_type operator()(unused_type, Subject const& subject, unused_type) const
Chris@16 87 {
Chris@16 88 return result_type(subject);
Chris@16 89 }
Chris@16 90 };
Chris@16 91 }}}
Chris@16 92
Chris@16 93 namespace boost { namespace spirit { namespace traits
Chris@16 94 {
Chris@16 95 ///////////////////////////////////////////////////////////////////////////
Chris@16 96 template <typename Subject>
Chris@16 97 struct has_semantic_action<qi::matches_directive<Subject> >
Chris@16 98 : unary_has_semantic_action<Subject> {};
Chris@16 99
Chris@16 100 ///////////////////////////////////////////////////////////////////////////
Chris@16 101 template <typename Subject, typename Attribute, typename Context
Chris@16 102 , typename Iterator>
Chris@16 103 struct handles_container<qi::matches_directive<Subject>, Attribute
Chris@16 104 , Context, Iterator>
Chris@16 105 : unary_handles_container<Subject, Attribute, Context, Iterator> {};
Chris@16 106 }}}
Chris@16 107
Chris@16 108 #endif