LCOV - code coverage report
Current view: top level - usr/include/boost/regex/v4 - sub_match.hpp (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 25 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *
       3             :  * Copyright (c) 1998-2002
       4             :  * John Maddock
       5             :  *
       6             :  * Use, modification and distribution are subject to the 
       7             :  * Boost Software License, Version 1.0. (See accompanying file 
       8             :  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       9             :  *
      10             :  */
      11             : 
      12             :  /*
      13             :   *   LOCATION:    see http://www.boost.org for most recent version.
      14             :   *   FILE         sub_match.cpp
      15             :   *   VERSION      see <boost/version.hpp>
      16             :   *   DESCRIPTION: Declares template class sub_match.
      17             :   */
      18             : 
      19             : #ifndef BOOST_REGEX_V4_SUB_MATCH_HPP
      20             : #define BOOST_REGEX_V4_SUB_MATCH_HPP
      21             : 
      22             : #ifdef BOOST_MSVC
      23             : #pragma warning(push)
      24             : #pragma warning(disable: 4103)
      25             : #endif
      26             : #ifdef BOOST_HAS_ABI_HEADERS
      27             : #  include BOOST_ABI_PREFIX
      28             : #endif
      29             : #ifdef BOOST_MSVC
      30             : #pragma warning(pop)
      31             : #endif
      32             : 
      33             : namespace boost{
      34             : 
      35             : template <class BidiIterator>
      36             : struct sub_match : public std::pair<BidiIterator, BidiIterator>
      37             : {
      38             :    typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidiIterator>::value_type       value_type;
      39             : #if defined(BOOST_NO_STD_ITERATOR_TRAITS)
      40             :    typedef          std::ptrdiff_t                                                   difference_type;
      41             : #else
      42             :    typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidiIterator>::difference_type  difference_type;
      43             : #endif
      44             :    typedef          BidiIterator                                                     iterator_type;
      45             :    typedef          BidiIterator                                                     iterator;
      46             :    typedef          BidiIterator                                                     const_iterator;
      47             : 
      48             :    bool matched;
      49             : 
      50           0 :    sub_match() : std::pair<BidiIterator, BidiIterator>(), matched(false) {}
      51           0 :    sub_match(BidiIterator i) : std::pair<BidiIterator, BidiIterator>(i, i), matched(false) {}
      52             : #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
      53             :                && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)\
      54             :                && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
      55             :    template <class T, class A>
      56           0 :    operator std::basic_string<value_type, T, A> ()const
      57             :    {
      58           0 :       return matched ? std::basic_string<value_type, T, A>(this->first, this->second) : std::basic_string<value_type, T, A>();
      59             :    }
      60             : #else
      61             :    operator std::basic_string<value_type> ()const
      62             :    {
      63             :       return str();
      64             :    }
      65             : #endif
      66           0 :    difference_type BOOST_REGEX_CALL length()const
      67             :    {
      68           0 :       difference_type n = matched ? ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0;
      69             :       return n;
      70             :    }
      71           0 :    std::basic_string<value_type> str()const
      72             :    {
      73           0 :       std::basic_string<value_type> result;
      74           0 :       if(matched)
      75             :       {
      76           0 :          std::size_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second);
      77           0 :          result.reserve(len);
      78           0 :          BidiIterator i = this->first;
      79           0 :          while(i != this->second)
      80             :          {
      81           0 :             result.append(1, *i);
      82           0 :             ++i;
      83             :          }
      84             :       }
      85           0 :       return result;
      86             :    }
      87             :    int compare(const sub_match& s)const
      88             :    {
      89             :       if(matched != s.matched)
      90             :          return static_cast<int>(matched) - static_cast<int>(s.matched);
      91             :       return str().compare(s.str());
      92             :    }
      93             :    int compare(const std::basic_string<value_type>& s)const
      94             :    {
      95             :       return str().compare(s);
      96             :    }
      97             :    int compare(const value_type* p)const
      98             :    {
      99             :       return str().compare(p);
     100             :    }
     101             : 
     102             :    bool operator==(const sub_match& that)const
     103             :    { return compare(that) == 0; }
     104             :    bool BOOST_REGEX_CALL operator !=(const sub_match& that)const
     105             :    { return compare(that) != 0; }
     106             :    bool operator<(const sub_match& that)const
     107             :    { return compare(that) < 0; }
     108             :    bool operator>(const sub_match& that)const
     109             :    { return compare(that) > 0; }
     110             :    bool operator<=(const sub_match& that)const
     111             :    { return compare(that) <= 0; }
     112             :    bool operator>=(const sub_match& that)const
     113             :    { return compare(that) >= 0; }
     114             : 
     115             : #ifdef BOOST_REGEX_MATCH_EXTRA
     116             :    typedef std::vector<sub_match<BidiIterator> > capture_sequence_type;
     117             : 
     118             :    const capture_sequence_type& captures()const
     119             :    {
     120             :       if(!m_captures) 
     121             :          m_captures.reset(new capture_sequence_type());
     122             :       return *m_captures;
     123             :    }
     124             :    //
     125             :    // Private implementation API: DO NOT USE!
     126             :    //
     127             :    capture_sequence_type& get_captures()const
     128             :    {
     129             :       if(!m_captures) 
     130             :          m_captures.reset(new capture_sequence_type());
     131             :       return *m_captures;
     132             :    }
     133             : 
     134             : private:
     135             :    mutable boost::scoped_ptr<capture_sequence_type> m_captures;
     136             : public:
     137             : 
     138             : #endif
     139           0 :    sub_match(const sub_match& that, bool 
     140             : #ifdef BOOST_REGEX_MATCH_EXTRA
     141             :       deep_copy
     142             : #endif
     143             :       = true
     144             :       ) 
     145             :       : std::pair<BidiIterator, BidiIterator>(that), 
     146           0 :         matched(that.matched) 
     147             :    {
     148             : #ifdef BOOST_REGEX_MATCH_EXTRA
     149             :       if(that.m_captures)
     150             :          if(deep_copy)
     151             :             m_captures.reset(new capture_sequence_type(*(that.m_captures)));
     152             : #endif
     153             :    }
     154           0 :    sub_match& operator=(const sub_match& that)
     155             :    {
     156           0 :       this->first = that.first;
     157           0 :       this->second = that.second;
     158           0 :       matched = that.matched;
     159             : #ifdef BOOST_REGEX_MATCH_EXTRA
     160             :       if(that.m_captures)
     161             :          get_captures() = *(that.m_captures);
     162             : #endif
     163           0 :       return *this;
     164             :    }
     165             :    //
     166             :    // Make this type a range, for both Boost.Range, and C++11:
     167             :    //
     168             :    BidiIterator begin()const { return this->first; }
     169             :    BidiIterator end()const { return this->second; }
     170             : 
     171             : 
     172             : #ifdef BOOST_OLD_REGEX_H
     173             :    //
     174             :    // the following are deprecated, do not use!!
     175             :    //
     176             :    operator int()const;
     177             :    operator unsigned int()const;
     178             :    operator short()const
     179             :    {
     180             :       return (short)(int)(*this);
     181             :    }
     182             :    operator unsigned short()const
     183             :    {
     184             :       return (unsigned short)(unsigned int)(*this);
     185             :    }
     186             : #endif
     187             : };
     188             : 
     189             : typedef sub_match<const char*> csub_match;
     190             : typedef sub_match<std::string::const_iterator> ssub_match;
     191             : #ifndef BOOST_NO_WREGEX
     192             : typedef sub_match<const wchar_t*> wcsub_match;
     193             : typedef sub_match<std::wstring::const_iterator> wssub_match;
     194             : #endif
     195             : 
     196             : // comparison to std::basic_string<> part 1:
     197             : template <class RandomAccessIterator, class traits, class Allocator>
     198             : inline bool operator == (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     199             :                   const sub_match<RandomAccessIterator>& m)
     200             : { return s.compare(m.str()) == 0; }
     201             : template <class RandomAccessIterator, class traits, class Allocator>
     202             : inline bool operator != (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     203             :                   const sub_match<RandomAccessIterator>& m)
     204             : { return s.compare(m.str()) != 0; }
     205             : template <class RandomAccessIterator, class traits, class Allocator>
     206             : inline bool operator < (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     207             :                  const sub_match<RandomAccessIterator>& m)
     208             : { return s.compare(m.str()) < 0; }
     209             : template <class RandomAccessIterator, class traits, class Allocator>
     210             : inline bool operator <= (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     211             :                   const sub_match<RandomAccessIterator>& m)
     212             : { return s.compare(m.str()) <= 0; }
     213             : template <class RandomAccessIterator, class traits, class Allocator>
     214             : inline bool operator >= (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     215             :                   const sub_match<RandomAccessIterator>& m)
     216             : { return s.compare(m.str()) >= 0; }
     217             : template <class RandomAccessIterator, class traits, class Allocator>
     218             : inline bool operator > (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     219             :                  const sub_match<RandomAccessIterator>& m)
     220             : { return s.compare(m.str()) > 0; }
     221             : // comparison to std::basic_string<> part 2:
     222             : template <class RandomAccessIterator, class traits, class Allocator>
     223             : inline bool operator == (const sub_match<RandomAccessIterator>& m,
     224             :                   const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     225             : { return m.str().compare(s) == 0; }
     226             : template <class RandomAccessIterator, class traits, class Allocator>
     227             : inline bool operator != (const sub_match<RandomAccessIterator>& m,
     228             :                   const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     229             : { return m.str().compare(s) != 0; }
     230             : template <class RandomAccessIterator, class traits, class Allocator>
     231             : inline bool operator < (const sub_match<RandomAccessIterator>& m,
     232             :                   const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     233             : { return m.str().compare(s) < 0; }
     234             : template <class RandomAccessIterator, class traits, class Allocator>
     235             : inline bool operator > (const sub_match<RandomAccessIterator>& m,
     236             :                   const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     237             : { return m.str().compare(s) > 0; }
     238             : template <class RandomAccessIterator, class traits, class Allocator>
     239             : inline bool operator <= (const sub_match<RandomAccessIterator>& m,
     240             :                   const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     241             : { return m.str().compare(s) <= 0; }
     242             : template <class RandomAccessIterator, class traits, class Allocator>
     243             : inline bool operator >= (const sub_match<RandomAccessIterator>& m,
     244             :                   const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     245             : { return m.str().compare(s) >= 0; }
     246             : // comparison to const charT* part 1:
     247             : template <class RandomAccessIterator>
     248             : inline bool operator == (const sub_match<RandomAccessIterator>& m,
     249             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
     250             : { return m.str().compare(s) == 0; }
     251             : template <class RandomAccessIterator>
     252             : inline bool operator != (const sub_match<RandomAccessIterator>& m,
     253             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
     254             : { return m.str().compare(s) != 0; }
     255             : template <class RandomAccessIterator>
     256             : inline bool operator > (const sub_match<RandomAccessIterator>& m,
     257             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
     258             : { return m.str().compare(s) > 0; }
     259             : template <class RandomAccessIterator>
     260             : inline bool operator < (const sub_match<RandomAccessIterator>& m,
     261             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
     262             : { return m.str().compare(s) < 0; }
     263             : template <class RandomAccessIterator>
     264             : inline bool operator >= (const sub_match<RandomAccessIterator>& m,
     265             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
     266             : { return m.str().compare(s) >= 0; }
     267             : template <class RandomAccessIterator>
     268             : inline bool operator <= (const sub_match<RandomAccessIterator>& m,
     269             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
     270             : { return m.str().compare(s) <= 0; }
     271             : // comparison to const charT* part 2:
     272             : template <class RandomAccessIterator>
     273             : inline bool operator == (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     274             :                   const sub_match<RandomAccessIterator>& m)
     275             : { return m.str().compare(s) == 0; }
     276             : template <class RandomAccessIterator>
     277             : inline bool operator != (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     278             :                   const sub_match<RandomAccessIterator>& m)
     279             : { return m.str().compare(s) != 0; }
     280             : template <class RandomAccessIterator>
     281             : inline bool operator < (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     282             :                   const sub_match<RandomAccessIterator>& m)
     283             : { return m.str().compare(s) > 0; }
     284             : template <class RandomAccessIterator>
     285             : inline bool operator > (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     286             :                   const sub_match<RandomAccessIterator>& m)
     287             : { return m.str().compare(s) < 0; }
     288             : template <class RandomAccessIterator>
     289             : inline bool operator <= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     290             :                   const sub_match<RandomAccessIterator>& m)
     291             : { return m.str().compare(s) >= 0; }
     292             : template <class RandomAccessIterator>
     293             : inline bool operator >= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     294             :                   const sub_match<RandomAccessIterator>& m)
     295             : { return m.str().compare(s) <= 0; }
     296             : 
     297             : // comparison to const charT& part 1:
     298             : template <class RandomAccessIterator>
     299             : inline bool operator == (const sub_match<RandomAccessIterator>& m,
     300             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     301             : { return m.str().compare(0, m.length(), &s, 1) == 0; }
     302             : template <class RandomAccessIterator>
     303             : inline bool operator != (const sub_match<RandomAccessIterator>& m,
     304             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     305             : { return m.str().compare(0, m.length(), &s, 1) != 0; }
     306             : template <class RandomAccessIterator>
     307             : inline bool operator > (const sub_match<RandomAccessIterator>& m,
     308             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     309             : { return m.str().compare(0, m.length(), &s, 1) > 0; }
     310             : template <class RandomAccessIterator>
     311             : inline bool operator < (const sub_match<RandomAccessIterator>& m,
     312             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     313             : { return m.str().compare(0, m.length(), &s, 1) < 0; }
     314             : template <class RandomAccessIterator>
     315             : inline bool operator >= (const sub_match<RandomAccessIterator>& m,
     316             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     317             : { return m.str().compare(0, m.length(), &s, 1) >= 0; }
     318             : template <class RandomAccessIterator>
     319             : inline bool operator <= (const sub_match<RandomAccessIterator>& m,
     320             :                   typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     321             : { return m.str().compare(0, m.length(), &s, 1) <= 0; }
     322             : // comparison to const charT* part 2:
     323             : template <class RandomAccessIterator>
     324             : inline bool operator == (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     325             :                   const sub_match<RandomAccessIterator>& m)
     326             : { return m.str().compare(0, m.length(), &s, 1) == 0; }
     327             : template <class RandomAccessIterator>
     328             : inline bool operator != (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     329             :                   const sub_match<RandomAccessIterator>& m)
     330             : { return m.str().compare(0, m.length(), &s, 1) != 0; }
     331             : template <class RandomAccessIterator>
     332             : inline bool operator < (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     333             :                   const sub_match<RandomAccessIterator>& m)
     334             : { return m.str().compare(0, m.length(), &s, 1) > 0; }
     335             : template <class RandomAccessIterator>
     336             : inline bool operator > (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     337             :                   const sub_match<RandomAccessIterator>& m)
     338             : { return m.str().compare(0, m.length(), &s, 1) < 0; }
     339             : template <class RandomAccessIterator>
     340             : inline bool operator <= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     341             :                   const sub_match<RandomAccessIterator>& m)
     342             : { return m.str().compare(0, m.length(), &s, 1) >= 0; }
     343             : template <class RandomAccessIterator>
     344             : inline bool operator >= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     345             :                   const sub_match<RandomAccessIterator>& m)
     346             : { return m.str().compare(0, m.length(), &s, 1) <= 0; }
     347             : 
     348             : // addition operators:
     349             : template <class RandomAccessIterator, class traits, class Allocator>
     350             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> 
     351             : operator + (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
     352             :                   const sub_match<RandomAccessIterator>& m)
     353             : {
     354             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
     355             :    result.reserve(s.size() + m.length() + 1);
     356             :    return result.append(s).append(m.first, m.second);
     357             : }
     358             : template <class RandomAccessIterator, class traits, class Allocator>
     359             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> 
     360             : operator + (const sub_match<RandomAccessIterator>& m,
     361             :             const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
     362             : {
     363             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
     364             :    result.reserve(s.size() + m.length() + 1);
     365             :    return result.append(m.first, m.second).append(s);
     366             : }
     367             : #if !(defined(__GNUC__) && defined(BOOST_NO_STD_LOCALE))
     368             : template <class RandomAccessIterator>
     369             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     370             : operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     371             :                   const sub_match<RandomAccessIterator>& m)
     372             : {
     373             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
     374             :    result.reserve(std::char_traits<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
     375             :    return result.append(s).append(m.first, m.second);
     376             : }
     377             : template <class RandomAccessIterator>
     378             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     379             : operator + (const sub_match<RandomAccessIterator>& m,
     380             :             typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const * s)
     381             : {
     382             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
     383             :    result.reserve(std::char_traits<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
     384             :    return result.append(m.first, m.second).append(s);
     385             : }
     386             : #else
     387             : // worwaround versions:
     388             : template <class RandomAccessIterator>
     389             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     390             : operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
     391             :                   const sub_match<RandomAccessIterator>& m)
     392             : {
     393             :    return s + m.str();
     394             : }
     395             : template <class RandomAccessIterator>
     396             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     397             : operator + (const sub_match<RandomAccessIterator>& m,
     398             :             typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const * s)
     399             : {
     400             :    return m.str() + s;
     401             : }
     402             : #endif
     403             : template <class RandomAccessIterator>
     404             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     405             : operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
     406             :                   const sub_match<RandomAccessIterator>& m)
     407             : {
     408             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
     409             :    result.reserve(m.length() + 2);
     410             :    return result.append(1, s).append(m.first, m.second);
     411             : }
     412             : template <class RandomAccessIterator>
     413             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     414             : operator + (const sub_match<RandomAccessIterator>& m,
     415             :             typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
     416             : {
     417             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
     418             :    result.reserve(m.length() + 2);
     419             :    return result.append(m.first, m.second).append(1, s);
     420             : }
     421             : template <class RandomAccessIterator>
     422             : inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> 
     423             : operator + (const sub_match<RandomAccessIterator>& m1,
     424             :             const sub_match<RandomAccessIterator>& m2)
     425             : {
     426             :    std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
     427             :    result.reserve(m1.length() + m2.length() + 1);
     428             :    return result.append(m1.first, m1.second).append(m2.first, m2.second);
     429             : }
     430             : #ifndef BOOST_NO_STD_LOCALE
     431             : template <class charT, class traits, class RandomAccessIterator>
     432             : std::basic_ostream<charT, traits>&
     433           0 :    operator << (std::basic_ostream<charT, traits>& os,
     434             :                 const sub_match<RandomAccessIterator>& s)
     435             : {
     436           0 :    return (os << s.str());
     437             : }
     438             : #else
     439             : template <class RandomAccessIterator>
     440             : std::ostream& operator << (std::ostream& os,
     441             :                            const sub_match<RandomAccessIterator>& s)
     442             : {
     443             :    return (os << s.str());
     444             : }
     445             : #endif
     446             : 
     447             : #ifdef BOOST_OLD_REGEX_H
     448             : namespace BOOST_REGEX_DETAIL_NS{
     449             : template <class BidiIterator, class charT>
     450             : int do_toi(BidiIterator i, BidiIterator j, char c, int radix)
     451             : {
     452             :    std::string s(i, j);
     453             :    char* p;
     454             :    int result = std::strtol(s.c_str(), &p, radix);
     455             :    if(*p)raise_regex_exception("Bad sub-expression");
     456             :    return result;
     457             : }
     458             : 
     459             : //
     460             : // helper:
     461             : template <class I, class charT>
     462             : int do_toi(I& i, I j, charT c)
     463             : {
     464             :    int result = 0;
     465             :    while((i != j) && (isdigit(*i)))
     466             :    {
     467             :       result = result*10 + (*i - '0');
     468             :       ++i;
     469             :    }
     470             :    return result;
     471             : }
     472             : }
     473             : 
     474             : 
     475             : template <class BidiIterator>
     476             : sub_match<BidiIterator>::operator int()const
     477             : {
     478             :    BidiIterator i = first;
     479             :    BidiIterator j = second;
     480             :    if(i == j)raise_regex_exception("Bad sub-expression");
     481             :    int neg = 1;
     482             :    if((i != j) && (*i == '-'))
     483             :    {
     484             :       neg = -1;
     485             :       ++i;
     486             :    }
     487             :    neg *= BOOST_REGEX_DETAIL_NS::do_toi(i, j, *i);
     488             :    if(i != j)raise_regex_exception("Bad sub-expression");
     489             :    return neg;
     490             : }
     491             : template <class BidiIterator>
     492             : sub_match<BidiIterator>::operator unsigned int()const
     493             : {
     494             :    BidiIterator i = first;
     495             :    BidiIterator j = second;
     496             :    if(i == j)
     497             :       raise_regex_exception("Bad sub-expression");
     498             :    return BOOST_REGEX_DETAIL_NS::do_toi(i, j, *first);
     499             : }
     500             : #endif
     501             : 
     502             : } // namespace boost
     503             : 
     504             : #ifdef BOOST_MSVC
     505             : #pragma warning(push)
     506             : #pragma warning(disable: 4103)
     507             : #endif
     508             : #ifdef BOOST_HAS_ABI_HEADERS
     509             : #  include BOOST_ABI_SUFFIX
     510             : #endif
     511             : #ifdef BOOST_MSVC
     512             : #pragma warning(pop)
     513             : #endif
     514             : 
     515             : #endif
     516             : 

Generated by: LCOV version 1.14