Chris@16: /*============================================================================= Chris@16: Copyright (c) 2002-2003 Hartmut Kaiser Chris@16: http://spirit.sourceforge.net/ Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: =============================================================================*/ Chris@16: #ifndef BOOST_SPIRIT_REGEX_HPP Chris@16: #define BOOST_SPIRIT_REGEX_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // Include the regular expression library of boost (Boost.Regex) Chris@16: // Chris@16: // Note though, that this library is not distributed with Spirit. You have to Chris@16: // obtain a separate copy from http://www.boost.org. Chris@16: // Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: #if defined(BOOST_SPIRIT_NO_REGEX_LIB) && BOOST_VERSION < 103300 Chris@16: // Chris@16: // Include all the Boost.regex library. Please note that this will not work, Chris@16: // if you are using the boost/spirit/regex.hpp header from more than one Chris@16: // translation units. Chris@16: // Chris@16: #define BOOST_REGEX_NO_LIB Chris@16: #define BOOST_REGEX_STATIC_LINK Chris@16: #define BOOST_REGEX_NO_EXTERNAL_TEMPLATES Chris@16: #include Chris@16: #include Chris@16: Chris@16: #else Chris@16: // Chris@16: // Include the Boost.Regex headers only. Note, that you will have to link your Chris@16: // application against the Boost.Regex library as described in the related Chris@16: // documentation. Chris@16: // This is the only way for Boost newer than V1.32.0 Chris@16: // Chris@16: #include Chris@16: #endif // defined(BOOST_SPIRIT_NO_REGEX_LIB) Chris@16: Chris@16: #include Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include // for boost::detail::iterator_traits Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: namespace boost { namespace spirit { Chris@16: Chris@16: BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // rxstrlit class Chris@16: template Chris@16: struct rxstrlit : public parser > { Chris@16: Chris@16: typedef rxstrlit self_t; Chris@16: Chris@16: rxstrlit(CharT const *first, CharT const *last) Chris@16: : rx(first, last) {} Chris@16: rxstrlit(CharT const *first) Chris@16: : rx(first) {} Chris@16: Chris@16: template Chris@16: typename parser_result::type Chris@16: parse(ScannerT const& scan) const Chris@16: { Chris@16: // Due to limitations in the boost::regex library the iterators wrapped in Chris@16: // the ScannerT object should be at least bidirectional iterators. Plain Chris@16: // forward iterators do not work here. Chris@16: typedef typename ScannerT::iterator_t iterator_t; Chris@16: typedef Chris@16: typename boost::detail::iterator_traits::iterator_category Chris@16: iterator_category; Chris@16: Chris@16: BOOST_STATIC_ASSERT(( Chris@16: boost::is_convertible::value Chris@16: )); Chris@16: Chris@16: typedef typename parser_result::type result_t; Chris@16: return impl::contiguous_parser_parse(rx, scan, scan); Chris@16: } Chris@16: Chris@16: private: Chris@16: impl::rx_parser rx; // contains the boost regular expression parser Chris@16: }; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: // Generator functions Chris@16: template Chris@16: inline rxstrlit Chris@16: regex_p(CharT const *first) Chris@16: { return rxstrlit(first); } Chris@16: Chris@16: ////////////////////////////////// Chris@16: template Chris@16: inline rxstrlit Chris@16: regex_p(CharT const *first, CharT const *last) Chris@16: { return rxstrlit(first, last); } Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: BOOST_SPIRIT_CLASSIC_NAMESPACE_END Chris@16: Chris@16: }} // namespace BOOST_SPIRIT_CLASSIC_NS Chris@16: Chris@16: #endif // BOOST_SPIRIT_REGEX_HPP