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

📄 _locimp.h

📁 realview22.rar
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
 *
 * _locimp.h - Declarations for the Standard Library locale private
 *             implementation classes.
 *
 * This is an internal header file used to implement the C++ Standard
 * Library. It should never be #included directly by a program.
 *
 * $Id: _locimp.h,v 1.1.1.1 2002/01/10 17:38:30 vkorstan Exp $
 *
 ***************************************************************************
 *
 * Copyright (c) 1994-2001 Rogue Wave Software, Inc.  All Rights Reserved.
 *
 * This computer software is owned by Rogue Wave Software, Inc. and is
 * protected by U.S. copyright laws and other laws and by international
 * treaties.  This computer software is furnished by Rogue Wave Software,
 * Inc. pursuant to a written license agreement and may be used, copied,
 * transmitted, and stored only in accordance with the terms of such
 * license and with the inclusion of the above copyright notice.  This
 * computer software or any other copies thereof may not be provided or
 * otherwise made available to any other person.
 *
 * U.S. Government Restricted Rights.  This computer software is provided
 * with Restricted Rights.  Use, duplication, or disclosure by the
 * Government is subject to restrictions as set forth in subparagraph (c)
 * (1) (ii) of The Rights in Technical Data and Computer Software clause
 * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
 * Commercial Computer Software--Restricted Rights at 48 CFR 52.227-19,
 * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
 * Flatiron Parkway, Boulder, Colorado 80301 USA.
 *
 **************************************************************************/

#ifndef _RWSTD_LOCIMP_H_INCLUDED
#define _RWSTD_LOCIMP_H_INCLUDED

#include <rw/_mutex.h>
#include <rw/_defs.h>

_RWSTD_NAMESPACE_BEGIN (std)

class _RWSTD_EXPORT locale;

template <class _CharT>
class ctype;

template <class _CharT>
class ctype_byname;

_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT ctype<char>;

_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT ctype_byname<char>;

#ifndef _RWSTD_NO_WCHAR_TYPE

_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT ctype<wchar_t>;

_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT ctype_byname<wchar_t>;

#endif   // _RWSTD_NO_WCHAR_TYPE

_RWSTD_NAMESPACE_END   // std


_RWSTD_NAMESPACE_BEGIN (__rw)

// Implementation class template -- __rw_timepunct<_CharT>
//
// A facet such as this should have been included in the standard.  We just
// declare it here; the definition occurs below, after locale::facet has been
// defined.

template <class _CharT> class __rw_timepunct;


// Implementation forward declarations:

class _RWSTD_EXPORT __rw_locale_imp;

class _RWSTD_EXPORT __rw_facet_base;

struct _RWSTD_EXPORT __rw_digit_map_base;

template <class _CharT>
class __rw_digit_map;

template <class _CharT>
struct __rw_keyword_def;

template <class _CharT>
struct __rw_keyword_map;

template <class _CharT>
class __rw_keyword_cracker;

class _RWSTD_EXPORT __rw_digit_reader_base;

template <class _CharT>
class __rw_digit_reader_base_1;

template <class _CharT, class _InputIter>
class __rw_digit_reader;

class _RWSTD_EXPORT __rw_digit_writer_base;

template <class _CharT>
class __rw_digit_writer_base_1;

template <class _CharT, class _OutputIter>
class __rw_digit_writer;


// We would prefer to define locale::id and locale::facet entirely as nested
// classes of locale, but current compilers have problems with out-of-line
// definition of members of such classes, so we have to derive most of their
// behavior from unnested implementation classes:

class _RWSTD_EXPORT __rw_facet_base: public __rw_synchronized
{
    friend class __rw_locale_imp;
    friend class _STD::locale;

public:

    enum {
        _C_facet_cat    = 0,   // facet category
        _C_ok_implicit  = 0,   // ok to create implicitly?
        _C_initialized = 1    // has facet been initialized?
    };

    void _C_set_ref (size_t __ref) {
        _C_ref_count = __ref;
    }

private:

    int              _C_category;     // same type as locale::category
    int              _C_flags;        // various flags (used externally)
    _RWSTD_C::size_t _C_ref_count;    // reference counter

protected:

    __rw_facet_base (_RWSTD_C::size_t __ref, int __cat = 0)
        : _C_category (__cat),  _C_flags (0), _C_ref_count (__ref) { }

    __rw_facet_base (const __rw_facet_base &__rhs)
        : __rw_synchronized (),
          _C_category (__rhs._C_category),
          _C_flags (__rhs._C_flags),
          _C_ref_count (__rhs._C_ref_count) { }

    __rw_facet_base& operator= (const __rw_facet_base &__rhs) {
        if (this != &__rhs) {
            _C_category  = __rhs._C_category;
            _C_flags     = __rhs._C_flags;
            _C_ref_count = __rhs._C_ref_count;
        }
        return *this;
    }

    virtual ~__rw_facet_base () { }

    // _C_initfacet() is called by locale::__install the first time a facet
    // is installed in its first locale.  Some facets override it to set up
    // private  data that depends on return values of virtual do_xxx
    // functions that can't be called yet in a constructor.

    virtual void _C_initfacet (const _STD::locale&) { }
};


_RWSTD_NAMESPACE_END   // __rw


#include <rw/_locvector.h>


_RWSTD_NAMESPACE_BEGIN (__rw)

// ----------------------------------------
// Implementation class -- __rw_locale_imp.
// ----------------------------------------

class _RWSTD_EXPORT __rw_locale_imp: public __rw_synchronized
{
public:
    // for convenience
    typedef _RWSTD_C::size_t size_type;

    friend class _RWSTD_EXPORT _STD::locale;
    
    enum {
        _C_none     = 0x0000,
        _C_collate  = 0x0010,
        _C_ctype    = 0x0020,
        _C_monetary = 0x0040,
        _C_numeric  = 0x0080,
        _C_time     = 0x0100,
        _C_messages = 0x0200,
        _C_all      =   _C_none | _C_collate | _C_ctype | _C_monetary
                      | _C_numeric | _C_time | _C_messages,

        // implementation details
        _C_libc_constants = 0x000f,
        _C_first_category = _C_collate,
        _C_n_categories   = 6
    };

    __rw_locale_vector<_STD::string>     _C_facet_names;  // names of facets
    __rw_locale_vector<__rw_facet_base*> _C_facets;       // pointers to facets

    int _C_native;
    int _C_named;

    // locale name; 0 if unnamed, "", "C", or implementation-defined
    const char *_C_name;

    size_type _C_ref_count;   // reference count

    __rw_locale_imp (const char* = 0, size_type = 36, size_type = 0);

    __rw_locale_imp (const __rw_locale_imp&, const char*, size_type);

    ~__rw_locale_imp () {
        // cast is for non-conforming compilers, such as MSVC6.3
        delete [] _RWSTD_CONST_CAST(char*,_C_name);
    }

    __rw_facet_base* _C_get_facet (size_type __inx) const {
        return __inx < _C_facets.size () ? _C_facets [__inx] : 0;
    }

private:
    inline const char *_C_category_name (int) const;

    // Map C library LC_xxx constants into facet categories.
    static int _C_map_category (int);

    // Parse a locale name into category names.
    static bool _C_parse_name (__rw_locale_vector<_STD::string>&, const char*);
};


// ---------------------------------
// Inline members of __rw_locale_imp
// ---------------------------------

inline __rw_locale_imp::__rw_locale_imp (const char *__name,
                                         size_type __size, size_type __ref)
    : _C_facets (__size, 0), 
      _C_native (0), 
      _C_named (0),
      _C_name (0),
      _C_ref_count (__ref) {


    if (__name) {
        __size = _RWSTD_C::strlen (__name) + 1;

⌨️ 快捷键说明

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