A WvBuffer is a dynamically-sized buffer. It's often perfect for storing streamed data.
WvBuffer is pretty simple to use. You can write data to it using put() and retrieve the data using get(). get() effectively deletes the data from the buffer, but you can use unget() to get it back if you haven't done any buffer operations in the meantime.
WvBuffer buf; buf.put("borkle borkle\n"); printf(buf.get(14)); buf.unget(14); printf(buf.get(14));
The above code will print "borkle borkle" twice.
unsigned char *alloc(size_t num)
allocates 'num' bytes in the buffer and returns a pointer to its start . Pointer is valid until next zap() or get().
void unalloc(size_t num)
unallocates the last 'num' bytes in the buffer that were previously al located using alloc() or put(), They are then available for a subseque nt alloc() or put().
void put(WvStringParm str)
Copy a WvString into the buffer, not including the terminating nul.
void put(const void *data, size_t num)
Copy 'buf' into the next 'num' bytes of buffer.
unsigned char *get(size_t num)
Return the next 'num' bytes in the buffer. Returns NULL if there are not enough bytes in the buffer.
void unget(size_t num)
Undo all or part of the previous get(). You can unget() up to the numb er of bytes you did in the last get(), assuming you have not done any other buffer operation in the meantime.
size_t match(const unsigned char chlist[], size_t numch, bool reverse = false)
Returns the number of leading bytes that match any in chlist. If rever se == trye, match bytes that are not in chlist.
void merge(WvBuffer &buf)
Merges another WvBuffer into this one, simply move all of its objects into our own list.