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

📄 _money.h

📁 realview22.rar
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
 *
 * _money.h - Definitions of the money facets
 *
 * This is an internal header file used to implement the C++ Standard
 * Library. It should never be #included directly by a program.
 *
 * $Id: _money.h,v 1.2 2002/12/09 16:32:11 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_MONEY_H_INCLUDED
#define _RWSTD_MONEY_H_INCLUDED


#include <rw/_codecvt.h>
#include <rw/_punct.h>
#include <rw/_locale.h>
#include <rw/_defs.h>


_RWSTD_NAMESPACE_BEGIN (std)


struct money_base
{
    enum part { none, space, symbol, sign, value };
    struct pattern { char field[4]; };
};


_RWSTD_NAMESPACE_END   // std


_RWSTD_NAMESPACE_BEGIN (__rw)

template <class _CharT>
class __rw_money_handler_base_1;

template <class _CharT>
class __rw_money_reader_base_1;

template <class _CharT>
class __rw_money_writer_base_1;

template <class _CharT, class _OutputIter>
class __rw_money_reader_base_2;

template <class _CharT, class _OutputIter>
class __rw_money_writer_base_2;

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

// Structure used to initialize a rwstd::__rw_moneypunct_impl_data<_CharT>.

template <class _CharT>
class __rw_moneypunct_init_data
{
public:
    bool          _C_del;    // Delete when initialization is done
    _CharT        _C_dp,
                  _C_ts;     // Decimal point and thousands separator
    const char   *_C_gr;     // Grouping pattern
    const _CharT *_C_cs;     // Currency symbol string
    const _CharT *_C_ps,
                 *_C_ns;     // Positive and negative sign strings
    int           _C_fd;     // Number of fractional digits

    _STD::money_base::pattern _C_pf; // Positive format pattern
    _STD::money_base::pattern _C_nf; // Negative format pattern
};

// ---------------------------------------------
// Implementation class -- __rw_moneypunct_impl_base.
// ---------------------------------------------

// Contains parts of __rw_moneypunct_impl_data<_CharT> that
// do not depend on the template parameter.

class _RWSTD_EXPORT __rw_moneypunct_impl_base
{
public:
    static const _RW::__rw_moneypunct_init_data<char>*
    _C_get_named_init (const char*, bool);
};

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

// moneypunct<_CharT, _Intl> derives from this (via
// __rw_moneypunct_impl<_CharT, _Intl>) to get its private data members.

template <class _CharT>
class __rw_moneypunct_impl_data
    : public __rw_moneypunct_impl_base, 
      public __rw_punct_data<_CharT>
{
    friend class __rw_money_handler_base_1<_CharT>;

    friend class _STD::moneypunct<_CharT, false>;
    friend class _STD::moneypunct<_CharT, true>;

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

    string_type _C_cs;           // Currency symbol
    string_type _C_ps,           // Positive and negative sign strings
                _C_ns;  
    int         _C_fd;           // Number of fractional digits

    // Positive and negative format patterns
    _STD::money_base::pattern _C_pf, _C_nf;

protected:
    __rw_moneypunct_impl_data (const __rw_moneypunct_init_data<_CharT>*);

    const __rw_moneypunct_init_data<_CharT>*
    _C_get_init_by_name_ (const char*, bool);
};

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_moneypunct_impl_data<char>);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_moneypunct_impl_data<wchar_t>);

#endif   // _RWSTD_NO_WCHAR_T


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

// Contains common __rw_money_reader and __rw_money_writer functionality that depends
// only on the _CharT template parameter.

template <class _CharT>
class __rw_money_handler_base_1
{
    const __rw_moneypunct_impl_data<_CharT> &_C_mpunct;

protected:

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

    __rw_money_handler_base_1 (const __rw_moneypunct_impl_data<_CharT> &__p)
        : _C_mpunct(__p) { }

    static const __rw_moneypunct_impl_data<_CharT>&
    _C_get_punct_data (const locale &__loc, bool __intl);

    const _STD::money_base::pattern& _C_get_pos_format() const {
        return _C_mpunct._C_pf;
    }

    const _STD::money_base::pattern& _C_get_neg_format() const {
        return _C_mpunct._C_nf;
    }

    const string_type &_C_get_positive_sign () const {
        return _C_mpunct._C_ps;
    }

    const string_type &_C_get_negative_sign () const {
        return _C_mpunct._C_ns;
    }

    const string_type &_C_get_curr_symbol () const {
        return _C_mpunct._C_cs;
    }

    int _C_get_frac_digits () const {
        return _C_mpunct._C_fd;
    }
};

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_money_handler_base_1<char>);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_money_handler_base_1<wchar_t>);

#endif   // _RWSTD_NO_WCHAR_T


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

// Contains parts of __rw_money_reader<_CharT, _InputIter>
// that depend only on the _CharT template parameter.

template <class _CharT>
class __rw_money_reader_base_1
    : public __rw_money_handler_base_1<_CharT>
{
protected:

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

    __rw_digit_reader_base_1<_CharT> &reader;

    __rw_money_reader_base_1 (__rw_digit_reader_base_1<_CharT> &__r, 
        const __rw_moneypunct_impl_data<_CharT> &mp)
        : __rw_money_handler_base_1<_CharT>(mp), reader(__r)
        {}

public:
    void _C_get_money_string (string_type&, const char*);
};

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_money_reader_base_1<char>);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_money_reader_base_1<wchar_t>);

#endif   // _RWSTD_NO_WCHAR_T


// ---------------------------------------------------------------------------
// Implementation class template - __rw_money_reader_base_2<_CharT, _InputIter>
// ---------------------------------------------------------------------------

// Contains parts of __rw_money_reader<_CharT, _InputIter> that do not depend
// on the intl constructor parameter.

template <class _CharT, class _InputIter>
class __rw_money_reader_base_2
    : public __rw_digit_reader<_CharT, _InputIter>, 
      public __rw_money_reader_base_1<_CharT>
{
protected:
    typedef _STD::char_traits<_CharT> traits_type;
    typedef _STD::basic_string<_CharT, traits_type, _STD::allocator<_CharT> >
    string_type;

    __rw_money_reader_base_2 (_InputIter&, _InputIter&, ios_base&, 
                              const __rw_moneypunct_impl_data<_CharT>&);

    __rw_digit_reader_base_1<_CharT> &_C_this_as_digit_reader () {
        return *this;
    }

public:
    char *_C_get_money_digits (void);    // Get monetary-format digits
};

_RWSTD_INSTANTIATE_3 (
    class _RWSTD_EXPORT
    __rw_money_reader_base_2<char,
        _STD::istreambuf_iterator<char, _STD::char_traits<char> > >
);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_3 (
    class _RWSTD_EXPORT
    __rw_money_reader_base_2<wchar_t,
        _STD::istreambuf_iterator<wchar_t, _STD::char_traits<wchar_t> > >
);

#endif   // _RWSTD_NO_WCHAR_T


// ------------------------------------------------------------------------
// Implementation class template -- __rw_money_reader<_CharT, _InputIter>.
// ------------------------------------------------------------------------

template <class _CharT, class _InputIter>
class __rw_money_reader
    : public __rw_money_reader_base_2<_CharT, _InputIter>
{
public:
    __rw_money_reader (_InputIter &__begin, _InputIter &__end, 
                       _STD::ios_base &__flags, bool __intl)
        : __rw_money_reader_base_2<_CharT, _InputIter> (__begin, __end, __flags,
        __rw_money_handler_base_1<_CharT>::_C_get_punct_data(__flags.getloc(),
                                                             __intl))
        { }
};


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

// Contains parts of __rw_money_writer<_CharT, _Intl, _OutputIter>
// that depend only on the _CharT template parameter.

template <class _CharT>
class __rw_money_writer_base_1
    : public __rw_money_handler_base_1<_CharT>
{
public:

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

    void _C_put_money (_CharT __fill);
    void _C_put_money (const string_type&, _CharT __fill);
    
protected:

    __rw_digit_writer_base_1<_CharT> &writer;

    __rw_money_writer_base_1 (__rw_digit_writer_base_1<_CharT> &__w, 
                         const __rw_moneypunct_impl_data<_CharT> &__mp)
    : __rw_money_handler_base_1<_CharT>(__mp), writer(__w)
        { }

    virtual void
    _C_put_money_sub (const _CharT*, const _CharT*, bool, _CharT) = 0;
};

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_money_writer_base_1<char>);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_1 (class _RWSTD_EXPORT __rw_money_writer_base_1<wchar_t>);

#endif   // _RWSTD_NO_WCHAR_T

// ---------------------------------------------------------------------------
// Implementation class template  __rw_money_writer_base_2<_CharT, _OutputIter>
// ---------------------------------------------------------------------------

// Contains parts of __rw_money_writer<_CharT, _OutputIter>
// that do not depend on the intl constructor parameter.

template <class _CharT, class _OutputIter>
class __rw_money_writer_base_2
    : public __rw_digit_writer<_CharT, _OutputIter>, 
      public __rw_money_writer_base_1<_CharT>
{
protected:
    typedef _STD::char_traits<_CharT> traits_type;
    typedef _STD::basic_string<_CharT, traits_type, _STD::allocator<_CharT> >
    string_type;

    __rw_money_writer_base_2 (_OutputIter &__it, _STD::ios_base &__flags, 
                              const __rw_moneypunct_impl_data<_CharT> &__mp)
        : __rw_digit_writer<_CharT, _OutputIter> (__it, __flags, __mp), 
          __rw_money_writer_base_1<_CharT> (this_as_digit_writer(), __mp)
        { }

    
    __rw_digit_writer_base_1<_CharT> &this_as_digit_writer () {
        return *this;
    }

    virtual void _C_put_money_sub (const _CharT*, const _CharT*, bool, _CharT);
};

_RWSTD_INSTANTIATE_3 (
    class _RWSTD_EXPORT
    __rw_money_writer_base_2<char,
        _STD::ostreambuf_iterator<char, _STD::char_traits<char> > >
);

#ifndef _RWSTD_NO_WCHAR_T

_RWSTD_INSTANTIATE_3 (
    class _RWSTD_EXPORT
    __rw_money_writer_base_2<wchar_t,
        _STD::ostreambuf_iterator<wchar_t, _STD::char_traits<wchar_t> > >
);

#endif   // _RWSTD_NO_WCHAR_T


// -------------------------------------------------------------------------
// Implementation class template -- __rw_money_writer<_CharT, _OutputIter>.
// -------------------------------------------------------------------------

template <class _CharT, class _OutputIter>
class __rw_money_writer
    : public __rw_money_writer_base_2<_CharT, _OutputIter>
{
public:
    __rw_money_writer (_OutputIter &__it, _STD::ios_base &__flags, bool __intl)
        : __rw_money_writer_base_2<_CharT, _OutputIter> (__it, __flags,
        __rw_money_handler_base_1<_CharT>::_C_get_punct_data(__flags.getloc(),
                                                             __intl))
        { }
};


template <class _CharT>
const __rw_moneypunct_init_data<_CharT>*
__rw_fixup_moneypunct_init (const __rw_moneypunct_init_data<char>*, _CharT*);

⌨️ 快捷键说明

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