Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:08

0001 /*=============================================================================
0002     Copyright (c) 2002-2003 Hartmut Kaiser
0003     http://spirit.sourceforge.net/
0004 
0005   Distributed under the Boost Software License, Version 1.0. (See accompanying
0006   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #ifndef BOOST_SPIRIT_REGEX_HPP
0009 #define BOOST_SPIRIT_REGEX_HPP
0010 
0011 #include <boost/version.hpp>
0012 
0013 ///////////////////////////////////////////////////////////////////////////////
0014 //
0015 //  Include the regular expression library of boost (Boost.Regex)
0016 //
0017 //  Note though, that this library is not distributed with Spirit. You have to
0018 //  obtain a separate copy from http://www.boost.org.
0019 //
0020 ///////////////////////////////////////////////////////////////////////////////
0021 #if defined(BOOST_SPIRIT_NO_REGEX_LIB) && BOOST_VERSION < 103300
0022 //
0023 //  Include all the Boost.regex library. Please note that this will not work,
0024 //  if you are using the boost/spirit/regex.hpp header from more than one
0025 //  translation units.
0026 //
0027 #define BOOST_REGEX_NO_LIB
0028 #define BOOST_REGEX_STATIC_LINK
0029 #define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
0030 #include <boost/regex.hpp>
0031 #include <boost/regex/src.cpp>
0032 
0033 #else
0034 //
0035 //  Include the Boost.Regex headers only. Note, that you will have to link your
0036 //  application against the Boost.Regex library as described in the related
0037 //  documentation.
0038 //  This is the only way for Boost newer than V1.32.0
0039 //
0040 #include <boost/regex.hpp>
0041 #endif // defined(BOOST_SPIRIT_NO_REGEX_LIB)
0042 
0043 #include <boost/static_assert.hpp>
0044 
0045 ///////////////////////////////////////////////////////////////////////////////
0046 #include <boost/spirit/home/classic/namespace.hpp>
0047 #include <boost/spirit/home/classic/meta/as_parser.hpp>
0048 #include <boost/spirit/home/classic/core/parser.hpp>
0049 #include <boost/spirit/home/classic/utility/impl/regex.ipp>
0050 #include <iterator> // for std::iterator_traits
0051 
0052 ///////////////////////////////////////////////////////////////////////////////
0053 namespace boost { namespace spirit {
0054 
0055 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0056 
0057 ///////////////////////////////////////////////////////////////////////////////
0058 // rxstrlit class
0059 template <typename CharT = char>
0060 struct rxstrlit : public parser<rxstrlit<CharT> > {
0061 
0062     typedef rxstrlit self_t;
0063 
0064     rxstrlit(CharT const *first, CharT const *last)
0065     : rx(first, last) {}
0066     rxstrlit(CharT const *first)
0067     : rx(first) {}
0068 
0069     template <typename ScannerT>
0070     typename parser_result<self_t, ScannerT>::type
0071     parse(ScannerT const& scan) const
0072     {
0073     //  Due to limitations in the boost::regex library the iterators wrapped in
0074     //  the ScannerT object should be at least bidirectional iterators. Plain
0075     //  forward iterators do not work here.
0076         typedef typename ScannerT::iterator_t iterator_t;
0077         typedef
0078             typename std::iterator_traits<iterator_t>::iterator_category
0079             iterator_category;
0080 
0081         BOOST_STATIC_ASSERT((
0082             boost::is_convertible<iterator_category,
0083                 std::bidirectional_iterator_tag>::value
0084         ));
0085 
0086         typedef typename parser_result<self_t, ScannerT>::type result_t;
0087         return impl::contiguous_parser_parse<result_t>(rx, scan, scan);
0088     }
0089 
0090 private:
0091     impl::rx_parser<CharT> rx;   // contains the boost regular expression parser
0092 };
0093 
0094 ///////////////////////////////////////////////////////////////////////////////
0095 // Generator functions
0096 template <typename CharT>
0097 inline rxstrlit<CharT>
0098 regex_p(CharT const *first)
0099 { return rxstrlit<CharT>(first); }
0100 
0101 //////////////////////////////////
0102 template <typename CharT>
0103 inline rxstrlit<CharT>
0104 regex_p(CharT const *first, CharT const *last)
0105 { return rxstrlit<CharT>(first, last); }
0106 
0107 ///////////////////////////////////////////////////////////////////////////////
0108 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0109 
0110 }} // namespace BOOST_SPIRIT_CLASSIC_NS
0111 
0112 #endif // BOOST_SPIRIT_REGEX_HPP