1*404b540aSrobert// Backward-compat support -*- C++ -*- 2*404b540aSrobert 3*404b540aSrobert// Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc. 4*404b540aSrobert// 5*404b540aSrobert// This file is part of the GNU ISO C++ Library. This library is free 6*404b540aSrobert// software; you can redistribute it and/or modify it under the 7*404b540aSrobert// terms of the GNU General Public License as published by the 8*404b540aSrobert// Free Software Foundation; either version 2, or (at your option) 9*404b540aSrobert// any later version. 10*404b540aSrobert 11*404b540aSrobert// This library is distributed in the hope that it will be useful, 12*404b540aSrobert// but WITHOUT ANY WARRANTY; without even the implied warranty of 13*404b540aSrobert// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*404b540aSrobert// GNU General Public License for more details. 15*404b540aSrobert 16*404b540aSrobert// You should have received a copy of the GNU General Public License along 17*404b540aSrobert// with this library; see the file COPYING. If not, write to the Free 18*404b540aSrobert// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19*404b540aSrobert// USA. 20*404b540aSrobert 21*404b540aSrobert// As a special exception, you may use this file as part of a free software 22*404b540aSrobert// library without restriction. Specifically, if other files instantiate 23*404b540aSrobert// templates or use macros or inline functions from this file, or you compile 24*404b540aSrobert// this file and link it with other files to produce an executable, this 25*404b540aSrobert// file does not by itself cause the resulting executable to be covered by 26*404b540aSrobert// the GNU General Public License. This exception does not however 27*404b540aSrobert// invalidate any other reasons why the executable file might be covered by 28*404b540aSrobert// the GNU General Public License. 29*404b540aSrobert 30*404b540aSrobert/* 31*404b540aSrobert * Copyright (c) 1998 32*404b540aSrobert * Silicon Graphics Computer Systems, Inc. 33*404b540aSrobert * 34*404b540aSrobert * Permission to use, copy, modify, distribute and sell this software 35*404b540aSrobert * and its documentation for any purpose is hereby granted without fee, 36*404b540aSrobert * provided that the above copyright notice appear in all copies and 37*404b540aSrobert * that both that copyright notice and this permission notice appear 38*404b540aSrobert * in supporting documentation. Silicon Graphics makes no 39*404b540aSrobert * representations about the suitability of this software for any 40*404b540aSrobert * purpose. It is provided "as is" without express or implied warranty. 41*404b540aSrobert */ 42*404b540aSrobert 43*404b540aSrobert// WARNING: The classes defined in this header are DEPRECATED. This 44*404b540aSrobert// header is defined in section D.7.1 of the C++ standard, and it 45*404b540aSrobert// MAY BE REMOVED in a future standard revision. You should use the 46*404b540aSrobert// header <sstream> instead. 47*404b540aSrobert 48*404b540aSrobert#ifndef __SGI_STL_STRSTREAM 49*404b540aSrobert#define __SGI_STL_STRSTREAM 50*404b540aSrobert 51*404b540aSrobert#include "backward_warning.h" 52*404b540aSrobert#include <iosfwd> 53*404b540aSrobert#include <ios> 54*404b540aSrobert#include <istream> 55*404b540aSrobert#include <ostream> 56*404b540aSrobert#include <string> 57*404b540aSrobert 58*404b540aSrobert_GLIBCXX_BEGIN_NAMESPACE(std) 59*404b540aSrobert 60*404b540aSrobert // Class strstreambuf, a streambuf class that manages an array of char. 61*404b540aSrobert // Note that this class is not a template. 62*404b540aSrobert class strstreambuf : public basic_streambuf<char, char_traits<char> > 63*404b540aSrobert { 64*404b540aSrobert public: 65*404b540aSrobert // Types. 66*404b540aSrobert typedef char_traits<char> _Traits; 67*404b540aSrobert typedef basic_streambuf<char, _Traits> _Base; 68*404b540aSrobert 69*404b540aSrobert public: 70*404b540aSrobert // Constructor, destructor 71*404b540aSrobert explicit strstreambuf(streamsize __initial_capacity = 0); 72*404b540aSrobert strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*)); 73*404b540aSrobert 74*404b540aSrobert strstreambuf(char* __get, streamsize __n, char* __put = 0); 75*404b540aSrobert strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); 76*404b540aSrobert strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0); 77*404b540aSrobert 78*404b540aSrobert strstreambuf(const char* __get, streamsize __n); 79*404b540aSrobert strstreambuf(const signed char* __get, streamsize __n); 80*404b540aSrobert strstreambuf(const unsigned char* __get, streamsize __n); 81*404b540aSrobert 82*404b540aSrobert virtual ~strstreambuf(); 83*404b540aSrobert 84*404b540aSrobert public: 85*404b540aSrobert void freeze(bool = true); 86*404b540aSrobert char* str(); 87*404b540aSrobert int pcount() const; 88*404b540aSrobert 89*404b540aSrobert protected: 90*404b540aSrobert virtual int_type overflow(int_type __c = _Traits::eof()); 91*404b540aSrobert virtual int_type pbackfail(int_type __c = _Traits::eof()); 92*404b540aSrobert virtual int_type underflow(); 93*404b540aSrobert virtual _Base* setbuf(char* __buf, streamsize __n); 94*404b540aSrobert virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, 95*404b540aSrobert ios_base::openmode __mode 96*404b540aSrobert = ios_base::in | ios_base::out); 97*404b540aSrobert virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode 98*404b540aSrobert = ios_base::in | ios_base::out); 99*404b540aSrobert 100*404b540aSrobert private: 101*404b540aSrobert strstreambuf& 102*404b540aSrobert operator=(const strstreambuf&); 103*404b540aSrobert 104*404b540aSrobert strstreambuf(const strstreambuf&); 105*404b540aSrobert 106*404b540aSrobert // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. 107*404b540aSrobert char* _M_alloc(size_t); 108*404b540aSrobert void _M_free(char*); 109*404b540aSrobert 110*404b540aSrobert // Helper function used in constructors. 111*404b540aSrobert void _M_setup(char* __get, char* __put, streamsize __n); 112*404b540aSrobert 113*404b540aSrobert private: 114*404b540aSrobert // Data members. 115*404b540aSrobert void* (*_M_alloc_fun)(size_t); 116*404b540aSrobert void (*_M_free_fun)(void*); 117*404b540aSrobert 118*404b540aSrobert bool _M_dynamic : 1; 119*404b540aSrobert bool _M_frozen : 1; 120*404b540aSrobert bool _M_constant : 1; 121*404b540aSrobert }; 122*404b540aSrobert 123*404b540aSrobert // Class istrstream, an istream that manages a strstreambuf. 124*404b540aSrobert class istrstream : public basic_istream<char> 125*404b540aSrobert { 126*404b540aSrobert public: 127*404b540aSrobert explicit istrstream(char*); 128*404b540aSrobert explicit istrstream(const char*); 129*404b540aSrobert istrstream(char* , streamsize); 130*404b540aSrobert istrstream(const char*, streamsize); 131*404b540aSrobert virtual ~istrstream(); 132*404b540aSrobert 133*404b540aSrobert strstreambuf* rdbuf() const; 134*404b540aSrobert char* str(); 135*404b540aSrobert 136*404b540aSrobert private: 137*404b540aSrobert strstreambuf _M_buf; 138*404b540aSrobert }; 139*404b540aSrobert 140*404b540aSrobert // Class ostrstream 141*404b540aSrobert class ostrstream : public basic_ostream<char> 142*404b540aSrobert { 143*404b540aSrobert public: 144*404b540aSrobert ostrstream(); 145*404b540aSrobert ostrstream(char*, int, ios_base::openmode = ios_base::out); 146*404b540aSrobert virtual ~ostrstream(); 147*404b540aSrobert 148*404b540aSrobert strstreambuf* rdbuf() const; 149*404b540aSrobert void freeze(bool = true); 150*404b540aSrobert char* str(); 151*404b540aSrobert int pcount() const; 152*404b540aSrobert 153*404b540aSrobert private: 154*404b540aSrobert strstreambuf _M_buf; 155*404b540aSrobert }; 156*404b540aSrobert 157*404b540aSrobert // Class strstream 158*404b540aSrobert class strstream : public basic_iostream<char> 159*404b540aSrobert { 160*404b540aSrobert public: 161*404b540aSrobert typedef char char_type; 162*404b540aSrobert typedef char_traits<char>::int_type int_type; 163*404b540aSrobert typedef char_traits<char>::pos_type pos_type; 164*404b540aSrobert typedef char_traits<char>::off_type off_type; 165*404b540aSrobert 166*404b540aSrobert strstream(); 167*404b540aSrobert strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); 168*404b540aSrobert virtual ~strstream(); 169*404b540aSrobert 170*404b540aSrobert strstreambuf* rdbuf() const; 171*404b540aSrobert void freeze(bool = true); 172*404b540aSrobert int pcount() const; 173*404b540aSrobert char* str(); 174*404b540aSrobert 175*404b540aSrobert private: 176*404b540aSrobert strstreambuf _M_buf; 177*404b540aSrobert }; 178*404b540aSrobert 179*404b540aSrobert_GLIBCXX_END_NAMESPACE 180*404b540aSrobert 181*404b540aSrobert#endif 182