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

« back to all changes in this revision

Viewing changes to boost/boost/spirit/utility/regex.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) 2002-2003 Hartmut Kaiser
 
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_REGEX_HPP
 
12
#define BOOST_SPIRIT_REGEX_HPP
 
13
 
 
14
#include "boost/spirit/core/impl/msvc.hpp"
 
15
 
 
16
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
 
17
#define BOOST_SPIRIT_IT_NS impl
 
18
#else
 
19
#define BOOST_SPIRIT_IT_NS std
 
20
#endif
 
21
 
 
22
///////////////////////////////////////////////////////////////////////////////
 
23
//
 
24
//  Include the regular expression library of boost (Boost.Regex)
 
25
//
 
26
//  Note though, that this library is not distributed with Spirit. You have to
 
27
//  obtain a separate copy from http://www.boost.org.
 
28
//
 
29
///////////////////////////////////////////////////////////////////////////////
 
30
#if defined(BOOST_SPIRIT_NO_REGEX_LIB)
 
31
//
 
32
//  Include all the Boost.regex library. Please note that this will not work,
 
33
//  if you are using the boost/spirit/regex.hpp header from more than one
 
34
//  translation units.
 
35
//
 
36
#define BOOST_REGEX_NO_LIB
 
37
#define BOOST_REGEX_STATIC_LINK
 
38
#define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
 
39
#include "boost/regex.hpp"
 
40
#include "boost/regex/src.cpp"
 
41
 
 
42
#else
 
43
//
 
44
//  Include the Boost.Regex headers only. Note, that you will have to link your
 
45
//  application against the Boost.Regex library as described in the related
 
46
//  documentation.
 
47
//
 
48
#include "boost/regex.hpp"
 
49
#endif // defined(BOOST_SPIRIT_NO_REGEX_LIB)
 
50
 
 
51
#include "boost/static_assert.hpp"
 
52
 
 
53
///////////////////////////////////////////////////////////////////////////////
 
54
#include "boost/spirit/core/meta/impl/parser_type.hpp"
 
55
#include "boost/spirit/core/parser.hpp"
 
56
#include "boost/spirit/utility/impl/regex.ipp"
 
57
 
 
58
///////////////////////////////////////////////////////////////////////////////
 
59
namespace boost { namespace spirit {
 
60
 
 
61
///////////////////////////////////////////////////////////////////////////////
 
62
// rxstrlit class
 
63
template <typename CharT = char>
 
64
struct rxstrlit : public parser<rxstrlit<CharT> > {
 
65
 
 
66
    typedef rxstrlit self_t;
 
67
 
 
68
    rxstrlit(CharT const *first, CharT const *last)
 
69
    : rx(first, last) {}
 
70
    rxstrlit(CharT const *first)
 
71
    : rx(first) {}
 
72
 
 
73
    template <typename ScannerT>
 
74
    typename parser_result<self_t, ScannerT>::type
 
75
    parse(ScannerT const& scan) const
 
76
    {
 
77
    //  Due to limitations in the boost::regex library the iterators wrapped in
 
78
    //  the ScannerT object should be at least bidirectional iterators. Plain
 
79
    //  forward iterators do not work here.
 
80
        typedef typename ScannerT::iterator_t iterator_t;
 
81
        typedef
 
82
            typename BOOST_SPIRIT_IT_NS::iterator_traits<iterator_t>::iterator_category
 
83
            iterator_category;
 
84
 
 
85
        BOOST_STATIC_ASSERT((
 
86
            boost::is_convertible<iterator_category,
 
87
                std::bidirectional_iterator_tag>::value
 
88
        ));
 
89
 
 
90
        typedef typename parser_result<self_t, ScannerT>::type result_t;
 
91
        return impl::contiguous_parser_parse<result_t>(rx, scan, scan);
 
92
    }
 
93
 
 
94
private:
 
95
    impl::rx_parser<CharT> rx;   // contains the boost regular expression parser
 
96
};
 
97
 
 
98
///////////////////////////////////////////////////////////////////////////////
 
99
// Generator functions
 
100
template <typename CharT>
 
101
inline rxstrlit<CharT>
 
102
regex_p(CharT const *first)
 
103
{ return rxstrlit<CharT>(first); }
 
104
 
 
105
//////////////////////////////////
 
106
template <typename CharT>
 
107
inline rxstrlit<CharT>
 
108
regex_p(CharT const *first, CharT const *last)
 
109
{ return rxstrlit<CharT>(first, last); }
 
110
 
 
111
///////////////////////////////////////////////////////////////////////////////
 
112
}} // namespace boost::spirit
 
113
 
 
114
#undef BOOST_SPIRIT_IT_NS
 
115
 
 
116
#endif // BOOST_SPIRIT_REGEX_HPP