⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regexpr2.h

📁 vsstylemanager1.0.4希望对大家有用啊,
💻 H
📖 第 1 页 / 共 3 页
字号:
        : basic_rpattern_base<IterT, SyntaxT>( pat, flags, mode )
    {
    }

    basic_rpattern
    (
        string_type const & pat,
        string_type const & subst,
        REGEX_FLAGS flags = NOFLAGS,
        REGEX_MODE mode = MODE_DEFAULT
    )                                                   //throw( bad_regexpr, std::bad_alloc )
        : basic_rpattern_base<IterT, SyntaxT>( pat, subst, flags, mode )
    {
    }

    basic_rpattern & operator=( basic_rpattern<IterT, SyntaxT> const & that ) //throw( bad_regexpr, std::bad_alloc )
    {
        basic_rpattern_base<IterT, SyntaxT>::operator=( that );
        return *this;
    }

    // Iter2 must be convertible to type IterT
    template< typename OtherT, typename AllocT >
    backref_type const & match
    (
        OtherT ibegin,
        OtherT iend,
        basic_match_results<IterT, AllocT> & results
    ) const
    {
        // If your compile breaks here, it is because OtherT is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        detail::static_assert< detail::is_convertible<OtherT,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        if( detail::regex_access<IterT>::_do_match( *this, results, ibegin, iend, false ) )
        {
            return results.backref(0);
        }
        else
        {
            return detail::static_init<backref_type>::value;
        }
    }

    template< typename CharT, typename AllocT >
    backref_type const & match
    (
        CharT * szbegin,
        basic_match_results<IterT, AllocT> & results
    ) const
    {
        // If your compile breaks here, it is because CharT* is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        detail::static_assert< detail::is_convertible<CharT*,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        if( detail::regex_access<IterT>::_do_match_c( *this, results, szbegin ) )
        {
            return results.backref(0);
        }
        else
        {
            return detail::static_init<backref_type>::value;
        }
    }

    template< typename CharT, typename TraitsT, typename AllocT >
    backref_type const & match
    (
        std::basic_string<CharT, TraitsT, AllocT> const & str,
        basic_match_results<IterT, AllocT> & results,
        size_type pos = 0,
        size_type len = static_cast<size_type>(-1)
    ) const
    {
        // If your compile breaks here, it is because iter_type is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        typedef typename std::basic_string<CharT, TraitsT, AllocT>::const_iterator iter_type;
        detail::static_assert< detail::is_convertible<iter_type,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        IterT ibegin = str.begin(), iend = str.begin();

        if( len == npos || pos + len >= str.size() )
            iend = IterT(str.end());
        else
            std::advance( iend, pos + len );

        std::advance( ibegin, pos );
        return match( ibegin, iend, results );
    }

    template< typename OtherT >
    size_t count( OtherT ibegin, OtherT iend ) const
    {
        // If your compile breaks here, it is because OtherT is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        detail::static_assert< detail::is_convertible<OtherT,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        return detail::regex_access<IterT>::_do_count( *this, ibegin, iend, false );
    }

    template< typename CharT >
    size_t count( CharT * szbegin ) const
    {
        // If your compile breaks here, it is because CharT* is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        detail::static_assert< detail::is_convertible<CharT*,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        return detail::regex_access<IterT>::_do_count( *this, szbegin, (CharT*)0, true );
    }

    template< typename CharT, typename TraitsT, typename AllocT >
    size_t count
    (
        std::basic_string<CharT, TraitsT, AllocT> const & str,
        size_type pos = 0,
        size_type len = static_cast<size_type>(-1)
    ) const
    {
        // If your compile breaks here, it is because iter_type is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        typedef typename std::basic_string<CharT, TraitsT, AllocT>::const_iterator iter_type;
        detail::static_assert< detail::is_convertible<iter_type,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        IterT ibegin = str.begin(), iend = str.begin();

        if( len == npos || pos + len >= str.size() )
            iend = IterT(str.end());
        else
            std::advance( iend, pos + len );

        std::advance( ibegin, pos );
        return count( ibegin, iend );
    }

    template< typename OtherT, typename CharT, typename TraitsT, typename AllocT >
    size_t split
    (
        OtherT ibegin,
        OtherT iend,
        basic_split_results<CharT, TraitsT, AllocT> & results,
        int limit = 0
    ) const
    {
        // If your compile breaks here, it is because OtherT is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        detail::static_assert< detail::is_convertible<OtherT,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        return detail::regex_access<IterT>::_do_split( *this, results, ibegin, iend, limit, false );
    }

    template< typename Char1T, typename Char2T, typename TraitsT, typename AllocT >
    size_t split
    (
        Char1T * szbegin,
        basic_split_results<Char2T, TraitsT, AllocT> & results,
        int limit = 0
    ) const
    {
        // If your compile breaks here, it is because Iter2 is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        detail::static_assert< detail::is_convertible<Char1T*,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        // If your compile breaks here, it's because the string you passed in doesn't have
        // the same character type as your split_results struct
        same_char_types( Char1T(), Char2T() );

        // If your compile breaks here, it is because CharT const * is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        return detail::regex_access<IterT>::_do_split( *this, results, szbegin, (Char1T*)0, limit, true );
    }

    template< typename CharT, typename TraitsT, typename AllocT >
    size_t split
    (
        std::basic_string<CharT, TraitsT, AllocT> const & str,
        basic_split_results<CharT, TraitsT, AllocT> & results,
        int limit = 0,
        size_type pos = 0,
        size_type len = static_cast<size_type>(-1)
    ) const
    {
        // If your compile breaks here, it is because iter_type is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        typedef typename std::basic_string<CharT, TraitsT, AllocT>::const_iterator iter_type;
        detail::static_assert< detail::is_convertible<iter_type,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        IterT ibegin = str.begin(), iend = str.begin();

        if( len == npos || pos + len >= str.size() )
            iend = IterT(str.end());
        else
            std::advance( iend, pos + len );

        std::advance( ibegin, pos );
        return split( ibegin, iend, results, limit );
    }

    template< typename CharT, typename TraitsT, typename AllocT >
    size_t substitute
    (
        std::basic_string<CharT, TraitsT, AllocT> & str,
        basic_subst_results<CharT, TraitsT, AllocT> & results,
        size_type pos = 0,
        size_type len = static_cast<size_type>(-1)
    ) const
    {
        // If your compile breaks here, it is because iter_type is not
        // convertible to type IterT. Check the declaration of your rpattern object.
        typedef typename std::basic_string<CharT, TraitsT, AllocT>::const_iterator iter_type;
        detail::static_assert< detail::is_convertible<iter_type,IterT>::value > const iterator_types_are_not_convertible;
        ( void ) iterator_types_are_not_convertible;

        return detail::regex_access<IterT>::_do_subst( *this, str, results, pos, len );
    }
};

// --------------------------------------------------------------------------
//
// Class:       basic_rpattern_c
//
// Description: a pattern object optimized for matching C-style, NULL-
//              terminated strings. It treats the null-terminator as
//              the end-of-string condition.
//
// Methods:     basic_rpattern_c - c'tor
//              basic_rpattern_c -
//              basic_rpattern_c -
//              match            - match a null-terminated string
//              count            - count matches in a null-terminated string
//              _do_match_c      - internal implementation
//
// History:     8/13/2001 - ericne - Created
//
// --------------------------------------------------------------------------
template< typename CharT, typename SyntaxT = perl_syntax<CharT> >
class basic_rpattern_c : public basic_rpattern_base<CharT const *, SyntaxT>
{
    typedef detail::basic_rpattern_base_impl<CharT const *> impl;
public:
    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::syntax_type     syntax_type;
    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::char_type       char_type;
    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::traits_type     traits_type;

    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::string_type     string_type;
    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::size_type       size_type;

    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::backref_type    backref_type;
    typedef typename basic_rpattern_base<CharT const *, SyntaxT>::backref_vector  backref_vector;

    basic_rpattern_c() //throw()
        : basic_rpattern_base<CharT const *, SyntaxT>()
    {
    }

    basic_rpattern_c( basic_rpattern_c const & that )
        : basic_rpattern_base<CharT const *, SyntaxT>( that )
    {
    }

    explicit basic_rpattern_c
    (
        string_type const & pat,
        REGEX_FLAGS flags = NOFLAGS,
        REGEX_MODE mode = MODE_DEFAULT
    )                                                           //throw( bad_regexpr, std::bad_alloc )
        : basic_rpattern_base<CharT const *, SyntaxT>( pat, flags, mode )
    {
    }

    basic_rpattern_c & operator=( basic_rpattern_c<CharT, SyntaxT> const & that )
    {
        basic_rpattern_base<CharT const *, SyntaxT>::operator=( that );
        return *this;
    }

    template< typename AllocT >
    backref_type const & match
    (
        CharT const * szbegin,
        basic_match_results_c<CharT, AllocT> & results
    ) const
    {
        if( detail::regex_access<CharT const*>::_do_match_c( *this, results, szbegin ) )
        {
            return results.backref(0);
        }
        else
        {
            return detail::static_init<backref_type>::value;
        }
    }

    size_t count( CharT const * szbegin ) const
    {
        return detail::regex_access<CharT const*>::_do_count( *this, szbegin, (CharT const*)0, true );
    }
};



#if defined(UNICODE) | defined(_UNICODE)
typedef wchar_t rechar_t;
#else
typedef char    rechar_t;
#endif

typedef std::basic_string<rechar_t> restring;

// On many implementations of the STL, string::iterator is not a typedef
// for char*. Rather, it is a wrapper class. As a result, the regex code
// gets instantiated twice, once for bare pointers (rpattern_c) and once for
// the wrapped pointers (rpattern). But if there is a conversion from the
// bare ptr to the wrapped ptr, then we only need to instantiate the template
// for the wrapped ptr, and the code will work for the bare ptrs, too.
// This can be a significant space savings.  The REGEX_FOLD_INSTANTIONS
// macro controls this optimization. The default is "off" for backwards
// compatibility. To turn the optimization on, compile with:
// -DREGEX_FOLD_INSTANTIATIONS=1
#ifndef REGEX_FOLD_INSTANTIATIONS
#define REGEX_FOLD_INSTANTIATIONS 0
#endif

typedef ::regex::detail::select
<
    REGEX_FOLD_INSTANTIATIONS &&
        detail::is_convertible<rechar_t const *,restring::const_iterator>::value,
    restring::const_iterator,
    rechar_t const *
>::type lpctstr_t;

// For matching against null-terminated strings
typedef basic_rpattern<lpctstr_t, perl_syntax<rechar_t> >  perl_rpattern_c;
typedef basic_rpattern<lpctstr_t, posix_syntax<rechar_t> > posix_rpattern_c;

// For matching against std::strings
typedef basic_rpattern<restring::const_iterator, perl_syntax<rechar_t> >  perl_rpattern;
typedef basic_rpattern<restring::const_iterator, posix_syntax<rechar_t> > posix_rpattern;

// Default to perl syntax
typedef perl_rpattern    rpattern;
typedef perl_rpattern_c  rpattern_c;

// typedefs for the commonly used match_results and subst_results
typedef basic_match_results<restring::const_iterator> match_results;
typedef basic_match_results<lpctstr_t>                match_results_c;
typedef basic_subst_results<rechar_t>                 subst_results;
typedef basic_split_results<rechar_t>                 split_results;

#if defined(_MSC_VER) & 1200 < _MSC_VER
// These are no longer useful, and will go away in a future release
// You should be using the version without the _c
# pragma deprecated( basic_rpattern_c )
# pragma deprecated( basic_match_results_c )
#endif

#define STATIC_RPATTERN_EX( type, var, params ) \
    static type const var params;

#define STATIC_RPATTERN( var, params ) \
    STATIC_RPATTERN_EX( regex::rpattern, var, params )

#define STATIC_RPATTERN_C( var, params ) \
    STATIC_RPATTERN_EX( regex::rpattern_c, var, params )

#if defined(_MSC_VER) & 1200 < _MSC_VER
#pragma deprecated(STATIC_RPATTERN_EX)
#endif

//
// ostream inserter operator for back-references
//
template< typename CharT, typename TraitsT, typename IterT >
inline std::basic_ostream<CharT, TraitsT> & operator<<
(
    std::basic_ostream<CharT, TraitsT> & sout,
    backref_tag<IterT> const & br
)
{
    return br.print( sout );
}

} // namespace regex


//
// specializations for std::swap
//
namespace std
{
    template<>
    inline void swap( regex::detail::regex_arena & left, regex::detail::regex_arena & right )
    {
        left.swap( right );
    }

    template< typename IterT, typename SyntaxT >
    inline void swap( regex::basic_rpattern_base<IterT, SyntaxT> & left, regex::basic_rpattern_base<IterT, SyntaxT> & right )
    {
        left.swap( right );
    }
}

#ifdef _MSC_VER
#pragma warning( pop )
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -