WvStreams
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
WvStream Class Referenceabstract

Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write at any given time. More...

#include <wvstream.h>

Inheritance diagram for WvStream:
Inheritance graph
[legend]

Public Member Functions

 WvStream ()
 Basic constructor for just a do-nothing WvStream.
 
virtual void close ()
 Close the stream if it is open; isok() becomes false from now on.
 
virtual void seterr (int _errnum)
 Override seterr() from WvError so that it auto-closes the stream.
 
void seterr (WvStringParm specialerr)
 
void seterr (WVSTRING_FORMAT_DECL)
 
virtual bool isok () const
 return true if the stream is actually usable right now
 
virtual size_t read (void *buf, size_t count)
 read a data block on the stream.
 
virtual size_t read (WvBuf &outbuf, size_t count)
 Reads up to 'count' bytes of data from the stream into the buffer.
 
virtual void unread (WvBuf &outbuf, size_t count)
 Puts data back into the stream's internal buffer.
 
virtual size_t write (const void *buf, size_t count)
 Write data to the stream.
 
virtual size_t write (WvBuf &inbuf, size_t count=INT_MAX)
 Writes data to the stream from the given buffer.
 
void outbuf_limit (size_t size)
 set the maximum size of outbuf, beyond which a call to write() will return 0.
 
virtual void noread ()
 Shuts down the reading side of the stream.
 
virtual void nowrite ()
 Shuts down the writing side of the stream.
 
virtual void maybe_autoclose ()
 Auto-close the stream if the time is right.
 
virtual bool isreadable ()
 Returns true if the stream is readable.
 
virtual bool iswritable ()
 Returns true if the stream is writable (without using the outbuf).
 
virtual size_t uread (void *buf, size_t count)
 unbuffered I/O functions; these ignore the buffer, which is handled by read().
 
virtual size_t uwrite (const void *buf, size_t count)
 unbuffered I/O functions; these ignore the buffer, which is handled by write().
 
char * getline (time_t wait_msec=0, char separator='\n', int readahead=1024)
 Read up to one line of data from the stream and return a pointer to the internal buffer containing this line.
 
char * getline (int wait_msec, char separator='\n', int readahead=1024)
 Auto-convert int to time_t.
 
char * getline (double wait_msec, char separator='\n', int readahead=1024)
 Auto-convert double to time_t.
 
char * blocking_getline (time_t wait_msec, int separator='\n', int readahead=1024)
 This is a version of getline() that allows you to block for more data to arrive.
 
char * continue_getline (time_t wait_msec, int separator='\n', int readahead=1024)
 This is a version of blocking_getline() that uses continue_select to avoid blocking other streams.
 
void queuemin (size_t count)
 force read() to not return any bytes unless 'count' bytes can be read at once.
 
void drain ()
 drain the input buffer (read and discard data until select(0) returns false)
 
void delay_output (bool is_delayed)
 force write() to always buffer output.
 
void auto_flush (bool is_automatic)
 if true, force write() to call flush() each time, the default behavour.
 
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 time.
 
virtual bool should_flush ()
 Returns true if we want to flush the output buffer right now.
 
void flush_then_close (int msec_timeout)
 flush the output buffer automatically as select() is called.
 
virtual void pre_select (SelectInfo &si)
 pre_select() sets up for eventually calling select().
 
void pre_select (SelectInfo &si, const SelectRequest &r)
 A more convenient version of pre_select() usable for overriding the 'want' value temporarily.
 
void xpre_select (SelectInfo &si, const SelectRequest &r)
 Like pre_select(), but still exists even if you override the other pre_select() in a subclass.
 
virtual bool post_select (SelectInfo &si)
 post_select() is called after select(), and returns true if this object is now ready.
 
bool xpost_select (SelectInfo &si, const SelectRequest &r)
 Like post_select(), but still exists even if you override the other post_select() in a subclass.
 
bool post_select (SelectInfo &si, const SelectRequest &r)
 A more convenient version of post_select() usable for overriding the 'want' value temporarily.
 
bool select (time_t msec_timeout)
 Return true if any of the requested features are true on the stream.
 
void runonce (time_t msec_timeout=-1)
 Exactly the same as: if (select(timeout)) callback();.
 
bool select (time_t msec_timeout, bool readable, bool writable, bool isex=false)
 This version of select() sets forceable==false, so we use the exact readable/writable/isexception options provided.
 
IWvStream::SelectRequest get_select_request ()
 Use get_select_request() to save the current state of the selection state of this stream.
 
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 when selecting on this stream.
 
void undo_force_select (bool readable, bool writable, bool isexception=false)
 Undo a previous force_select() - ie.
 
bool continue_select (time_t msec_timeout)
 return to the caller from execute(), but don't really return exactly; this uses WvCont::yield() to return to the caller of callback() without losing our place in execute() itself.
 
void terminate_continue_select ()
 you MUST run this from your destructor if you use continue_select(), or very weird things will happen if someone deletes your object while in continue_select().
 
virtual const WvAddrsrc () const
 get the remote address from which the last data block was received.
 
void setcallback (IWvStreamCallback _callfunc)
 define the callback function for this stream, called whenever the callback() member is run, and passed the 'userdata' pointer.
 
IWvStreamCallback setreadcallback (IWvStreamCallback _callback)
 Sets a callback to be invoked when the stream is readable.
 
IWvStreamCallback setwritecallback (IWvStreamCallback _callback)
 Sets a callback to be invoked when the stream is writable.
 
IWvStreamCallback setexceptcallback (IWvStreamCallback _callback)
 Sets a callback to be invoked when the stream is in exception state.
 
IWvStreamCallback setclosecallback (IWvStreamCallback _callback)
 Sets a callback to be invoked on close().
 
void autoforward (WvStream &s)
 set the callback function for this stream to an internal routine that auto-forwards all incoming stream data to the given output stream.
 
void noautoforward ()
 Stops autoforwarding.
 
void * _callwrap (void *)
 A wrapper that's compatible with WvCont, but calls the "real" callback.
 
void _callback ()
 Actually call the registered callfunc and execute().
 
virtual void callback ()
 if the stream has a callback function defined, call it now.
 
void alarm (time_t msec_timeout)
 set an alarm, ie.
 
time_t alarm_remaining ()
 return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (infinity), 0 means the alarm has been hit and will be cleared by the next callback().
 
size_t write (WvStringParm s)
 print a preformatted WvString to the stream.
 
size_t print (WvStringParm s)
 
size_t operator() (WvStringParm s)
 
size_t print (WVSTRING_FORMAT_DECL)
 preformat and write() a string.
 
size_t operator() (WVSTRING_FORMAT_DECL)
 
const char * wsname () const
 
void set_wsname (WvStringParm wsname)
 
void set_wsname (WVSTRING_FORMAT_DECL)
 
const char * wstype () const
 
WSID wsid () const
 
virtual WvString getattr (WvStringParm name) const
 
 WvStream ()
 Basic constructor for just a do-nothing WvStream.
 
virtual void close ()
 Close the stream if it is open; isok() becomes false from now on.
 
virtual void seterr (int _errnum)
 Override seterr() from WvError so that it auto-closes the stream.
 
void seterr (WvStringParm specialerr)
 
void seterr (WVSTRING_FORMAT_DECL)
 
virtual bool isok () const
 return true if the stream is actually usable right now
 
virtual size_t read (void *buf, size_t count)
 read a data block on the stream.
 
virtual size_t read (WvBuf &outbuf, size_t count)
 Reads up to 'count' bytes of data from the stream into the buffer.
 
virtual void unread (WvBuf &outbuf, size_t count)
 Puts data back into the stream's internal buffer.
 
virtual size_t write (const void *buf, size_t count)
 Write data to the stream.
 
virtual size_t write (WvBuf &inbuf, size_t count=INT_MAX)
 Writes data to the stream from the given buffer.
 
void outbuf_limit (size_t size)
 set the maximum size of outbuf, beyond which a call to write() will return 0.
 
virtual void noread ()
 Shuts down the reading side of the stream.
 
virtual void nowrite ()
 Shuts down the writing side of the stream.
 
virtual void maybe_autoclose ()
 Auto-close the stream if the time is right.
 
virtual bool isreadable ()
 Returns true if the stream is readable.
 
virtual bool iswritable ()
 Returns true if the stream is writable (without using the outbuf).
 
virtual size_t uread (void *buf, size_t count)
 unbuffered I/O functions; these ignore the buffer, which is handled by read().
 
virtual size_t uwrite (const void *buf, size_t count)
 unbuffered I/O functions; these ignore the buffer, which is handled by write().
 
char * getline (time_t wait_msec=0, char separator='\n', int readahead=1024)
 Read up to one line of data from the stream and return a pointer to the internal buffer containing this line.
 
char * getline (int wait_msec, char separator='\n', int readahead=1024)
 Auto-convert int to time_t.
 
char * getline (double wait_msec, char separator='\n', int readahead=1024)
 Auto-convert double to time_t.
 
char * blocking_getline (time_t wait_msec, int separator='\n', int readahead=1024)
 This is a version of getline() that allows you to block for more data to arrive.
 
char * continue_getline (time_t wait_msec, int separator='\n', int readahead=1024)
 This is a version of blocking_getline() that uses continue_select to avoid blocking other streams.
 
void queuemin (size_t count)
 force read() to not return any bytes unless 'count' bytes can be read at once.
 
void drain ()
 drain the input buffer (read and discard data until select(0) returns false)
 
void delay_output (bool is_delayed)
 force write() to always buffer output.
 
void auto_flush (bool is_automatic)
 if true, force write() to call flush() each time, the default behavour.
 
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 time.
 
virtual bool should_flush ()
 Returns true if we want to flush the output buffer right now.
 
void flush_then_close (int msec_timeout)
 flush the output buffer automatically as select() is called.
 
virtual void pre_select (SelectInfo &si)
 pre_select() sets up for eventually calling select().
 
void pre_select (SelectInfo &si, const SelectRequest &r)
 A more convenient version of pre_select() usable for overriding the 'want' value temporarily.
 
void xpre_select (SelectInfo &si, const SelectRequest &r)
 Like pre_select(), but still exists even if you override the other pre_select() in a subclass.
 
virtual bool post_select (SelectInfo &si)
 post_select() is called after select(), and returns true if this object is now ready.
 
bool xpost_select (SelectInfo &si, const SelectRequest &r)
 Like post_select(), but still exists even if you override the other post_select() in a subclass.
 
bool post_select (SelectInfo &si, const SelectRequest &r)
 A more convenient version of post_select() usable for overriding the 'want' value temporarily.
 
bool select (time_t msec_timeout)
 Return true if any of the requested features are true on the stream.
 
void runonce (time_t msec_timeout=-1)
 Exactly the same as: if (select(timeout)) callback();.
 
bool select (time_t msec_timeout, bool readable, bool writable, bool isex=false)
 This version of select() sets forceable==false, so we use the exact readable/writable/isexception options provided.
 
IWvStream::SelectRequest get_select_request ()
 Use get_select_request() to save the current state of the selection state of this stream.
 
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 when selecting on this stream.
 
void undo_force_select (bool readable, bool writable, bool isexception=false)
 Undo a previous force_select() - ie.
 
bool continue_select (time_t msec_timeout)
 return to the caller from execute(), but don't really return exactly; this uses WvCont::yield() to return to the caller of callback() without losing our place in execute() itself.
 
void terminate_continue_select ()
 you MUST run this from your destructor if you use continue_select(), or very weird things will happen if someone deletes your object while in continue_select().
 
virtual const WvAddrsrc () const
 get the remote address from which the last data block was received.
 
void setcallback (IWvStreamCallback _callfunc)
 define the callback function for this stream, called whenever the callback() member is run, and passed the 'userdata' pointer.
 
IWvStreamCallback setreadcallback (IWvStreamCallback _callback)
 Sets a callback to be invoked when the stream is readable.
 
IWvStreamCallback setwritecallback (IWvStreamCallback _callback)
 Sets a callback to be invoked when the stream is writable.
 
IWvStreamCallback setexceptcallback (IWvStreamCallback _callback)
 Sets a callback to be invoked when the stream is in exception state.
 
IWvStreamCallback setclosecallback (IWvStreamCallback _callback)
 Sets a callback to be invoked on close().
 
void autoforward (WvStream &s)
 set the callback function for this stream to an internal routine that auto-forwards all incoming stream data to the given output stream.
 
void noautoforward ()
 Stops autoforwarding.
 
void * _callwrap (void *)
 A wrapper that's compatible with WvCont, but calls the "real" callback.
 
void _callback ()
 Actually call the registered callfunc and execute().
 
virtual void callback ()
 if the stream has a callback function defined, call it now.
 
void alarm (time_t msec_timeout)
 set an alarm, ie.
 
time_t alarm_remaining ()
 return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (infinity), 0 means the alarm has been hit and will be cleared by the next callback().
 
size_t write (WvStringParm s)
 print a preformatted WvString to the stream.
 
size_t print (WvStringParm s)
 
size_t operator() (WvStringParm s)
 
size_t print (WVSTRING_FORMAT_DECL)
 preformat and write() a string.
 
size_t operator() (WVSTRING_FORMAT_DECL)
 
const char * wsname () const
 
void set_wsname (WvStringParm wsname)
 
void set_wsname (WVSTRING_FORMAT_DECL)
 
const char * wstype () const
 
WSID wsid () const
 
virtual WvString getattr (WvStringParm name) const
 
virtual int geterr () const
 If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.
 
virtual int geterr () const
 If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.
 
virtual WvString errstr () const
 
virtual WvString errstr () const
 
void seterr (const WvErrorBase &err)
 
void seterr_both (int _errnum, WvStringParm specialerr)
 
void seterr_both (int _errnum, WVSTRING_FORMAT_DECL)
 
void seterr_both (int _errnum, WvStringParm specialerr)
 
void seterr_both (int _errnum, WVSTRING_FORMAT_DECL)
 
void noerr ()
 Reset our error state - there's no error condition anymore.
 
void noerr ()
 Reset our error state - there's no error condition anymore.
 
virtual unsigned int addRef ()=0
 Indicate you are using this object.
 
virtual unsigned int addRef ()=0
 Indicate you are using this object.
 
virtual unsigned int release ()=0
 Indicate that you are finished using this object.
 
virtual unsigned int release ()=0
 Indicate that you are finished using this object.
 
virtual IObjectgetInterface (const UUID &)=0
 Returns the requested XPLC interface.
 
virtual IObjectgetInterface (const UUID &)=0
 Returns the requested XPLC interface.
 
virtual IWeakRefgetWeakRef ()=0
 Return a weak reference to this object.
 
virtual IWeakRefgetWeakRef ()=0
 Return a weak reference to this object.
 

Static Public Member Functions

static void autoforward_callback (WvStream &input, WvStream &output)
 
static IWvStreamfind_by_wsid (WSID wsid)
 
static void autoforward_callback (WvStream &input, WvStream &output)
 
static IWvStreamfind_by_wsid (WSID wsid)
 
static IWvStreamcreate (WvStringParm moniker, IObject *obj=NULL)
 
static IWvStreamcreate (WvStringParm moniker, IObject *obj=NULL)
 
static WvString strerror (int errnum)
 A replacement for the operating system strerror() function that can map more kinds of error strings (especially in win32).
 
static WvString strerror (int errnum)
 A replacement for the operating system strerror() function that can map more kinds of error strings (especially in win32).
 

Public Attributes

WvStreamread_requires_writable
 If this is set, select() doesn't return true for read unless the given stream also returns true for write.
 
WvStreamwrite_requires_readable
 If this is set, select() doesn't return true for write unless the given stream also returns true for read.
 
bool uses_continue_select
 If this is set, enables the use of continue_select().
 
size_t personal_stack_size
 Specifies the stack size to reserve for continue_select().
 
bool alarm_was_ticking
 This will be true during callback execution if the callback was triggered by the alarm going off.
 
bool stop_read
 True if noread()/nowrite()/close() have been called, respectively.
 
bool stop_write
 
bool closed
 

Protected Member Functions

void setattr (WvStringParm name, WvStringParm value)
 
void _build_selectinfo (SelectInfo &si, time_t msec_timeout, bool readable, bool writable, bool isexcept, bool forceable)
 
int _do_select (SelectInfo &si)
 
bool _process_selectinfo (SelectInfo &si, bool forceable)
 
bool flush_outbuf (time_t msec_timeout)
 
virtual bool flush_internal (time_t msec_timeout)
 
virtual int getrfd () const
 
virtual int getwfd () const
 
virtual void execute ()
 The callback() function calls execute(), and then calls the user- specified callback if one is defined.
 
void setattr (WvStringParm name, WvStringParm value)
 
void _build_selectinfo (SelectInfo &si, time_t msec_timeout, bool readable, bool writable, bool isexcept, bool forceable)
 
int _do_select (SelectInfo &si)
 
bool _process_selectinfo (SelectInfo &si, bool forceable)
 
bool flush_outbuf (time_t msec_timeout)
 
virtual bool flush_internal (time_t msec_timeout)
 
virtual int getrfd () const
 
virtual int getwfd () const
 
virtual void execute ()
 The callback() function calls execute(), and then calls the user- specified callback if one is defined.
 

Static Protected Member Functions

static void debugger_streams_display_header (WvStringParm cmd, WvStreamsDebugger::ResultCallback result_cb)
 
static void debugger_streams_display_one_stream (WvStream *s, WvStringParm cmd, WvStreamsDebugger::ResultCallback result_cb)
 
static void debugger_streams_maybe_display_one_stream (WvStream *s, WvStringParm cmd, const WvStringList &args, WvStreamsDebugger::ResultCallback result_cb)
 
static void debugger_streams_display_header (WvStringParm cmd, WvStreamsDebugger::ResultCallback result_cb)
 
static void debugger_streams_display_one_stream (WvStream *s, WvStringParm cmd, WvStreamsDebugger::ResultCallback result_cb)
 
static void debugger_streams_maybe_display_one_stream (WvStream *s, WvStringParm cmd, const WvStringList &args, WvStreamsDebugger::ResultCallback result_cb)
 

Protected Attributes

WvDynBuf inbuf
 
WvDynBuf outbuf
 
IWvStreamCallback callfunc
 
wv::function< void *(void *)> call_ctx
 
IWvStreamCallback readcb
 
IWvStreamCallback writecb
 
IWvStreamCallback exceptcb
 
IWvStreamCallback closecb
 
size_t max_outbuf_size
 
bool outbuf_delayed_flush
 
bool is_auto_flush
 
bool want_to_flush
 
bool is_flushing
 
size_t queue_min
 
time_t autoclose_time
 
WvTime alarm_time
 
WvTime last_alarm_check
 
int errnum
 
WvString errstring
 

Static Protected Attributes

static WvStreamglobalstream = NULL
 

Friends

class WvHTTPClientProxyStream
 

Detailed Description

Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write at any given time.

We provide typical read and write routines, as well as a select() function for each stream.

Definition at line 24 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Constructor & Destructor Documentation

◆ WvStream()

WvStream::WvStream ( )

Basic constructor for just a do-nothing WvStream.

Definition at line 249 of file wvstream.cc.

◆ ~WvStream()

WvStream::~WvStream ( )
virtual

Definition at line 311 of file wvstream.cc.

Member Function Documentation

◆ close() [1/2]

void WvStream::close ( )
virtual

Close the stream if it is open; isok() becomes false from now on.

Note!! If you override this function in a derived class, you must call it yourself from your destructor. WvStream::~WvStream() can only call WvStream::close() because of the way virtual functions work in C++.

Implements IWvStream.

Reimplemented in UniClientConn, UniConfDaemon, UniConfDaemonConn, WvAtomicFile, WvBufStream, WvDBusConn, WvEncoderStream, WvFdStream, WvHttpStream, WvFtpStream, WvModemBase, WvModem, WvSSLStream, WvStreamClone, UniClientConn, UniConfDaemon, UniConfDaemonConn, WvAtomicFile, WvBufStream, WvDBusConn, WvEncoderStream, WvFdStream, WvHttpStream, WvFtpStream, WvModemBase, WvModem, WvSSLStream, WvStreamClone, _WvConStream, WvUrlStream, and WvUrlStream.

Definition at line 341 of file wvstream.cc.

References flush().

Referenced by UniConfDaemon::close(), WvBufStream::close(), WvFdStream::close(), WvStreamClone::close(), maybe_autoclose(), seterr(), terminate_continue_select(), and WvDBusServer::~WvDBusServer().

◆ seterr() [1/7]

void WvStream::seterr ( int  _errnum)
virtual

◆ seterr() [2/7]

void WvStream::seterr ( WvStringParm  specialerr)
inline

◆ seterr() [3/7]

void WvStream::seterr ( WVSTRING_FORMAT_DECL  )
inline

◆ isok() [1/2]

bool WvStream::isok ( ) const
virtual

◆ read() [1/4]

size_t WvStream::read ( void *  buf,
size_t  count 
)
virtual

◆ read() [2/4]

size_t WvStream::read ( WvBuf &  outbuf,
size_t  count 
)
virtual

Reads up to 'count' bytes of data from the stream into the buffer.

Returns the actual amount read.

If 'count' is greater than the amount of free space available in the buffer, only reads at most that amount. You should specify a reasonable upper bound on how much data should be read at once.

Implements IWvStream.

Definition at line 461 of file wvstream.cc.

References WvBufBaseCommonImpl< T >::alloc(), read(), and WvBufBaseCommonImpl< T >::unalloc().

◆ unread() [1/2]

void WvStream::unread ( WvBuf &  outbuf,
size_t  count 
)
virtual

Puts data back into the stream's internal buffer.

We cheat so that there's no restriction on how much (or what) data can be unread(). This is different from WvBuf::unget() (which is rather restrictive).

Definition at line 1190 of file wvstream.cc.

References WvBufBaseCommonImpl< T >::merge(), and WvBufBaseCommonImpl< T >::zap().

Referenced by WvHttpStream::execute().

◆ write() [1/6]

size_t WvStream::write ( const void *  buf,
size_t  count 
)
virtual

Write data to the stream.

Returns the actual amount written. Since WvStream has an output buffer, it always successfully "writes" the full amount (but you might have to flush the buffers later so it actually gets sent).

Implements IWvStream.

Definition at line 532 of file wvstream.cc.

References flush(), isok(), WvBufBaseCommonImpl< T >::put(), should_flush(), WvBufBaseCommonImpl< T >::used(), and uwrite().

Referenced by WvLogFileBase::_mid_line(), WvDBusClientAuth::authorize(), WvModem::close(), WvHttpStream::execute(), WvIStreamList::execute(), WvModemBase::hangup(), WvLog::operator()(), print(), WvDBusConn::send(), UniFileSystemGen::set(), WvFdStream::uwrite(), WvProtoStream::uwrite(), write(), write(), and UniClientConn::writecmd().

◆ write() [2/6]

size_t WvStream::write ( WvBuf &  inbuf,
size_t  count = INT_MAX 
)
virtual

Writes data to the stream from the given buffer.

Returns the actual amount written.

If count is greater than the amount of data available in the buffer, only writes at most that amount.

Implements IWvStream.

Definition at line 477 of file wvstream.cc.

References write().

◆ outbuf_limit() [1/2]

void WvStream::outbuf_limit ( size_t  size)
inlinevirtual

set the maximum size of outbuf, beyond which a call to write() will return 0.

I need to do this for tape backups, since all I can do is write to the loopback as fast as I can, which causes us to run out of memory and get SIGABRT'd. (dcoombs: 12/15/2000)

FIXME: there must be a better way. This confuses the semantics of write(); can you trust it to always write all the bytes, or not?

Implements IWvStream.

Definition at line 129 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

◆ noread() [1/2]

void WvStream::noread ( )
virtual

Shuts down the reading side of the stream.

This is the opposite of nowrite(), but the name is actually slightly misleading; subsequent calls to read() might not fail; rather, if the other end of the connection tries to write to us, they should fail.

After noread(), if the read buffer (if any) is empty once, we promise that it will never refill.

If you call both noread() and nowrite(), then the stream does close() automatically once all buffers are empty.

Implements IWvStream.

Reimplemented in WvSSLStream, WvStreamClone, WvSSLStream, and WvStreamClone.

Definition at line 569 of file wvstream.cc.

References maybe_autoclose(), and stop_read.

Referenced by WvResolver::findaddr(), and WvStreamClone::noread().

◆ nowrite() [1/2]

void WvStream::nowrite ( )
virtual

Shuts down the writing side of the stream.

Subsequent calls to write() will fail. But if there's data in the output buffer, it will still be flushed.

If you call both noread() and nowrite(), then the stream does close() automatically once all buffers are empty.

Implements IWvStream.

Reimplemented in WvSSLStream, WvStreamClone, WvSSLStream, and WvStreamClone.

Definition at line 576 of file wvstream.cc.

References maybe_autoclose().

Referenced by WvResolver::findaddr(), and WvStreamClone::nowrite().

◆ maybe_autoclose() [1/2]

void WvStream::maybe_autoclose ( )
virtual

Auto-close the stream if the time is right.

If noread() and nowrite() and all buffers are empty, then we can probably close.

Implements IWvStream.

Reimplemented in WvFdStream, and WvFdStream.

Definition at line 583 of file wvstream.cc.

References close(), stop_read, and WvBufBaseCommonImpl< T >::used().

Referenced by blocking_getline(), WvFdStream::maybe_autoclose(), noread(), nowrite(), pre_select(), and read().

◆ isreadable() [1/2]

bool WvStream::isreadable ( )
virtual

Returns true if the stream is readable.

Implements IWvStream.

Definition at line 590 of file wvstream.cc.

References isok(), and select().

Referenced by drain(), and UniClientGen::flush_buffers().

◆ iswritable() [1/2]

bool WvStream::iswritable ( )
virtual

Returns true if the stream is writable (without using the outbuf).

Implements IWvStream.

Definition at line 596 of file wvstream.cc.

References isok(), and select().

◆ uread() [1/2]

virtual size_t WvStream::uread ( void *  buf,
size_t  count 
)
inlinevirtual

unbuffered I/O functions; these ignore the buffer, which is handled by read().

Don't call these functions explicitly unless you have a really good reason.

This is what you would override in a derived class.

Reimplemented in WvFdStream, WvIPRawStream, WvUDPStream, WvFdStream, WvIPRawStream, WvUDPStream, WvMagicLoopback, WvSSLStream, WvMagicLoopback, WvSSLStream, WvBufStream, WvEncoderStream, WvStreamClone, WvBufStream, WvEncoderStream, and WvStreamClone.

Definition at line 146 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by blocking_getline(), and read().

◆ uwrite() [1/2]

virtual size_t WvStream::uwrite ( const void *  buf,
size_t  count 
)
inlinevirtual

unbuffered I/O functions; these ignore the buffer, which is handled by write().

Don't call these functions explicitly unless you have a really good reason.

This is what you would override in a derived class.

Reimplemented in WvFdStream, WvIPRawStream, WvTCPConn, WvUDPStream, WvUnixDGSocket, WvFdStream, WvIPRawStream, WvTCPConn, WvUDPStream, WvUnixDGSocket, WvLog, WvMagicLoopback, WvSSLStream, WvLog, WvMagicLoopback, WvSSLStream, WvBufStream, WvEncoderStream, WvStreamClone, WvBufStream, WvEncoderStream, WvStreamClone, WvProtoStream, and WvProtoStream.

Definition at line 156 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by write().

◆ getline() [1/6]

char * WvStream::getline ( time_t  wait_msec = 0,
char  separator = '\n',
int  readahead = 1024 
)
inline

Read up to one line of data from the stream and return a pointer to the internal buffer containing this line.

If the end-of-line 'separator' is encountered, it is removed from the string. If there is not a full line available, returns NULL. You can read what we have so far by calling read().

Readahead specifies the maximum amount of data that the stream is allowed to read in one shot.

It is expected that there will be no NULL characters on the line.

wait_msec is provided so that legacy code does not break. But it really should be 0.

Definition at line 175 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References blocking_getline().

Referenced by WvHttpStream::execute(), WvProtoStream::execute(), WvIPRouteList::get_kernel(), getline(), and getline().

◆ getline() [2/6]

char * WvStream::getline ( int  wait_msec,
char  separator = '\n',
int  readahead = 1024 
)
inline

Auto-convert int to time_t.

Definition at line 182 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References getline().

◆ getline() [3/6]

char * WvStream::getline ( double  wait_msec,
char  separator = '\n',
int  readahead = 1024 
)
inline

Auto-convert double to time_t.

Definition at line 189 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References getline().

◆ blocking_getline() [1/2]

char * WvStream::blocking_getline ( time_t  wait_msec,
int  separator = '\n',
int  readahead = 1024 
)

This is a version of getline() that allows you to block for more data to arrive.

This should be used carefully, as blocking is generally unexpected in WvStreams programs.

If wait_msec < 0, it will wait forever for the 'separator' (often a bad idea!). If wait_msed == 0, this is the equivalent of getline().

Definition at line 602 of file wvstream.cc.

References WvBufBaseCommonImpl< T >::alloc(), continue_select(), WvBufBaseCommonImpl< T >::get(), isok(), maybe_autoclose(), WvBufBaseCommonImpl< T >::mutablepeek(), WvBufBaseCommonImpl< T >::put(), queuemin(), select(), stop_read, WvBufBaseCommonImpl< T >::unalloc(), uread(), WvBufBaseCommonImpl< T >::used(), and uses_continue_select.

Referenced by WvResolver::findaddr(), WvIPRouteList::get_kernel(), getline(), and UniIniGen::refresh().

◆ continue_getline()

char * WvStream::continue_getline ( time_t  wait_msec,
int  separator = '\n',
int  readahead = 1024 
)

This is a version of blocking_getline() that uses continue_select to avoid blocking other streams.

Definition at line 690 of file wvstream.cc.

References uses_continue_select.

◆ queuemin() [1/2]

void WvStream::queuemin ( size_t  count)
inline

force read() to not return any bytes unless 'count' bytes can be read at once.

(Useful for processing Content-Length headers, etc.) Use count==0 to disable this feature.

WARNING: getline() sets queuemin to 0 automatically!

Definition at line 232 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by blocking_getline().

◆ drain()

void WvStream::drain ( )

drain the input buffer (read and discard data until select(0) returns false)

Definition at line 699 of file wvstream.cc.

References isreadable(), and read().

Referenced by WvModem::close(), WvModemBase::hangup(), and WvMagicLoopback::pre_select().

◆ delay_output() [1/2]

void WvStream::delay_output ( bool  is_delayed)
inline

force write() to always buffer output.

This can be more efficient if you write a lot of small segments and want to "coagulate" them automatically. To flush the output buffer, use flush() or select().

Definition at line 246 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

◆ auto_flush() [1/2]

void WvStream::auto_flush ( bool  is_automatic)
inline

if true, force write() to call flush() each time, the default behavour.

otherwise, flush() is granted special meaning when explicitly invoked by the client and write() may empty the output buffer, but will not explicitly flush().

Definition at line 258 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

◆ flush() [1/2]

bool WvStream::flush ( time_t  msec_timeout)
virtual

flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time.

(-1 means wait forever)

Returns true if the flushing finished (the output buffer is empty).

Implements IWvStream.

Definition at line 707 of file wvstream.cc.

Referenced by close(), flush_then_close(), post_select(), WvStreamClone::post_select(), and write().

◆ should_flush() [1/2]

bool WvStream::should_flush ( )
virtual

Returns true if we want to flush the output buffer right now.

This allows us to implement delayed_flush(), flush_then_close(), etc, but it's still super-ugly and probably needs to go away. (In fact, all our buffer flushing is super-ugly right now.)

Implements IWvStream.

Definition at line 724 of file wvstream.cc.

Referenced by WvFdStream::post_select(), post_select(), and write().

◆ flush_then_close() [1/2]

void WvStream::flush_then_close ( int  msec_timeout)

flush the output buffer automatically as select() is called.

If the buffer empties, close the stream. If msec_timeout seconds pass, close the stream. After the stream closes, it will become !isok() (and a WvStreamList can delete it automatically)

Definition at line 827 of file wvstream.cc.

References flush(), and WvBufBaseCommonImpl< T >::used().

◆ pre_select() [1/4]

void WvStream::pre_select ( SelectInfo si)
virtual

pre_select() sets up for eventually calling select().

It adds the right fds to the read, write, and except lists in the SelectInfo struct.

Returns true if we already know this stream is ready, and there's no need to actually do a real select(). Some streams, such as timers, can be implemented by only either returning true or false here after doing a calculation, and never actually adding anything to the SelectInfo.

You can add your stream to any of the lists even if readable, writable, or isexception isn't set. This is what force_select() does. You can also choose not to add yourself to the list if you know it would be useless right now.

pre_select() is only called if isok() is true.

pre_select() is allowed to reduce msec_timeout (or change it if it's -1). However, it's not allowed to increase msec_timeout.

Implements IWvStream.

Reimplemented in WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, WvUnixDGSocket, WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, and WvUnixDGSocket.

Definition at line 844 of file wvstream.cc.

References alarm_remaining(), isok(), maybe_autoclose(), and WvBufBaseCommonImpl< T >::used().

Referenced by WvBufStream::pre_select(), WvDailyEvent::pre_select(), WvFdStream::pre_select(), WvHttpStream::pre_select(), WvFtpStream::pre_select(), WvLog::pre_select(), WvStreamClone::pre_select(), WvTimeStream::pre_select(), pre_select(), and xpre_select().

◆ pre_select() [2/4]

void WvStream::pre_select ( SelectInfo si,
const SelectRequest r 
)
inline

A more convenient version of pre_select() usable for overriding the 'want' value temporarily.

Definition at line 306 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References pre_select().

◆ xpre_select() [1/2]

void WvStream::xpre_select ( SelectInfo si,
const SelectRequest r 
)
inline

Like pre_select(), but still exists even if you override the other pre_select() in a subclass.

Sigh.

Definition at line 318 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References pre_select().

Referenced by WvResolver::pre_select().

◆ post_select() [1/4]

bool WvStream::post_select ( SelectInfo si)
virtual

post_select() is called after select(), and returns true if this object is now ready.

Usually this is done by checking for this object in the read, write, and except lists in the SelectInfo structure. If you want to do it in some other way, you should usually do it in pre_select() instead.

You may also want to do extra maintenance functions here; for example, the standard WvStream::post_select tries to flush outbuf if it's nonempty. WvTCPConn might retry connect() if it's waiting for a connection to be established.

Implements IWvStream.

Reimplemented in WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, WvUnixDGSocket, WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, and WvUnixDGSocket.

Definition at line 875 of file wvstream.cc.

References alarm_remaining(), flush(), should_flush(), and WvBufBaseCommonImpl< T >::used().

Referenced by WvBufStream::post_select(), WvDailyEvent::post_select(), WvFdStream::post_select(), WvHttpStream::post_select(), WvFtpStream::post_select(), WvLog::post_select(), WvMagicLoopback::post_select(), WvStreamClone::post_select(), WvTimeStream::post_select(), post_select(), and xpost_select().

◆ xpost_select() [1/2]

bool WvStream::xpost_select ( SelectInfo si,
const SelectRequest r 
)
inline

Like post_select(), but still exists even if you override the other post_select() in a subclass.

Sigh.

Definition at line 339 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References post_select().

Referenced by WvResolver::post_select().

◆ post_select() [2/4]

bool WvStream::post_select ( SelectInfo si,
const SelectRequest r 
)
inline

A more convenient version of post_select() usable for overriding the 'want' value temporarily.

Definition at line 346 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References post_select().

◆ select() [1/4]

bool WvStream::select ( time_t  msec_timeout)
inline

Return true if any of the requested features are true on the stream.

If msec_timeout < 0, waits forever (bad idea!). ==0, does not wait. Otherwise, waits for up to msec_timeout milliseconds.

NOTE select() is not virtual! To change the select() behaviour of a stream, override the pre_select() and/or post_select() functions.

This version of select() sets forceable==true, so force_select options are taken into account.

You almost always use this version of select() with callbacks, like this: if (stream.select(1000)) stream.callback();

If you want to read/write the stream in question, try using the other variant of select().

DEPRECATED. Call runonce() instead.

Definition at line 376 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by blocking_getline(), continue_select(), WvResolver::findaddr(), WvModemBase::hangup(), isreadable(), iswritable(), WvFdStream::post_select(), WvStreamClone::post_select(), and runonce().

◆ runonce() [1/2]

void WvStream::runonce ( time_t  msec_timeout = -1)
inline

Exactly the same as: if (select(timeout)) callback();.

...except that the above is deprecated, because it assumes callbacks aren't called automatically and that the return value of one-parameter select() is actually meaningful.

Update your main loop to call runonce() instead of the above.

Almost all modern programs should use msec_timeout = -1.

Definition at line 391 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References callback(), and select().

Referenced by WvDBusConn::send_and_wait().

◆ select() [2/4]

bool WvStream::select ( time_t  msec_timeout,
bool  readable,
bool  writable,
bool  isex = false 
)
inline

This version of select() sets forceable==false, so we use the exact readable/writable/isexception options provided.

You normally use this variant of select() when deciding whether you should read/write a particular stream. For example:

if (stream.select(1000, true, false))
        len = stream.read(buf, sizeof(buf));

This variant of select() is probably not what you want with most WvStreamLists, unless you know exactly what you're doing.

WARNING: the difference between the one-parameter and multi-parameter versions of select() is incredibly confusing. Make sure you use the right one!

DEPRECATED. Call isreadable() or iswritable() instead, if msec_timeout was going to be zero. Other values of msec_timeout are not really recommended anyway.

Definition at line 415 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

◆ get_select_request() [1/2]

IWvStream::SelectRequest WvStream::get_select_request ( )

Use get_select_request() to save the current state of the selection state of this stream.

That way, you can call force_select() and undo_force_select() to restore this properly.

Definition at line 1020 of file wvstream.cc.

◆ force_select() [1/2]

void WvStream::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 when selecting on this stream.

If an option is set 'true', we will select on that option when someone does a select(). If it's set 'false', we don't change its force status. (To de-force something, use undo_force_select().)

Definition at line 1027 of file wvstream.cc.

Referenced by WvStreamClone::WvStreamClone().

◆ undo_force_select() [1/2]

void WvStream::undo_force_select ( bool  readable,
bool  writable,
bool  isexception = false 
)

Undo a previous force_select() - ie.

un-forces the options which are 'true', and leaves the false ones alone.

Definition at line 1038 of file wvstream.cc.

◆ continue_select() [1/2]

bool WvStream::continue_select ( time_t  msec_timeout)

return to the caller from execute(), but don't really return exactly; this uses WvCont::yield() to return to the caller of callback() without losing our place in execute() itself.

So, next time someone calls callback(), it will be as if continue_select() returned.

NOTE: execute() will won't be called recursively this way, but any other member function might get called, or member variables changed, or the state of the world updated while continue_select() runs. Don't assume that nothing has changed after a call to continue_select().

NOTE 2: if you're going to call continue_select(), you should set uses_continue_select=true before the first call to callback(). Otherwise your WvCont won't get created.

NOTE 3: if msec_timeout >= 0, this uses WvStream::alarm().

Definition at line 1089 of file wvstream.cc.

References alarm(), alarm_was_ticking, select(), uses_continue_select, and WvCont::yield().

Referenced by blocking_getline().

◆ terminate_continue_select()

void WvStream::terminate_continue_select ( )

you MUST run this from your destructor if you use continue_select(), or very weird things will happen if someone deletes your object while in continue_select().

Definition at line 1116 of file wvstream.cc.

References close().

◆ src() [1/2]

const WvAddr * WvStream::src ( ) const
virtual

get the remote address from which the last data block was received.

May be NULL. The pointer becomes invalid upon the next call to read().

Implements IWvStream.

Reimplemented in WvIPRawStream, WvStreamClone, WvTCPConn, WvUDPStream, WvUnixConn, WvIPRawStream, WvStreamClone, WvTCPConn, WvUDPStream, and WvUnixConn.

Definition at line 1123 of file wvstream.cc.

◆ setcallback()

void WvStream::setcallback ( IWvStreamCallback  _callfunc)

define the callback function for this stream, called whenever the callback() member is run, and passed the 'userdata' pointer.

Definition at line 1129 of file wvstream.cc.

Referenced by autoforward(), noautoforward(), and UniClientGen::UniClientGen().

◆ setreadcallback() [1/2]

IWvStreamCallback WvStream::setreadcallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked when the stream is readable.

Implements IWvStream.

Definition at line 1144 of file wvstream.cc.

References _callback().

◆ setwritecallback() [1/2]

IWvStreamCallback WvStream::setwritecallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked when the stream is writable.

Implements IWvStream.

Definition at line 1154 of file wvstream.cc.

References _callback().

◆ setexceptcallback() [1/2]

IWvStreamCallback WvStream::setexceptcallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked when the stream is in exception state.

Implements IWvStream.

Definition at line 1164 of file wvstream.cc.

References _callback().

◆ setclosecallback() [1/2]

IWvStreamCallback WvStream::setclosecallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked on close().


Implements IWvStream.

Definition at line 1174 of file wvstream.cc.

References _callback(), and isok().

◆ autoforward()

void WvStream::autoforward ( WvStream s)

set the callback function for this stream to an internal routine that auto-forwards all incoming stream data to the given output stream.

Definition at line 362 of file wvstream.cc.

References read_requires_writable, and setcallback().

◆ noautoforward()

void WvStream::noautoforward ( )

Stops autoforwarding.

Definition at line 369 of file wvstream.cc.

References read_requires_writable, and setcallback().

◆ autoforward_callback()

void WvStream::autoforward_callback ( WvStream input,
WvStream output 
)
static

Definition at line 376 of file wvstream.cc.

◆ _callwrap()

void * WvStream::_callwrap ( void *  )

A wrapper that's compatible with WvCont, but calls the "real" callback.

Definition at line 394 of file wvstream.cc.

References _callback().

Referenced by callback().

◆ _callback()

void WvStream::_callback ( )

Actually call the registered callfunc and execute().

Definition at line 386 of file wvstream.cc.

References execute().

Referenced by _callwrap(), callback(), setclosecallback(), setexceptcallback(), setreadcallback(), and setwritecallback().

◆ callback() [1/2]

void WvStream::callback ( )
virtual

if the stream has a callback function defined, call it now.

otherwise call execute().

Implements IWvStream.

Definition at line 401 of file wvstream.cc.

References _callback(), _callwrap(), alarm_remaining(), alarm_was_ticking, personal_stack_size, and uses_continue_select.

Referenced by UniClientGen::flush_buffers(), and runonce().

◆ alarm() [1/2]

void WvStream::alarm ( time_t  msec_timeout)

set an alarm, ie.

select() will return true after this many ms. The alarm is cleared when callback() is called.

Definition at line 1049 of file wvstream.cc.

Referenced by continue_select(), WvHttpStream::execute(), WvSubProcQueueStream::execute(), and WvUnixDGSocket::post_select().

◆ alarm_remaining()

time_t WvStream::alarm_remaining ( )

return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (infinity), 0 means the alarm has been hit and will be cleared by the next callback().

Definition at line 1058 of file wvstream.cc.

Referenced by callback(), WvIStreamList::post_select(), post_select(), WvIStreamList::pre_select(), pre_select(), and WvUnixDGSocket::pre_select().

◆ write() [3/6]

size_t WvStream::write ( WvStringParm  s)
inline

print a preformatted WvString to the stream.

see the simple version of write() way up above.

Definition at line 538 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References WvFastString::cstr(), and write().

◆ print() [1/4]

size_t WvStream::print ( WvStringParm  s)
inline

◆ operator()() [1/4]

size_t WvStream::operator() ( WvStringParm  s)
inline

◆ print() [2/4]

size_t WvStream::print ( WVSTRING_FORMAT_DECL  )
inline

preformat and write() a string.

Definition at line 546 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

References write().

◆ operator()() [2/4]

size_t WvStream::operator() ( WVSTRING_FORMAT_DECL  )
inline

◆ wsname() [1/2]

const char * WvStream::wsname ( ) const
inlinevirtual

◆ set_wsname() [1/4]

void WvStream::set_wsname ( WvStringParm  wsname)
inlinevirtual

◆ set_wsname() [2/4]

void WvStream::set_wsname ( WVSTRING_FORMAT_DECL  )
inline

◆ wstype() [1/2]

const char * WvStream::wstype ( ) const
inlinevirtual

◆ wsid() [1/2]

WSID WvStream::wsid ( ) const
inlinevirtual

◆ find_by_wsid()

IWvStream * WvStream::find_by_wsid ( WSID  wsid)
static

Definition at line 1200 of file wvstream.cc.

◆ getattr() [1/2]

virtual WvString WvStream::getattr ( WvStringParm  name) const
inlinevirtual

◆ setattr() [1/2]

void WvStream::setattr ( WvStringParm  name,
WvStringParm  value 
)
inlineprotected

◆ _build_selectinfo()

void WvStream::_build_selectinfo ( SelectInfo si,
time_t  msec_timeout,
bool  readable,
bool  writable,
bool  isexcept,
bool  forceable 
)
protected

Definition at line 901 of file wvstream.cc.

◆ _do_select()

int WvStream::_do_select ( SelectInfo si)
protected

Definition at line 939 of file wvstream.cc.

◆ _process_selectinfo()

bool WvStream::_process_selectinfo ( SelectInfo si,
bool  forceable 
)
protected

Definition at line 977 of file wvstream.cc.

◆ flush_outbuf()

bool WvStream::flush_outbuf ( time_t  msec_timeout)
protected

Definition at line 730 of file wvstream.cc.

◆ flush_internal() [1/2]

bool WvStream::flush_internal ( time_t  msec_timeout)
protectedvirtual

Reimplemented in WvEncoderStream, WvStreamClone, WvEncoderStream, and WvStreamClone.

Definition at line 808 of file wvstream.cc.

◆ getrfd() [1/2]

int WvStream::getrfd ( ) const
protectedvirtual

Implements IWvStream.

Reimplemented in WvFdStream, and WvFdStream.

Definition at line 815 of file wvstream.cc.

◆ getwfd() [1/2]

int WvStream::getwfd ( ) const
protectedvirtual

Implements IWvStream.

Reimplemented in WvFdStream, and WvFdStream.

Definition at line 821 of file wvstream.cc.

◆ execute() [1/2]

virtual void WvStream::execute ( )
inlineprotectedvirtual

The callback() function calls execute(), and then calls the user- specified callback if one is defined.

Do not call execute() directly; call callback() instead.

The default execute() function does nothing.

Note: If you override this function in a derived class, you must call the parent execute() yourself from the derived class.

Reimplemented in UniConfDaemonConn, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvProtoStream, WvStreamClone, WvSubProcQueueStream, WvTimeoutStream, WvTimeStream, UniConfDaemonConn, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvProtoStream, WvStreamClone, WvSubProcQueueStream, WvTimeoutStream, WvTimeStream, WvUrlStream, and WvUrlStream.

Definition at line 652 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by _callback(), UniConfDaemonConn::execute(), WvIStreamList::execute(), WvStreamClone::execute(), WvTimeoutStream::execute(), and WvTimeStream::execute().

◆ debugger_streams_display_header()

void WvStream::debugger_streams_display_header ( WvStringParm  cmd,
WvStreamsDebugger::ResultCallback  result_cb 
)
staticprotected

Definition at line 125 of file wvstream.cc.

◆ debugger_streams_display_one_stream()

void WvStream::debugger_streams_display_one_stream ( WvStream s,
WvStringParm  cmd,
WvStreamsDebugger::ResultCallback  result_cb 
)
staticprotected

Definition at line 152 of file wvstream.cc.

◆ debugger_streams_maybe_display_one_stream()

void WvStream::debugger_streams_maybe_display_one_stream ( WvStream s,
WvStringParm  cmd,
const WvStringList args,
WvStreamsDebugger::ResultCallback  result_cb 
)
staticprotected

Definition at line 171 of file wvstream.cc.

◆ close() [2/2]

virtual void WvStream::close ( )
virtual

Close the stream if it is open; isok() becomes false from now on.

Note!! If you override this function in a derived class, you must call it yourself from your destructor. WvStream::~WvStream() can only call WvStream::close() because of the way virtual functions work in C++.

Implements IWvStream.

Reimplemented in UniClientConn, UniConfDaemon, UniConfDaemonConn, WvAtomicFile, WvBufStream, WvDBusConn, WvEncoderStream, WvFdStream, WvHttpStream, WvFtpStream, WvModemBase, WvModem, WvSSLStream, WvStreamClone, UniClientConn, UniConfDaemon, UniConfDaemonConn, WvAtomicFile, WvBufStream, WvDBusConn, WvEncoderStream, WvFdStream, WvHttpStream, WvFtpStream, WvModemBase, WvModem, WvSSLStream, WvStreamClone, _WvConStream, WvUrlStream, and WvUrlStream.

◆ seterr() [4/7]

virtual void WvStream::seterr ( int  _errnum)
virtual

Override seterr() from WvError so that it auto-closes the stream.

Reimplemented from WvErrorBase.

◆ seterr() [5/7]

void WvStream::seterr ( WvStringParm  specialerr)
inline

Definition at line 74 of file include/wvstream.h.

◆ seterr() [6/7]

void WvStream::seterr ( WVSTRING_FORMAT_DECL  )
inline

Definition at line 76 of file include/wvstream.h.

◆ isok() [2/2]

virtual bool WvStream::isok ( ) const
virtual

◆ read() [3/4]

virtual size_t WvStream::read ( void *  buf,
size_t  count 
)
virtual

read a data block on the stream.

Returns the actual amount read.

Implements IWvStream.

◆ read() [4/4]

virtual size_t WvStream::read ( WvBuf &  outbuf,
size_t  count 
)
virtual

Reads up to 'count' bytes of data from the stream into the buffer.

Returns the actual amount read.

If 'count' is greater than the amount of free space available in the buffer, only reads at most that amount. You should specify a reasonable upper bound on how much data should be read at once.

Implements IWvStream.

◆ unread() [2/2]

virtual void WvStream::unread ( WvBuf &  outbuf,
size_t  count 
)
virtual

Puts data back into the stream's internal buffer.

We cheat so that there's no restriction on how much (or what) data can be unread(). This is different from WvBuf::unget() (which is rather restrictive).

◆ write() [4/6]

virtual size_t WvStream::write ( const void *  buf,
size_t  count 
)
virtual

Write data to the stream.

Returns the actual amount written. Since WvStream has an output buffer, it always successfully "writes" the full amount (but you might have to flush the buffers later so it actually gets sent).

Implements IWvStream.

◆ write() [5/6]

virtual size_t WvStream::write ( WvBuf &  inbuf,
size_t  count = INT_MAX 
)
virtual

Writes data to the stream from the given buffer.

Returns the actual amount written.

If count is greater than the amount of data available in the buffer, only writes at most that amount.

Implements IWvStream.

◆ outbuf_limit() [2/2]

void WvStream::outbuf_limit ( size_t  size)
inlinevirtual

set the maximum size of outbuf, beyond which a call to write() will return 0.

I need to do this for tape backups, since all I can do is write to the loopback as fast as I can, which causes us to run out of memory and get SIGABRT'd. (dcoombs: 12/15/2000)

FIXME: there must be a better way. This confuses the semantics of write(); can you trust it to always write all the bytes, or not?

Implements IWvStream.

Definition at line 129 of file include/wvstream.h.

◆ noread() [2/2]

virtual void WvStream::noread ( )
virtual

Shuts down the reading side of the stream.

This is the opposite of nowrite(), but the name is actually slightly misleading; subsequent calls to read() might not fail; rather, if the other end of the connection tries to write to us, they should fail.

After noread(), if the read buffer (if any) is empty once, we promise that it will never refill.

If you call both noread() and nowrite(), then the stream does close() automatically once all buffers are empty.

Implements IWvStream.

Reimplemented in WvSSLStream, WvStreamClone, WvSSLStream, and WvStreamClone.

◆ nowrite() [2/2]

virtual void WvStream::nowrite ( )
virtual

Shuts down the writing side of the stream.

Subsequent calls to write() will fail. But if there's data in the output buffer, it will still be flushed.

If you call both noread() and nowrite(), then the stream does close() automatically once all buffers are empty.

Implements IWvStream.

Reimplemented in WvSSLStream, WvStreamClone, WvSSLStream, and WvStreamClone.

◆ maybe_autoclose() [2/2]

virtual void WvStream::maybe_autoclose ( )
virtual

Auto-close the stream if the time is right.

If noread() and nowrite() and all buffers are empty, then we can probably close.

Implements IWvStream.

Reimplemented in WvFdStream, and WvFdStream.

◆ isreadable() [2/2]

virtual bool WvStream::isreadable ( )
virtual

Returns true if the stream is readable.

Implements IWvStream.

◆ iswritable() [2/2]

virtual bool WvStream::iswritable ( )
virtual

Returns true if the stream is writable (without using the outbuf).

Implements IWvStream.

◆ uread() [2/2]

virtual size_t WvStream::uread ( void *  buf,
size_t  count 
)
inlinevirtual

unbuffered I/O functions; these ignore the buffer, which is handled by read().

Don't call these functions explicitly unless you have a really good reason.

This is what you would override in a derived class.

Reimplemented in WvFdStream, WvIPRawStream, WvUDPStream, WvFdStream, WvIPRawStream, WvUDPStream, WvMagicLoopback, WvSSLStream, WvMagicLoopback, WvSSLStream, WvBufStream, WvEncoderStream, WvStreamClone, WvBufStream, WvEncoderStream, and WvStreamClone.

Definition at line 146 of file include/wvstream.h.

◆ uwrite() [2/2]

virtual size_t WvStream::uwrite ( const void *  buf,
size_t  count 
)
inlinevirtual

unbuffered I/O functions; these ignore the buffer, which is handled by write().

Don't call these functions explicitly unless you have a really good reason.

This is what you would override in a derived class.

Reimplemented in WvFdStream, WvIPRawStream, WvTCPConn, WvUDPStream, WvUnixDGSocket, WvFdStream, WvIPRawStream, WvTCPConn, WvUDPStream, WvUnixDGSocket, WvLog, WvMagicLoopback, WvSSLStream, WvLog, WvMagicLoopback, WvSSLStream, WvBufStream, WvEncoderStream, WvStreamClone, WvBufStream, WvEncoderStream, WvStreamClone, WvProtoStream, and WvProtoStream.

Definition at line 156 of file include/wvstream.h.

◆ getline() [4/6]

char * WvStream::getline ( time_t  wait_msec = 0,
char  separator = '\n',
int  readahead = 1024 
)
inline

Read up to one line of data from the stream and return a pointer to the internal buffer containing this line.

If the end-of-line 'separator' is encountered, it is removed from the string. If there is not a full line available, returns NULL. You can read what we have so far by calling read().

Readahead specifies the maximum amount of data that the stream is allowed to read in one shot.

It is expected that there will be no NULL characters on the line.

wait_msec is provided so that legacy code does not break. But it really should be 0.

Definition at line 175 of file include/wvstream.h.

References blocking_getline().

◆ getline() [5/6]

char * WvStream::getline ( int  wait_msec,
char  separator = '\n',
int  readahead = 1024 
)
inline

Auto-convert int to time_t.

Definition at line 182 of file include/wvstream.h.

References getline().

◆ getline() [6/6]

char * WvStream::getline ( double  wait_msec,
char  separator = '\n',
int  readahead = 1024 
)
inline

Auto-convert double to time_t.

Definition at line 189 of file include/wvstream.h.

References getline().

◆ blocking_getline() [2/2]

char * WvStream::blocking_getline ( time_t  wait_msec,
int  separator = '\n',
int  readahead = 1024 
)

This is a version of getline() that allows you to block for more data to arrive.

This should be used carefully, as blocking is generally unexpected in WvStreams programs.

If wait_msec < 0, it will wait forever for the 'separator' (often a bad idea!). If wait_msed == 0, this is the equivalent of getline().

◆ queuemin() [2/2]

void WvStream::queuemin ( size_t  count)
inline

force read() to not return any bytes unless 'count' bytes can be read at once.

(Useful for processing Content-Length headers, etc.) Use count==0 to disable this feature.

WARNING: getline() sets queuemin to 0 automatically!

Definition at line 232 of file include/wvstream.h.

◆ delay_output() [2/2]

void WvStream::delay_output ( bool  is_delayed)
inline

force write() to always buffer output.

This can be more efficient if you write a lot of small segments and want to "coagulate" them automatically. To flush the output buffer, use flush() or select().

Definition at line 246 of file include/wvstream.h.

◆ auto_flush() [2/2]

void WvStream::auto_flush ( bool  is_automatic)
inline

if true, force write() to call flush() each time, the default behavour.

otherwise, flush() is granted special meaning when explicitly invoked by the client and write() may empty the output buffer, but will not explicitly flush().

Definition at line 258 of file include/wvstream.h.

◆ flush() [2/2]

virtual bool WvStream::flush ( time_t  msec_timeout)
virtual

flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time.

(-1 means wait forever)

Returns true if the flushing finished (the output buffer is empty).

Implements IWvStream.

◆ should_flush() [2/2]

virtual bool WvStream::should_flush ( )
virtual

Returns true if we want to flush the output buffer right now.

This allows us to implement delayed_flush(), flush_then_close(), etc, but it's still super-ugly and probably needs to go away. (In fact, all our buffer flushing is super-ugly right now.)

Implements IWvStream.

◆ flush_then_close() [2/2]

void WvStream::flush_then_close ( int  msec_timeout)

flush the output buffer automatically as select() is called.

If the buffer empties, close the stream. If msec_timeout seconds pass, close the stream. After the stream closes, it will become !isok() (and a WvStreamList can delete it automatically)

◆ pre_select() [3/4]

virtual void WvStream::pre_select ( SelectInfo si)
virtual

pre_select() sets up for eventually calling select().

It adds the right fds to the read, write, and except lists in the SelectInfo struct.

Returns true if we already know this stream is ready, and there's no need to actually do a real select(). Some streams, such as timers, can be implemented by only either returning true or false here after doing a calculation, and never actually adding anything to the SelectInfo.

You can add your stream to any of the lists even if readable, writable, or isexception isn't set. This is what force_select() does. You can also choose not to add yourself to the list if you know it would be useless right now.

pre_select() is only called if isok() is true.

pre_select() is allowed to reduce msec_timeout (or change it if it's -1). However, it's not allowed to increase msec_timeout.

Implements IWvStream.

Reimplemented in WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, WvUnixDGSocket, WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, and WvUnixDGSocket.

◆ pre_select() [4/4]

void WvStream::pre_select ( SelectInfo si,
const SelectRequest r 
)
inline

A more convenient version of pre_select() usable for overriding the 'want' value temporarily.

Definition at line 306 of file include/wvstream.h.

References pre_select().

◆ xpre_select() [2/2]

void WvStream::xpre_select ( SelectInfo si,
const SelectRequest r 
)
inline

Like pre_select(), but still exists even if you override the other pre_select() in a subclass.

Sigh.

Definition at line 318 of file include/wvstream.h.

References pre_select().

◆ post_select() [3/4]

virtual bool WvStream::post_select ( SelectInfo si)
virtual

post_select() is called after select(), and returns true if this object is now ready.

Usually this is done by checking for this object in the read, write, and except lists in the SelectInfo structure. If you want to do it in some other way, you should usually do it in pre_select() instead.

You may also want to do extra maintenance functions here; for example, the standard WvStream::post_select tries to flush outbuf if it's nonempty. WvTCPConn might retry connect() if it's waiting for a connection to be established.

Implements IWvStream.

Reimplemented in WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, WvUnixDGSocket, WvBufStream, WvDailyEvent, WvEncoderStream, WvFdStream, WvFile, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvLog, WvMagicLoopback, WvSSLStream, WvStreamClone, WvTCPConn, WvTimeStream, and WvUnixDGSocket.

◆ xpost_select() [2/2]

bool WvStream::xpost_select ( SelectInfo si,
const SelectRequest r 
)
inline

Like post_select(), but still exists even if you override the other post_select() in a subclass.

Sigh.

Definition at line 339 of file include/wvstream.h.

References post_select().

◆ post_select() [4/4]

bool WvStream::post_select ( SelectInfo si,
const SelectRequest r 
)
inline

A more convenient version of post_select() usable for overriding the 'want' value temporarily.

Definition at line 346 of file include/wvstream.h.

References post_select().

◆ select() [3/4]

bool WvStream::select ( time_t  msec_timeout)
inline

Return true if any of the requested features are true on the stream.

If msec_timeout < 0, waits forever (bad idea!). ==0, does not wait. Otherwise, waits for up to msec_timeout milliseconds.

NOTE select() is not virtual! To change the select() behaviour of a stream, override the pre_select() and/or post_select() functions.

This version of select() sets forceable==true, so force_select options are taken into account.

You almost always use this version of select() with callbacks, like this: if (stream.select(1000)) stream.callback();

If you want to read/write the stream in question, try using the other variant of select().

DEPRECATED. Call runonce() instead.

Definition at line 376 of file include/wvstream.h.

◆ runonce() [2/2]

void WvStream::runonce ( time_t  msec_timeout = -1)
inline

Exactly the same as: if (select(timeout)) callback();.

...except that the above is deprecated, because it assumes callbacks aren't called automatically and that the return value of one-parameter select() is actually meaningful.

Update your main loop to call runonce() instead of the above.

Almost all modern programs should use msec_timeout = -1.

Definition at line 391 of file include/wvstream.h.

References callback(), and select().

◆ select() [4/4]

bool WvStream::select ( time_t  msec_timeout,
bool  readable,
bool  writable,
bool  isex = false 
)
inline

This version of select() sets forceable==false, so we use the exact readable/writable/isexception options provided.

You normally use this variant of select() when deciding whether you should read/write a particular stream. For example:

if (stream.select(1000, true, false))
        len = stream.read(buf, sizeof(buf));

This variant of select() is probably not what you want with most WvStreamLists, unless you know exactly what you're doing.

WARNING: the difference between the one-parameter and multi-parameter versions of select() is incredibly confusing. Make sure you use the right one!

DEPRECATED. Call isreadable() or iswritable() instead, if msec_timeout was going to be zero. Other values of msec_timeout are not really recommended anyway.

Definition at line 415 of file include/wvstream.h.

◆ get_select_request() [2/2]

IWvStream::SelectRequest WvStream::get_select_request ( )

Use get_select_request() to save the current state of the selection state of this stream.

That way, you can call force_select() and undo_force_select() to restore this properly.

◆ force_select() [2/2]

void WvStream::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 when selecting on this stream.

If an option is set 'true', we will select on that option when someone does a select(). If it's set 'false', we don't change its force status. (To de-force something, use undo_force_select().)

◆ undo_force_select() [2/2]

void WvStream::undo_force_select ( bool  readable,
bool  writable,
bool  isexception = false 
)

Undo a previous force_select() - ie.

un-forces the options which are 'true', and leaves the false ones alone.

◆ continue_select() [2/2]

bool WvStream::continue_select ( time_t  msec_timeout)

return to the caller from execute(), but don't really return exactly; this uses WvCont::yield() to return to the caller of callback() without losing our place in execute() itself.

So, next time someone calls callback(), it will be as if continue_select() returned.

NOTE: execute() will won't be called recursively this way, but any other member function might get called, or member variables changed, or the state of the world updated while continue_select() runs. Don't assume that nothing has changed after a call to continue_select().

NOTE 2: if you're going to call continue_select(), you should set uses_continue_select=true before the first call to callback(). Otherwise your WvCont won't get created.

NOTE 3: if msec_timeout >= 0, this uses WvStream::alarm().

◆ src() [2/2]

virtual const WvAddr * WvStream::src ( ) const
virtual

get the remote address from which the last data block was received.

May be NULL. The pointer becomes invalid upon the next call to read().

Implements IWvStream.

Reimplemented in WvIPRawStream, WvStreamClone, WvTCPConn, WvUDPStream, WvUnixConn, WvIPRawStream, WvStreamClone, WvTCPConn, WvUDPStream, and WvUnixConn.

◆ setreadcallback() [2/2]

IWvStreamCallback WvStream::setreadcallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked when the stream is readable.

Implements IWvStream.

◆ setwritecallback() [2/2]

IWvStreamCallback WvStream::setwritecallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked when the stream is writable.

Implements IWvStream.

◆ setexceptcallback() [2/2]

IWvStreamCallback WvStream::setexceptcallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked when the stream is in exception state.

Implements IWvStream.

◆ setclosecallback() [2/2]

IWvStreamCallback WvStream::setclosecallback ( IWvStreamCallback  _callback)
virtual

Sets a callback to be invoked on close().


Implements IWvStream.

◆ callback() [2/2]

virtual void WvStream::callback ( )
virtual

if the stream has a callback function defined, call it now.

otherwise call execute().

Implements IWvStream.

◆ alarm() [2/2]

void WvStream::alarm ( time_t  msec_timeout)

set an alarm, ie.

select() will return true after this many ms. The alarm is cleared when callback() is called.

◆ write() [6/6]

size_t WvStream::write ( WvStringParm  s)
inline

print a preformatted WvString to the stream.

see the simple version of write() way up above.

Definition at line 538 of file include/wvstream.h.

References WvFastString::cstr(), and write().

◆ print() [3/4]

size_t WvStream::print ( WvStringParm  s)
inline

Definition at line 540 of file include/wvstream.h.

◆ operator()() [3/4]

size_t WvStream::operator() ( WvStringParm  s)
inline

Definition at line 542 of file include/wvstream.h.

◆ print() [4/4]

size_t WvStream::print ( WVSTRING_FORMAT_DECL  )
inline

preformat and write() a string.

Definition at line 546 of file include/wvstream.h.

References write().

◆ operator()() [4/4]

size_t WvStream::operator() ( WVSTRING_FORMAT_DECL  )
inline

Definition at line 548 of file include/wvstream.h.

◆ wsname() [2/2]

const char * WvStream::wsname ( ) const
inlinevirtual

Implements IWvStream.

Definition at line 551 of file include/wvstream.h.

◆ set_wsname() [3/4]

void WvStream::set_wsname ( WvStringParm  wsname)
inlinevirtual

Implements IWvStream.

Definition at line 553 of file include/wvstream.h.

◆ set_wsname() [4/4]

void WvStream::set_wsname ( WVSTRING_FORMAT_DECL  )
inline

Definition at line 555 of file include/wvstream.h.

◆ wstype() [2/2]

const char * WvStream::wstype ( ) const
inlinevirtual

Implements IWvStream.

Definition at line 558 of file include/wvstream.h.

◆ wsid() [2/2]

WSID WvStream::wsid ( ) const
inlinevirtual

Implements IWvStream.

Definition at line 560 of file include/wvstream.h.

◆ getattr() [2/2]

virtual WvString WvStream::getattr ( WvStringParm  name) const
inlinevirtual

Implements IWvStream.

Definition at line 563 of file include/wvstream.h.

◆ setattr() [2/2]

void WvStream::setattr ( WvStringParm  name,
WvStringParm  value 
)
inlineprotected

Definition at line 580 of file include/wvstream.h.

◆ flush_internal() [2/2]

virtual bool WvStream::flush_internal ( time_t  msec_timeout)
protectedvirtual

◆ getrfd() [2/2]

virtual int WvStream::getrfd ( ) const
protectedvirtual

Implements IWvStream.

Reimplemented in WvFdStream, and WvFdStream.

◆ getwfd() [2/2]

virtual int WvStream::getwfd ( ) const
protectedvirtual

Implements IWvStream.

Reimplemented in WvFdStream, and WvFdStream.

◆ execute() [2/2]

virtual void WvStream::execute ( )
inlineprotectedvirtual

The callback() function calls execute(), and then calls the user- specified callback if one is defined.

Do not call execute() directly; call callback() instead.

The default execute() function does nothing.

Note: If you override this function in a derived class, you must call the parent execute() yourself from the derived class.

Reimplemented in UniConfDaemonConn, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvProtoStream, WvStreamClone, WvSubProcQueueStream, WvTimeoutStream, WvTimeStream, UniConfDaemonConn, WvHttpStream, WvFtpStream, WvHttpPool, WvIStreamList, WvProtoStream, WvStreamClone, WvSubProcQueueStream, WvTimeoutStream, WvTimeStream, WvUrlStream, and WvUrlStream.

Definition at line 652 of file include/wvstream.h.

◆ create()

IWvStream * IWvStream::create ( WvStringParm  moniker,
IObject obj = NULL 
)
staticinherited

Definition at line 80 of file wvstream.cc.

◆ geterr() [1/2]

virtual int WvErrorBase::geterr ( ) const
inlinevirtualinherited

If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.

If isok() is true, returns an undefined number.

Reimplemented in WvDBusServer, WvStreamClone, WvDBusServer, and WvStreamClone.

Definition at line 48 of file debian/libwvstreams-dev/usr/include/wvstreams/wverror.h.

Referenced by UniIniGen::commit(), UniFileSystemGen::get(), WvDBusServer::geterr(), WvStreamClone::geterr(), WvEncoderStream::isok(), UniConfDaemon::listen(), UniIniGen::refresh(), seterr(), and WvMagicCircle::WvMagicCircle().

◆ geterr() [2/2]

virtual int WvErrorBase::geterr ( ) const
inlinevirtualinherited

If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.

If isok() is true, returns an undefined number.

Reimplemented in WvDBusServer, WvStreamClone, WvDBusServer, and WvStreamClone.

Definition at line 48 of file include/wverror.h.

◆ errstr()

WvString WvErrorBase::errstr ( ) const
virtualinherited

Definition at line 127 of file wverror.cc.

◆ strerror()

WvString WvErrorBase::strerror ( int  errnum)
staticinherited

A replacement for the operating system strerror() function that can map more kinds of error strings (especially in win32).

Definition at line 91 of file wverror.cc.

References WvErrorBase::strerror().

Referenced by WvLog::perror(), WvErrorBase::strerror(), WvSSLStream::uread(), and WvSSLStream::uwrite().

◆ seterr() [7/7]

void WvErrorBase::seterr ( const WvErrorBase err)
inherited

Definition at line 170 of file wverror.cc.

◆ seterr_both() [1/3]

void WvErrorBase::seterr_both ( int  _errnum,
WvStringParm  specialerr 
)
inherited

Definition at line 179 of file wverror.cc.

◆ seterr_both() [2/3]

void WvErrorBase::seterr_both ( int  _errnum,
WVSTRING_FORMAT_DECL   
)
inlineinherited

◆ seterr_both() [3/3]

void WvErrorBase::seterr_both ( int  _errnum,
WVSTRING_FORMAT_DECL   
)
inlineinherited

Definition at line 73 of file include/wverror.h.

◆ noerr() [1/2]

void WvErrorBase::noerr ( )
inlineinherited

Reset our error state - there's no error condition anymore.

Definition at line 78 of file debian/libwvstreams-dev/usr/include/wvstreams/wverror.h.

◆ noerr() [2/2]

void WvErrorBase::noerr ( )
inlineinherited

Reset our error state - there's no error condition anymore.

Definition at line 78 of file include/wverror.h.

◆ addRef() [1/2]

virtual unsigned int IObject::addRef ( )
pure virtualinherited

Indicate you are using this object.

This increases the reference count of the object by one. Usually, when the reference count reaches zero, the object is freed automatically.

This called a "strong reference", because they will prevent the object from being destroyed. They should thus be used carefully, as they control the lifetime of the object. For example, you do not need to call addRef() on object passed as parameters, unless you intend on keeping them.

addRef() is often called automatically for you in XPLC, but you'll have to call release() by hand sometimes unless you use xplc_ptr.

Referenced by WvIStreamList::execute(), IObjectImplInternal::getInterface(), WeakRef::getObject(), StaticServiceHandler::getObject(), WvIStreamList::post_select(), WvQtStreamClone::WvQtStreamClone(), and WvSSLStream::WvSSLStream().

◆ addRef() [2/2]

virtual unsigned int IObject::addRef ( )
pure virtualinherited

Indicate you are using this object.

This increases the reference count of the object by one. Usually, when the reference count reaches zero, the object is freed automatically.

This called a "strong reference", because they will prevent the object from being destroyed. They should thus be used carefully, as they control the lifetime of the object. For example, you do not need to call addRef() on object passed as parameters, unless you intend on keeping them.

addRef() is often called automatically for you in XPLC, but you'll have to call release() by hand sometimes unless you use xplc_ptr.

◆ release() [1/2]

virtual unsigned int IObject::release ( )
pure virtualinherited

Indicate that you are finished using this object.

This decreases the reference count of the object by one. Usually, when the reference count reaches zero, the object is freed automatically.

You will usually need to manually release() any object given to you by any other XPLC function, unless you give the object to someone else who will call release.

If you use xplc_ptr, it will do this for you.

Referenced by WvIStreamList::execute(), mutate(), MonikerService::resolve(), and NewMoniker::resolve().

◆ release() [2/2]

virtual unsigned int IObject::release ( )
pure virtualinherited

Indicate that you are finished using this object.

This decreases the reference count of the object by one. Usually, when the reference count reaches zero, the object is freed automatically.

You will usually need to manually release() any object given to you by any other XPLC function, unless you give the object to someone else who will call release.

If you use xplc_ptr, it will do this for you.

◆ getInterface() [1/2]

virtual IObject * IObject::getInterface ( const UUID )
pure virtualinherited

Returns the requested XPLC interface.

Will return NULL if the interface is not supported. The returned interface has been addRef()ed, so you will need to release() it when done. Note that the interface returned may be a pointer to the same object or a different one - that's none of your business. Asking for the IObject interface should always return the same pointer for a given logical object, so this can be used for comparison by identity.

You should probably use the convenient mutate() and get() functions instead of this, or use an xplc_ptr, which mutates the object for you.

Referenced by get(), and mutate().

◆ getInterface() [2/2]

virtual IObject * IObject::getInterface ( const UUID )
pure virtualinherited

Returns the requested XPLC interface.

Will return NULL if the interface is not supported. The returned interface has been addRef()ed, so you will need to release() it when done. Note that the interface returned may be a pointer to the same object or a different one - that's none of your business. Asking for the IObject interface should always return the same pointer for a given logical object, so this can be used for comparison by identity.

You should probably use the convenient mutate() and get() functions instead of this, or use an xplc_ptr, which mutates the object for you.

◆ getWeakRef() [1/2]

virtual IWeakRef * IObject::getWeakRef ( )
pure virtualinherited

Return a weak reference to this object.

A weak reference points at the object, but does not control the lifetime of the object. An object can thus still be deleted while someone holds a weak reference. You will still need to release() the weak reference when you are done with it.

See also
IWeakRef

◆ getWeakRef() [2/2]

virtual IWeakRef * IObject::getWeakRef ( )
pure virtualinherited

Return a weak reference to this object.

A weak reference points at the object, but does not control the lifetime of the object. An object can thus still be deleted while someone holds a weak reference. You will still need to release() the weak reference when you are done with it.

See also
IWeakRef

Friends And Related Symbol Documentation

◆ WvHTTPClientProxyStream

WvHTTPClientProxyStream
friend

Member Data Documentation

◆ read_requires_writable

WvStream * WvStream::read_requires_writable

If this is set, select() doesn't return true for read unless the given stream also returns true for write.

Definition at line 36 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by autoforward(), noautoforward(), WvFdStream::post_select(), and WvStreamClone::post_select().

◆ write_requires_readable

WvStream * WvStream::write_requires_readable

If this is set, select() doesn't return true for write unless the given stream also returns true for read.

Definition at line 42 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by WvFdStream::post_select(), and WvStreamClone::post_select().

◆ uses_continue_select

bool WvStream::uses_continue_select

If this is set, enables the use of continue_select().

Definition at line 45 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by blocking_getline(), callback(), continue_getline(), and continue_select().

◆ personal_stack_size

size_t WvStream::personal_stack_size

Specifies the stack size to reserve for continue_select().

Definition at line 48 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by callback().

◆ alarm_was_ticking

bool WvStream::alarm_was_ticking

This will be true during callback execution if the callback was triggered by the alarm going off.

Definition at line 54 of file debian/libwvstreams-dev/usr/include/wvstreams/wvstream.h.

Referenced by callback(), continue_select(), WvHttpStream::execute(), WvTimeoutStream::execute(), and WvTimeStream::execute().

◆ stop_read

bool WvStream::stop_read

◆ stop_write

bool WvStream::stop_write

◆ closed

bool WvStream::closed

◆ inbuf

WvDynBuf WvStream::inbuf
protected

◆ outbuf

WvDynBuf WvStream::outbuf
protected

◆ callfunc

IWvStreamCallback WvStream::callfunc
protected

◆ call_ctx

wv::function< void *(void *)> WvStream::call_ctx
protected

◆ readcb

IWvStreamCallback WvStream::readcb
protected

◆ writecb

IWvStreamCallback WvStream::writecb
protected

◆ exceptcb

IWvStreamCallback WvStream::exceptcb
protected

◆ closecb

IWvStreamCallback WvStream::closecb
protected

◆ max_outbuf_size

size_t WvStream::max_outbuf_size
protected

◆ outbuf_delayed_flush

bool WvStream::outbuf_delayed_flush
protected

◆ is_auto_flush

bool WvStream::is_auto_flush
protected

◆ want_to_flush

bool WvStream::want_to_flush
protected

◆ is_flushing

bool WvStream::is_flushing
protected

◆ queue_min

size_t WvStream::queue_min
protected

◆ autoclose_time

time_t WvStream::autoclose_time
protected

◆ alarm_time

WvTime WvStream::alarm_time
protected

◆ last_alarm_check

WvTime WvStream::last_alarm_check
protected

◆ globalstream

WvStream * WvStream::globalstream = NULL
staticprotected

◆ errnum

int WvErrorBase::errnum
protectedinherited

◆ errstring

WvString WvErrorBase::errstring
protectedinherited

The documentation for this class was generated from the following files: