// strstream standard header
#ifndef _STRSTREAM_
#define _STRSTREAM_

#pragma info(none)
#ifndef __CHKHDR__
#  pragma report(level, E)
#endif
#pragma info(restore)

#if __IBMCPP__ < 400
#error This file to be used only with IBM VisualAge C++ v4 and later compilers.
#endif /* __IBMCPP__ */

#pragma namemangling(ansi)

   /********************************************************************/
   /*  <strstream> header file                                         */
   /*                                                                  */
   /*  VisualAge C++, Version 4.0                                      */
   /*    Licensed Material - Property of IBM                           */
   /*                                                                  */
   /*  5801-AAR and Other Materials                                    */
   /*                                                                  */
   /*  (c) Copyright IBM Corp 1991, 1998. All rights reserved.         */
   /*                                                                  */
   /*                                                                  */
   /*  Licensed Materials.                                             */
   /*                                                                  */
   /*  Dinkum C++ Library                                              */
   /*  Copyright (c) 1998.  Licensed to IBM Corp. and its suppliers.   */
   /*                                                                  */
   /********************************************************************/

#include <istream>
_STD_BEGIN
		// CLASS strstreambuf
class _CXX_IMPORT strstreambuf : public streambuf {
public:
	enum __Strstate {_Allocated = 1, _Constant = 2,
		_Dynamic = 4, _Frozen = 8};
	_BITMASK(__Strstate, _Strstate);
	explicit strstreambuf(streamsize _N = 0)
		{_Init(_N); }
	strstreambuf(void *(*_A)(size_t),
		void (*_F)(void *))
		{_Init(), _Palloc = _A, _Pfree = _F; }
	strstreambuf(char *_G, streamsize _N, char *_P = 0)
		{_Init(_N, _G, _P); }
	strstreambuf(unsigned char *_G, streamsize _N,
		unsigned char *_P = 0)
		{_Init(_N, (char *)_G, (char *)_P); }
	strstreambuf(const char *_G, streamsize _N)
		{_Init(_N, (char *)_G, 0, _Constant); }
	strstreambuf(const unsigned char *_G, streamsize _N)
		{_Init(_N, (char *)_G, 0, _Constant); }
	virtual ~strstreambuf();
	void freeze(bool = true);
	char *str()
		{freeze();
		return (gptr()); }
	streamsize pcount() const
		{return (pptr() == 0 ? 0 : pptr() - pbase()); }
	strstreambuf(signed char *_G, streamsize _N,
		signed char *_P = 0)
		{_Init(_N, (char *)_G, (char *)_P); }
	strstreambuf(const signed char *_G, streamsize _N)
		{_Init(_N, (char *)_G, 0, _Constant); }
protected:
	virtual int overflow(int = EOF);
	virtual int pbackfail(int = EOF);
	virtual int underflow();
	virtual streampos seekoff(streamoff, ios::seekdir,
		ios::openmode = ios::in | ios::out);
	virtual streampos seekpos(streampos,
		ios::openmode = ios::in | ios::out);
	void _Init(int = 0, char * = 0, char * = 0,
		_Strstate = (_Strstate)0);
	void _Tidy();
private:
	enum {_ALSIZE = 512, _MINSIZE = 32};
	char *_Pendsave, *_Seekhigh;
	int _Alsize;
	_Strstate _Strmode;
	void *(*_Palloc)(size_t);
	void (*_Pfree)(void *);
	};
_BITMASK_OPS(strstreambuf::__Strstate)
		// CLASS istrstream
class istrstream : public istream {
public:
	explicit istrstream(const char *_S)
		: istream(&_Sb), _Sb(_S, 0) {}
	istrstream(const char *_S, streamsize _N)
		: istream(&_Sb), _Sb(_S, _N) {}
	explicit istrstream(char *_S)
		: istream(&_Sb), _Sb((const char *)_S, 0) {}
	istrstream(char *_S, int _N)
		: istream(&_Sb), _Sb((const char *)_S, _N) {}
	virtual ~istrstream();
	strstreambuf *rdbuf() const
		{return ((strstreambuf *)&_Sb); }
	char *str()
		{return (_Sb.str()); }
private:
	strstreambuf _Sb;
	};
		// CLASS ostrstream
class ostrstream : public ostream {
public:
	ostrstream()
		: ostream(&_Sb), _Sb() {}
	ostrstream(char *, streamsize,
		ios::openmode = ios::out);
	virtual ~ostrstream();
	strstreambuf *rdbuf() const
		{return ((strstreambuf *)&_Sb); }
	void freeze(bool _F = true)
		{_Sb.freeze(_F); }
	char *str()
		{return (_Sb.str()); }
	streamsize pcount() const
		{return (_Sb.pcount()); }
private:
	strstreambuf _Sb;
	};
		// CLASS strstream
class strstream : public iostream {
public:
	typedef char char_type;
	typedef int int_type;
	typedef streampos pos_type;
	typedef streamoff off_type;
	strstream()
		: iostream(&_Sb), _Sb() {}
	strstream(char *, streamsize, ios::openmode =
		ios::in | ios::out);
	virtual ~strstream();
	strstreambuf *rdbuf() const
		{return ((strstreambuf *)&_Sb); }
	void freeze(bool _F = true)
		{_Sb.freeze(_F); }
	char *str()
		{return (_Sb.str()); }
	streamsize pcount() const
		{return (_Sb.pcount()); }
private:
	strstreambuf _Sb;
	};
_STD_END

#pragma namemangling()

#pragma info(none)
#ifndef __CHKHDR__
#  pragma report(pop)
#endif
#pragma info(restore)

#endif /* _STRSTREAM_ */

/*
 * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
 * Consult your license regarding permissions and restrictions.
V2.2:0081 */
