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

  1. #ifndef __SSTREAM_H
  2. #define __SSTREAM_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. #ifndef __STD_SSTREAM__
  6. #define __STD_SSTREAM__
  7.  
  8. /***************************************************************************
  9.  *
  10.  * sstream - Declarations for the Standard Library basic streams
  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 <streambuf>
  37. #include <istream>
  38. #include <ostream>
  39.  
  40. #ifndef _RWSTD_NO_NAMESPACE
  41. namespace std{
  42. #endif
  43.   
  44.   template<class charT, class traits, class Allocator>
  45.   class _RWSTDExportTemplate basic_stringbuf : public basic_streambuf<charT, traits>
  46.   {
  47.  
  48.   public:
  49.     //
  50.     // Types:
  51.     //
  52.     typedef charT                                    char_type;
  53.     typedef _TYPENAME traits::int_type               int_type;
  54.     typedef _TYPENAME traits::pos_type               pos_type;
  55.     typedef _TYPENAME traits::off_type               off_type;
  56.     typedef traits                                   traits_type;
  57.   
  58.     typedef basic_ios<charT, traits>                 ios_type;
  59.     typedef basic_string<charT, traits, Allocator >  string_type;
  60.  
  61.     _EXPLICIT basic_stringbuf(ios_base::openmode which = 
  62.                               ios_base::in | ios_base::out );
  63.      
  64.     _EXPLICIT basic_stringbuf(const string_type& str,
  65.                               ios_base::openmode which = 
  66.                               ios_base::in | ios_base::out );
  67.     
  68.     virtual ~basic_stringbuf();
  69.      
  70.     string_type str() const;
  71.     void str(const string_type& str_arg);
  72.  
  73.   protected:
  74.  
  75.     virtual int_type overflow(int_type c = traits::eof());
  76.     virtual int_type pbackfail(int_type c = traits::eof());
  77.     virtual int_type underflow();
  78.     virtual pos_type seekoff(off_type off, ios_base::seekdir way,
  79.                              ios_base::openmode which =
  80.                              ios_base::in | ios_base::out);
  81.  
  82.     virtual pos_type seekpos(pos_type sp,
  83.                              ios_base::openmode which =
  84.                              ios_base::in | ios_base::out);
  85.  
  86.     virtual basic_streambuf<charT,traits>* setbuf(char_type* s, streamsize n);
  87.     virtual streamsize xsputn(const char_type *s, streamsize n);
  88.  
  89.   private:
  90.     charT                   *__data;
  91.     streamsize               __length;
  92.     streamsize               __end_pos;
  93.   };
  94.   template<class charT, class traits, class Allocator>
  95.   class _RWSTDExportTemplate basic_istringstream : public basic_istream<charT, traits>
  96.   {
  97.  
  98.   public:
  99.     //
  100.     // Types:
  101.     //
  102.     typedef charT                                           char_type;
  103.     typedef _TYPENAME traits::int_type                      int_type;
  104.     typedef _TYPENAME traits::pos_type                      pos_type;
  105.     typedef _TYPENAME traits::off_type                      off_type;
  106.     typedef traits                                          traits_type;
  107.   
  108.     typedef basic_stringbuf<charT, traits, Allocator>       sb_type;
  109.     typedef basic_ios<charT, traits>                        ios_type;
  110.     typedef basic_string<charT, traits, Allocator >         string_type;
  111.  
  112.     _EXPLICIT basic_istringstream(ios_base::openmode which = ios_base::in);
  113.     _EXPLICIT basic_istringstream(const string_type& str,
  114.                                   ios_base::openmode which = ios_base::in);
  115.  
  116.     virtual ~basic_istringstream();
  117.  
  118.     basic_stringbuf<charT, traits, Allocator> *rdbuf() const;
  119.     string_type str() const;
  120.  
  121.     void str(const string_type& str);
  122.  
  123.   protected:
  124.  
  125.   private:
  126.     basic_stringbuf<charT, traits, Allocator>    __sb;
  127.   };
  128.   template<class charT, class traits, class Allocator>
  129.   class _RWSTDExportTemplate basic_ostringstream : public basic_ostream<charT, traits>
  130.   {
  131.  
  132.   public:
  133.     //
  134.     // Types:
  135.     //
  136.     typedef charT                                             char_type;
  137.     typedef _TYPENAME traits::int_type                        int_type;
  138.     typedef _TYPENAME traits::pos_type                        pos_type;
  139.     typedef _TYPENAME traits::off_type                        off_type;
  140.     typedef traits                                            traits_type;
  141.       
  142.     typedef basic_stringbuf<charT, traits, Allocator>         sb_type;
  143.     typedef basic_ios<charT, traits>                          ios_type;
  144.     typedef basic_string<charT, traits, Allocator>            string_type;
  145.  
  146.     _EXPLICIT basic_ostringstream(ios_base::openmode which = ios_base::out);
  147.     _EXPLICIT basic_ostringstream(const string_type& str,
  148.                                   ios_base::openmode which = ios_base::out);
  149.  
  150.     virtual ~basic_ostringstream();
  151.     basic_stringbuf<charT, traits, Allocator> *rdbuf() const;
  152.  
  153.     string_type str() const;
  154.     void str(const string_type& str);
  155.  
  156.   protected:
  157.  
  158.   private:
  159.     sb_type            __sb;
  160.   };
  161.   /*
  162.    *  Class stringstream
  163.    */
  164.  
  165.   template<class charT, class traits, class Allocator>
  166.   class _RWSTDExportTemplate basic_stringstream : public basic_iostream<charT, traits>
  167.   {
  168.  
  169.   public:
  170.     //
  171.     // Types:
  172.     //
  173.     typedef charT                                             char_type;
  174.     typedef _TYPENAME traits::int_type                        int_type;
  175.     typedef _TYPENAME traits::pos_type                        pos_type;
  176.     typedef _TYPENAME traits::off_type                        off_type;
  177.     typedef traits                                            traits_type;
  178.       
  179.     typedef basic_stringbuf<charT, traits, Allocator>         sb_type;
  180.     typedef basic_ios<charT, traits>                          ios_type;
  181.     typedef basic_string<charT, traits, Allocator>            string_type;
  182.     _EXPLICIT basic_stringstream(ios_base::openmode which = ios_base::out | 
  183.                                  ios_base::in);
  184.  
  185.     _EXPLICIT basic_stringstream(const string_type& str,
  186.                                  ios_base::openmode which = 
  187.                                  ios_base::out | ios_base::in);
  188.  
  189.     virtual ~basic_stringstream();
  190.     basic_stringbuf<charT, traits, Allocator> *rdbuf() const;
  191.     string_type str() const;
  192.     void str(const string_type& str);
  193.  
  194.   protected:
  195.  
  196.   private:
  197.     sb_type            __sb;
  198.   };
  199. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  200.   typedef basic_stringbuf<char>                                      stringbuf;
  201. #else
  202.   typedef basic_stringbuf<char, char_traits<char>, allocator<char> > stringbuf;
  203. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  204.   
  205. #ifndef _RWSTD_NO_WIDE_CHAR
  206. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  207.   typedef basic_stringbuf<wchar_t>                                            wstringbuf;
  208. #else
  209.   typedef basic_stringbuf<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstringbuf;
  210. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  211. #endif // _RWSTD_NO_WIDE_CHAR
  212.  
  213. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  214.   typedef basic_istringstream<char>                                      istringstream;
  215. #else
  216.   typedef basic_istringstream<char, char_traits<char>, allocator<char> > istringstream;
  217. #endif
  218.   
  219. #ifndef _RWSTD_NO_WIDE_CHAR
  220. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  221.   typedef basic_istringstream<wchar_t>                                            wistringstream;
  222. #else
  223.   typedef basic_istringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wistringstream;
  224. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  225. #endif // _RWSTD_NO_WIDE_CHAR 
  226. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  227.   typedef basic_ostringstream<char>                                         ostringstream;
  228. #else
  229.   typedef basic_ostringstream<char, char_traits<char>, allocator<char> >    ostringstream;
  230. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES 
  231.   
  232. #ifndef _RWSTD_NO_WIDE_CHAR
  233. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  234.   typedef basic_ostringstream<wchar_t>                                            wostringstream;
  235. #else
  236.   typedef basic_ostringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wostringstream;
  237. #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES 
  238. #endif // _RWSTD_NO_WIDE_CHAR
  239.  
  240. #ifndef _RWSTD_NO_DEFAULT_TEMPLATES
  241.   typedef basic_stringstream<char>                                        stringstream;
  242. #else
  243.   typedef basic_stringstream<char, char_traits<char>, allocator<char> >   stringstream;
  244. #endif // _RWSTD_NO_DEFAULT_TEMPLATES 
  245.  
  246. #ifndef _RWSTD_NO_WIDE_CHAR
  247. #ifndef _RWSTD_NO_DEFAULT_TEMPLATES
  248.   typedef basic_stringstream<wchar_t>                                             wstringstream;
  249. #else
  250.   typedef basic_stringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >  wstringstream;
  251. #endif // _RWSTD_NO_DEFAULT_TEMPLATES
  252. #endif // _RWSTD_NO_WIDE_CHAR
  253. #ifndef _RWSTD_NO_NAMESPACE
  254. }
  255. #endif
  256. #ifdef _RWSTD_COMPILE_INSTANTIATE
  257. #include <sstream.cc>
  258. #endif
  259. #endif // __STD_SSTREAM__ 
  260. #ifndef __USING_STD_NAMES__
  261.   using namespace std;
  262. #endif
  263.  
  264. #pragma option pop
  265. #endif /* __SSTREAM_H */
  266.