Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BASE64STREAM_H_
00009 #define BASE64STREAM_H_
00010
00011 #include "ibrcommon/data/Base64.h"
00012 #include <iostream>
00013 #include <streambuf>
00014 #include <stdint.h>
00015
00016 namespace ibrcommon
00017 {
00018 class Base64Stream : public std::basic_streambuf<char, std::char_traits<char> >, public std::ostream
00019 {
00020 public:
00021 Base64Stream(std::ostream &stream, bool decode = false, const size_t linebreak = 0, const size_t buffer = 2048);
00022 virtual ~Base64Stream();
00023
00024 protected:
00025 virtual int sync();
00026 virtual std::char_traits<char>::int_type overflow(std::char_traits<char>::int_type = std::char_traits<char>::eof());
00027
00028 private:
00029 void set_b64(char val);
00030 void set_byte(char val);
00031
00032 void __flush_encoder__();
00033
00034 bool _decode;
00035
00036 std::ostream &_stream;
00037
00038
00039 char *data_buf_;
00040
00041
00042 size_t data_size_;
00043
00044 uint8_t _base64_state;
00045
00046 size_t _char_counter;
00047
00048 Base64::Group _group;
00049 char _base64_padding;
00050
00051 const size_t _linebreak;
00052 };
00053 }
00054
00055 #endif