29 : std::ostream(this), _decode(decode), _stream(stream), data_buf_(buffer), data_size_(buffer), _base64_state(0), _char_counter(0), _base64_padding(0), _linebreak(linebreak)
31 setp(&data_buf_[0], &data_buf_[0] + data_size_ - 1);
38 void Base64Stream::set_byte(
char val)
40 switch (_base64_state)
59 void Base64Stream::set_b64(
char val)
61 switch (_base64_state)
87 int ret = std::char_traits<char>::eq_int_type(this->
overflow(
88 std::char_traits<char>::eof()), std::char_traits<char>::eof()) ? -1
91 if (!_decode && (_base64_state > 0))
101 char *ibegin = &data_buf_[0];
104 if (!std::char_traits<char>::eq_int_type(c, std::char_traits<char>::eof()))
106 *iend++ = std::char_traits<char>::to_char_type(c);
110 setp(&data_buf_[0], &data_buf_[0] + data_size_ - 1);
113 size_t len = (iend - ibegin);
118 return std::char_traits<char>::not_eof(c);
122 for (
size_t i = 0; i < len; ++i)
137 switch (_base64_state)
141 return std::char_traits<char>::eof();
145 return std::char_traits<char>::eof();
154 if (_base64_padding == 0)
168 set_b64(static_cast<char>(c));
174 if (_base64_state == 4)
176 if (_base64_padding == 0)
178 _stream.put( _group.
get_0() );
179 _stream.put( _group.
get_1() );
180 _stream.put( _group.
get_2() );
182 else if (_base64_padding == 3)
184 _stream.put( _group.
get_0() );
185 _stream.put( _group.
get_1() );
187 else if (_base64_padding == 2)
189 _stream.put( _group.
get_0() );
202 if (_base64_state == 3)
210 return std::char_traits<char>::not_eof(c);
213 void Base64Stream::__flush_encoder__()
215 switch (_base64_state)
245 if (_char_counter >= _linebreak)