Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvbase64.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * Base64 encoder and decoder implementations.
00006  */
00007 #ifndef __WVBASE64_H
00008 #define __WVBASE64_H
00009 
00010 #include "wvencoder.h"
00011 
00012 /**
00013  * A base 64 encoder.
00014  * 
00015  * On finish(), outputs any needed pad characters.
00016  * 
00017  * Supports reset().
00018  * 
00019  */
00020 class WvBase64Encoder : public WvEncoder
00021 {
00022     enum State {
00023         ATBIT0, ATBIT2, ATBIT4
00024     };
00025     State state;
00026     unsigned int bits; // remaining bits shifted left 8 bits
00027     
00028 public:
00029     /** Creates a base 64 encoder. */
00030     WvBase64Encoder();
00031     virtual ~WvBase64Encoder() { }
00032 
00033 protected:
00034     // on flush, outputs any needed pad characters
00035     virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
00036     virtual bool _finish(WvBuf &out);
00037     virtual bool _reset(); // supported
00038 };
00039 
00040 
00041 /**
00042  * A base 64 decoder.
00043  * 
00044  * Becomes isfinished() == true on detection of padding.
00045  * 
00046  * Supports reset().
00047  * 
00048  */
00049 class WvBase64Decoder : public WvEncoder
00050 {
00051     enum State {
00052         ATBIT0, ATBIT2, ATBIT4, ATBIT6, PAD
00053     };
00054     State state;
00055     unsigned int bits; // remaining bits shifted left 6 bits
00056     
00057 public:
00058     /** Creates a base 64 decoder. */
00059     WvBase64Decoder();
00060     virtual ~WvBase64Decoder() { }
00061 
00062 protected:
00063     virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
00064     virtual bool _reset(); // supported
00065 };
00066 
00067 #endif // __WVBASE64_H

Generated on Sat Mar 13 14:55:28 2004 for WvStreams by doxygen 1.3.6-20040222