9#if !defined(__BASE64_H_INCLUDED__)
10#define __BASE64_H_INCLUDED__ 1
17int _base64Chars[]= {
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
18 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
19 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
23#define _0000_0011 0x03
24#define _1111_1100 0xFC
25#define _1111_0000 0xF0
26#define _0011_0000 0x30
27#define _0011_1100 0x3C
28#define _0000_1111 0x0F
29#define _1100_0000 0xC0
30#define _0011_1111 0x3F
32#define _EQUAL_CHAR (-1)
33#define _UNKNOWN_CHAR (-2)
35#define _IOS_FAILBIT std::ios_base::failbit
36#define _IOS_EOFBIT std::ios_base::eofbit
37#define _IOS_BADBIT std::ios_base::badbit
38#define _IOS_GOODBIT std::ios_base::goodbit
41template<
class _E =
char,
class _Tr = std::
char_traits<_E> >
59 *_To = _Tr::to_char_type(
'\r'); ++_To;
60 *_To = _Tr::to_char_type(
'\n'); ++_To;
71 *_To = _Tr::to_char_type(
'\r'); ++_To;
72 *_To = _Tr::to_char_type(
'\n'); ++_To;
73 *_To = _Tr::to_char_type(
' '); ++_To;
154 template<
class _II,
class _OI,
class _State,
class _Endline>
155 _II
put(_II _First, _II _Last, _OI _To, _State& _St, _Endline _Endl)
const
160 while(_First != _Last)
165 _3to4.
set_0(*_First);
170 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_0()]); ++_To;
171 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_1()]); ++_To;
172 *_To = _Tr::to_char_type(
'='); ++_To;
173 *_To = _Tr::to_char_type(
'='); ++_To;
177 _3to4.
set_1(*_First);
182 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_0()]); ++_To;
183 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_1()]); ++_To;
184 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_2()]); ++_To;
185 *_To = _Tr::to_char_type(
'='); ++_To;
189 _3to4.
set_2(*_First);
192 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_0()]); ++_To;
193 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_1()]); ++_To;
194 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_2()]); ++_To;
195 *_To = _Tr::to_char_type(_base64Chars[_3to4.
b64_3()]); ++_To;
197 if(line_octets == 17)
214 template<
class _II,
class _OI,
class _State>
215 _II
get(_II _First, _II _Last, _OI _To, _State& _St)
const
220 while(_First != _Last)
230 if(++_First == _Last)
247 while(++_First != _Last)
251 if(_First == _Last) {
267 while(++_First != _Last)
271 if(_First == _Last) {
283 if(++_First == _Last)
308 while(++_First != _Last)
312 if(_First == _Last) {
354 if(_base64Chars[62] == _Ch)
357 if(_base64Chars[63] == _Ch)
360 if((_base64Chars[0] <= _Ch) && (_base64Chars[25] >= _Ch))
361 return _Ch - _base64Chars[0];
363 if((_base64Chars[26] <= _Ch) && (_base64Chars[51] >= _Ch))
364 return _Ch - _base64Chars[26] + 26;
366 if((_base64Chars[52] <= _Ch) && (_base64Chars[61] >= _Ch))
367 return _Ch - _base64Chars[52] + 52;
369 if(_Ch == _Tr::to_int_type(
'='))
_II put(_II _First, _II _Last, _OI _To, _State &_St, _Endline _Endl) const
_II get(_II _First, _II _Last, _OI _To, _State &_St) const
int _getCharType(int _Ch) const
_OI operator()(_OI _To) const
_OI operator()(_OI _To) const
_OI operator()(_OI _To) const