summaryrefslogtreecommitdiff
path: root/comm/BufStream.h
blob: dc2511ef9bece8982f1f750ea7c695ef4eb27902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 *	The Unix Channel
 *
 *	by Michel Beaudouin-Lafon
 *
 *	Copyright 1990-1997
 *	Laboratoire de Recherche en Informatique (LRI)
 *
 *	Buffered streams
 *
 *	$Id$
 *	$CurLog$
 *	Created from bits of MsgStream.h
 */

#ifndef BufStream_H_
#define BufStream_H_

#include "Stream.h"
#include "MsgBuffer.h"

class IvlBufStream : public IvlStream {
protected:
	IvlMsgBuffer	InBuffer;
	IvlMsgBuffer	OutBuffer;
	int		OutSize;
	bool		Sync;

		IvlBufStream (const IvlBufStream&);
	int	ReadInput ();
	void	HandleWrite ();

	void	WriteLong (lword);
	void	WriteShort (sword);
	void	WriteByte (byte);
	void	WriteChar (char);
	void	WriteString (const char*);
	void	WriteBuf (const byte*, int);

	
	bool	ReadLong (lword&);
	bool	ReadShort (sword&);
	bool	ReadByte (byte&);
	bool	ReadChar (char&);
	int	ReadString (char*, int);
	int	ReadString (IvlString&);
	bool	ReadBuf (byte*, int);

public:
		IvlBufStream (IvlAddress* = 0, IvlAddress* = 0);
		~IvlBufStream ();

	void		InputBuffer (int min, int grow, int max);
	void		OutputBuffer (int min, int grow, int max);
inline	bool		GetSyncMode ()		{ return Sync; }
inline	void		SetSyncMode (bool s)	{ Sync = s; Flush (); }
inline	void		FlushSize (int n)		{ OutSize = n; }
virtual	void		Flush ();

virtual	void		Closing (bool);
};

#endif	/* BufStream_H_ */