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

📄 _ctype.h

📁 realview22.rar
💻 H
📖 第 1 页 / 共 2 页
字号:
};


inline const ctype<wchar_t>::char_type*
ctype<wchar_t>::
do_is (const char_type* __lo, const char_type* __hi, mask* __vec) const
{
    while (__lo != __hi)
        *__vec++ = mask_of (*__lo++);
    return __hi;
}


inline const ctype<wchar_t>::char_type*
ctype<wchar_t>::
do_scan_is (ctype_base::mask __m,
            const char_type* __low, const char_type* __high) const
{
    while (__low != __high && !(mask_of (*__low) & __m))
        ++__low;
    return __low;
}


inline const ctype<wchar_t>::char_type*
ctype<wchar_t>::
do_scan_not ( mask __m, const char_type* __low, const char_type* __high) const
{
    while (__low != __high && (mask_of (*__low) & __m))
        ++__low;
    return __low;
}


inline const ctype<wchar_t>::char_type*
ctype<wchar_t>::do_toupper (char_type* __low, const char_type* __high) const
{
    for (; __low < __high; ++__low)
        if (mask_of (*__low) & lower)
            *__low &=~ 0x20;
    return __low;
}


inline const ctype<wchar_t>::char_type*
ctype<wchar_t>::do_tolower (char_type* __low, const char_type* __high) const
{
    for (; __low < __high; ++__low)
        if ((mask_of (*__low) & upper) != 0) *__low |= 0x20;
    return __low;
}



inline const char*
ctype<wchar_t>::
do_widen (const char* __lo, const char* __hi, char_type* __dest) const
{
    while (__lo != __hi) {
        *__dest = (char_type)(unsigned char)*__lo;
        ++__lo; ++__dest;
    }
    return __hi;
}


inline const ctype<wchar_t>::char_type*
ctype<wchar_t>::do_narrow (const char_type* __lo, const char_type* __hi,
                           char __dfault, char* __dest) const {
    for ( ; __lo != __hi; __lo++)
        *__dest++ = _C_fits (*__lo) ? (char)(unsigned char)*__lo : __dfault;
    return __hi;
}

#ifndef _RWSTD_NO_EXT_LOCALE

inline ctype<wchar_t>::string_type
ctype<wchar_t>::widen (const string &__s) const
{
    string_type __res (__s.size (), 0);
    do_widen (__s.c_str (), __s.c_str () + __s.length (), &*__res.begin ());
    return __res;
}


inline string
ctype<wchar_t>::narrow (const string_type &__s, char __dfault) const
{
    string __res (__s.size (), 0);
    do_narrow (__s.c_str (), __s.c_str () + __s.length (), __dfault,
               &*__res.begin ());
    return __res;
}

#endif //_RWSTD_NO_EXT_LOCALE

#endif // _RWSTD_NO_WCHAR_T


// 22.2.1.1
template <class _CharT>
class ctype : public locale::facet, public ctype_base,
              public _RW::__rw_ctype_helper<_CharT>
{
public:

    typedef _CharT char_type;

protected:

    // inline virtual functions defined first to allow compilers to
    // inline their definitions when being called from nonvirtuals

    // 22.2.1.1.2, p1
    virtual bool do_is (mask, char_type) const {
        return false;
    }

    virtual const char_type*
    do_is (const char_type*, const char_type* __high, mask*) const {
        return __high;
    }

    // 22.2.1.1.2, p3
    virtual const char_type*
    do_scan_is (mask, const char_type*, const char_type* __high) const {
        return __high;
    }

    // 22.2.1.1.2, p5
    virtual const char_type*
    do_scan_not (mask, const char_type*, const char_type* __high) const {
        return __high;
    }

    // 22.2.1.1.2, p7
    virtual char_type do_toupper (char_type __c) const {
        return __c;
    }

    virtual const char_type*
    do_toupper (char_type*, const char_type* __high) const {
        return __high;
    }

    // 22.2.1.1.2, p9
    virtual char_type do_tolower (char_type __c) const {
        return __c;
    }

    virtual const char_type*
    do_tolower (char_type*, const char_type* __high) const {
        return __high;
    }

    // 22.2.1.1.2, p11
    virtual char_type do_widen (char __c) const {
        return char_type (__c);
    }

    virtual const char*
    do_widen (const char* __lo, const char* __hi, char_type* __dest) const {
        while (__lo < __hi)
            *__dest++ = char_type (*__lo++);
        return __hi;
    }

    // 22.2.1.1.2, p13
    virtual char do_narrow (char_type, char __dfault) const {
        return __dfault;
    }

    virtual const char_type*
    do_narrow (const char_type*, const char_type* __hi, char, char*) const {
        return __hi;
    }

public:

    _EXPLICIT ctype (size_t __ref = 0)
        : locale::facet (__ref, locale::ctype) { }


    // 22.2.1.1.1, p1
    bool is (mask __m, char_type __c) const {
        return do_is ( __m, __c);
    }

    const char_type*
    is (const char_type* __low, const char_type* __high, mask* __vec) const {
        return do_is (__low, __high, __vec);
    }

    // 22.2.1.1.1, p2
    const char_type*
    scan_is (mask __m, const char_type* __low, const char_type* __high) const {
        return do_scan_is ( __m, __low, __high);
    }

    // 22.2.1.1.1, p3
    const char_type*
    scan_not (mask __m, const char_type* __low, const char_type* __high) const {
        return do_scan_not ( __m, __low, __high);
    }

    // 22.2.1.1.1, p4
    char_type (toupper) (char_type __c) const {
        return do_toupper (__c);
    }

    const char_type* (toupper)(char_type* __low, const char_type* __high) const{
        return do_toupper (__low, __high);
    }

    // 22.2.1.1.1, p5
    char_type (tolower)(char_type __c) const {
        return do_tolower (__c);
    }

    const char_type* (tolower)(char_type* __low, const char_type* __high) const{
        return do_tolower (__low, __high);
    }

    // 22.2.1.1.1, p6
    char_type  widen (char __c) const {
        return do_widen (__c);
    }

    const char*
    widen (const char* __lo, const char* __hi, char_type* __to) const {
        return do_widen (__lo, __hi, __to);
    }

    // 22.2.1.1.1, p7
    char narrow (char_type __c, char __dfault) const {
        return do_narrow (__c, __dfault);
    }

    const char_type* narrow (const char_type* __lo, const char_type* __hi,
                             char __dfault, char* __to) const {
        return do_narrow (__lo, __hi, __dfault, __to);
    }

    static locale::id id;

#ifndef _RWSTD_NO_EXT_LOCALE

    // extensions:
    typedef
    basic_string<char_type, char_traits<char_type>, allocator<char_type> >
    string_type;

    string_type widen (const string&) const;

    string narrow (const string_type&, char) const;

#endif   // _RWSTD_NO_EXT_LOCALE

    // Implementation:
    enum { _C_facet_cat = locale::ctype, _C_ok_implicit = 1 };

private:

#ifdef _RWSTD_NO_MEMBER_TEMPLATES

    locale::id &_C_get_id () const {
        return id;
    }

#endif   // _RWSTD_NO_MEMBER_TEMPLATES

};


_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT ctype_byname<char>: public ctype<char>
{
public:

    _EXPLICIT ctype_byname (const char*, size_t __ref = 0);

private:

    static const mask *_C_get_mask_table (const char*);
};


#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT ctype_byname<wchar_t>: public ctype<wchar_t>
{
public:

    _EXPLICIT ctype_byname (const char*, size_t __ref = 0)
	: ctype<wchar_t> (__ref) { }
};

#endif   // _RWSTD_NO_WCHAR_T


// 22.2.1.2
template <class _CharT>
class ctype_byname: public ctype<_CharT>
{
public:

    _EXPLICIT ctype_byname (const char*, size_t __ref = 0)
	: ctype<_CharT>(__ref) { }
};

// convenience interfaces: is*(char)
// names parenthesized to avoid clashing with masking macros

template <class _CharT>
inline bool (isspace)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::space, __c);
}


template <class _CharT>
inline bool (isprint)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::print, __c);
}

template <class _CharT>
inline bool (iscntrl)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is(ctype_base::cntrl, __c);
}


template <class _CharT>
inline bool (isupper)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::upper, __c);
}


template <class _CharT>
inline bool (islower)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::lower, __c);
}


template <class _CharT>
inline bool (isalpha)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::alpha, __c);
}


template <class _CharT>
inline bool (isdigit)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::digit, __c);
}


template <class _CharT>
inline bool (ispunct)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is(ctype_base::punct, __c);
}


template <class _CharT>
inline bool (isxdigit)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::xdigit, __c);
}


template <class _CharT>
inline bool (isalnum)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::alnum, __c);
}


template <class _CharT>
inline bool (isgraph)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).is (ctype_base::graph, __c);
}


template <class _CharT>
inline _CharT (toupper)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).toupper (__c);
}


template <class _CharT>
inline _CharT (tolower)(_CharT __c, const locale& __loc)
{
    return _USE_FACET (ctype<_CharT>, __loc).tolower (__c);
}


_RWSTD_NAMESPACE_END   // std


_RWSTD_NAMESPACE_BEGIN (__rw)


inline const __rw_digit_map<char>&
__rw_digit_map<char>::_C_get_digit_map (const _STD::ctype<char>& __ctp)
{
    return __ctp._C_digit_map;
}


_RWSTD_SPECIALIZED_FUNCTION
inline _STD::ctype<char>*
__rw_create_named_facet (_STD::ctype<char>*, const char *__name, size_t __ref)
{
    return new _STD::ctype_byname<char>(__name, __ref);
}


_RWSTD_SPECIALIZED_FUNCTION
inline _STD::ctype<char>*
__rw_create_native_facet (_STD::ctype<char>*)
{
    return new _STD::ctype<char>(0, false, 1);
}


_RWSTD_SPECIALIZED_FUNCTION
inline _STD::ctype<char>*
__rw_create_classic_facet (_STD::ctype<char>*)
{
    return new _STD::ctype<char>(0, false, 0);
}


_RWSTD_NAMESPACE_END   // __rw


#if _RWSTD_DEFINE_TEMPLATE (CTYPE)
#  include <rw/_ctype.cc>
#endif

#endif   // _RWSTD_CTYPE_H_INCLUDED

⌨️ 快捷键说明

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