IBR-DTNSuite 0.6

ibrcommon/ibrcommon/data/Base64Reader.h

Go to the documentation of this file.
00001 /*
00002  * Base64Reader.h
00003  *
00004  *  Created on: 21.06.2011
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef BASE64READER_H_
00009 #define BASE64READER_H_
00010 
00011 #include <iostream>
00012 #include <string.h>
00013 #include <stdint.h>
00014 
00015 namespace ibrcommon
00016 {
00017         class Base64Reader : public std::basic_streambuf<char, std::char_traits<char> >, public std::istream
00018         {
00019         public:
00020                 Base64Reader(std::istream &stream, const size_t limit = 0, const size_t buffer = 2048);
00021                 virtual ~Base64Reader();
00022 
00023         protected:
00024                 virtual int underflow();
00025 
00026         private:
00027                 static const char decodeCharacterTable[];
00028 
00029                 std::istream &_stream;
00030 
00031                 // Output buffer
00032                 char *data_buf_;
00033 
00034                 // length of the data buffer
00035                 size_t data_size_;
00036 
00037                 uint8_t _base64_state;
00038 
00039                 size_t _char_counter;
00040 
00041                 char _base64_buf[4];
00042                 char _base64_padding;
00043 
00044                 size_t _byte_read;
00045                 size_t _byte_limit;
00046         };
00047 }
00048 
00049 #endif /* BASE64READER_H_ */