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

  1. #ifndef __STREAMBU_H
  2. #define __STREAMBU_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. #ifndef __STD_STREAMBUF__
  6. #define __STD_STREAMBUF__
  7.  
  8. /***************************************************************************
  9.  *
  10.  * streambuf - Declarations for the Standard Library stream buffers
  11.  *
  12.  ***************************************************************************
  13.  *
  14.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  15.  *
  16.  * This computer software is owned by Rogue Wave Software, Inc. and is
  17.  * protected by U.S. copyright laws and other laws and by international
  18.  * treaties.  This computer software is furnished by Rogue Wave Software,
  19.  * Inc. pursuant to a written license agreement and may be used, copied,
  20.  * transmitted, and stored only in accordance with the terms of such
  21.  * license and with the inclusion of the above copyright notice.  This
  22.  * computer software or any other copies thereof may not be provided or
  23.  * otherwise made available to any other person.
  24.  *
  25.  * U.S. Government Restricted Rights.  This computer software is provided
  26.  * with Restricted Rights.  Use, duplication, or disclosure by the
  27.  * Government is subject to restrictions as set forth in subparagraph (c)
  28.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  29.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  30.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  31.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  32.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  33.  *
  34.  **************************************************************************/
  35.  
  36. #include <stdcomp.h>
  37.  
  38. #ifndef _RWSTD_NO_NEW_HEADER
  39. #include <cstdlib>
  40. #else
  41. #include <stdlib.h>
  42. #endif
  43.  
  44. #include <ios>
  45.  
  46. #ifndef _RWSTD_NO_NAMESPACE
  47. namespace std {
  48. #endif
  49.  
  50.   template<class charT, class traits>
  51.   class _RWSTDExportTemplate basic_streambuf {
  52.  
  53.   public:
  54.     //
  55.     // Types:
  56.     //
  57.     typedef charT                                       char_type;
  58.     typedef _TYPENAME traits::int_type                  int_type;
  59.     typedef _TYPENAME traits::pos_type                  pos_type;
  60.     typedef _TYPENAME traits::off_type                  off_type;
  61.     typedef traits                                      traits_type;
  62.  
  63.     virtual ~basic_streambuf();
  64.  
  65.     locale pubimbue( const locale& loc);
  66.     locale getloc() const; 
  67.  
  68.     inline  basic_streambuf<char_type, traits> *
  69.     pubsetbuf(char_type *s, streamsize n);
  70.  
  71.     inline pos_type pubseekoff(off_type off, ios_base::seekdir way,
  72.                                ios_base::openmode which =
  73.                                ios_base::in | ios_base::out);
  74.  
  75.     inline pos_type pubseekpos(pos_type sp, ios_base::openmode which =
  76.                                ios_base::in | ios_base::out);
  77.  
  78.     inline int pubsync( );
  79.     inline ios_base::openmode which_open_mode();
  80.     inline streamsize   in_avail();
  81.  
  82.     inline int_type snextc();
  83.     inline int_type sbumpc();
  84.     inline int_type sgetc();
  85.     inline streamsize sgetn(char_type *s, streamsize n);
  86.  
  87.     inline int_type sputbackc(char_type c);
  88.     inline int_type sungetc();
  89.  
  90.     inline int_type sputc(char_type c);
  91.     inline streamsize sputn(const char_type *s, streamsize n);
  92.  
  93. #ifdef _RWSTD_MULTI_THREAD
  94.     _RWSTDMutex buffer_mutex_;
  95.  
  96.     void _RW_lock_buffer()
  97.     {
  98.       _RWSTDGuard* tmp = new _RWSTDGuard(buffer_mutex_);
  99.       if ( tmp )
  100.         __buffer_guard = tmp;
  101.       else
  102.         __buffer_guard = 0;
  103.     }
  104.  
  105.     void _RW_unlock_buffer()
  106.     {
  107.       if ( __buffer_guard )
  108.       {
  109.         _RWSTDGuard* tmp = __buffer_guard;
  110.         __buffer_guard = 0;
  111.         delete tmp;
  112.       }
  113.     }
  114. #endif // _RWSTD_MULTI_THREAD
  115.  
  116.   protected:
  117.     basic_streambuf();
  118.  
  119.     ios_base::openmode mode_;
  120.      
  121.     inline char_type *eback() const;  
  122.     inline char_type *gptr() const;
  123.     inline char_type *egptr() const;
  124.     inline void gbump(int n);
  125.     inline void setg(char_type *gbeg_arg,char_type *gnext_arg,char_type *gend_arg);
  126.  
  127.     inline char_type *pbase() const;  
  128.     inline char_type *pptr() const;   
  129.     inline char_type *epptr() const;
  130.     inline void pbump(int n);
  131.     inline void setp(char_type *pbeg_arg,char_type *pend_arg);
  132.  
  133.     virtual void imbue( const locale& loc);
  134.  
  135.     virtual basic_streambuf<charT, traits> *
  136.     setbuf(char_type *s, streamsize n);
  137.  
  138.     virtual pos_type seekoff(off_type off,
  139.                              ios_base::seekdir way, ios_base::openmode which = 
  140.                              ios_base::in | ios_base::out);
  141.  
  142.     virtual pos_type seekpos(pos_type sp,
  143.                              ios_base::openmode which = 
  144.                              ios_base::in | ios_base::out);
  145.  
  146.     virtual streamsize showmanyc();
  147.     virtual streamsize xsgetn(char_type *s, streamsize n);
  148.     virtual int_type underflow();
  149.     virtual int_type uflow();
  150.     virtual int_type overflow(int_type c = traits::eof());
  151.       
  152.     virtual int_type pbackfail(int_type c = traits::eof());      
  153.     virtual streamsize xsputn(const char_type *s, streamsize n);
  154.  
  155.     virtual int sync( );
  156.     void streambuf_init(bool set_mode= true);
  157.  
  158.   private:
  159.  
  160.     char_type       *__gbeg;    
  161.     char_type       *__gnext;  
  162.     char_type       *__gend;    
  163.  
  164.     char_type       *__pbeg;   
  165.     char_type       *__pnext;   
  166.     char_type       *__pend;  
  167.  
  168.     locale          __loc_buf; 
  169.  
  170. #ifdef _RWSTD_MULTI_THREAD
  171.     _RWSTDGuard *__buffer_guard; 
  172. #endif // _RWSTD_MULTI_THREAD
  173.   };
  174.   /* 
  175.    * inline functions
  176.    */
  177.  
  178.   /*
  179.    * int_type snextc()
  180.    * returns the next character
  181.    */
  182.  
  183.   template<class charT, class traits>
  184.   inline _TYPENAME basic_streambuf<charT, traits>::int_type
  185.   basic_streambuf<charT, traits>::snextc()
  186.   {
  187.     if( traits::eq_int_type(sbumpc(),traits::eof()) )
  188.       return traits::eof();
  189.  
  190.     return sgetc();
  191.   }
  192.  
  193.   /*
  194.    * int_type sbumpc()
  195.    * returns the current character and increments the pointer
  196.    */
  197.  
  198.   template<class charT, class traits>
  199.   inline _TYPENAME basic_streambuf<charT, traits>::int_type
  200.   basic_streambuf<charT, traits>::sbumpc()
  201.   { 
  202.     char_type c;
  203.  
  204.     if( gptr()>= egptr()) {
  205.       return uflow();
  206.     } 
  207.     c=*gptr();  
  208.     gbump(1); 
  209.     return traits::to_int_type(c);
  210.   }
  211.  
  212.   /*
  213.    * int_type sgetc()
  214.    * returns the current character
  215.    */
  216.  
  217.   template<class charT, class traits>
  218.   inline _TYPENAME basic_streambuf<charT, traits>::int_type
  219.   basic_streambuf<charT, traits>::sgetc()
  220.   {
  221.  
  222.     if(gptr() >= egptr()) {  
  223.       return underflow();
  224.     }
  225.  
  226.     return traits::to_int_type(*gptr());
  227.   }
  228.  
  229.   /*
  230.    * streamsize sgetn(char_type *, streamsize)
  231.    * reads in 'n' characters into 's'
  232.    */
  233.  
  234.   template<class charT, class traits>
  235.   inline streamsize basic_streambuf<charT, traits>::
  236.   sgetn(char_type *s, streamsize n)
  237.   {
  238.     return xsgetn(s, n);
  239.   }
  240.  
  241.   /*
  242.    * int_type sputbackc(char_type)
  243.    * puts the character back into the sequence if possible
  244.    */
  245.  
  246.   template<class charT, class traits>
  247.   inline _TYPENAME basic_streambuf<charT, traits>::int_type
  248.   basic_streambuf<charT, traits>::sputbackc(char_type c)
  249.   {
  250.     if( gptr() > eback())
  251.     { 
  252.       gbump(-1);
  253.       if( !traits::eq(*gptr(),c) )
  254.       { 
  255.         gbump(1); 
  256.         return pbackfail(traits::to_int_type(c));
  257.       }
  258.  
  259.       return traits::to_int_type(*gptr());
  260.     }
  261.  
  262.     return pbackfail(traits::to_int_type(c)); 
  263.   }
  264.  
  265.   /*
  266.    * int sungetc()
  267.    * puts the character back into the sequence. The putback character doesn't
  268.    * have to already be there.  Similar to sputbackc(...)
  269.    */
  270.  
  271.   template<class charT, class traits>
  272.   inline _TYPENAME basic_streambuf<charT, traits>::int_type
  273.   basic_streambuf<charT, traits>::sungetc()
  274.   {
  275.     if(gptr() > eback())
  276.     {
  277.       gbump(-1);
  278.       return traits::to_int_type(*gptr());
  279.     } 
  280.     return pbackfail();
  281.   }
  282.  
  283.   /*
  284.    * int sputc(char_type)
  285.    * puts the character into the sequence
  286.    */
  287.  
  288.   template<class charT, class traits>
  289.   inline _TYPENAME basic_streambuf<charT, traits>::int_type
  290.   basic_streambuf<charT, traits>::sputc(char_type c)
  291.   {
  292.   
  293.     if( pptr() >= epptr() )
  294.     {
  295.       return overflow(traits::to_int_type(c));
  296.     }
  297.     *__pnext++ =c; 
  298.     return traits::to_int_type(c);
  299.   }
  300.  
  301.   /*
  302.    * streamsize sputn(const char_type *, streamsize)
  303.    * writes n characters from s into the sequence
  304.    */
  305.  
  306.   template<class charT, class traits>
  307.   inline streamsize
  308.   basic_streambuf<charT, traits>::sputn(const char_type *s, streamsize n)
  309.   {
  310.     return xsputn(s, n);
  311.   }
  312.  
  313.   /*
  314.    * void gbump(int)
  315.    * increments the get pointer by n.  Does no checking to see if this
  316.    * is a valid operation
  317.    */
  318.  
  319.   template<class charT, class traits>
  320.   inline void 
  321.   basic_streambuf<charT, traits>::gbump(int n)
  322.   {
  323.     __gnext += n;
  324.   }
  325.  
  326.   /*
  327.    * void setg(char_type *, char_type *, char_type *)
  328.    * sets the get pointers
  329.    */
  330.  
  331.   template<class charT, class traits>
  332.   inline void 
  333.   basic_streambuf<charT, traits>::
  334.   setg(char_type *gbeg, char_type *gnext, char_type *gend)
  335.   {
  336.     __gbeg  = gbeg;
  337.     __gnext = gnext;
  338.     __gend  = gend;
  339.   }
  340.  
  341.   /*
  342.    * void pbump(int)
  343.    * increments the put pointer.  No checking to see if this is valid
  344.    */
  345.  
  346.   template<class charT, class traits>
  347.   inline void 
  348.   basic_streambuf<charT, traits>::pbump(int n)
  349.   {
  350.     __pnext += n;
  351.   }
  352.  
  353.   /*
  354.    * void setp(char_type *, char_type *)
  355.    * sets up the put pointers
  356.    */
  357.  
  358.   template<class charT, class traits>
  359.   inline void 
  360.   basic_streambuf<charT, traits>::
  361.   setp(char_type *pbeg, char_type *pend)
  362.   {
  363.     __pbeg = pbeg;
  364.     __pnext = pbeg;
  365.     __pend = pend;
  366.   }
  367.  
  368.   /*
  369.    * char_type *eback() const
  370.    * returns the beginning of the get sequence
  371.    */
  372.  
  373.   template<class charT, class traits>
  374.   inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  375.   basic_streambuf<charT, traits>::eback() const
  376.   {
  377.     return __gbeg;
  378.   }
  379.  
  380.   /*
  381.    * char_type *gptr() const
  382.    */
  383.  
  384.   template<class charT, class traits>
  385.   inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  386.   basic_streambuf<charT, traits>::gptr() const
  387.   {
  388.     return __gnext;
  389.   }
  390.  
  391.   /*
  392.    * char_type *egptr() const
  393.    */
  394.  
  395.   template<class charT, class traits>
  396.   inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  397.   basic_streambuf<charT, traits>::egptr() const
  398.   {
  399.     return __gend;
  400.   }
  401.  
  402.   /*
  403.    * char_type *pbase() const
  404.    */
  405.  
  406.   template<class charT, class traits>
  407.   inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  408.   basic_streambuf<charT, traits>::pbase() const
  409.   {
  410.     return __pbeg;
  411.   }
  412.  
  413.   /*
  414.    * char_type *pptr() const
  415.    */
  416.  
  417.   template<class charT, class traits>
  418.   inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  419.   basic_streambuf<charT, traits>::pptr() const
  420.   {
  421.     return __pnext;
  422.   }
  423.  
  424.   /*
  425.    * char_type *epptr() const
  426.    */
  427.  
  428.   template<class charT, class traits>
  429.   inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  430.   basic_streambuf<charT, traits>::epptr() const
  431.   {
  432.     return __pend;
  433.   }
  434.  
  435.   /*
  436.    * streamsize in_avail()
  437.    * returns how many characters are available
  438.    */
  439.  
  440.   template<class charT, class traits>
  441.   inline streamsize 
  442.   basic_streambuf<charT, traits>::in_avail()
  443.   {
  444.     if(gptr() >= egptr())
  445.       return showmanyc();
  446.  
  447.     return ( (streamsize)(egptr() - gptr()) );
  448.   }
  449.  
  450.   /*
  451.    * int pubsync()
  452.    */
  453.  
  454.   template<class charT, class traits>
  455.   inline int 
  456.   basic_streambuf<charT, traits>::pubsync()
  457.   {
  458.     return sync();
  459.   }
  460.  
  461.   /*
  462.    * pos_type pubseekoff(off_type, ios_base::seekdir, ios_base::openmode)
  463.    */
  464.  
  465.   template<class charT, class traits>
  466.   inline _TYPENAME basic_streambuf<charT, traits>::pos_type
  467.   basic_streambuf<charT, traits>::
  468.   pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which)
  469.   {
  470.     return seekoff(off, way, which);
  471.   }
  472.  
  473.   /*
  474.    * pos_type pubseekpos(pos_type, ios_base::openmode)
  475.    */
  476.  
  477.   template<class charT, class traits>
  478.   inline _TYPENAME basic_streambuf<charT, traits>::pos_type
  479.   basic_streambuf<charT, traits>::
  480.   pubseekpos(pos_type sp,
  481.              ios_base::openmode which)
  482.   {
  483.     return seekpos(sp, which);
  484.   }
  485.  
  486.   /*
  487.    * basic_streambuf *pubsetbuf(char_type *, streamsize)
  488.    */
  489.  
  490.   template<class charT, class traits>
  491.   inline  basic_streambuf<charT, traits> *
  492.   basic_streambuf<charT, traits>::
  493.   pubsetbuf(char_type *s, streamsize n)
  494.   {
  495.     return setbuf(s, n);
  496.   }
  497.  
  498.   /*
  499.    * ios_base::openmode which_open_mode()
  500.    */
  501.  
  502.   template<class charT, class traits>
  503.   inline ios_base::openmode
  504.   basic_streambuf<charT, traits>::which_open_mode()
  505.   {
  506.     return mode_; 
  507.   }
  508.  
  509.   /*
  510.    *   streambuf iterators
  511.    */
  512.  
  513.   /*
  514.    *  ostreambuf_iterator
  515.    */
  516.  
  517.   template<class charT, class traits >
  518.   class _RWSTDExportTemplate ostreambuf_iterator 
  519.     : public iterator<output_iterator_tag,charT, 
  520.   _TYPENAME traits::off_type,charT*,charT&>
  521.   {
  522.  
  523.   public:
  524.     //
  525.     // Types:
  526.     //
  527.     typedef charT                          char_type;
  528.     typedef traits                         traits_type;
  529.     typedef basic_streambuf<charT, traits> streambuf_type;
  530.     typedef basic_ostream<charT, traits>   ostream_type;
  531.  
  532.     ostreambuf_iterator(ostream_type& s) _RWSTD_INLINE_NO_THROW
  533.     : __sbuf(s.rdbuf())
  534.     {
  535.       if ( s.rdbuf() ) __failed_flag = false;
  536.       else 
  537.         __failed_flag = true; 
  538.     }
  539.  
  540.     ostreambuf_iterator(streambuf_type *s) _RWSTD_INLINE_NO_THROW
  541.     : __sbuf(s)
  542.     { 
  543.       if ( s ) __failed_flag = false;
  544.       else 
  545.         __failed_flag = true;
  546.     }
  547.  
  548.     ostreambuf_iterator<charT,traits>& operator*()
  549.     { return *this; }
  550.     ostreambuf_iterator<charT,traits>& operator++()
  551.     { return *this; }
  552.     ostreambuf_iterator<charT,traits> operator++(int)
  553.     { return *this; }
  554.  
  555.     ostreambuf_iterator<charT,traits>& operator=(charT c)
  556.     { 
  557.       if ( !__failed_flag )
  558.       {
  559.         if ( traits::eq_int_type(__sbuf->sputc(c),traits::eof()) )
  560.           __failed_flag=true;
  561.       }
  562.       return *this;
  563.     }
  564.  
  565.     bool failed( ) const _RWSTD_INLINE_NO_THROW
  566.     { return __failed_flag; }
  567.  
  568.   protected:
  569.  
  570.   private:
  571.     streambuf_type        *__sbuf;
  572.     bool                   __failed_flag;
  573.   };
  574.  
  575.   /*
  576.    * istreambuf_iterator 
  577.    */
  578.  
  579.   template<class charT, class traits >
  580.   class _RWSTDExportTemplate istreambuf_iterator
  581.     : public iterator<input_iterator_tag,charT,
  582.   _TYPENAME traits::off_type,charT*,charT&>
  583.   {
  584.  
  585.   public:
  586.     //
  587.     // Types:
  588.     //
  589.     typedef charT                          char_type;
  590.     typedef _TYPENAME traits::int_type      int_type;
  591.     typedef traits                         traits_type;
  592.  
  593.     typedef basic_streambuf<charT, traits> streambuf_type;
  594.     typedef basic_istream<charT, traits>   istream_type;
  595.  
  596.     // class to maintain a character and an associated streambuf
  597.     class proxy {
  598.       char_type                       __keep;
  599.       streambuf_type                  *__sbuf;
  600.  
  601.       proxy(char_type c, streambuf_type *sbuf)
  602.         : __keep(c), __sbuf(sbuf)
  603.       { ; }
  604.  
  605.     public:
  606.  
  607.       char_type operator*()
  608.       { return __keep; }
  609.  
  610.       friend class istreambuf_iterator<charT, traits>;
  611.     };
  612.  
  613.   public:
  614.  
  615.     istreambuf_iterator()  _RWSTD_INLINE_NO_THROW
  616.     : __sbuf(0)
  617.     { __failed_flag = true; }
  618.     istreambuf_iterator(istream_type& s)  _RWSTD_INLINE_NO_THROW
  619.     : __sbuf(s.rdbuf())
  620.     { 
  621.       if ( s.rdbuf() ) __failed_flag = false;
  622.       else 
  623.         __failed_flag = true; 
  624.     }
  625.     istreambuf_iterator(streambuf_type *s) _RWSTD_INLINE_NO_THROW
  626.     : __sbuf(s)
  627.     {
  628.       if ( s ) __failed_flag = false;
  629.       else 
  630.         __failed_flag = true;
  631.     }
  632.     istreambuf_iterator(const proxy& p) _RWSTD_INLINE_NO_THROW
  633.     : __sbuf(p.__sbuf)
  634.     { ; }
  635.     inline char_type operator*();
  636.     inline istreambuf_iterator<charT, traits>& operator++();
  637.     inline proxy operator++(int);
  638.     inline bool equal(istreambuf_iterator<charT, traits>& b);
  639.  
  640.     bool failed( ) const _RWSTD_INLINE_NO_THROW
  641.     { return __failed_flag; }
  642.  
  643.   protected:
  644.  
  645.   private:
  646.     streambuf_type     *__sbuf;
  647.     bool                __failed_flag;
  648.   };
  649.  
  650.   /*
  651.    * inline functions
  652.    */
  653.  
  654.   /*
  655.    * char_type operator*()
  656.    */
  657.  
  658.   template<class charT, class traits>
  659.   inline _TYPENAME istreambuf_iterator<charT, traits>::char_type
  660.   istreambuf_iterator<charT, traits>::operator*()
  661.   {
  662.     int_type c;
  663.  
  664.     if ( __sbuf && !__failed_flag )
  665.     {
  666.       c= __sbuf->sgetc();
  667.       if ( traits::eq_int_type(c,traits::eof()) ) 
  668.       {
  669.         __sbuf = 0;
  670.         __failed_flag = true;
  671.       }
  672.     }
  673.     else return traits::eof();
  674.  
  675.     return traits::to_char_type(c);
  676.   }
  677.  
  678.   /*
  679.    * istreambuf_iterator& operator++()
  680.    */
  681.  
  682.   template<class charT, class traits>
  683.   inline istreambuf_iterator<charT, traits>&
  684.   istreambuf_iterator<charT, traits>::operator++()
  685.   {
  686.     if (__sbuf && !__failed_flag )
  687.     { 
  688.       __sbuf->sbumpc();
  689.       if ( traits::eq_int_type(__sbuf->sgetc(),traits::eof()) ) 
  690.       {
  691.         __sbuf = 0;
  692.         __failed_flag = true;
  693.       } 
  694.     }
  695.     return *this;
  696.   }
  697.  
  698.   /*
  699.    * proxy operator++(int)
  700.    */
  701.  
  702.   template<class charT, class traits>
  703.   inline _TYPENAME istreambuf_iterator<charT, traits>::proxy 
  704.   istreambuf_iterator<charT, traits>::operator++(int)
  705.   {
  706.  
  707.     if (__sbuf && !__failed_flag )
  708.     {
  709.       proxy     prev(__sbuf->sgetc(), __sbuf);
  710.       __sbuf->sbumpc();
  711.       if ( traits::eq_int_type(__sbuf->sgetc(),traits::eof()) ) 
  712.       {
  713.         __sbuf = 0;
  714.         __failed_flag = true;
  715.       }  
  716.       return prev;
  717.     }
  718.     
  719.     charT     c=traits::to_char_type(traits::eof());
  720.     return proxy(c, __sbuf);
  721.   }
  722.  
  723.   /*
  724.    * bool equal(istreambuf_iterator&)
  725.    */
  726.  
  727.   template<class charT, class traits>
  728.   inline bool
  729.   istreambuf_iterator<charT, traits>::
  730.   equal(istreambuf_iterator<charT, traits>& b)
  731.   {
  732.     if( ((__sbuf ==0) && (b.__sbuf==0)) || ((__sbuf !=0) && (b.__sbuf !=0)) )
  733.       return true;  
  734.     else
  735.       return false;
  736.   }
  737.  
  738.   /*
  739.    * bool operator==(istreambuf_iterator& a, istreambuf_iterator& b)
  740.    */
  741.  
  742.   template<class charT, class traits>
  743.   inline bool _RWSTDExportTemplate operator==(istreambuf_iterator<charT, traits>& a,
  744.                                               istreambuf_iterator<charT, traits>& b)
  745.   {
  746.     return a.equal(b);
  747.   }
  748.  
  749.   /*
  750.    * bool operator!=(istreambuf_iterator& a, istreambuf_iterator& b)
  751.    */
  752.  
  753.   template<class charT, class traits>
  754.   inline bool _RWSTDExportTemplate operator!=(istreambuf_iterator<charT, traits>& a,
  755.                                               istreambuf_iterator<charT, traits>& b)
  756.   {
  757.     return !(a.equal(b));
  758.   }
  759.  
  760.   // end inlining
  761. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  762.   typedef basic_streambuf<char>                             streambuf;
  763. #else
  764.   typedef basic_streambuf<char, char_traits<char> >         streambuf;
  765. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  766.  
  767. #ifndef _RWSTD_NO_WIDE_CHAR
  768. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  769.   typedef basic_streambuf<wchar_t>                          wstreambuf;
  770. #else
  771.   typedef basic_streambuf<wchar_t, char_traits<wchar_t> >   wstreambuf;
  772. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  773. #endif // _RWSTD_NO_WIDE_CHAR
  774. #ifndef _RWSTD_NO_NAMESPACE
  775. }
  776. #endif
  777.  
  778. #ifdef _RWSTD_COMPILE_INSTANTIATE
  779. #include <streambu.cc> 
  780. #endif
  781.  
  782. #endif // __STD_STREAMBUF__ 
  783.  
  784. #ifndef __USING_STD_NAMES__
  785.   using namespace std;
  786. #endif
  787.  
  788. #pragma option pop
  789. #endif /* __STREAMBU_H */
  790.