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
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
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
A base 64 decoder.
Definition wvbase64.h:50
WvBase64Decoder()
Creates a base 64 decoder.
Definition wvbase64.cc:117
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition wvbase64.cc:131
virtual bool _reset()
Template method implementation of reset().
Definition wvbase64.cc:123
A base 64 encoder.
Definition wvbase64.h:21
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition wvbase64.cc:59
virtual bool _reset()
Template method implementation of reset().
Definition wvbase64.cc:51
WvBase64Encoder()
Creates a base 64 encoder.
Definition wvbase64.cc:45
virtual bool _finish(WvBuf &out)
Template method implementation of finish().
Definition wvbase64.cc:93
The base encoder class.
Definition wvencoder.h:68
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition wvencoder.h:163