WvStreams
include/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
20class 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
28public:
31 virtual ~WvBase64Encoder() { }
32
33protected:
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
49class 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
57public:
60 virtual ~WvBase64Decoder() { }
61
62protected:
63 virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
64 virtual bool _reset(); // supported
65};
66
67#endif // __WVBASE64_H
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
WvBase64Decoder()
Creates a base 64 decoder.
virtual bool _reset()
Template method implementation of reset().
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
WvBase64Encoder()
Creates a base 64 encoder.
virtual bool _reset()
Template method implementation of reset().
virtual bool _finish(WvBuf &out)
Template method implementation of finish().
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.