This class template implements the Base64 encoding as defined in RFC 4648 for a given character type and encoding alphabet.
More...
|
template<class InputIterator , class OutputIterator > |
static OutputIterator | encode (InputIterator first, InputIterator last, OutputIterator result, bool pad=true) |
| Encodes a range of octets. More...
|
|
template<class InputIterator , class OutputIterator > |
static OutputIterator | decode (InputIterator first, InputIterator last, OutputIterator result) |
| Decodes a range of characters. More...
|
|
template<class InputIterator , class OutputIterator , class Predicate > |
static OutputIterator | decode (InputIterator first, InputIterator last, OutputIterator result, Predicate skip) |
| Decodes a range of characters. More...
|
|
template<class sizeT > |
static sizeT | max_encode_size (sizeT n) |
| Computes the maximum length of an encoded character sequence. More...
|
|
template<class sizeT > |
static sizeT | max_decode_size (sizeT n) |
| Computes the maximum length of a decoded octet sequence. More...
|
|
template<class charT, class traits = base64_traits<charT>>
class stlencoders::base64< charT, traits >
This class template implements the Base64 encoding as defined in RFC 4648 for a given character type and encoding alphabet.
The Base64 encoding is designed to represent arbitrary sequences of octets in a form that allows the use of both upper- and lowercase letters but that need not be human readable.
The encoding process represents 24-bit groups of input data as output strings of 4 encoded characters. Proceeding from left to right, a 24-bit input group is formed by concatenating 3 8-bit input groups. These 24 bits are then treated as 4 concatenated 6-bit groups, each of which is translated into a single character in the Base64 alphabet.
- Template Parameters
-
charT | the encoding character type |
traits | the character encoding traits type |
template<class charT , class traits = base64_traits<charT>>
template<class InputIterator , class OutputIterator , class Predicate >
static OutputIterator stlencoders::base64< charT, traits >::decode |
( |
InputIterator |
first, |
|
|
InputIterator |
last, |
|
|
OutputIterator |
result, |
|
|
Predicate |
skip |
|
) |
| |
|
inlinestatic |
Decodes a range of characters.
For every character c
not in the encoding alphabet,
- if skip(c) evaluates to
true
, the character is ignored
- if
c
equals traits::pad()
, returns
- otherwise, throws invalid_character
- Template Parameters
-
InputIterator | an iterator type satisfying input iterator requirements and referring to elements implicitly convertible to char_type |
OutputIterator | an iterator type satisfying output iterator requirements |
Predicate | a predicate type |
- Parameters
-
first | an input iterator to the first position in the character range to be decoded |
last | an input iterator to the final position in the character range to be decoded |
result | an output iterator to the decoded octet range |
skip | a function object that, when applied to a value of type char_type, returns a value testable as true |
- Returns
- an output iterator referring to one past the last value assigned to the output range
- Exceptions
-
invalid_character | if a character not in the encoding alphabet is encountered |
invalid_length | if the input range contains an invalid number of encoding characters |