WvStreams
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WvTypedEncoder< IT, OT, S > Class Template Referenceabstract

This template facilitates the creation and use of encoders that manipulate typed buffers. More...

#include <wvtypedencoder.h>

Inheritance diagram for WvTypedEncoder< IT, OT, S >:
Inheritance graph
[legend]

Public Types

typedef IT IType
 
typedef OT OType
 
typedef WvBufBase< IType > IBuffer
 
typedef WvBufBase< OType > OBuffer
 
typedef WvBufViewBase< IType > IBufferView
 
typedef WvBufViewBase< OType > OBufferView
 

Public Member Functions

bool encode (IBuffer &inbuf, OBuffer &outbuf, bool flush=false, bool finish=false)
 Typed variant of encode(). More...
 
bool flush (IBuffer &inbuf, OBuffer &outbuf, bool finish=false)
 Typed variant of flush(). More...
 
bool finish (OBuffer &outbuf)
 Typed variant of finish(). More...
 
bool encode (WvBuf &inbuf, WvBuf &outbuf, bool flush=false, bool finish=false)
 
bool flush (WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
 
bool finish (WvBuf &outbuf)
 
bool isok () const
 Returns true if the encoder has not encountered an error. More...
 
bool isfinished () const
 Returns true if the encoder can no longer encode data. More...
 
WvString geterror () const
 Returns an error message if any is available. More...
 
bool reset ()
 Asks an encoder to reset itself to its initial state at creation time, if supported. More...
 
bool flushstrbuf (WvStringParm instr, WvBuf &outbuf, bool finish=false)
 Flushes data through the encoder from a string to a buffer. More...
 
bool flushstrstr (WvStringParm instr, WvString &outstr, bool finish=false)
 Flushes data through the encoder from a string to a string. More...
 
bool encodebufstr (WvBuf &inbuf, WvString &outstr, bool flush=false, bool finish=false)
 Encodes data from a buffer to a string. More...
 
bool flushbufstr (WvBuf &inbuf, WvString &outstr, bool finish=false)
 Flushes data through the encoder from a buffer to a string. More...
 
WvString strflushstr (WvStringParm instr, bool finish=false)
 Flushes data through the encoder from a string to a string. More...
 
WvString strflushbuf (WvBuf &inbuf, bool finish=false)
 Flushes data through the encoder from a buffer to a string. More...
 
bool flushmembuf (const void *inmem, size_t inlen, WvBuf &outbuf, bool finish=false)
 Flushes data through the encoder from memory to a buffer. More...
 
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. More...
 
bool encodebufmem (WvBuf &inbuf, void *outmem, size_t *outlen, bool flush=false, bool finish=false)
 Encodes data from a buffer to memory. More...
 
bool flushbufmem (WvBuf &inbuf, void *outmem, size_t *outlen, bool finish=false)
 Flushes data through the encoder from a buffer to memory. More...
 
bool flushstrmem (WvStringParm instr, void *outmem, size_t *outlen, bool finish=false)
 Flushes data through the encoder from a string to memory. More...
 
WvString strflushmem (const void *inmem, size_t inlen, bool finish=false)
 Flushes data through the encoder from memory to a string. More...
 

Protected Member Functions

virtual bool _typedencode (IBuffer &inbuf, OBuffer &outbuf, bool flush)=0
 Typed variant of _encode(). More...
 
virtual bool _typedfinish (OBuffer &outbuf)
 Typed variant of _finish(). More...
 
virtual bool _encode (WvBuf &inbuf, WvBuf &outbuf, bool flush)
 Wrapper implementation of _encode().
 
virtual bool _finish (WvBuf &outbuf)
 Wrapper implementation of _finish().
 
void setnotok ()
 Sets 'okay' to false explicitly.
 
void seterror (WvStringParm message)
 Sets an error condition, then setnotok().
 
void seterror (WVSTRING_FORMAT_DECL)
 Sets an error condition, then setnotok().
 
void setfinished ()
 Sets 'finished' to true explicitly.
 
virtual bool _isok () const
 Template method implementation of isok(). More...
 
virtual bool _isfinished () const
 Template method implementation of isfinished(). More...
 
virtual WvString _geterror () const
 Template method implementation of geterror(). More...
 
virtual bool _reset ()
 Template method implementation of reset(). More...
 

Protected Attributes

bool okay
 
bool finished
 
WvString errstr
 

Detailed Description

template<class IT, class OT, class S = WvEncoder>
class WvTypedEncoder< IT, OT, S >

This template facilitates the creation and use of encoders that manipulate typed buffers.

A typed encoder accepts both typed and untyped buffers, but is implementated in terms of typed buffers. Untyped buffers are automatically wrapped into the required form before being passed on to the implementation.

This type is designed to function as a statically bound mixin to make it easier to incorporate typed encoders into untyped encoder hierarchies. This is somewhat ugly, but necessary.

"IT" is the input buffer datatype "OT" is the output buffer datatype "S" is the WvEncoder supertype

See also
WvEncoder

Definition at line 33 of file wvtypedencoder.h.

Member Function Documentation

◆ encode()

template<class IT , class OT , class S = WvEncoder>
bool WvTypedEncoder< IT, OT, S >::encode ( IBuffer inbuf,
OBuffer outbuf,
bool  flush = false,
bool  finish = false 
)
inline

Typed variant of encode().

See also
encode(WvBuf&, WvBuf&, bool, bool)

Definition at line 47 of file wvtypedencoder.h.

◆ flush()

template<class IT , class OT , class S = WvEncoder>
bool WvTypedEncoder< IT, OT, S >::flush ( IBuffer inbuf,
OBuffer outbuf,
bool  finish = false 
)
inline

◆ finish()

template<class IT , class OT , class S = WvEncoder>
bool WvTypedEncoder< IT, OT, S >::finish ( OBuffer outbuf)
inline

◆ _typedencode()

template<class IT , class OT , class S = WvEncoder>
virtual bool WvTypedEncoder< IT, OT, S >::_typedencode ( IBuffer inbuf,
OBuffer outbuf,
bool  flush 
)
protectedpure virtual

◆ _typedfinish()

template<class IT , class OT , class S = WvEncoder>
virtual bool WvTypedEncoder< IT, OT, S >::_typedfinish ( OBuffer outbuf)
inlineprotectedvirtual

◆ isok()

bool WvEncoder::isok ( ) const
inlineinherited

Returns true if the encoder has not encountered an error.

This should only be used to record permanent failures. Transient errors (eg. bad block, but recoverable) should be detected in a different fashion.

Returns: true if the encoder is ok

Definition at line 90 of file wvencoder.h.

References WvEncoder::_isok(), and WvEncoder::okay.

Referenced by WvEncoder::geterror().

◆ isfinished()

bool WvEncoder::isfinished ( ) const
inlineinherited

Returns true if the encoder can no longer encode data.

This will be set when the encoder detects and end-of-data mark in its input, or when finish() is called.

Returns: true if the encoder is finished

Definition at line 101 of file wvencoder.h.

References WvEncoder::_isfinished(), and WvEncoder::finished.

◆ geterror()

WvString WvEncoder::geterror ( ) const
inherited

Returns an error message if any is available.

Returns: the error message, or the null string is isok() == true

Definition at line 23 of file wvencoder.cc.

References WvEncoder::_geterror(), WvEncoder::errstr, and WvEncoder::isok().

◆ reset()

bool WvEncoder::reset ( )
inherited

Asks an encoder to reset itself to its initial state at creation time, if supported.

This function may be called at any time, even if isok() == false, or isfinished() == true.

If the behaviour is not supported or an error occurs, then false is returned and afterwards isok() == false.

Returns: true on success

See also
_reset for the actual implementation

Definition at line 60 of file wvencoder.cc.

References WvEncoder::_reset(), WvEncoder::errstr, WvEncoder::finished, WvEncoder::okay, and WvEncoder::seterror().

◆ flushstrbuf()

bool WvEncoder::flushstrbuf ( WvStringParm  instr,
WvBuf outbuf,
bool  finish = false 
)
inherited

Flushes data through the encoder from a string to a buffer.

"instr" is the input string "outbuf" is the output buffer "finish" is if true, calls finish() on success Returns: true on success

Definition at line 77 of file wvencoder.cc.

References WvEncoder::encode(), and WvEncoder::finish().

◆ flushstrstr()

bool WvEncoder::flushstrstr ( WvStringParm  instr,
WvString outstr,
bool  finish = false 
)
inherited

Flushes data through the encoder from a string to a string.

The output data is appended to the target string.

"instr" is the input string "outstr" is the output string "finish" is if true, calls finish() on success Returns: true on success

Definition at line 86 of file wvencoder.cc.

References WvEncoder::encode(), WvEncoder::finish(), and WvBufBase< unsigned char >::getstr().

Referenced by WvEncoder::strflushstr().

◆ encodebufstr()

bool WvEncoder::encodebufstr ( WvBuf inbuf,
WvString outstr,
bool  flush = false,
bool  finish = false 
)
inherited

Encodes data from a buffer to a string.

The output data is appended to the target string.

"inbuf" is the input buffer "outstr" is the output string "flush" is if true, flushes the encoder "finish" is if true, calls finish() on success Returns: true on success

Definition at line 97 of file wvencoder.cc.

References WvEncoder::encode(), WvEncoder::finish(), WvEncoder::flush(), and WvBufBase< unsigned char >::getstr().

Referenced by WvEncoder::flushbufstr().

◆ flushbufstr()

bool WvEncoder::flushbufstr ( WvBuf inbuf,
WvString outstr,
bool  finish = false 
)
inlineinherited

Flushes data through the encoder from a buffer to a string.

The output data is appended to the target string.

"inbuf" is the input buffer "outstr" is the output string "finish" is if true, calls finish() on success Returns: true on success

Definition at line 249 of file wvencoder.h.

References WvEncoder::encodebufstr(), and WvEncoder::finish().

Referenced by WvEncoder::strflushbuf().

◆ strflushstr()

WvString WvEncoder::strflushstr ( WvStringParm  instr,
bool  finish = false 
)
inherited

Flushes data through the encoder from a string to a string.

"inbuf" is the input buffer "finish" is if true, calls finish() on success Returns: the resulting encoded string, does not signal errors

Definition at line 107 of file wvencoder.cc.

References WvEncoder::finish(), and WvEncoder::flushstrstr().

Referenced by WvDBusServerAuth::authorize().

◆ strflushbuf()

WvString WvEncoder::strflushbuf ( WvBuf inbuf,
bool  finish = false 
)
inherited

Flushes data through the encoder from a buffer to a string.

"inbuf" is the input buffer "finish" is if true, calls finish() on success Returns: the resulting encoded string, does not signal errors

Definition at line 115 of file wvencoder.cc.

References WvEncoder::finish(), and WvEncoder::flushbufstr().

Referenced by WvX509Mgr::sign(), and WvEncoder::strflushmem().

◆ flushmembuf()

bool WvEncoder::flushmembuf ( const void *  inmem,
size_t  inlen,
WvBuf outbuf,
bool  finish = false 
)
inherited

Flushes data through the encoder from memory to a buffer.

"inmem" is the input data pointer "inlen" is the input data length "outbuf" is the output buffer "finish" is if true, calls finish() on success Returns: true on success

Definition at line 123 of file wvencoder.cc.

References WvEncoder::encode(), and WvEncoder::finish().

◆ flushmemmem()

bool WvEncoder::flushmemmem ( const void *  inmem,
size_t  inlen,
void *  outmem,
size_t *  outlen,
bool  finish = false 
)
inherited

Flushes data through the encoder from memory to memory.

The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned.

"inmem" is the input data pointer "inlen" is the input data length "outmem" is the output data pointer "outlen" is the output data length, by reference "finish" is if true, calls finish() on success Returns: true on success

Definition at line 132 of file wvencoder.cc.

References WvEncoder::encodebufmem(), and WvEncoder::finish().

Referenced by unhexify().

◆ encodebufmem()

bool WvEncoder::encodebufmem ( WvBuf inbuf,
void *  outmem,
size_t *  outlen,
bool  flush = false,
bool  finish = false 
)
inherited

Encodes data from a buffer to memory.

The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned.

"inmem" is the input data pointer "inlen" is the input data length "outmem" is the output data pointer "outlen" is the output data length, by reference "flush" is if true, flushes the encoder "finish" is if true, calls finish() on success Returns: true on success

Definition at line 140 of file wvencoder.cc.

References WvEncoder::encode(), WvEncoder::finish(), and WvBufBaseCommonImpl< T >::used().

Referenced by WvEncoder::flushbufmem(), and WvEncoder::flushmemmem().

◆ flushbufmem()

bool WvEncoder::flushbufmem ( WvBuf inbuf,
void *  outmem,
size_t *  outlen,
bool  finish = false 
)
inlineinherited

Flushes data through the encoder from a buffer to memory.

The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned.

"inbuf" is the input buffer "outmem" is the output data pointer "outlen" is the output data length, by reference "finish" is if true, calls finish() on success Returns: true on success

Definition at line 337 of file wvencoder.h.

References WvEncoder::encodebufmem(), and WvEncoder::finish().

Referenced by WvEncoder::flushstrmem().

◆ flushstrmem()

bool WvEncoder::flushstrmem ( WvStringParm  instr,
void *  outmem,
size_t *  outlen,
bool  finish = false 
)
inherited

Flushes data through the encoder from a string to memory.

The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned.

"instr" is the input string "outmem" is the output data pointer "outlen" is the output data length, by reference "finish" is if true, calls finish() on success Returns: true on success

Definition at line 150 of file wvencoder.cc.

References WvEncoder::finish(), and WvEncoder::flushbufmem().

Referenced by WvX509::verify().

◆ strflushmem()

WvString WvEncoder::strflushmem ( const void *  inmem,
size_t  inlen,
bool  finish = false 
)
inherited

Flushes data through the encoder from memory to a string.

"inmem" is the input data pointer "inlen" is the input data length "finish" is if true, calls finish() on success Returns: the resulting encoded string, does not signal errors

Definition at line 158 of file wvencoder.cc.

References WvEncoder::finish(), and WvEncoder::strflushbuf().

◆ _isok()

virtual bool WvEncoder::_isok ( ) const
inlineprotectedvirtualinherited

Template method implementation of isok().

Not called if any of the following cases are true:

  • okay == false

Most implementations do not need to override this.

Returns: true if the encoder is ok

See also
setnotok

Reimplemented in WvEncoderChain.

Definition at line 400 of file wvencoder.h.

Referenced by WvEncoder::isok().

◆ _isfinished()

virtual bool WvEncoder::_isfinished ( ) const
inlineprotectedvirtualinherited

Template method implementation of isfinished().

Not called if any of the following cases are true:

  • finished == true

Most implementations do not need to override this.

Returns: true if the encoder is finished

See also
setfinished

Reimplemented in WvEncoderChain.

Definition at line 416 of file wvencoder.h.

Referenced by WvEncoder::isfinished().

◆ _geterror()

virtual WvString WvEncoder::_geterror ( ) const
inlineprotectedvirtualinherited

Template method implementation of geterror().

Not called if any of the following cases are true:

  • isok() == true
  • errstr is not null

Most implementations do not need to override this.

Returns: the error message, or the null string if _isok() == true

See also
seterror

Reimplemented in WvEncoderChain.

Definition at line 433 of file wvencoder.h.

Referenced by WvEncoder::geterror().

◆ _reset()

virtual bool WvEncoder::_reset ( )
inlineprotectedvirtualinherited

Template method implementation of reset().

When this method is invoked, the current local state will be okay == true and finished == false. If false is returned, then okay will be set to false.

May set a detailed error message if an error occurs.

Returns: true on success, false on error or if not supported

See also
reset

Reimplemented in WvEncoderChain, WvPassthroughEncoder, WvNullEncoder, WvAdler32Digest, WvCrc32Digest, WvHMACDigest, WvRSAEncoder, WvBackslashDecoder, WvGzipEncoder, WvTripleDESEncoder, WvHexDecoder, WvBase64Decoder, WvBlowfishEncoder, WvFunctorEncoder< IT, OT, FT >, WvEVPMDDigest, WvBackslashEncoder, WvHexEncoder, WvBase64Encoder, and WvWordWrapEncoder.

Definition at line 498 of file wvencoder.h.

Referenced by WvEncoder::reset().

Member Data Documentation

◆ okay

bool WvEncoder::okay
protectedinherited

◆ finished

bool WvEncoder::finished
protectedinherited

◆ errstr

WvString WvEncoder::errstr
protectedinherited

the error message

Definition at line 72 of file wvencoder.h.

Referenced by WvEncoder::geterror(), WvEncoder::reset(), and WvEncoder::seterror().


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