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

📄 _punct.h

📁 realview22.rar
💻 H
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************
 *
 * _punct.h - Definitions of the punct and supporting template classes
 *
 * This is an internal header file used to implement the C++ Standard
 * Library. It should never be #included directly by a program.
 *
 * $Id: _punct.h,v 1.4 2004/01/30 22:33:19 sdouglas 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_PUNCT_H_INCLUDED
#define _RWSTD_PUNCT_H_INCLUDED

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

#include _RWSTD_CTIME


_RWSTD_NAMESPACE_BEGIN (std)

template <class _CharT>
class numpunct;

template <class _CharT, bool _Intl>
class moneypunct;

_RWSTD_NAMESPACE_END   // std


_RWSTD_NAMESPACE_BEGIN (__rw)

// ---------------------------------------------------------
// Implementation class template -- __rw_keyword_def<_CharT>.
// ---------------------------------------------------------

// Helper class used in parsing keywords from input_C_indx (such as true/false
// in num_get, month and day names in time_get, etc).

template <class _CharT>
struct __rw_keyword_def
{
    const _CharT *_C_name;
    int           _C_indx;
};

// ---------------------------------------------------------
// Implementation class template -- __rw_keyword_map<_CharT>.
// ---------------------------------------------------------

// Defines a set of keywords to be recognized on input and to be written to
// output.  Private instances are hidden in numpunct (for true/false) and
// rwstd::__rw_timepunct (for month and weekday names).

template <class _CharT>
struct __rw_keyword_map
{
    int                             _C_numdefs;
    const __rw_keyword_def<_CharT> *_C_defs;
};


// --------------------------------------------------------
// Implementation class template -- __rw_punct_data<_CharT>.
// --------------------------------------------------------

template <class _CharT>
class __rw_digit_handler_base_1;

// Common base class for __rw::__rw_numpunct_impl_data and
// __rw::__rw_moneypunct_impl_data.

template <class _CharT>
class __rw_punct_data
{
    friend class __rw_digit_handler_base_1<_CharT>;

public:
    typedef _STD::char_traits<_CharT> traits_type;
    typedef _STD::basic_string<_CharT, traits_type, _STD::allocator<_CharT> >
    string_type;

protected:

    _CharT _C_dp, _C_ts;
    _STD::string _C_gr;
};

// -----------------------------------------------------------
// Implementation class template -- __rw_numpunct_init_data<_CharT>.
// -----------------------------------------------------------

template <class _CharT>
struct __rw_numpunct_init_data
{
    bool _C_del;                     // Kill the bearer of this message
    _CharT _C_dp, _C_ts;             // Decimal point and thousands separator
    const char *_C_gr;               // Digit grouping rule
    const _CharT *_C_tn, *_C_fn;     // Strings for boolean true and false
};

// ------------------------------------------
// Implementation class -- __rw_numpunct_impl_base.
// ------------------------------------------

// Contains parts of numpunct<_CharT> that don't depend on the _CharT template
// parameter.

class _RWSTD_EXPORT __rw_numpunct_impl_base
{
public:
  static __rw_numpunct_init_data<char> *_C_get_named_init_ (const char*);
};

// -----------------------------------------------------------
// Implementation class template -- __rw_numpunct_impl_data<_CharT>.
// -----------------------------------------------------------

// numpunct<_CharT> derives from this (via __rw::__rw_numpunct_impl) to get its
// private data members.

template <class _CharT>
class __rw_numpunct_impl_data
    : public __rw_numpunct_impl_base, 
      public __rw_punct_data<_CharT>
{
protected:
    inline __rw_numpunct_impl_data (const __rw_numpunct_init_data<_CharT>*);
    static __rw_numpunct_init_data<_CharT> *_C_get_init_by_name_ (const char*);
    void _C_initfacetbase (const locale&);

public:
    typedef _STD::char_traits<_CharT> traits_type;
    typedef _STD::basic_string<_CharT, traits_type, allocator<_CharT> >
    string_type;

private:
    friend class numpunct<_CharT>;
    friend class __rw_keyword_cracker<_CharT>;

    string_type _C_tn, _C_fn;

  __rw_keyword_def<_CharT> tf_defs_[2];
  __rw_keyword_map<_CharT> tf_map_;

};


template <class _CharT>
inline
__rw_numpunct_impl_data<_CharT>::
__rw_numpunct_impl_data (const __rw_numpunct_init_data<_CharT> *__np)
{
    if (!__np) {
        this->_C_dp = _CharT ('.');
        this->_C_ts = _CharT (',');
    } else {
        this->_C_dp = __np->_C_dp;
        this->_C_ts = __np->_C_ts;
        this->_C_gr = __np->_C_gr;
        _C_tn       = __np->_C_tn;
        _C_fn       = __np->_C_fn;

        if (__np->_C_del)
            delete[] _RWSTD_CONST_CAST (char*,
                                        _RWSTD_REINTERPRET_CAST (const char*,
                                                                 __np));
    }
}

template <class _CharT>
__rw_numpunct_init_data<_CharT>*
__rw_fixup_numpunct_init (__rw_numpunct_init_data<char>*, _CharT*);

_RWSTD_SPECIALIZED_FUNCTION
inline __rw_numpunct_init_data<char>*
__rw_fixup_numpunct_init (__rw_numpunct_init_data<char> *__np, char*)
{
    return __np;
}

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_numpunct_impl_data<char>);

#ifndef _RWSTD_NO_WCHAR_TYPE

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_numpunct_impl_data<wchar_t>);

#endif   // _RWSTD_NO_WCHAR_TYPE


// ------------------------------------------------------------
// Implementation class template -- __rw_numpunct_impl<_CharT>.
// ------------------------------------------------------------

// numpunct<_CharT> derives from this to obtain the part of its behavior that
// must be specialized for char and wchar_t.  This lets us avoid specializing
// the whole numpunct<_CharT> template.  Currently the only specialized behavior
// is the initialization of private data members in the constructor.

template <class _CharT>
class __rw_numpunct_impl
    : public __rw_numpunct_impl_data<_CharT>
{
    static const __rw_numpunct_init_data<_CharT> _C_ivals;

protected:

    __rw_numpunct_impl (const __rw_numpunct_init_data<_CharT>* __np)
        : __rw_numpunct_impl_data<_CharT>(__np) { }

public:

    static const __rw_numpunct_init_data<_CharT> *_C_get_ivals () {
        return &_C_ivals;
    }
};


template <class _CharT>
struct __rw_bool_name
{
    static const _CharT _C_name[][6];
};


// __rw_bool_name explicitly instantiated to work around a g++ 2.95.2 bug
// on AIX (and a few other platforms) where it "forgets" to do so implicitly
_RWSTD_INSTANTIATE_1 (struct _RWSTD_EXPORT __rw_bool_name<char>);
_RWSTD_INSTANTIATE_1 (class  _RWSTD_EXPORT __rw_numpunct_impl<char>);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_1 (struct _RWSTD_EXPORT __rw_bool_name<wchar_t>);
_RWSTD_INSTANTIATE_1 (class  _RWSTD_EXPORT __rw_numpunct_impl<wchar_t>);

#endif   // _RWSTD_NO_WCHAR_T


// -------------------------------------------------------------
// Implementation class template -- __rw_timepunct_init_data<_CharT>.
// -------------------------------------------------------------

// Structure used to initialize the private data members of
// __rw_timepunct<_CharT>.
template <class _CharT>
class __rw_timepunct_init_data
{
public:
  const _CharT *_C_day_nms[7][2];   // Day names and abbreviations
  const _CharT *_C_month_nms[12][2];// Month names and abbreviations
  const _CharT *_C_ampm_nms[2];     // AM/PM strings
  const _CharT *_C_bad_nm;          // Bad value output signal
  const _CharT *_C_ord_nms[100];    // Ordinal numbers
  const _CharT *_C_dt_tm_pats[6];   // Patterns for formats "xXcDrT" resp.
};

template <class _CharT>
class __rw_timepunct_init;

_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT __rw_timepunct_init<char> 
{
public:
    typedef _STD::char_traits<char> traits_type;
    typedef _STD::basic_string<char, traits_type, _STD::allocator<char> >
    string_type;

  const __rw_timepunct_init_data<char>& _C_tinit;

  __rw_timepunct_init (const __rw_timepunct_init_data<char> &__np)
    : _C_tinit (__np) 
  {}

  const string_type _C_get_day (int, bool) const;
  const string_type _C_get_month (int, bool) const;
  const string_type _C_get_ampm (bool) const;
  const string_type _C_get_bad() const  {
      return _C_tinit._C_bad_nm;
  }

  const string_type _C_get_ord(int __i) const {
      return _C_tinit._C_ord_nms[__i];
  }

  const string_type _C_get_pattern(int __i) const {
      return _C_tinit._C_dt_tm_pats[__i];
  }
};

#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_SPECIALIZED_CLASS
class _RWSTD_EXPORT __rw_timepunct_init<wchar_t> 
{

public:
    typedef _STD::char_traits<wchar_t> traits_type;
    typedef basic_string<wchar_t, traits_type, _STD::allocator<wchar_t> >
    string_type;

  const __rw_timepunct_init_data<wchar_t>& _C_tinit;

  __rw_timepunct_init (const __rw_timepunct_init_data<wchar_t> &__np)
    : _C_tinit(__np) 
  {}

  const string_type _C_get_day(int __i, bool __abr) const;
  const string_type _C_get_month(int __i, bool __abr) const;
  const string_type _C_get_ampm(bool __pm) const;

#if 0

  const string_type _C_get_day (int __i, bool __abr) const {
      return _C_tinit._C_day_nms[__i][__abr];
  }

  const string_type _C_get_month(int __i, bool __abr) const {
      return _C_tinit._C_month_nms[__i][__abr];
  }

  const string_type _C_get_ampm(bool __pm) const {
      return _C_tinit._C_ampm_nms[__pm];
  }

#endif   // 0/1


  const string_type _C_get_bad() const  {
      return _C_tinit._C_bad_nm;
  }

  const string_type _C_get_ord(int __i) const {
      return _C_tinit._C_ord_nms[__i];
  }

  const string_type _C_get_pattern(int __i) const {
      return _C_tinit._C_dt_tm_pats[__i];
  }
};
#endif // _RWSTD_NO_WCHAR_T


template <class _CharT>
class __rw_timepunct_init
{

public:
    typedef _STD::char_traits<_CharT> traits_type;
    typedef _STD::basic_string<_CharT, traits_type, _STD::allocator<_CharT> >
    string_type;

    const __rw_timepunct_init_data<_CharT>& _C_tinit;

    __rw_timepunct_init (const __rw_timepunct_init_data<_CharT> &__p)
        : _C_tinit(__p) 
        {}

  const string_type _C_get_day(int __i, bool __abr) const {
      return _C_tinit._C_day_nms[__i][__abr];
  }

  const string_type _C_get_month(int __i, bool __abr) const {
      return _C_tinit._C_month_nms[__i][__abr];
  }

  const string_type _C_get_ampm(bool __pm) const {
      return _C_tinit._C_ampm_nms[__pm];
  }

  const string_type _C_get_bad() const  {
      return _C_tinit._C_bad_nm;
  }

  const string_type _C_get_ord(int __i) const {
      return _C_tinit._C_ord_nms[__i];
  }

  const string_type _C_get_pattern(int __i) const {

⌨️ 快捷键说明

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