]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/utility/regex.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / utility / regex.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2002-2003 Hartmut Kaiser
3 http://spirit.sourceforge.net/
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7=============================================================================*/
8#ifndef BOOST_SPIRIT_REGEX_HPP
9#define BOOST_SPIRIT_REGEX_HPP
10
11#include <boost/version.hpp>
12
13///////////////////////////////////////////////////////////////////////////////
14//
15// Include the regular expression library of boost (Boost.Regex)
16//
17// Note though, that this library is not distributed with Spirit. You have to
18// obtain a separate copy from http://www.boost.org.
19//
20///////////////////////////////////////////////////////////////////////////////
21#if defined(BOOST_SPIRIT_NO_REGEX_LIB) && BOOST_VERSION < 103300
22//
23// Include all the Boost.regex library. Please note that this will not work,
24// if you are using the boost/spirit/regex.hpp header from more than one
25// translation units.
26//
27#define BOOST_REGEX_NO_LIB
28#define BOOST_REGEX_STATIC_LINK
29#define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
30#include <boost/regex.hpp>
31#include <boost/regex/src.cpp>
32
33#else
34//
35// Include the Boost.Regex headers only. Note, that you will have to link your
36// application against the Boost.Regex library as described in the related
37// documentation.
38// This is the only way for Boost newer than V1.32.0
39//
40#include <boost/regex.hpp>
41#endif // defined(BOOST_SPIRIT_NO_REGEX_LIB)
42
43#include <boost/static_assert.hpp>
44
45///////////////////////////////////////////////////////////////////////////////
46#include <boost/spirit/home/classic/namespace.hpp>
47#include <boost/spirit/home/classic/meta/as_parser.hpp>
48#include <boost/spirit/home/classic/core/parser.hpp>
49#include <boost/spirit/home/classic/utility/impl/regex.ipp>
50#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
51
52///////////////////////////////////////////////////////////////////////////////
53namespace boost { namespace spirit {
54
55BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
56
57///////////////////////////////////////////////////////////////////////////////
58// rxstrlit class
59template <typename CharT = char>
60struct rxstrlit : public parser<rxstrlit<CharT> > {
61
62 typedef rxstrlit self_t;
63
64 rxstrlit(CharT const *first, CharT const *last)
65 : rx(first, last) {}
66 rxstrlit(CharT const *first)
67 : rx(first) {}
68
69 template <typename ScannerT>
70 typename parser_result<self_t, ScannerT>::type
71 parse(ScannerT const& scan) const
72 {
73 // Due to limitations in the boost::regex library the iterators wrapped in
74 // the ScannerT object should be at least bidirectional iterators. Plain
75 // forward iterators do not work here.
76 typedef typename ScannerT::iterator_t iterator_t;
77 typedef
78 typename boost::detail::iterator_traits<iterator_t>::iterator_category
79 iterator_category;
80
81 BOOST_STATIC_ASSERT((
82 boost::is_convertible<iterator_category,
83 std::bidirectional_iterator_tag>::value
84 ));
85
86 typedef typename parser_result<self_t, ScannerT>::type result_t;
87 return impl::contiguous_parser_parse<result_t>(rx, scan, scan);
88 }
89
90private:
91 impl::rx_parser<CharT> rx; // contains the boost regular expression parser
92};
93
94///////////////////////////////////////////////////////////////////////////////
95// Generator functions
96template <typename CharT>
97inline rxstrlit<CharT>
98regex_p(CharT const *first)
99{ return rxstrlit<CharT>(first); }
100
101//////////////////////////////////
102template <typename CharT>
103inline rxstrlit<CharT>
104regex_p(CharT const *first, CharT const *last)
105{ return rxstrlit<CharT>(first, last); }
106
107///////////////////////////////////////////////////////////////////////////////
108BOOST_SPIRIT_CLASSIC_NAMESPACE_END
109
110}} // namespace BOOST_SPIRIT_CLASSIC_NS
111
112#endif // BOOST_SPIRIT_REGEX_HPP