stlencoders  1.1.3
Classes | Public Types | Static Public Member Functions | List of all members
stlencoders::base64< charT, traits > Class Template Reference

This class template implements the Base64 encoding as defined in RFC 4648 for a given character type and encoding alphabet. More...

Public Types

typedef charT char_type
 The encoding character type. More...
 
typedef traits traits_type
 The character encoding traits type. More...
 
typedef traits::int_type int_type
 An integral type representing an octet. More...
 

Static Public Member Functions

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...
 

Detailed Description

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
charTthe encoding character type
traitsthe character encoding traits type

Member Typedef Documentation

template<class charT , class traits = base64_traits<charT>>
typedef charT stlencoders::base64< charT, traits >::char_type

The encoding character type.

template<class charT , class traits = base64_traits<charT>>
typedef traits::int_type stlencoders::base64< charT, traits >::int_type

An integral type representing an octet.

template<class charT , class traits = base64_traits<charT>>
typedef traits stlencoders::base64< charT, traits >::traits_type

The character encoding traits type.

Member Function Documentation

template<class charT , class traits = base64_traits<charT>>
template<class InputIterator , class OutputIterator >
static OutputIterator stlencoders::base64< charT, traits >::decode ( InputIterator  first,
InputIterator  last,
OutputIterator  result 
)
inlinestatic

Decodes a range of characters.

Template Parameters
InputIteratoran iterator type satisfying input iterator requirements and referring to elements implicitly convertible to char_type
OutputIteratoran iterator type satisfying output iterator requirements
Parameters
firstan input iterator to the first position in the character range to be decoded
lastan input iterator to the final position in the character range to be decoded
resultan output iterator to the decoded octet range
Returns
an output iterator referring to one past the last value assigned to the output range
Exceptions
invalid_characterif a character not in the encoding alphabet is encountered
invalid_lengthif the input range contains an invalid number of encoding characters
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
InputIteratoran iterator type satisfying input iterator requirements and referring to elements implicitly convertible to char_type
OutputIteratoran iterator type satisfying output iterator requirements
Predicatea predicate type
Parameters
firstan input iterator to the first position in the character range to be decoded
lastan input iterator to the final position in the character range to be decoded
resultan output iterator to the decoded octet range
skipa 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_characterif a character not in the encoding alphabet is encountered
invalid_lengthif the input range contains an invalid number of encoding characters
template<class charT , class traits = base64_traits<charT>>
template<class InputIterator , class OutputIterator >
static OutputIterator stlencoders::base64< charT, traits >::encode ( InputIterator  first,
InputIterator  last,
OutputIterator  result,
bool  pad = true 
)
inlinestatic

Encodes a range of octets.

Template Parameters
InputIteratoran iterator type satisfying input iterator requirements and referring to elements implicitly convertible to int_type
OutputIteratoran iterator type satisfying output iterator requirements
Parameters
firstan input iterator to the first position in the octet range to be encoded
lastan input iterator to the final position in the octet range to be encoded
resultan output iterator to the encoded character range
padif true, performs padding at the end of the encoded character range
Returns
an output iterator referring to one past the last value assigned to the output range
template<class charT , class traits = base64_traits<charT>>
template<class sizeT >
static sizeT stlencoders::base64< charT, traits >::max_decode_size ( sizeT  n)
inlinestatic

Computes the maximum length of a decoded octet sequence.

Template Parameters
sizeTan integral type
Parameters
nthe length of the input character sequence
Returns
the maximum length of the decoded octet sequence
template<class charT , class traits = base64_traits<charT>>
template<class sizeT >
static sizeT stlencoders::base64< charT, traits >::max_encode_size ( sizeT  n)
inlinestatic

Computes the maximum length of an encoded character sequence.

Template Parameters
sizeTan integral type
Parameters
nthe length of the input octet sequence
Returns
the maximum length of the encoded character sequence