IBR-DTNSuite  0.8
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 "ibrcommon/data/Base64.h"
00012 #include <iostream>
00013 #include <string.h>
00014 #include <stdint.h>
00015 
00016 namespace ibrcommon
00017 {
00018         class Base64Reader : public std::basic_streambuf<char, std::char_traits<char> >, public std::istream
00019         {
00020         public:
00021                 Base64Reader(std::istream &stream, const size_t limit = 0, const size_t buffer = 2048);
00022                 virtual ~Base64Reader();
00023 
00024         protected:
00025                 virtual std::char_traits<char>::int_type underflow();
00026 
00027         private:
00028                 void set_b64(char val);
00029 
00030                 std::istream &_stream;
00031 
00032                 // Output buffer
00033                 char *data_buf_;
00034 
00035                 // length of the data buffer
00036                 size_t data_size_;
00037 
00038                 uint8_t _base64_state;
00039 
00040                 Base64::Group _group;
00041                 char _base64_padding;
00042 
00043                 size_t _byte_read;
00044                 size_t _byte_limit;
00045         };
00046 }
00047 
00048 #endif /* BASE64READER_H_ */