From 158d215b33d5b5bf07f73bb7547aae1fb12593b3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 18 Jun 2009 19:57:12 +0000 Subject: Added a new enum value to Bu::File, Bu::File::WriteNew which combines Write, Truncate, and Create, the flags used most commonly when writing a new file. Also added the Bu::Base64 filter class, it does base64 encoding and decoding, it may need a couple more interfaces added, but for the most part, it's solid. --- src/base64.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/base64.h (limited to 'src/base64.h') diff --git a/src/base64.h b/src/base64.h new file mode 100644 index 0000000..2c3b331 --- /dev/null +++ b/src/base64.h @@ -0,0 +1,45 @@ +#ifndef BU_BASE64_H +#define BU_BASE64_H + +#include "bu/filter.h" + +namespace Bu +{ + /** + * + *@ingroup Streams + */ + class Base64 : public Bu::Filter + { + public: + enum Mode + { + Encode = 0x01, + Read = 0x01, + Decode = 0x02, + Write = 0x02 + }; + + public: + Base64( Bu::Stream &rNext, Mode eMode ); + virtual ~Base64(); + + virtual void start(); + virtual size_t stop(); + virtual size_t read( void *pBuf, size_t nBytes ); + virtual size_t write( const void *pBuf, size_t nBytes ); + + virtual bool isOpen(); + + private: + int iBPos; + int iBuf; + size_t iTotalIn; + size_t iTotalOut; + static const char tblEnc[65]; + char tblDec[80]; + Mode eMode; + }; +}; + +#endif -- cgit v1.2.3