home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / devtools / files / borland_ccompiler55.exe / Include / sstream.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  20.1 KB  |  721 lines

  1. #ifndef __SSTREAM_CC
  2. #define __SSTREAM_CC
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. /***************************************************************************
  5.  *
  6.  * sstream.cc - Declarations for the Standard Library basic strings
  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. #ifndef _RWSTD_NO_NAMESPACE
  33. namespace std {
  34. #endif
  35.  
  36.   /*
  37.    * basic_stringbuf(basic_ios::openmode)
  38.    */
  39.  
  40.   template<class charT, class traits, class Allocator>
  41.   basic_stringbuf<charT, traits, Allocator>::
  42.   basic_stringbuf( ios_base::openmode which)
  43.   : basic_streambuf<charT, traits>()
  44.   , __data(0)
  45.   , __length(0)
  46.   , __end_pos(0)
  47.   {
  48.     this->setp(0,0);
  49.     this->setg(0,0,0);
  50.     basic_streambuf<charT,traits>::mode_ = which;
  51.   }
  52.  
  53.   /*
  54.    * basic_stringbuf(const basic_string, ios_base::openmode)
  55.    */
  56.  
  57.   template<class charT, class traits, class Allocator>
  58.   basic_stringbuf<charT, traits, Allocator>::
  59.   basic_stringbuf(const string_type& s, ios_base::openmode which)
  60.   : basic_streambuf<charT, traits>()
  61.   , __length(s.length())
  62.   {
  63.     basic_streambuf<charT,traits>::mode_ = which;
  64.  
  65.     __data = new charT[__length];
  66.  
  67.     if(s.data())
  68.       traits::copy(__data, s.data(), __length);
  69.  
  70.     if(which & ios_base::in)
  71.       this->setg(__data, __data, __data+__length);
  72.  
  73.     if(which & ios_base::out)
  74.       this->setp(__data, __data+__length);
  75.  
  76.     if(which & ( ios_base::app | ios_base::ate ) )
  77.       pbump(__length);
  78.  
  79.     __end_pos = __length;
  80.  
  81.   }
  82.  
  83.   /*
  84.    * virtual ~basic_stringbuf()
  85.    */
  86.  
  87.   template<class charT, class traits, class Allocator>
  88.   basic_stringbuf<charT, traits, Allocator>::~basic_stringbuf()
  89.   {
  90.     if ( __data )
  91.       delete [] __data;
  92.   }
  93.  
  94.   /*
  95.    * basic_string str() const
  96.    */
  97.  
  98.   template<class charT, class traits, class Allocator>
  99.   basic_string<charT, traits, Allocator>
  100.   basic_stringbuf<charT, traits, Allocator>::str() const
  101.   {
  102.  
  103.     if ( __end_pos == 0 )  return string_type();
  104.  
  105.     if ( (__end_pos > ( this->pptr() - this->pbase() )) && (__end_pos > ( this->egptr() - this->eback() )) )
  106.       return string_type(__data, __end_pos);
  107.     else 
  108.     {
  109.       if ( ( this->pptr() - this->pbase() ) > ( this->egptr() - this->eback() ) )
  110.         return string_type(__data, this->pptr() - this->pbase() );
  111.       else
  112.         return string_type(__data, this->egptr() - this->eback() );
  113.     }
  114.    
  115.   }
  116.  
  117.   /*
  118.    * void str(const basic_string&)
  119.    */
  120.  
  121.   template<class charT, class traits, class Allocator>
  122.   void 
  123.   basic_stringbuf<charT, traits, Allocator>::
  124.   str(const string_type& s)
  125.   {
  126.     if ( __data )
  127.       delete [] __data;
  128.  
  129.     __length = s.length();
  130.  
  131.     if(__length == 0)
  132.     {
  133.       this->setg(0,0,0);
  134.       this->setp(0,0);
  135.       __data = 0;
  136.       __end_pos = 0;
  137.       return;
  138.     }
  139.  
  140.     __data = new charT[__length];
  141.  
  142.     if(s.data())
  143.       traits::copy(__data, s.data(), __length);
  144.     
  145.     if(basic_streambuf<charT,traits>::mode_ & ios_base::in)
  146.       this->setg(__data, __data, __data+__length);
  147.  
  148.     if(basic_streambuf<charT,traits>::mode_ & ios_base::out)
  149.     {
  150.       this->setp(__data, __data+__length);
  151.       if( (basic_streambuf<charT,traits>::mode_ & ios_base::app) || (basic_streambuf<charT,traits>::mode_ & ios_base::ate ) )
  152.         this->pbump(__length); 
  153.     } 
  154.  
  155.     __end_pos = __length;
  156.   }
  157.   /*
  158.    * int_type overflow(int_type)
  159.    */
  160.  
  161.   template<class charT, class traits, class Allocator>
  162.   _TYPENAME basic_stringbuf<charT, traits, Allocator>::int_type
  163.   basic_stringbuf<charT, traits, Allocator>::overflow(int_type c)
  164.   {
  165.     if((basic_streambuf<charT,traits>::mode_ & ios_base::out) == 0) {
  166.       return traits::eof();
  167.     }
  168.   
  169.     charT        *temp;
  170.     int          old_numb_of_elements,new_numb_of_elements;
  171.     const int    increment=128;
  172.     int_type     var;
  173.  
  174.     if (this->pptr())
  175.     {
  176.       old_numb_of_elements = this->pptr() - __data;
  177.       new_numb_of_elements = old_numb_of_elements + increment;
  178.       temp = new charT[new_numb_of_elements];
  179.  
  180.       traits::copy(temp, __data, old_numb_of_elements);   
  181.       this->setp (temp,temp+new_numb_of_elements);
  182.       this->pbump(old_numb_of_elements);  
  183.      
  184.       charT *tmp=temp+(this->gptr()-this->eback()); 
  185.       this->setg(temp, tmp, this->pptr()+1);
  186.  
  187.       delete [] __data;
  188.       __data = temp;
  189.     }
  190.     else
  191.     {
  192.       new_numb_of_elements=increment;
  193.       temp = new charT[new_numb_of_elements];
  194.       this->setp(temp,temp+new_numb_of_elements);
  195.  
  196.       if((basic_streambuf<charT,traits>::mode_ & ios_base::in) != 0)
  197.         this->setg(temp, temp , temp);
  198.  
  199.       __data =temp; 
  200.     }
  201.   
  202.     if ( traits::eq_int_type(c,traits::eof()) ) var = traits::not_eof(c);
  203.     else
  204.       var = sputc(c);
  205.  
  206.     if ( (this->pptr() - this->pbase()) > __end_pos )
  207.       __end_pos = this->pptr() - this->pbase(); 
  208.  
  209.     return var;
  210.   }
  211.  
  212.   /*
  213.    * int_type pbackfail(int_type)
  214.    */
  215.  
  216.   template<class charT, class traits, class Allocator>
  217.   _TYPENAME basic_stringbuf<charT, traits, Allocator>::int_type
  218.   basic_stringbuf<charT, traits, Allocator>::pbackfail(int_type c)
  219.   {
  220.   
  221.     if ( (!traits::eq_int_type(c,traits::eof())) && (this->gptr()>this->eback()) )
  222.     {
  223.  
  224.       if ( traits::eq(*(this->gptr()-1),traits::to_char_type(c)) ) 
  225.       {
  226.         this->gbump(-1);
  227.         return c;
  228.       }
  229.       else
  230.       {
  231.         if( basic_streambuf<charT,traits>::mode_ & ios_base::out )
  232.         {
  233.           this->gbump(-1);
  234.           *this->gptr()=traits::to_char_type(c);
  235.           return c;
  236.         }
  237.       }
  238.     }       
  239.  
  240.     if ( (traits::eq_int_type(c,traits::eof())) && (this->gptr()>this->eback()) )
  241.     { 
  242.       this->gbump(-1);
  243.       return traits::not_eof(c);
  244.     }
  245.     return traits::eof();
  246.   }
  247.   /*
  248.    * basic_streambuf<charT,traits>* setbuf(char_type* s, streamsize n)
  249.    */
  250.  
  251.   template<class charT, class traits, class Allocator>
  252.   basic_streambuf<charT, traits>*
  253.   basic_stringbuf<charT, traits, Allocator>::setbuf(char_type* s, streamsize n)
  254.   {
  255.     if((basic_streambuf<charT,traits>::mode_ & ios_base::out) != 0)
  256.     {
  257.       if ( n > ( this->pptr() - this->pbase() ) )
  258.       {
  259.         if ( s == 0 ) s = new charT[n];
  260.  
  261.         if ( s )
  262.         {
  263.           int          old_numb_of_elements;
  264.  
  265.           if (this->pptr())
  266.           {
  267.             old_numb_of_elements = this->pptr() - __data;
  268.             traits::copy(s, __data, old_numb_of_elements);   
  269.             this->setp (s,s+n-1);
  270.             this->pbump(old_numb_of_elements);  
  271.  
  272.             charT *tmp=s+(this->gptr()-this->eback()); 
  273.             this->setg(s, tmp, this->pptr()+1);
  274.  
  275.             delete [] __data;
  276.             __data = s;
  277.           }
  278.           else
  279.           {
  280.             this->setp(s,s+n-1);
  281.             if((basic_streambuf<charT,traits>::mode_ & ios_base::in) != 0)
  282.               this->setg(s, s , s);
  283.             __data =s; 
  284.           }
  285.         }
  286.         else
  287.           return (basic_streambuf<charT,traits>*)(0);
  288.       }
  289.       else
  290.         return (basic_streambuf<charT,traits>*)(0);
  291.     }
  292.     return (basic_streambuf<charT,traits>*)(this);
  293.   }
  294.  
  295.   /*
  296.    * int_type underflow()
  297.    */
  298.  
  299.   template<class charT, class traits, class Allocator>
  300.   _TYPENAME basic_stringbuf<charT, traits, Allocator>::int_type
  301.   basic_stringbuf<charT, traits, Allocator>::underflow()
  302.   {
  303.     if(this->gptr() && (this->gptr()<this->egptr()) ) return traits::to_int_type(*this->gptr());
  304.  
  305.     if(((this->pptr() != 0) && ( (this->pptr() > this->egptr()) || ( __end_pos > (this->egptr() - this->eback()) ) ) ) && (!this->gptr())) 
  306.     {
  307.       if ( __end_pos > ( this->pptr() - this->pbase() ) )
  308.         this->setg(this->pbase(), this->pbase(), this->pbase()+__end_pos );
  309.       else     
  310.         this->setg(this->pbase(), this->pbase(), this->pptr());
  311.       return traits::to_int_type(*this->gptr());
  312.     }
  313.  
  314.     if((this->pptr() != 0) && ( (this->pptr() > this->egptr()) || ( __end_pos > ( this->egptr() - this->eback() )) ) ) 
  315.     {
  316.       if ( __end_pos > ( this->pptr() - this->pbase() ) )
  317.         this->setg(this->eback(),this->gptr(),this->eback()+__end_pos);
  318.       else
  319.         this->setg(this->eback(), this->gptr(), this->pptr());
  320.       return traits::to_int_type(*this->gptr());
  321.     }
  322.     return traits::eof();
  323.   }
  324.  
  325.   /*
  326.    * pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode)
  327.    */
  328.  
  329.   template<class charT, class traits, class Allocator>
  330.   _TYPENAME basic_stringbuf<charT, traits, Allocator>::pos_type
  331.   basic_stringbuf<charT, traits, Allocator>::
  332.   seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which)
  333.   {
  334.     streamsize       newoff;
  335.   
  336.     if((which & ios_base::in) && (which & ios_base::out))
  337.     {
  338.       if ( (way==ios_base::beg) || (way==ios_base::end) )
  339.       {
  340.         if ( seekoff(off,way,ios_base::out) == pos_type(off_type(-1)) )
  341.           return pos_type(off_type(-1));
  342.         return seekoff(off,way,ios_base::in);
  343.       }
  344.       else
  345.         return pos_type(off_type(-1)); 
  346.     }
  347.   
  348.     if((which & ios_base::in) && (this->gptr()!=0))
  349.     {
  350.       if ( (this->egptr() - this->eback()) > __end_pos )
  351.         __end_pos = this->egptr() - this->eback(); 
  352.  
  353.       if ( (this->pptr() - this->pbase()) > __end_pos )
  354.         __end_pos = this->pptr() - this->pbase(); 
  355.  
  356.       if(way == ios_base::beg)
  357.         newoff = 0;
  358.       if(way == ios_base::cur)
  359.         newoff = this->gptr() - this->eback();
  360.       if(way == ios_base::end)
  361.         newoff = __end_pos;
  362.  
  363.       if ( newoff<0 )  return pos_type(off_type(-1)); 
  364.  
  365.       if ( ((this->eback()+long(newoff)+long(off))> this->egptr()) || ((newoff+off)< 0) )
  366.         return pos_type(-1);
  367.  
  368.       this->setg(this->eback(), this->eback() + long(newoff) + long(off), this->egptr());
  369.       return pos_type(newoff+off);
  370.     }
  371.  
  372.     if((which & ios_base::in) && (this->gptr()==0) && (this->egptr()==0) && (this->eback()==0) ) 
  373.       return pos_type(0);
  374.  
  375.     if((which & ios_base::out) && (this->pptr()!=0) && !(basic_streambuf<charT,traits>::mode_ & ios_base::app) )
  376.     {
  377.  
  378.       if ( (this->egptr() - this->eback()) > __end_pos )
  379.         __end_pos = this->egptr() - this->eback(); 
  380.  
  381.       if ( (this->pptr() - this->pbase()) > __end_pos )
  382.         __end_pos = this->pptr() - this->pbase(); 
  383.  
  384.       if(way == ios_base::beg)
  385.         newoff = 0;
  386.       if(way == ios_base::cur)
  387.         newoff = this->pptr() - this->pbase();
  388.       if(way == ios_base::end)
  389.         newoff = __end_pos;
  390.  
  391.       if ( (this->pptr() - this->pbase()) > __end_pos ) __end_pos = this->pptr() - this->pbase();
  392.  
  393.       if ( ((newoff+off)<0) || ((this->pbase()+long(newoff)+long(off))> this->epptr()) )
  394.         return pos_type(off_type(-1));   
  395.  
  396.       this->pbump( newoff+off-(this->pptr()-this->pbase())  );
  397.  
  398.       if (this->eback() !=0 && this->gptr()<=this->pptr() )
  399.         this->setg(this->eback(),this->gptr(),this->pptr());
  400.       else
  401.       {
  402.         if ( (basic_streambuf<charT,traits>::mode_ & ios_base::out  ) &&
  403.              !(basic_streambuf<charT,traits>::mode_ & ios_base::in ) )
  404.           this->setg(this->pbase(),this->pptr(),this->pptr());
  405.       } 
  406.       return pos_type(newoff+off);
  407.     }
  408.     else 
  409.     {
  410.       if ( basic_streambuf<charT,traits>::mode_ & ios_base::app )
  411.         return pos_type(this->pptr()-this->pbase());
  412.  
  413.       if((which & ios_base::out) && (this->pptr()==0) && (this->epptr()==0) && (this->pbase()==0) )
  414.         return pos_type(0);
  415.     }
  416.     return pos_type(off_type(-1));
  417.   }
  418.  
  419.   /*
  420.    * pos_type seekpos(pos_type, ios_base::openmode)
  421.    */
  422.  
  423.   template<class charT, class traits, class Allocator>
  424.   _TYPENAME basic_stringbuf<charT, traits, Allocator>::pos_type
  425.   basic_stringbuf<charT, traits, Allocator>::
  426.   seekpos(pos_type sp, ios_base::openmode which)
  427.   {
  428.     streamsize    newoff = sp;
  429.  
  430.     if((which & ios_base::in) && (which & ios_base::out))
  431.     {
  432.       if ( seekpos(sp,ios_base::out) == pos_type(off_type(-1)) )
  433.         return pos_type(off_type(-1));
  434.       return seekpos(sp,ios_base::in);
  435.     }
  436.  
  437.     if((which & ios_base::in) && (this->gptr()!=0))
  438.     {
  439.     
  440.       if ( newoff<0 )  return pos_type(off_type(-1));
  441.       if ( (this->eback()+long(newoff))> this->egptr() ) return pos_type(off_type(-1));
  442.  
  443.       this->setg(this->eback(), this->eback() + long(newoff), this->egptr());
  444.       return pos_type(newoff);
  445.     }
  446.     if((which & ios_base::out) && (this->pptr()!=0) && !(basic_streambuf<charT,traits>::mode_ & ios_base::app) )
  447.     {
  448.       if ( (newoff<0) || ((this->pbase()+long(newoff))> this->epptr()) )
  449.         return pos_type(off_type(-1)); 
  450.  
  451.       if ( (this->pptr() - this->pbase()) > __end_pos ) __end_pos = this->pptr() - this->pbase();
  452.       this->pbump( newoff-(this->pptr()-this->pbase())  );
  453.  
  454.       if (this->eback() !=0 && this->gptr()<=this->pptr() )
  455.         this->setg(this->eback(),this->gptr(),this->pptr());
  456.       else
  457.       {
  458.         if ( (basic_streambuf<charT,traits>::mode_ & ios_base::out  ) &&
  459.              !(basic_streambuf<charT,traits>::mode_ & ios_base::in ) )
  460.           this->setg(this->pbase(),this->pptr(),this->epptr());
  461.       }
  462.       return pos_type(newoff);
  463.     }
  464.     else 
  465.       if ( basic_streambuf<charT,traits>::mode_ & ios_base::app )
  466.         return pos_type(this->pptr()-this->pbase());
  467.     return pos_type(off_type(-1));
  468.   }
  469.  
  470.   /*
  471.    * streamsize xsputn(const char_type *, streamsize)
  472.    */
  473.  
  474.   template<class charT, class traits, class Allocator>
  475.   streamsize basic_stringbuf<charT, traits, Allocator>::
  476.   xsputn(const char_type *s, streamsize n)
  477.   {
  478.     if ( !s || (n == 0) ) return 0;
  479.  
  480.     if ( n > ( this->epptr()-this->pptr()+128 ) )
  481.     {
  482.       if ( setbuf(0, this->pptr()-this->pbase()+n+128)== 0)
  483.       {
  484.         return 0;
  485.       }
  486.  
  487.       traits::copy(this->pptr(), s, n);
  488.       this->pbump(n);
  489.       __end_pos =  (this->pptr() - this->pbase());
  490.     }
  491.     else
  492.     {
  493.       int         i=0;
  494.       while((i < n) && ( !traits::eq_int_type(sputc(*s++),traits::eof())))
  495.         i++;
  496.       return i;
  497.     }
  498.     return n;    
  499.   }
  500.  
  501.   /*
  502.    * class basic_istringstream
  503.    */
  504.  
  505.   /*
  506.    * basic_istringstream(ios_base::openmode)
  507.    */
  508.  
  509.   template<class charT, class traits, class Allocator>
  510.   basic_istringstream<charT, traits, Allocator>::
  511.   basic_istringstream(ios_base::openmode m)
  512.   : basic_istream<charT, traits>( )
  513.   , __sb(m | ios_base::in)
  514.   {
  515.     init(&__sb);
  516.   }
  517.  
  518.   /*
  519.    * basic_istringstream(const basic_string<charT>&, ios_base::openmode)
  520.    */
  521.  
  522.   template<class charT, class traits, class Allocator>
  523.   basic_istringstream<charT, traits, Allocator>::
  524.   basic_istringstream(const string_type& s, ios_base::openmode which)
  525.   : basic_istream<charT, traits>( )
  526.   , __sb(s, which | ios_base::in)
  527.   {
  528.     init(&__sb);
  529.   }
  530.  
  531.   /*
  532.    * virtual ~basic_istringstream()
  533.    */
  534.  
  535.   template<class charT, class traits, class Allocator>
  536.   basic_istringstream<charT, traits, Allocator>::~basic_istringstream()
  537.   {
  538.   }
  539.  
  540.   /*
  541.    * basic_stringbuf *rdbuf() const
  542.    */
  543.  
  544.   template<class charT, class traits, class Allocator>
  545.   basic_stringbuf<charT, traits, Allocator> *
  546.   basic_istringstream<charT, traits, Allocator>::rdbuf() const
  547.   {
  548.     return (basic_stringbuf<charT, traits, Allocator> *)&__sb;
  549.   }
  550.  
  551.   /*
  552.    * basic_string<charT> str() const
  553.    */
  554.  
  555.   template<class charT, class traits, class Allocator>
  556.   basic_string<charT, traits, Allocator>
  557.   basic_istringstream<charT, traits, Allocator>::str() const
  558.   {
  559.     return __sb.str();
  560.   }
  561.  
  562.   /*
  563.    * void str(const basic_string<charT>& )
  564.    */
  565.  
  566.   template<class charT, class traits, class Allocator>
  567.   void basic_istringstream<charT, traits, Allocator>::str(const string_type& s)
  568.   {
  569.     __sb.str(s);
  570.   }
  571.  
  572.   /*
  573.    * class basic_ostringstring
  574.    */
  575.  
  576.   /*
  577.    * basic_ostringstream(ios_base::openmode)
  578.    */
  579.  
  580.   template<class charT, class traits, class Allocator>
  581.   basic_ostringstream<charT, traits, Allocator>::
  582.   basic_ostringstream(ios_base::openmode w)
  583.   : basic_ostream<charT, traits>( )           
  584.   , __sb(w | ios_base::out )
  585.   {
  586.     init(&__sb);
  587.   }
  588.  
  589.   /*
  590.    * basic_ostringstream(const basic_string&, ios_base::openmode)
  591.    */
  592.  
  593.   template<class charT, class traits, class Allocator>
  594.   basic_ostringstream<charT, traits, Allocator>::
  595.   basic_ostringstream(const string_type& s, ios_base::openmode which)
  596.   : basic_ostream<charT, traits>( )
  597.   , __sb(s, which | ios_base::out )
  598.   {
  599.     init(&__sb);
  600.   }
  601.  
  602.   /*
  603.    * virtual ~basic_ostringstream()
  604.    */
  605.  
  606.   template<class charT, class traits, class Allocator>
  607.   basic_ostringstream<charT, traits, Allocator>::~basic_ostringstream()
  608.   {
  609.   }
  610.  
  611.   /*
  612.    * basic_stringbuf *rdbuf() const
  613.    */
  614.  
  615.   template<class charT, class traits, class Allocator>
  616.   basic_stringbuf<charT, traits, Allocator> *
  617.   basic_ostringstream<charT, traits, Allocator>::rdbuf() const
  618.   {
  619.     return (basic_stringbuf<charT, traits, Allocator> *)&__sb;
  620.   }
  621.  
  622.   /*
  623.    * basic_string str() const
  624.    */
  625.  
  626.   template<class charT, class traits, class Allocator>
  627.   basic_string<charT, traits, Allocator>
  628.   basic_ostringstream<charT, traits, Allocator>::str() const
  629.   {
  630.     return __sb.str();
  631.   }
  632.  
  633.   /*
  634.    * void str(const basic_string& s)
  635.    */
  636.  
  637.   template<class charT, class traits, class Allocator>
  638.   void basic_ostringstream<charT, traits, Allocator>::
  639.   str(const string_type& s)
  640.   {
  641.     __sb.str(s);
  642.   }
  643.  
  644.   /*
  645.    * class basic_stringstream
  646.    */
  647.  
  648.   /*
  649.    * basic_stringstream(ios_base::openmode)
  650.    */
  651.  
  652.   template<class charT, class traits, class Allocator>
  653.   basic_stringstream<charT, traits, Allocator>::
  654.   basic_stringstream(ios_base::openmode w)
  655.   : basic_iostream<charT, traits>( )          
  656.   , __sb(w)
  657.   {
  658.     init(&__sb);
  659.   }
  660.  
  661.   /*
  662.    * basic_stringstream(const basic_string&, ios_base::openmode)
  663.    */
  664.  
  665.   template<class charT, class traits, class Allocator>
  666.   basic_stringstream<charT, traits, Allocator>::
  667.   basic_stringstream(const string_type& s, ios_base::openmode which)
  668.   : basic_iostream<charT, traits>( )
  669.   , __sb(s, which)
  670.   {
  671.     init(&__sb);
  672.   }
  673.  
  674.   /*
  675.    * virtual ~basic_stringstream()
  676.    */
  677.  
  678.   template<class charT, class traits, class Allocator>
  679.   basic_stringstream<charT, traits, Allocator>::~basic_stringstream()
  680.   {
  681.   }
  682.  
  683.   /*
  684.    * basic_stringbuf *rdbuf() const
  685.    */
  686.  
  687.   template<class charT, class traits, class Allocator>
  688.   basic_stringbuf<charT, traits, Allocator> *
  689.   basic_stringstream<charT, traits, Allocator>::rdbuf() const
  690.   {
  691.     return (basic_stringbuf<charT, traits, Allocator> *)&__sb;
  692.   }
  693.  
  694.   /*
  695.    * basic_string str() const
  696.    */
  697.  
  698.   template<class charT, class traits, class Allocator>
  699.   basic_string<charT, traits, Allocator>
  700.   basic_stringstream<charT, traits, Allocator>::str() const
  701.   {
  702.     return __sb.str();
  703.   }
  704.  
  705.   /*
  706.    * void str(const basic_string& s)
  707.    */
  708.  
  709.   template<class charT, class traits, class Allocator>
  710.   void basic_stringstream<charT, traits, Allocator>::
  711.   str(const string_type& s)
  712.   {
  713.     __sb.str(s);
  714.   }
  715. #ifndef _RWSTD_NO_NAMESPACE
  716. }
  717. #endif
  718.  
  719. #pragma option pop
  720. #endif /* __SSTREAM_CC */
  721.