11 #include "wvlinklist.h"
299 bool flushmemmem(
const void *inmem,
size_t inlen,
void *outmem,
300 size_t *outlen,
bool finish =
false);
356 bool flushstrmem(WvStringParm instr,
void *outmem,
size_t *outlen,
434 {
return WvString::null; }
559 : enc(enc), autofree(autofree) { }
560 ~ChainElem() {
if (autofree)
delete enc; }
562 DeclareWvList(ChainElem);
564 ChainElemList encoders;
646 virtual bool _isok()
const;
702 bool do_encode(
WvBuf &in,
WvBuf &out, ChainElem *start_after,
706 #endif // __WVENCODER_H
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
virtual bool _isok() const
Returns true if the encoder has not encountered an error.
bool isfinished() const
Returns true if the encoder can no longer encode data.
virtual bool _finish(WvBuf &out)
Finishes the chain of encoders.
bool flushmemmem(const void *inmem, size_t inlen, void *outmem, size_t *outlen, bool finish=false)
Flushes data through the encoder from memory to memory.
void zap()
Clears the encoder chain.
virtual bool _reset()
Template method implementation of reset().
void append(WvEncoder *enc, bool autofree)
Appends an encoder to the tail of the chain.
WvEncoderChain()
Creates an initially empty chain of encoders.
virtual bool _isfinished() const
Template method implementation of isfinished().
void setnotok()
Sets 'okay' to false explicitly.
WvString strflushstr(WvStringParm instr, bool finish=false)
Flushes data through the encoder from a string to a string.
virtual bool _isfinished() const
Returns true if the encoder can no longer encode data.
WvString strflushmem(const void *inmem, size_t inlen, bool finish=false)
Flushes data through the encoder from memory to a string.
An encoder that discards all of its input.
void seterror(WVSTRING_FORMAT_DECL)
Sets an error condition, then setnotok().
bool encode(WvBuf &inbuf, WvBuf &outbuf, bool flush=false, bool finish=false)
Reads data from the input buffer, encodes it, and writes the result to the output buffer.
size_t bytes_processed()
Returns the number of bytes processed so far.
WvString is an implementation of a simple and efficient printable-string class.
bool flushstrbuf(WvStringParm instr, WvBuf &outbuf, bool finish=false)
Flushes data through the encoder from a string to a buffer.
bool encodebufstr(WvBuf &inbuf, WvString &outstr, bool flush=false, bool finish=false)
Encodes data from a buffer to a string.
virtual bool _reset()
Resets the chain of encoders.
virtual ~WvEncoder()
Destroys the encoder.
WvEncoder()
Creates a new WvEncoder.
size_t buffered()
Returns true if there is data in an internal buffer.
void set_autofree(WvEncoder *enc, bool autofree)
Sets the autofree state of a particular encoder in the chain.
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)=0
Template method implementation of encode().
bool continue_encode(WvBuf &inbuf, WvBuf &outbuf)
"Continues" encoding a buffer.
bool flushbufmem(WvBuf &inbuf, void *outmem, size_t *outlen, bool finish=false)
Flushes data through the encoder from a buffer to memory.
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
WvString strflushbuf(WvBuf &inbuf, bool finish=false)
Flushes data through the encoder from a buffer to a string.
WvString geterror() const
Returns an error message if any is available.
bool isok() const
Returns true if the encoder has not encountered an error.
bool finish(WvBuf &outbuf)
Tells the encoder that NO MORE DATA will ever be encoded.
bool flushstrstr(WvStringParm instr, WvString &outstr, bool finish=false)
Flushes data through the encoder from a string to a string.
void unlink(WvEncoder *enc)
Unlinks the encoder from the chain.
bool flushbufstr(WvBuf &inbuf, WvString &outstr, bool finish=false)
Flushes data through the encoder from a buffer to a string.
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
A very efficient passthrough encoder that just merges the input buffer into the output buffer.
void prepend(WvEncoder *enc, bool autofree)
Prepends an encoder to the head of the chain.
An encoder chain owns a list of encoders that are used in sequence to transform data from a source bu...
void setfinished()
Sets 'finished' to true explicitly.
virtual bool _isok() const
Template method implementation of isok().
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
virtual WvString _geterror() const
Template method implementation of geterror().
virtual bool _reset()
Template method implementation of reset().
bool flushstrmem(WvStringParm instr, void *outmem, size_t *outlen, bool finish=false)
Flushes data through the encoder from a string to memory.
bool flushmembuf(const void *inmem, size_t inlen, WvBuf &outbuf, bool finish=false)
Flushes data through the encoder from memory to a buffer.
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Passes the data through the entire chain of encoders.
bool encodebufmem(WvBuf &inbuf, void *outmem, size_t *outlen, bool flush=false, bool finish=false)
Encodes data from a buffer to memory.
void seterror(WvStringParm message)
Sets an error condition, then setnotok().
virtual bool _finish(WvBuf &outbuf)
Template method implementation of finish().
virtual ~WvEncoderChain()
Destroys the encoder chain.
bool get_autofree(WvEncoder *enc) const
Gets the autofree state of a particular encoder in the chain.
virtual bool _reset()
Template method implementation of reset().
bool reset()
Asks an encoder to reset itself to its initial state at creation time, if supported.
virtual WvString _geterror() const
Returns the error message, if any.