/*
 *	(c) 1998-99 Sassafras Software Inc.
 *
 *	Lets you write to an XGArgStream.  Useful for building
 *	dialogs/views on the fly (some views can only be built
 *	via an arguement stream).
 */

/**********************************************************************

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

**********************************************************************/

#ifndef SS_WRITABLESTREAM
#define SS_WRITABLESTREAM

#include <XView.h>		/* for XGArgStream */

/************************************************************************/
/*																		*/
/*	Class Declarations													*/
/*																		*/
/************************************************************************/

/*$	XGWritableStream
 *
 *		This is an override to allow us to create XGArgStream objects
 *	on the fly. To use, create one of these with a pointer to a
 *	buffer to use as a scratch, and then call the various WriteXXX()
 *	routines. You cannot mix the XGArgStream's read and this class's
 *	write routines.
 */

class XGWritableStream : public XGArgStream {
	public:
						XGWritableStream (unsigned char *, long);

		long			Length (void);
		void			Rewind (void);

		/*
		 *	Write routines
		 */
		 
		void			WriteBoolean (bool);
		void			WriteInteger (long);
		void			WriteString (char *);
		void			WriteString (unsigned char *);
		void			WriteString (void *s, long len);

	private:
		long			fSize;
		unsigned char	*fStart;

		long			fRemains;
		unsigned char	*fPosition;
};

#endif
