epoc32/include/stdapis/stlport/stl/_ios.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  * Copyright (c) 1999
     4  * Silicon Graphics Computer Systems, Inc.
     5  *
     6  * Copyright (c) 1999 
     7  * Boris Fomitchev
     8  *
     9  * This material is provided "as is", with absolutely no warranty expressed
    10  * or implied. Any use is at your own risk.
    11  *
    12  * Permission to use or copy this software for any purpose is hereby granted 
    13  * without fee, provided the above notices are retained on all copies.
    14  * Permission to modify the code and to distribute modified code is granted,
    15  * provided the above notices are retained, and a notice that the code was
    16  * modified is included with the above copyright notice.
    17  *
    18  */ 
    19 #ifndef _STLP_INTERNAL_IOS_H
    20 #define _STLP_INTERNAL_IOS_H
    21 
    22 
    23 #ifndef _STLP_IOS_BASE_H
    24 # include <stl/_ios_base.h>
    25 #endif
    26 
    27 #ifndef _STLP_INTERNAL_CTYPE_H
    28 # include <stl/_ctype.h>
    29 #endif
    30 #ifndef _STLP_INTERNAL_NUMPUNCT_H
    31 # include <stl/_numpunct.h>
    32 #endif
    33 
    34 _STLP_BEGIN_NAMESPACE
    35 
    36 // ----------------------------------------------------------------------
    37 
    38 // Class basic_ios, a subclass of ios_base.  The only important difference
    39 // between the two is that basic_ios is a class template, parameterized
    40 // by the character type.  ios_base exists to factor out all of the
    41 // common properties that don't depend on the character type.
    42 
    43 // The second template parameter, _Traits, defaults to char_traits<_CharT>.
    44 // The default is declared in header <iosfwd>, and it isn't declared here
    45 // because C++ language rules do not allow it to be declared twice.
    46 
    47 template <class _CharT, class _Traits>
    48 #ifdef __SYMBIAN32__
    49 class basic_ios : public ios_base {
    50 #else
    51 class basic_ios : public ios_base {
    52 #endif
    53   friend class ios_base;
    54 public:                         // Synonyms for types.
    55   typedef _CharT                     char_type;
    56   typedef typename _Traits::int_type int_type;
    57   typedef typename _Traits::pos_type pos_type;
    58   typedef typename _Traits::off_type off_type;
    59   typedef _Traits                    traits_type;
    60 
    61 public:                         // Constructor, destructor.
    62   explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf);
    63   virtual ~basic_ios() {}
    64 
    65 public:                         // Members from clause 27.4.4.2
    66   basic_ostream<_CharT, _Traits>* tie() const {
    67     return _M_tied_ostream;
    68   }
    69   basic_ostream<_CharT, _Traits>*
    70   tie(basic_ostream<char_type, traits_type>* __new_tied_ostream) {
    71     basic_ostream<char_type, traits_type>* __tmp = _M_tied_ostream;
    72     _M_tied_ostream = __new_tied_ostream;
    73     return __tmp;
    74   }
    75 
    76   basic_streambuf<_CharT, _Traits>* rdbuf() const
    77     { return _M_streambuf; }
    78 
    79   basic_streambuf<_CharT, _Traits>*
    80   rdbuf(basic_streambuf<char_type, traits_type>*);
    81 
    82   // Copies __x's state to *this.
    83   basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x);
    84 
    85   char_type fill() const { return _M_fill; }
    86   char_type fill(char_type __fill) {
    87     char_type __tmp(_M_fill);
    88     _M_fill = __fill;
    89     return __tmp;
    90   }
    91 
    92 public:                         // Members from 27.4.4.3.  These four functions
    93                                 // can almost be defined in ios_base.
    94 
    95   void clear(iostate __state = goodbit) {
    96     _M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit));
    97     _M_check_exception_mask();
    98   }
    99   void setstate(iostate __state) { this->clear(rdstate() | __state); }
   100 
   101   iostate exceptions() const { return this->_M_get_exception_mask(); }
   102   void exceptions(iostate __mask) {
   103     this->_M_set_exception_mask(__mask);
   104     this->clear(this->rdstate());
   105   }
   106 
   107 public:                         // Locale-related member functions.
   108   locale imbue(const locale&);
   109 
   110   inline char narrow(_CharT, char) const ;
   111   inline _CharT widen(char) const; 
   112 
   113   // Helper function that makes testing for EOF more convenient.
   114   static bool _STLP_CALL _S_eof(int_type __c) {
   115     const int_type __eof = _Traits::eof();
   116     return _Traits::eq_int_type(__c, __eof);
   117   }
   118 
   119 protected:
   120   basic_ios();
   121 
   122   void init(basic_streambuf<_CharT, _Traits>* __streambuf);
   123 
   124 public:
   125   
   126   // Helper function used in istream and ostream.  It is called only from
   127   // a catch clause.
   128   void _M_handle_exception(ios_base::iostate __flag);
   129   
   130 private:                        // Data members
   131   char_type _M_fill;            // The fill character, used for padding.
   132 
   133   basic_streambuf<_CharT, _Traits>* _M_streambuf;
   134   basic_ostream<_CharT, _Traits>*   _M_tied_ostream;
   135 
   136 };
   137 
   138 
   139 template <class _CharT, class _Traits>
   140 inline char 
   141 basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const
   142 { return ((const ctype<_CharT>*)this->_M_ctype_facet())->narrow(__c, __default); }
   143 
   144 template <class _CharT, class _Traits>
   145 inline _CharT 
   146 basic_ios<_CharT, _Traits>::widen(char __c) const
   147 { 
   148   return ((const ctype<_CharT>*)this->_M_ctype_facet())->widen(__c); }
   149 
   150 # if defined (_STLP_USE_TEMPLATE_EXPORT)
   151 _STLP_EXPORT_TEMPLATE_CLASS basic_ios<char, char_traits<char> >;
   152 #  if ! defined (_STLP_NO_WCHAR_T)
   153 _STLP_EXPORT_TEMPLATE_CLASS basic_ios<wchar_t, char_traits<wchar_t> >;
   154 #  endif
   155 # endif /* _STLP_USE_TEMPLATE_EXPORT */
   156 
   157 # if !defined (_STLP_NO_METHOD_SPECIALIZATION)
   158 _STLP_TEMPLATE_NULL
   159 inline char
   160 basic_ios<char, char_traits<char> >::narrow(char __c, char) const
   161 {
   162   return __c;
   163 }
   164 
   165 _STLP_TEMPLATE_NULL
   166 inline char
   167 basic_ios<char, char_traits<char> >::widen(char __c) const
   168 {
   169   return __c;
   170 }
   171 # endif /* _STLP_NO_METHOD_SPECIALIZATION */
   172 
   173 
   174 _STLP_END_NAMESPACE
   175 
   176 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
   177 #  include <stl/_ios.c>
   178 # endif
   179 
   180 // The following is needed to ensure that the inlined _Stl_loc_init functions
   181 // that ios_base::_Loc_init::_Loc_init() calls are found eventually.
   182 // Otherwise, undefined externs may be caused.
   183 
   184 #if defined(__BORLANDC__) && defined(_RTLDLL)
   185 # ifndef _STLP_INTERNAL_NUM_PUT_H
   186 #  include <stl/_num_put.h>
   187 # endif
   188 # ifndef _STLP_INTERNAL_NUM_GET_H
   189 #   include <stl/_num_get.h>
   190 # endif
   191 # ifndef _STLP_INTERNAL_MONETARY_H
   192 #  include <stl/_monetary.h>
   193 # endif
   194 # ifndef _STLP_INTERNAL_TIME_FACETS_H
   195 #  include <stl/_time_facets.h>
   196 # endif
   197 #endif
   198 
   199 #endif /* _STLP_IOS */
   200 
   201 // Local Variables:
   202 // mode:C++
   203 // End:
   204