13 #include "wvstreamclone.h" 14 #include "wvmoniker.h" 17 #pragma warning(disable : 4073) 29 #if MUTATE_ISNT_BROKEN 30 return mutate<IWvStream>(_obj);
45 my_type(
"WvStreamClone:(none)")
77 if (cloned && !outbuf.
used())
98 if (stop_write && !outbuf.
used())
100 return cloned->
flush(msec_timeout);
115 len = cloned->read(buf, size);
116 if (len == 0 && !cloned->
isok())
130 return cloned->write(buf, size);
159 WvString WvStreamClone::errstr()
const 162 return WvStream::errstr();
164 return cloned->errstr();
165 return "No child stream!";
169 void WvStreamClone::close_callback()
192 if (newclone != NULL)
193 my_type =
WvString(
"WvStreamClone:%s", newclone->wstype());
195 my_type =
"WvStreamClone:(none)";
204 if (cloned && cloned->
isok())
206 if (!si.inherit_request)
208 si.wants.readable |=
static_cast<bool>(readcb);
209 si.wants.writable |=
static_cast<bool>(writecb);
210 si.wants.isexception |=
static_cast<bool>(exceptcb);
213 if (outbuf.
used() || autoclose_time)
214 si.wants.writable =
true;
216 cloned->pre_select(si);
228 bool val, want_write;
233 if (cloned && cloned->
isok())
235 if (!si.inherit_request)
237 si.wants.readable |=
static_cast<bool>(readcb);
238 si.wants.writable |=
static_cast<bool>(writecb);
239 si.wants.isexception |=
static_cast<bool>(exceptcb);
242 val = cloned->post_select(si);
243 want_write = si.wants.writable;
248 if (want_write && outbuf.
used())
257 return val || result;
267 return cloned->src();
275 if (cloned) cloned->callback();
280 WvString ret = WvStream::getattr(name);
281 if (ret.
isnull() && cloned)
282 return cloned->getattr(name);
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
virtual void nowrite()
Shuts down the writing side of the stream.
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
WvStreamClone(IWvStream *_cloned=NULL)
Constructs the stream, then calls setclone(_cloned).
The basic interface which is included by all other XPLC interfaces and objects.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
WvStream * write_requires_readable
If this is set, select() doesn't return true for write unless the given stream also returns true for ...
virtual void close()
Close the stream if it is open; isok() becomes false from now on.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
virtual void nowrite()
Shuts down the writing side of the stream.
virtual bool isok() const
return true if the stream is actually usable right now
virtual ~WvStreamClone()
The WvStreamClone destructor.
bool isnull() const
returns true if this string is null
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
virtual bool flush(time_t msec_timeout)
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a ti...
virtual size_t uread(void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by read().
virtual IWvStreamCallback setclosecallback(IWvStreamCallback _callfunc)=0
Sets a callback to be invoked on close().
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
virtual void noread()
Shuts down the reading side of the stream.
virtual bool flush(time_t msec_timeout)=0
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a ti...
virtual void nowrite()=0
Shuts down the writing side of the stream.
virtual void setclone(IWvStream *clone)
WvStreamClone takes ownership of the given stream; it will WVRELEASE() the stream when you setclone()...
virtual bool should_flush()=0
Returns true if we want to flush the output buffer right now.
virtual bool flush_internal(time_t msec_timeout)
WvStream overrides.
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
the data structure used by pre_select()/post_select() and internally by select(). ...
A SelectRequest is a convenient way to remember what we want to do to a particular stream: read from ...
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
bool stop_read
True if noread()/nowrite()/close() have been called, respectively.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
WvStream * read_requires_writable
If this is set, select() doesn't return true for read unless the given stream also returns true for w...
size_t used() const
Returns the number of elements in the buffer currently available for reading.
void force_select(bool readable, bool writable, bool isexception=false)
Use force_select() to force one or more particular modes (readable, writable, or isexception) to true...
virtual void close()
Close this stream.
virtual void noread()=0
Shuts down the reading side of the stream.
virtual bool isok() const =0
By default, returns true if geterr() == 0.
Base class for different address types, each of which will have the ability to convert itself to/from...
virtual bool isok() const
return true if the stream is actually usable right now
virtual size_t uwrite(const void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
WvString is an implementation of a simple and efficient printable-string class.
virtual const WvAddr * src() const
get the remote address from which the last data block was received.
WvStreamClone simply forwards all requests to the "cloned" stream.
virtual void noread()
Shuts down the reading side of the stream.