NCBI C++ ToolKit
|
Search Toolkit Book for CRWStreambuf
Reader-writer-based stream buffer. More...
#include <corelib/impl/rwstreambuf.hpp>
Public Types | |
enum | EFlags { fOwnReader = 1 << 0 , fOwnWriter = 1 << 1 , fOwnAll = fOwnReader + fOwnWriter , fUntie = 1 << 2 , fNoStatusLog = 1 << 3 , fLogExceptions = 1 << 4 , fLeakExceptions = 1 << 5 } |
Which of the objects (passed in the constructor) must be deleted on this object's destruction, whether to tie I/O, and how to process exceptions thrown at lower levels... More... | |
typedef int | TFlags |
Bitwise OR of EFlags. More... | |
Public Member Functions | |
CRWStreambuf (IReaderWriter *rw=0, streamsize buf_size=0, CT_CHAR_TYPE *buf=0, TFlags flags=0) | |
CRWStreambuf (IReader *r, IWriter *w, streamsize buf_size=0, CT_CHAR_TYPE *buf=0, TFlags flags=0) | |
NOTE: if both reader and writer have actually happened to be the same object, then when owned, it will _not_ be deleted twice. More... | |
virtual | ~CRWStreambuf () |
Protected Member Functions | |
virtual CT_INT_TYPE | overflow (CT_INT_TYPE c) |
virtual streamsize | xsputn (const CT_CHAR_TYPE *buf, streamsize n) |
virtual CT_INT_TYPE | underflow (void) |
virtual streamsize | xsgetn (CT_CHAR_TYPE *s, streamsize n) |
virtual streamsize | showmanyc (void) |
virtual int | sync (void) |
virtual CNcbiStreambuf * | setbuf (CT_CHAR_TYPE *buf, streamsize buf_size) |
Per the standard, setbuf(0, 0) makes I/O unbuffered. More... | |
virtual CT_POS_TYPE | seekoff (CT_OFF_TYPE off, IOS_BASE::seekdir whence, IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out) |
Only seekoff(0, IOS_BASE::cur, *) to obtain current position, and input skip-forward are permitted: seekoff(off, IOS_BASE::cur or IOS_BASE::beg, IOS_BASE::in) when the requested stream position is past the current input position (so the stream can read forward internally to reach that position). More... | |
virtual streamsize | _Xsgetn_s (CT_CHAR_TYPE *buf, size_t, streamsize n) |
CT_POS_TYPE | x_GetGPos (void) |
CT_POS_TYPE | x_GetPPos (void) |
int | x_Sync (void) |
streamsize | x_Read (CT_CHAR_TYPE *s, streamsize n) |
ERW_Result | x_Pushback (void) |
Protected Attributes | |
TFlags | m_Flags |
AutoPtr< IReader > | m_Reader |
AutoPtr< IWriter > | m_Writer |
size_t | m_BufSize |
CT_CHAR_TYPE * | m_ReadBuf |
CT_CHAR_TYPE * | m_WriteBuf |
CT_CHAR_TYPE * | m_pBuf |
CT_CHAR_TYPE | x_Buf |
CT_POS_TYPE | x_GPos |
get position [for istream::tellg()] More... | |
CT_POS_TYPE | x_PPos |
put position [for ostream::tellp()] More... | |
bool | x_Eof |
whether at EOF More... | |
bool | x_Err |
whether there was a _write_ error More... | |
CT_POS_TYPE | x_ErrPos |
position of the _write_ error (if x_Err) More... | |
Private Member Functions | |
CRWStreambuf (const CRWStreambuf &) | |
CRWStreambuf | operator= (const CRWStreambuf &) |
Reader-writer-based stream buffer.
Definition at line 59 of file rwstreambuf.hpp.
typedef int CRWStreambuf::TFlags |
Bitwise OR of EFlags.
Definition at line 74 of file rwstreambuf.hpp.
enum CRWStreambuf::EFlags |
Which of the objects (passed in the constructor) must be deleted on this object's destruction, whether to tie I/O, and how to process exceptions thrown at lower levels...
Definition at line 65 of file rwstreambuf.hpp.
CRWStreambuf::CRWStreambuf | ( | IReaderWriter * | rw = 0 , |
streamsize | buf_size = 0 , |
||
CT_CHAR_TYPE * | buf = 0 , |
||
CRWStreambuf::TFlags | f = 0 |
||
) |
Definition at line 165 of file rwstreambuf.cpp.
References kDefaultBufSize, n, and setbuf().
CRWStreambuf::CRWStreambuf | ( | IReader * | r, |
IWriter * | w, | ||
streamsize | buf_size = 0 , |
||
CT_CHAR_TYPE * | buf = 0 , |
||
CRWStreambuf::TFlags | f = 0 |
||
) |
NOTE: if both reader and writer have actually happened to be the same object, then when owned, it will _not_ be deleted twice.
Definition at line 180 of file rwstreambuf.cpp.
References kDefaultBufSize, m_Reader, m_Writer, n, and setbuf().
|
virtual |
Definition at line 224 of file rwstreambuf.cpp.
References ERR_POST_X, eRW_NotImplemented, eRW_Success, m_pBuf, NCBI_CATCH_ALL_X, result, x_Err, x_ErrPos, x_GetPPos(), x_Pushback(), and x_Sync().
|
private |
|
inlineprotectedvirtual |
Definition at line 129 of file rwstreambuf.hpp.
|
private |
|
protectedvirtual |
Definition at line 286 of file rwstreambuf.cpp.
References _ASSERT, b, CT_CHAR_TYPE, CT_EOF, CT_EQ_INT_TYPE, CT_NOT_EOF, CT_OFF_TYPE, CT_TO_CHAR_TYPE, eRW_Eof, eRW_Error, eRW_Success, failure, IWriter::Flush(), AutoPtr< X, Del >::get(), m_Writer, memmove, result, RWSTREAMBUF_HANDLE_EXCEPTIONS, THROW1_TRACE, IWriter::Write(), x_CheckRW(), x_Err, x_ErrPos, x_GetPPos(), and x_PPos.
Referenced by sync().
|
protectedvirtual |
Only seekoff(0, IOS_BASE::cur, *) to obtain current position, and input skip-forward are permitted: seekoff(off, IOS_BASE::cur or IOS_BASE::beg, IOS_BASE::in) when the requested stream position is past the current input position (so the stream can read forward internally to reach that position).
Definition at line 654 of file rwstreambuf.cpp.
References CT_OFF_TYPE, CT_POS_TYPE, in(), m_Reader, out(), x_GetGPos(), x_GetPPos(), and x_Read().
|
protectedvirtual |
Per the standard, setbuf(0, 0) makes I/O unbuffered.
Other behavior is implementation-dependent: "buf_size" == 1 makes I/O unbuffered ("buf", if provided, may still be used internally as a one-char un-get location). Special case: setbuf(non-NULL, 0) creates an internal buffer of some predefined size, which will be automatically deallocated in dtor; the value of the first argument is ignored (can be any non-NULL pointer). Otherwise, setbuf() sets I/O arena of size "buf_size" located at "buf", and halved between the I/O directions, if both are used. If "buf" is provided as NULL, the buffer of the requested size gets allocated internally, and gets automatically freed upon CRWStreambuf destruction. Before replacing the buffer, this call first attempts to flush any pending output (sync) to the output device, and return any pending input sequence (internal read buffer) to the input device (pushback).
Definition at line 243 of file rwstreambuf.cpp.
References _ASSERT, Critical(), CT_CHAR_TYPE, ERR_POST_X, eRW_Success, kDefaultBufSize, m_BufSize, m_pBuf, m_ReadBuf, m_Reader, m_WriteBuf, m_Writer, n, x_Buf, x_Pushback(), and x_Sync().
Referenced by CRWStreambuf().
|
protectedvirtual |
Definition at line 611 of file rwstreambuf.cpp.
References _ASSERT, count, eRW_Error, eRW_NotImplemented, eRW_Success, failure, fUntie, AutoPtr< X, Del >::get(), m_Flags, m_Reader, IReader::PendingCount(), result, RWSTREAMBUF_HANDLE_EXCEPTIONS, THROW1_TRACE, x_CheckRW(), x_Eof, and x_Sync().
|
protectedvirtual |
Definition at line 645 of file rwstreambuf.cpp.
References _ASSERT, CT_EOF, CT_EQ_INT_TYPE, and overflow().
Referenced by x_Sync().
|
protectedvirtual |
Definition at line 468 of file rwstreambuf.cpp.
References _ASSERT, CT_CHAR_TYPE, CT_EOF, CT_OFF_TYPE, CT_TO_INT_TYPE, eRW_Eof, eRW_Error, eRW_Success, failure, fUntie, AutoPtr< X, Del >::get(), m_BufSize, m_Flags, m_ReadBuf, m_Reader, IReader::Read(), result, RWSTREAMBUF_HANDLE_EXCEPTIONS, THROW1_TRACE, x_CheckRW(), x_Eof, x_GPos, and x_Sync().
|
inlineprotected |
Definition at line 134 of file rwstreambuf.hpp.
References CT_OFF_TYPE, and x_GPos.
Referenced by seekoff().
|
inlineprotected |
Definition at line 137 of file rwstreambuf.hpp.
References CT_OFF_TYPE, and x_PPos.
Referenced by overflow(), seekoff(), xsputn(), and ~CRWStreambuf().
|
protected |
Definition at line 196 of file rwstreambuf.cpp.
References _ASSERT, count, CT_CHAR_TYPE, eRW_Error, eRW_Success, failure, m_pBuf, m_Reader, IReader::Pushback(), result, RWSTREAMBUF_HANDLE_EXCEPTIONS, THROW1_TRACE, and x_Eof.
Referenced by setbuf(), and ~CRWStreambuf().
|
protected |
Definition at line 520 of file rwstreambuf.cpp.
References _ASSERT, buf, CT_CHAR_TYPE, CT_OFF_TYPE, eRW_Eof, eRW_Error, eRW_Success, failure, fUntie, m_BufSize, m_Flags, m_ReadBuf, m_Reader, max(), n, IReader::Read(), result, RWSTREAMBUF_HANDLE_EXCEPTIONS, THROW1_TRACE, x_Eof, x_GPos, and x_Sync().
|
inlineprotected |
Definition at line 140 of file rwstreambuf.hpp.
References sync().
Referenced by setbuf(), showmanyc(), underflow(), x_Read(), and ~CRWStreambuf().
|
protectedvirtual |
Definition at line 603 of file rwstreambuf.cpp.
References _ASSERT, buf, AutoPtr< X, Del >::get(), m_Reader, x_CheckRW(), and x_Read().
Referenced by _Xsgetn_s().
|
protectedvirtual |
Definition at line 375 of file rwstreambuf.cpp.
References _ASSERT, buf, CT_OFF_TYPE, eRW_Error, eRW_Success, failure, AutoPtr< X, Del >::get(), m_Writer, max(), memmove, n, result, RWSTREAMBUF_HANDLE_EXCEPTIONS, THROW1_TRACE, IWriter::Write(), x_CheckRW(), x_Err, x_ErrPos, x_GetPPos(), and x_PPos.
|
protected |
Definition at line 153 of file rwstreambuf.hpp.
Referenced by setbuf(), underflow(), and x_Read().
|
protected |
Definition at line 148 of file rwstreambuf.hpp.
Referenced by showmanyc(), underflow(), and x_Read().
|
protected |
Definition at line 157 of file rwstreambuf.hpp.
Referenced by setbuf(), x_Pushback(), and ~CRWStreambuf().
|
protected |
Definition at line 154 of file rwstreambuf.hpp.
Referenced by setbuf(), underflow(), and x_Read().
Definition at line 150 of file rwstreambuf.hpp.
Referenced by CRWStreambuf(), seekoff(), setbuf(), showmanyc(), underflow(), x_Pushback(), x_Read(), and xsgetn().
|
protected |
Definition at line 155 of file rwstreambuf.hpp.
Referenced by setbuf().
Definition at line 151 of file rwstreambuf.hpp.
Referenced by CRWStreambuf(), overflow(), setbuf(), and xsputn().
|
protected |
Definition at line 158 of file rwstreambuf.hpp.
Referenced by setbuf().
|
protected |
whether at EOF
Definition at line 163 of file rwstreambuf.hpp.
Referenced by showmanyc(), underflow(), x_Pushback(), and x_Read().
|
protected |
whether there was a _write_ error
Definition at line 164 of file rwstreambuf.hpp.
Referenced by overflow(), xsputn(), and ~CRWStreambuf().
|
protected |
position of the _write_ error (if x_Err)
Definition at line 165 of file rwstreambuf.hpp.
Referenced by overflow(), xsputn(), and ~CRWStreambuf().
|
protected |
get position [for istream::tellg()]
Definition at line 160 of file rwstreambuf.hpp.
Referenced by underflow(), x_GetGPos(), and x_Read().
|
protected |
put position [for ostream::tellp()]
Definition at line 161 of file rwstreambuf.hpp.
Referenced by overflow(), x_GetPPos(), and xsputn().