/* * ALSTREAM.H * * Header file for ArchiveLib 1.0 * * Copyright (c) 1994 Greenleaf Software, Inc. * All Rights Reserved * * DESCRIPTION * * These macros and types are all used in the debug versions of the * ArchiveLib. * This is a utility class that is used in some of the demos. * It is a simple implementation of a C++ iostream that writes * to a multiline edit control. The constructor wants a window * handle and a control ID. In the implementations in the demos, * the window handle is that of the dialog box, and the control * ID is that of the multiline edit control. This class * works pretty well, but it is by no means bulletproof. For one * thing, it won't work from inside a DLL, because of far/near * problems. So if you link to the DLL, you are still going to * have to link to the static library to get this class. That * is why the class isn't defined with the usual AL_CLASS_TYPE * and AL_PROTO macros. * * Note that _ALControlStream is used internally as a helper. * ALEditControlStream is what the programmer uses, but when * creating an ALEditControlStream, we have to create an * _ALControlStream object to do some of the work. * * CLASS DEFINITIONS: * * _ALControlStream : The streambuf used by ALEditControlStream * * ALEditControlStream : The ostream that writes to multiline edit * controls. * PROTOTYPES: * * ostream& gfendl( ostream &s ) : Used to generate a newline and * a flush for ALEditControlStream. * * REVISION HISTORY * * May 26, 1994 1.0A : First release * */ #ifndef _ALSTREAM_H #define _ALSTREAM_H #define STRICT #include #include "arclib.h" #if defined( __cplusplus ) /* Won't work in a DLL! */ #if !defined( AL_BUILDING_DLL ) #include /* * class _ALControlStream * * DESCRIPTION * * This is a class derived from streambuf. We attach this to an * ALEditControlStream, and it will write to the edit control * specified in the constructor. * * DATA MEMBERS * * hWindow : The handle of the edit control. * * MEMBER FUNCTIONS * * _ALControlStream() : The constructor, called by the ALEditControlStream * constructor. * * ~_ALControlStream() : The virtual destructor. * * overflow() : Called by the base class when the buffer is about * to overflow. This is our cue to send bytes out * to the edit control. * * underflow() : Called by the base class when the more data is * needed by the buffer for reading. We don't * supply any data, this is a stub. * * sync() : Base class calls this when it feels like flushing * the buffers. * * REVISION HISTORY * * May 26, 1994 1.0A : First release * */ class _ALControlStream : public streambuf { /* * Constructors, destructors, friend declarations */ friend class ALEditControlStream; public : _ALControlStream( HWND hwnd, int control ); virtual ~_ALControlStream(); /* * The copy constructor and assignment operator are not supported. I * declare them here because I don't want the compiler to generate * default versions for me. */ protected : operator=( _ALControlStream& ); _ALControlStream( _ALControlStream& ); /* * Member functions and overloaded operators */ protected : virtual int overflow( int ); virtual int underflow(); virtual int sync(); /* * Data members */ protected : HWND hWindow; }; /* * class ALEditControlStream * * DESCRIPTION * * This is the demo class that actually performs output to the * edit control. It doesn't really have to do anything other than * create itself and then create the streambuf derivative, because * the streambuf does al the work. * * DATA MEMBERS * * mpControlStream : A pointer to the streambuf object we create, * because without him I am nothing. * * MEMBER FUNCTIONS * * ALEditControlStream() : The constructor. * ~ALEditControlStream() : The destructor. * * * REVISION HISTORY * * May 26, 1994 1.0A : First release * */ class ALEditControlStream : public ostream { /* * Constructors, destructors, and friends */ public : ALEditControlStream( HWND handle, int control_id = -1 ); ~ALEditControlStream(); /* * The copy constructor and assignment operator are not supported. I * declare them here because I don't want the compiler to generate * default versions for me. */ protected : operator=( ALEditControlStream& ); ALEditControlStream( ALEditControlStream& ); /* * Data members */ _ALControlStream mpControlStream; }; /* * The gfendl manipulator is used to send an eol and flush the buffer * when writing to an ALEditControlStream. It serves the same purpose * as an endl written to a normal stream. The difference is that an * eol on a regular stream has a "/n/r" pair, and this guy doesn't. */ ostream& gfendl( ostream &s ); #endif /* #if !defined( AL_BUILDING_DLL ) */ #endif /* #if defined( __cplusplus ) */ #endif /* #ifdef _ALSTREAM_H */