Streambuf-like class for I/O on C char* buffers. More...
Public Member Functions | |
Constructors etc. | |
mcbuffer (size_t size=CB_DEFAULT_SIZE) | |
mcbuffer (void *data, size_t used, size_t alloc=0, size_t get=CB_DEFAULT_GET) | |
mcbuffer (const micbuffer &cb) | |
void | assign (const void *data, size_t len) |
virtual | ~mcbuffer (void) |
void | clear (void) |
void | release (void) |
Output Methods | |
virtual bool | flush (void) |
virtual bool | write (const char *buf, size_t n) |
virtual bool | putbyte (unsigned char c) |
virtual bool | puts (const char *s) |
virtual bool | puts (const std::string &s) |
virtual bool | vprintf (const char *fmt, va_list &ap) |
Utilities | |
bool | reserve (size_t size, size_t pad=0) |
Public Member Functions inherited from mootio::micbuffer | |
micbuffer (const void *data, size_t len) | |
micbuffer (const micbuffer &cb) | |
virtual | ~micbuffer (void) |
void | clear (void) |
void | release (void) |
void | assign (const void *data, size_t len) |
virtual bool | valid (void) |
virtual bool | eof (void) |
virtual ByteCount | read (char *buf, size_t n) |
virtual int | getbyte (void) |
const char * | data (void) const |
size_t | size (void) const |
size_t | capacity (void) const |
size_t | offset (void) const |
std::string | as_string (bool normalize_ws=false, bool trim_left=false, bool trim_right=false) const |
void | to_string (std::string &str, bool normalize_ws=false, bool trim_left=false, bool trim_right=false) const |
Public Member Functions inherited from mootio::mistream | |
mistream (void) | |
virtual | ~mistream (void) |
virtual ByteCount | getline (std::string &s, const std::string &delim="\") |
Public Member Functions inherited from mootio::mstream | |
mstream (const std::string &myname="") | |
virtual | ~mstream (void) |
operator bool (void) | |
virtual std::string | errmsg (void) |
virtual bool | reopen (void) |
virtual bool | close (void) |
Public Member Functions inherited from mootio::mostream | |
mostream (void) | |
virtual | ~mostream (void) |
bool | printf (const char *fmt,...) |
Public Attributes | |
char * | cb_wdata |
underlying character data buffer (write) More... | |
size_t | cb_alloc |
allocated size of buffer (in bytes) More... | |
size_t | cb_get |
number of extra bytes to get on internal reserve() calls More... | |
bool | cb_created |
whether we allocated the cb_wdata buffer ourself More... | |
Public Attributes inherited from mootio::micbuffer | |
const char * | cb_rdata |
underlying character data buffer More... | |
size_t | cb_offset |
current read offset position in buffer More... | |
size_t | cb_used |
used length of buffer (in bytes) More... | |
Public Attributes inherited from mootio::mstream | |
std::string | name |
symbolic name of this stream More... | |
Static Public Attributes | |
static const size_t | CB_DEFAULT_SIZE = 32 |
Default initial buffer size. More... | |
static const size_t | CB_DEFAULT_GET = 32 |
Default number of extra bytes to get on reserve() More... | |
This class provides an API for in-memory I/O which does not resort to C++ sstream : this is a Good Thing, because:
|
inline |
Default constructor, given optional initial buffer size
References mootio::micbuffer::size().
|
inline |
Constructor from a user-specified buffer Read/write operations will be performed on this buffer as long as possible. On write overflow, a new local buffer will be allocated (which will be freed on release()). User is responsible for freeing memory associated with data
passed to this constructor.
References mootio::micbuffer::cb_rdata, and mootio::micbuffer::cb_used.
|
inline |
Copy constructor
References mootio::micbuffer::cb_offset, mootio::micbuffer::cb_rdata, and mootio::micbuffer::cb_used.
|
inlinevirtual |
Destructor
References mootio::micbuffer::release().
|
inline |
Asignment to a different data buffer (always copies)
References mootio::micbuffer::cb_offset, mootio::micbuffer::cb_rdata, and mootio::micbuffer::cb_used.
|
inline |
Clear buffer
References mootio::micbuffer::cb_offset, and mootio::micbuffer::cb_used.
Referenced by moot::TokenWriterNative::sentence2string(), and moot::TokenWriterNative::token2string().
|
inline |
Free locally allocated data buffer, if any. Implicitly calls clear()
References mootio::micbuffer::cb_rdata, and mootio::micbuffer::clear().
|
inlinevirtual |
"Flush" all data before offset() from the buffer.
Reimplemented from mootio::mostream.
References mootio::micbuffer::cb_offset, and mootio::micbuffer::cb_used.
|
inlinevirtual |
Write n
bytes from buf
to the buffer
Reimplemented from mootio::mostream.
References mootio::micbuffer::cb_used.
|
inlinevirtual |
Write a single byte to the buffer
Reimplemented from mootio::mostream.
References mootio::micbuffer::cb_used.
|
inlinevirtual |
Write a C string to the buffer
Reimplemented from mootio::mostream.
|
inlinevirtual |
Write a C++ string to the buffer
Reimplemented from mootio::mostream.
|
inlinevirtual |
printf() to the buffer, va_list version
Reimplemented from mootio::mostream.
References mootio::micbuffer::cb_used.
|
inline |
Grow the buffer to fit at least size + pad
bytes in it
References mootio::micbuffer::cb_rdata, and mootio::micbuffer::cb_used.
|
static |
|
static |
char* mootio::mcbuffer::cb_wdata |
size_t mootio::mcbuffer::cb_alloc |
size_t mootio::mcbuffer::cb_get |
bool mootio::mcbuffer::cb_created |