WvStreams
wvbufstream.cc
1/*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * WvBufStream stores data written by write(), and returns it in read().
6 *
7 * See wvbufstream.h.
8 */
9#include "wvbufstream.h"
10
11
12WvBufStream::WvBufStream()
13{
14 dead = eof = false;
15}
16
17
18WvBufStream::~WvBufStream()
19{
20 close();
21}
22
23
25{
26 dead = true;
28}
29
30
31// if uread() is called, someone has already exhausted inbuf... so now it's
32// time to close our stream so they know they're at EOF.
33size_t WvBufStream::uread(void *buf, size_t size)
34{
35 if (eof)
36 close();
37 return 0;
38}
39
40
41size_t WvBufStream::uwrite(const void *buf, size_t size)
42{
43 inbuf.put(buf, size);
44 return size;
45}
46
47
49{
50 return !dead;
51}
52
53
55{
57
58 if (si.wants.writable || eof)
59 si.msec_timeout = 0;
60}
61
62
64{
65 return WvStream::post_select(si) || si.wants.writable || eof;
66}
void put(const T *data, size_t count)
Writes the specified number of elements from the specified storage location into the buffer at its ta...
Definition wvbufbase.h:483
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
virtual bool isok() const
return true if the stream is actually usable right now
virtual void close()
Close the stream if it is open; isok() becomes false from now on.
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual size_t uread(void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by read().
virtual size_t uwrite(const void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
Definition wvstream.cc:875
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
Definition wvstream.cc:844
virtual void close()
Close the stream if it is open; isok() becomes false from now on.
Definition wvstream.cc:341
the data structure used by pre_select()/post_select() and internally by select().
Definition iwvstream.h:50