home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / ios.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  5.0 KB  |  214 lines

  1. #ifndef __IOS_CC
  2. #define __IOS_CC
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. /***************************************************************************
  5.  *
  6.  * ios.cc - Definition for the Standard Library iostreams
  7.  *
  8.  ***************************************************************************
  9.  *
  10.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  11.  *
  12.  * This computer software is owned by Rogue Wave Software, Inc. and is
  13.  * protected by U.S. copyright laws and other laws and by international
  14.  * treaties.  This computer software is furnished by Rogue Wave Software,
  15.  * Inc. pursuant to a written license agreement and may be used, copied,
  16.  * transmitted, and stored only in accordance with the terms of such
  17.  * license and with the inclusion of the above copyright notice.  This
  18.  * computer software or any other copies thereof may not be provided or
  19.  * otherwise made available to any other person.
  20.  *
  21.  * U.S. Government Restricted Rights.  This computer software is provided
  22.  * with Restricted Rights.  Use, duplication, or disclosure by the
  23.  * Government is subject to restrictions as set forth in subparagraph (c)
  24.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  25.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  26.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  27.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  28.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  29.  *
  30.  **************************************************************************/
  31.  
  32. #include <streambuf>
  33. #include <iosfwd>
  34. #ifndef _RWSTD_NO_NAMESPACE
  35. namespace std { 
  36. #endif
  37.   
  38.   extern istream _RWSTDExport cin;
  39.  
  40. #ifndef _RWSTD_NO_WIDE_CHAR
  41.   extern wistream _RWSTDExport wcin;
  42. #endif
  43.   /*
  44.    * Class basic_ios  member functions   
  45.    */
  46.  
  47.   /*
  48.    * basic_ios(basic_streambuf *)
  49.    */
  50.  
  51.   template<class charT, class traits>
  52.   basic_ios<charT, traits>::
  53.   basic_ios(basic_streambuf<charT, traits> *sb_arg)
  54.   {
  55.     init(sb_arg);
  56.   }
  57.  
  58.   /*
  59.    * ~basic_ios()
  60.    */
  61.  
  62.   template<class charT, class traits>
  63.   basic_ios<charT, traits>::~basic_ios()
  64.   {
  65.  
  66.   }
  67.  
  68.   /*
  69.    * ios_type& copyfmt(const ios_type& )
  70.    */
  71.  
  72.   template<class charT, class traits>
  73.   basic_ios<charT, traits>&
  74.   basic_ios<charT, traits>::
  75.   copyfmt(const basic_ios<charT, traits>& rhs)
  76.   {
  77. #ifdef _RWSTD_MULTI_THREAD
  78.     _RWSTDGuard guard(this->__stream_mutex);
  79. #endif
  80.     __tiestr = rhs.__tiestr;
  81.     __fillch = rhs.__fillch;
  82.     ios_base::_RW_UNSAFE_copyfmt( rhs );
  83.     _Except = rhs._Except;
  84.  
  85.     return *this;
  86.   }
  87.   /*
  88.    * basic_ostream *tie(basic_ostream *)
  89.    */
  90.  
  91.   template<class charT, class traits>
  92.   basic_ostream<charT, traits> *
  93.   basic_ios<charT, traits>::
  94.   tie(basic_ostream<charT, traits> *tie_arg)
  95.   {
  96. #ifdef _RWSTD_MULTI_THREAD
  97.     _RWSTDGuard guard(this->__stream_mutex);
  98. #endif
  99.     basic_ostream<charT, traits>   *temp = __tiestr;
  100.     __tiestr = tie_arg;
  101.     return temp;
  102.   }
  103.  
  104.   /*
  105.    * basic_streambuf *rdbuf(basic_streambuf *)
  106.    */
  107.  
  108.   template<class charT, class traits>
  109.   _TYPENAME basic_ios<charT, traits>::streambuf_type* 
  110.   basic_ios<charT, traits>::                     
  111.   rdbuf( basic_streambuf<charT, traits> *sb)
  112.   {
  113. #ifdef _RWSTD_MULTI_THREAD
  114.     _RWSTDGuard guard(this->__stream_mutex);
  115. #endif
  116.  
  117.     basic_streambuf<charT, traits>   *temp = __sb;
  118.  
  119.     __sb = sb;
  120.  
  121.     if ( sb==0 ) 
  122.       __state |= ios_base::badbit;
  123.  
  124.     _RW_UNSAFE_clear();
  125.  
  126.     return temp;
  127.   }
  128.  
  129.   /*
  130.    * basic_ios()
  131.    */
  132.  
  133.   template<class charT, class traits>
  134.   basic_ios<charT, traits>::basic_ios()
  135.   {
  136.     init(0);
  137.   }
  138.  
  139.   /*
  140.    * void imbue(const locale& )
  141.    */
  142.  
  143.   template<class charT, class traits>
  144.   locale basic_ios<charT, traits>::
  145.   imbue(const locale& loc)
  146.   {
  147.     locale tmp = getloc();
  148.    
  149.     ((ios_base *)(this))->imbue(loc);
  150.    
  151.     if ( rdbuf() )
  152.       rdbuf()->pubimbue(loc);
  153.  
  154.     return tmp;  
  155.   }
  156.  
  157.   /*
  158.    * void init(basic_streambuf *)
  159.    */
  160.  
  161.   template<class charT, class traits>
  162.   void basic_ios<charT, traits>::
  163.   init(basic_streambuf<charT, traits> *sb)
  164.   {
  165. #ifdef _RWSTD_MULTI_THREAD
  166.     _RWSTDGuard guard(this->__stream_mutex);
  167. #endif
  168.     __sb = sb;
  169.     __tiestr = 0;
  170.  
  171.     if(__sb)
  172.       __state = goodbit;
  173.     else
  174.       __state = badbit;
  175.  
  176.     _Except = goodbit;
  177.     __fmtfl  = skipws | dec;
  178.     __wide   = 0;
  179.     __prec   = 6;
  180.  
  181.     __fillch = widen(' ');
  182.  
  183.   }
  184.  
  185.   /*
  186.    * lock the buffer
  187.    */
  188.  
  189. #ifdef _RWSTD_MULTI_THREAD
  190.   template <class charT, class traits>
  191.   basic_ios<charT,traits>& __lock(basic_ios<charT,traits>& strm)
  192.   {
  193.     if ( strm.rdbuf() )
  194.       strm.rdbuf()->_RW_lock_buffer();
  195.  
  196.     return strm;
  197.   }
  198.  
  199.   template <class charT, class traits>
  200.   basic_ios<charT,traits>& __unlock(basic_ios<charT,traits>& strm)
  201.   {
  202.     if ( strm.rdbuf() )
  203.       strm.rdbuf()->_RW_unlock_buffer();
  204.  
  205.     return strm;
  206.   }
  207.  
  208. #endif //  _RWSTD_MULTI_THREAD
  209. #ifndef _RWSTD_NO_NAMESPACE
  210. }
  211. #endif
  212. #pragma option pop
  213. #endif /* __IOS_CC */
  214.