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