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