1
/*=============================================================================
3
Copyright (c) 2002-2003 Hartmut Kaiser
4
http://spirit.sourceforge.net/
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
14
#include "boost/spirit/core/impl/msvc.hpp"
16
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
17
#define BOOST_SPIRIT_IT_NS impl
19
#define BOOST_SPIRIT_IT_NS std
22
///////////////////////////////////////////////////////////////////////////////
24
// Include the regular expression library of boost (Boost.Regex)
26
// Note though, that this library is not distributed with Spirit. You have to
27
// obtain a separate copy from http://www.boost.org.
29
///////////////////////////////////////////////////////////////////////////////
30
#if defined(BOOST_SPIRIT_NO_REGEX_LIB)
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
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"
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
48
#include "boost/regex.hpp"
49
#endif // defined(BOOST_SPIRIT_NO_REGEX_LIB)
51
#include "boost/static_assert.hpp"
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"
58
///////////////////////////////////////////////////////////////////////////////
59
namespace boost { namespace spirit {
61
///////////////////////////////////////////////////////////////////////////////
63
template <typename CharT = char>
64
struct rxstrlit : public parser<rxstrlit<CharT> > {
66
typedef rxstrlit self_t;
68
rxstrlit(CharT const *first, CharT const *last)
70
rxstrlit(CharT const *first)
73
template <typename ScannerT>
74
typename parser_result<self_t, ScannerT>::type
75
parse(ScannerT const& scan) const
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;
82
typename BOOST_SPIRIT_IT_NS::iterator_traits<iterator_t>::iterator_category
86
boost::is_convertible<iterator_category,
87
std::bidirectional_iterator_tag>::value
90
typedef typename parser_result<self_t, ScannerT>::type result_t;
91
return impl::contiguous_parser_parse<result_t>(rx, scan, scan);
95
impl::rx_parser<CharT> rx; // contains the boost regular expression parser
98
///////////////////////////////////////////////////////////////////////////////
99
// Generator functions
100
template <typename CharT>
101
inline rxstrlit<CharT>
102
regex_p(CharT const *first)
103
{ return rxstrlit<CharT>(first); }
105
//////////////////////////////////
106
template <typename CharT>
107
inline rxstrlit<CharT>
108
regex_p(CharT const *first, CharT const *last)
109
{ return rxstrlit<CharT>(first, last); }
111
///////////////////////////////////////////////////////////////////////////////
112
}} // namespace boost::spirit
114
#undef BOOST_SPIRIT_IT_NS
116
#endif // BOOST_SPIRIT_REGEX_HPP