WvStreams
wvbase64.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * Base64 encoder and decoder implementations.
6  */
7 #ifndef __WVBASE64_H
8 #define __WVBASE64_H
9 
10 #include "wvencoder.h"
11 
20 class WvBase64Encoder : public WvEncoder
21 {
22  enum State {
23  ATBIT0, ATBIT2, ATBIT4
24  };
25  State state;
26  unsigned int bits; // remaining bits shifted left 8 bits
27 
28 public:
31  virtual ~WvBase64Encoder() { }
32 
33 protected:
34  // on flush, outputs any needed pad characters
35  virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
36  virtual bool _finish(WvBuf &out);
37  virtual bool _reset(); // supported
38 };
39 
40 
49 class WvBase64Decoder : public WvEncoder
50 {
51  enum State {
52  ATBIT0, ATBIT2, ATBIT4, ATBIT6, PAD
53  };
54  State state;
55  unsigned int bits; // remaining bits shifted left 6 bits
56 
57 public:
60  virtual ~WvBase64Decoder() { }
61 
62 protected:
63  virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
64  virtual bool _reset(); // supported
65 };
66 
67 #endif // __WVBASE64_H
WvEncoder
The base encoder class.
Definition: wvencoder.h:67
WvBase64Decoder
A base 64 decoder.
Definition: wvbase64.h:49
WvBase64Decoder::WvBase64Decoder
WvBase64Decoder()
Creates a base 64 decoder.
Definition: wvbase64.cc:117
WvBase64Encoder::_encode
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition: wvbase64.cc:59
WvBase64Encoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvbase64.cc:51
WvBase64Encoder
A base 64 encoder.
Definition: wvbase64.h:20
WvBase64Encoder::WvBase64Encoder
WvBase64Encoder()
Creates a base 64 encoder.
Definition: wvbase64.cc:45
WvBase64Decoder::_encode
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition: wvbase64.cc:131
WvBufBase< unsigned char >
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
Definition: wvbuf.h:22
WvBase64Decoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvbase64.cc:123
WvBase64Encoder::_finish
virtual bool _finish(WvBuf &out)
Template method implementation of finish().
Definition: wvbase64.cc:93
WvEncoder::flush
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition: wvencoder.h:163