home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / IOS.CC < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  5.5 KB  |  226 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.  * (c) Copyright 1994, 1998 Rogue Wave Software, Inc.
  11.  * ALL RIGHTS RESERVED
  12.  *
  13.  * The software and information contained herein are proprietary to, and
  14.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  15.  * intends to preserve as trade secrets such software and information.
  16.  * This software is furnished pursuant to a written license agreement and
  17.  * may be used, copied, transmitted, and stored only in accordance with
  18.  * the terms of such license and with the inclusion of the above copyright
  19.  * notice.  This software and information or any other copies thereof may
  20.  * not be provided or otherwise made available to any other person.
  21.  *
  22.  * Notwithstanding any other lease or license that may pertain to, or
  23.  * accompany the delivery of, this computer software and information, the
  24.  * rights of the Government regarding its use, reproduction and disclosure
  25.  * are as set forth in Section 52.227-19 of the FARS Computer
  26.  * Software-Restricted Rights clause.
  27.  * 
  28.  * Use, duplication, or disclosure by the Government is subject to
  29.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  30.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  31.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  32.  * P.O. Box 2328, Corvallis, Oregon 97339.
  33.  *
  34.  * This computer software and information is distributed with "restricted
  35.  * rights."  Use, duplication or disclosure is subject to restrictions as
  36.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  37.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  38.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  39.  * then the "Alternate III" clause applies.
  40.  *
  41.  **************************************************************************/
  42.  
  43. #include <streambuf>
  44. #include <iosfwd>
  45. #ifndef _RWSTD_NO_NAMESPACE
  46. namespace std { 
  47. #endif
  48.   
  49.   extern istream _RWSTDExport cin;
  50.  
  51. #ifndef _RWSTD_NO_WIDE_CHAR
  52.   extern wistream _RWSTDExport wcin;
  53. #endif
  54.   /*
  55.    * Class basic_ios  member functions   
  56.    */
  57.  
  58.   /*
  59.    * basic_ios(basic_streambuf *)
  60.    */
  61.  
  62.   template<class charT, class traits>
  63.   basic_ios<charT, traits>::
  64.   basic_ios(basic_streambuf<charT, traits> *sb_arg)
  65.   {
  66.     init(sb_arg);
  67.   }
  68.  
  69.   /*
  70.    * ~basic_ios()
  71.    */
  72.  
  73.   template<class charT, class traits>
  74.   basic_ios<charT, traits>::~basic_ios()
  75.   {
  76.  
  77.   }
  78.  
  79.   /*
  80.    * ios_type& copyfmt(const ios_type& )
  81.    */
  82.  
  83.   template<class charT, class traits>
  84.   basic_ios<charT, traits>&
  85.   basic_ios<charT, traits>::
  86.   copyfmt(const basic_ios<charT, traits>& rhs)
  87.   {
  88. #ifdef _RWSTD_MULTI_THREAD
  89.     _RWSTDGuard guard(this->__stream_mutex);
  90. #endif
  91.     __tiestr = rhs.__tiestr;
  92.     __fillch = rhs.__fillch;
  93.     ios_base::_RW_UNSAFE_copyfmt( rhs );
  94.     _Except = rhs._Except;
  95.  
  96.     return *this;
  97.   }
  98.   /*
  99.    * basic_ostream *tie(basic_ostream *)
  100.    */
  101.  
  102.   template<class charT, class traits>
  103.   basic_ostream<charT, traits> *
  104.   basic_ios<charT, traits>::
  105.   tie(basic_ostream<charT, traits> *tie_arg)
  106.   {
  107. #ifdef _RWSTD_MULTI_THREAD
  108.     _RWSTDGuard guard(this->__stream_mutex);
  109. #endif
  110.     basic_ostream<charT, traits>   *temp = __tiestr;
  111.     __tiestr = tie_arg;
  112.     return temp;
  113.   }
  114.  
  115.   /*
  116.    * basic_streambuf *rdbuf(basic_streambuf *)
  117.    */
  118.  
  119.   template<class charT, class traits>
  120.   _TYPENAME basic_ios<charT, traits>::streambuf_type* 
  121.   basic_ios<charT, traits>::                     
  122.   rdbuf( basic_streambuf<charT, traits> *sb)
  123.   {
  124. #ifdef _RWSTD_MULTI_THREAD
  125.     _RWSTDGuard guard(this->__stream_mutex);
  126. #endif
  127.  
  128.     basic_streambuf<charT, traits>   *temp = __sb;
  129.  
  130.     __sb = sb;
  131.  
  132.     if ( sb==0 ) 
  133.       __state |= ios_base::badbit;
  134.  
  135.     _RW_UNSAFE_clear();
  136.  
  137.     return temp;
  138.   }
  139.  
  140.   /*
  141.    * basic_ios()
  142.    */
  143.  
  144.   template<class charT, class traits>
  145.   basic_ios<charT, traits>::basic_ios()
  146.   {
  147.     init(0);
  148.   }
  149.  
  150.   /*
  151.    * void imbue(const locale& )
  152.    */
  153.  
  154.   template<class charT, class traits>
  155.   locale basic_ios<charT, traits>::
  156.   imbue(const locale& loc)
  157.   {
  158.     locale tmp = getloc();
  159.    
  160.     ((ios_base *)(this))->imbue(loc);
  161.    
  162.     if ( rdbuf() )
  163.       rdbuf()->pubimbue(loc);
  164.  
  165.     return tmp;  
  166.   }
  167.  
  168.   /*
  169.    * void init(basic_streambuf *)
  170.    */
  171.  
  172.   template<class charT, class traits>
  173.   void basic_ios<charT, traits>::
  174.   init(basic_streambuf<charT, traits> *sb)
  175.   {
  176. #ifdef _RWSTD_MULTI_THREAD
  177.     _RWSTDGuard guard(this->__stream_mutex);
  178. #endif
  179.     __sb = sb;
  180.     __tiestr = 0;
  181.  
  182.     if(__sb)
  183.       __state = goodbit;
  184.     else
  185.       __state = badbit;
  186.  
  187.     _Except = goodbit;
  188.     __fmtfl  = skipws | dec;
  189.     __wide   = 0;
  190.     __prec   = 6;
  191.  
  192.     __fillch = widen(' ');
  193.  
  194.   }
  195.  
  196.   /*
  197.    * lock the buffer
  198.    */
  199.  
  200. #ifdef _RWSTD_MULTI_THREAD
  201.   template <class charT, class traits>
  202.   basic_ios<charT,traits>& __lock(basic_ios<charT,traits>& strm)
  203.   {
  204.     if ( strm.rdbuf() )
  205.       strm.rdbuf()->_RW_lock_buffer();
  206.  
  207.     return strm;
  208.   }
  209.  
  210.   template <class charT, class traits>
  211.   basic_ios<charT,traits>& __unlock(basic_ios<charT,traits>& strm)
  212.   {
  213.     if ( strm.rdbuf() )
  214.       strm.rdbuf()->_RW_unlock_buffer();
  215.  
  216.     return strm;
  217.   }
  218.  
  219. #endif //  _RWSTD_MULTI_THREAD
  220. #ifndef _RWSTD_NO_NAMESPACE
  221. }
  222. #endif
  223.  
  224. #pragma option pop
  225. #endif /* __IOS_CC */
  226.