~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/spirit/utility/flush_multi_pass.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=============================================================================
 
2
    Spirit v1.6.1
 
3
    Copyright (c) 2001-2003 Daniel Nuffer
 
4
    http://spirit.sourceforge.net/
 
5
 
 
6
    Permission to copy, use, modify, sell and distribute this software is
 
7
    granted provided this copyright notice appears in all copies. This
 
8
    software is provided "as is" without express or implied warranty, and
 
9
    with no claim as to its suitability for any purpose.
 
10
=============================================================================*/
 
11
#ifndef BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP
 
12
#define BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP
 
13
 
 
14
///////////////////////////////////////////////////////////////////////////////
 
15
#include "boost/spirit/core.hpp"
 
16
#include "boost/spirit/iterator/multi_pass.hpp"
 
17
 
 
18
///////////////////////////////////////////////////////////////////////////////
 
19
namespace boost { namespace spirit {
 
20
 
 
21
    namespace impl {
 
22
 
 
23
        template <typename T>
 
24
        void flush_iterator(T &) {}
 
25
 
 
26
        template <typename T1, typename T2, typename T3, typename T4>
 
27
        void flush_iterator(boost::spirit::multi_pass<
 
28
            T1, T2, T3, T4, boost::spirit::multi_pass_policies::std_deque> &i)
 
29
        {
 
30
            i.clear_queue();
 
31
        }
 
32
 
 
33
    }   // namespace impl
 
34
 
 
35
    ///////////////////////////////////////////////////////////////////////////
 
36
    //
 
37
    //  flush_multi_pass_parser
 
38
    //
 
39
    //      The flush_multi_pass_parser flushes an underlying
 
40
    //      multi_pass_iterator during the normal parsing process. This may
 
41
    //      be used at certain points during the parsing process, when it is
 
42
    //      clear, that no backtracking is needed anymore and the input
 
43
    //      gathered so far may be discarded.
 
44
    //
 
45
    ///////////////////////////////////////////////////////////////////////////
 
46
    class flush_multi_pass_parser
 
47
    :   public parser<flush_multi_pass_parser>
 
48
    {
 
49
    public:
 
50
        typedef flush_multi_pass_parser this_t;
 
51
 
 
52
        template <typename ScannerT>
 
53
        typename parser_result<this_t, ScannerT>::type
 
54
        parse(ScannerT const& scan) const
 
55
        {
 
56
            impl::flush_iterator(scan.first);
 
57
            return scan.empty_match();
 
58
        }
 
59
    };
 
60
 
 
61
    ///////////////////////////////////////////////////////////////////////////
 
62
    //
 
63
    //  predefined flush_multi_pass_p object
 
64
    //
 
65
    //      This object should may used to flush a multi_pass_iterator along
 
66
    //      the way during the normal parsing process.
 
67
    //
 
68
    ///////////////////////////////////////////////////////////////////////////
 
69
 
 
70
    flush_multi_pass_parser const
 
71
        flush_multi_pass_p = flush_multi_pass_parser();
 
72
 
 
73
}} // namespace boost::spirit
 
74
 
 
75
#endif // BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP