Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes

bdlde::Base64Encoder Class Reference

#include <bdlde_base64encoder.h>

List of all members.

Public Types

typedef Base64Alphabet::Enum Alphabet

Public Member Functions

 BSLS_DEPRECATE_FEATURE ("bdl","encodedLength","use overload with 'options'") static int encodedLength(int inputLength)
 BSLS_DEPRECATE_FEATURE ("bdl","encodedLength","use overload with 'options'") static int encodedLength(int inputLength
 BSLS_DEPRECATE_FEATURE ("bdl","encodedLines","use overload with 'options'") static int encodedLines(int inputLength)
 BSLS_DEPRECATE_FEATURE ("bdl","encodedLines","use overload with 'options'") static int encodedLines(int inputLength
 Base64Encoder (const EncoderOptions &options=EncoderOptions::mime())
 BSLS_DEPRECATE_FEATURE ("bdl","Base64Encoder","use overload with 'options'") explicit Base64Encoder(Alphabet alphabet)
 BSLS_DEPRECATE_FEATURE ("bdl","Base64Encoder","use overload with 'options'") explicit Base64Encoder(int maxLineLength
 ~Base64Encoder ()
template<class OUTPUT_ITERATOR , class INPUT_ITERATOR >
int convert (OUTPUT_ITERATOR out, INPUT_ITERATOR begin, INPUT_ITERATOR end)
template<class OUTPUT_ITERATOR , class INPUT_ITERATOR >
int convert (OUTPUT_ITERATOR out, int *numOut, int *numIn, INPUT_ITERATOR begin, INPUT_ITERATOR end, int maxNumOut=-1)
template<class OUTPUT_ITERATOR >
int endConvert (OUTPUT_ITERATOR out)
template<class OUTPUT_ITERATOR >
int endConvert (OUTPUT_ITERATOR out, int *numOut, int maxNumOut=-1)
void resetState ()
Alphabet alphabet () const
bool isAcceptable () const
bool isDone () const
bool isError () const
bool isInitialState () const
bool isPadded () const
int maxLineLength () const
EncoderOptions options () const
int outputLength () const

Static Public Member Functions

static bsl::size_t encodedLength (const EncoderOptions &options, bsl::size_t inputLength)
static bsl::size_t encodedLines (const EncoderOptions &options, bsl::size_t inputLength)

Public Attributes

int maxLineLength
Alphabet alphabet = e_BASIC)

Static Public Attributes

static const Alphabet e_BASIC = Base64Alphabet::e_BASIC
static const Alphabet e_URL = Base64Alphabet::e_URL

Detailed Description

This class implements a mechanism capable of converting data of arbitrary length to its corresponding Base64 representation.

See Component bdlde_base64encoder


Member Typedef Documentation


Constructor & Destructor Documentation

bdlde::Base64Encoder::Base64Encoder ( const EncoderOptions options = EncoderOptions::mime()  )  [explicit]

Create a Base64 encoder in the initial state, defaulting the state of the maximum allowable line-length, the padding, and the alphabet according to the values of the specified options.

bdlde::Base64Encoder::~Base64Encoder (  ) 

Destroy this object.


Member Function Documentation

static bsl::size_t bdlde::Base64Encoder::encodedLength ( const EncoderOptions options,
bsl::size_t  inputLength 
) [static]

Return the exact number of encoded bytes that would result from an input byte sequence of the specified inputLength provided to the convert method of an encoder configured with the specified options. The behavior is undefined if inputLength is large enough for the result to overflow a size_t.

bdlde::Base64Encoder::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"encodedLength"  ,
"use overload with 'options'"   
)

Return the exact number of encoded bytes that would result from an input byte sequence of the specified inputLength provided to the convert method of an encoder with the maximum allowable line-length of the output being 76 characters (as recommended by the MIME standard). The behavior is undefined unless 0 <= inputLength.

DEPRECATED: use the overload with options instead.

bdlde::Base64Encoder::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"encodedLength"  ,
"use overload with 'options'"   
)
static bsl::size_t bdlde::Base64Encoder::encodedLines ( const EncoderOptions options,
bsl::size_t  inputLength 
) [static]

Return the exact number of encoded lines that would result from an input byte sequence of the specified inputLength provided to the convert method of an encoder configured with the specified options. The behavior is undefined if inputLength is large enough to overflow the result.

bdlde::Base64Encoder::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"encodedLines"  ,
"use overload with 'options'"   
)

Return the exact number of encoded lines that would result from an input byte sequence of the specified inputLength provided to the convert method of an encoder with the maximum allowable line-length of the output being 76 characters (as recommended by the MIME standard). The behavior is undefined unless 0 <= inputLength. Note also that the number of encoded bytes need not be the number of output bytes.

DEPRECATED: use the overload with options instead.

bdlde::Base64Encoder::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"encodedLines"  ,
"use overload with 'options'"   
)
bdlde::Base64Encoder::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"Base64Encoder"  ,
"use overload with 'options'"   
)

Create a Base64 encoder in the initial state, defaulting the maximum allowable line-length of the output to 76 (as recommended by the MIME standard). Optionally specify an alphabet used to encode characters. If alphabet is not specified, then the basic alphabet, "base64", is used. Note that the convert and endConvert methods of this encoder will insert a CRLF to prevent each line of the output from exceeding 76 characters.

DEPRECATED: Create and pass an options object instead.

bdlde::Base64Encoder::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"Base64Encoder"  ,
"use overload with 'options'"   
)
template<class OUTPUT_ITERATOR , class INPUT_ITERATOR >
int bdlde::Base64Encoder::convert ( OUTPUT_ITERATOR  out,
INPUT_ITERATOR  begin,
INPUT_ITERATOR  end 
)
template<class OUTPUT_ITERATOR , class INPUT_ITERATOR >
int bdlde::Base64Encoder::convert ( OUTPUT_ITERATOR  out,
int *  numOut,
int *  numIn,
INPUT_ITERATOR  begin,
INPUT_ITERATOR  end,
int  maxNumOut = -1 
)

Encode the sequence of input characters starting at the specified begin position up to, but not including, the specified end position, writing any resulting output characters to the specified out buffer. Optionally specify the maxNumOut limit on the number of bytes to output; if maxNumOut is negative, no limit is imposed. If the maxNumOut limit is reached, no further input will be consumed. Load into the (optionally) specified numOut and numIn the number of output bytes produced and input bytes consumed, respectively. Return a non-negative value on success and a negative value otherwise. A positive return status indicates the number of valid processed output bytes retained by this encoder and not written to out because maxNumOut has been reached; these bytes are available for output if this method is called with appropriate input. Note that calling this method after endConvert has been invoked without an intervening resetState call will place this instance in an error state, and return an error status. Note also that it is recommended that after all calls to convert are finished, the endConvert method be called to complete the encoding of any unprocessed input characters that do not complete a 3-byte sequence.

template<class OUTPUT_ITERATOR >
int bdlde::Base64Encoder::endConvert ( OUTPUT_ITERATOR  out  ) 
template<class OUTPUT_ITERATOR >
int bdlde::Base64Encoder::endConvert ( OUTPUT_ITERATOR  out,
int *  numOut,
int  maxNumOut = -1 
)

Terminate encoding for this encoder; write any retained output (e.g., from a previous call to convert) to the specified out buffer. Optionally specify the maxNumOut limit on the number of bytes to output; if maxNumOut is negative, no limit is imposed. Load into the (optionally) specified numOut the number of output bytes produced. Return 0 if output was successfully completed and a non-zero value otherwise. Any retained bytes are available on a subsequent call to endConvert. Once this method is called, no additional input may be supplied without an intervening call to resetState; once this method returns a zero status, a subsequent call will place this encoder in the error state, and return an error status.

void bdlde::Base64Encoder::resetState (  ) 

Reset this instance to its initial state (i.e., as if no input had been consumed).

Return the alphabet supplied at construction of this object.

bool bdlde::Base64Encoder::isAcceptable (  )  const

Return true if the input read so far is considered syntactically complete and all resulting output has been emitted to out, and false otherwise. Note that endConvert must be called if the total length of all data processed is not divisible by 3.

bool bdlde::Base64Encoder::isDone (  )  const

Return true if the current input is acceptable and any additional input (including endConvert) would be an error, and false otherwise. Note that if this decoder isDone then all resulting output has been emitted to out.

bool bdlde::Base64Encoder::isError (  )  const

Return true if there is no possibility of achieving an "acceptable" result, and false otherwise.

bool bdlde::Base64Encoder::isInitialState (  )  const

Return true if this instance is in the initial state (i.e., as if no input had been consumed), and false otherwise.

bool bdlde::Base64Encoder::isPadded (  )  const

Return true if padding by = characters was specified at construction of this object.

Return the currently installed value for the maximum line length.

EncoderOptions bdlde::Base64Encoder::options (  )  const

Return an options object reflecting the options this object was configured with.

int bdlde::Base64Encoder::outputLength (  )  const

Return the total length of the output emitted thus far (including soft line breaks where appropriate).


Member Data Documentation

const Alphabet bdlde::Base64Encoder::e_BASIC = Base64Alphabet::e_BASIC [static]
const Alphabet bdlde::Base64Encoder::e_URL = Base64Alphabet::e_URL [static]

Return the exact number of encoded bytes that would result from an input byte sequence of the specified inputLength provided to the convert method of an encoder configured with the specified maxLineLength. The behavior is undefined unless 0 <= inputLength and 0 <= maxLineLength. Note that if maxLineLength is 0, no CRLF characters will appear in the output. Note also that the number of encoded bytes need not be the number of output bytes.

DEPRECATED: use the overload with options instead.

Return the exact number of encoded lines that would result from an input byte sequence of the specified inputLength provided to the convert method of an encoder configured with the specified maxLineLength. The behavior is undefined unless 0 <= inputLength and 0 <= maxLineLength. Note that if maxLineLength is 0, no CRLF characters will appear in the output. Note also that the number of encoded bytes need not be the number of output bytes.

DEPRECATED: use the overload with options instead.

Create a Base64 encoder in the initial state, setting the maximum allowable line-length of the output to the specified maxLineLength. Specifying 0 for maxLineLength will result in a single output line (i.e., one with no CRLF in it). Optionally specify an alphabet used to encode characters. If alphabet is not specified, then the basic alphabet, "base64", is used.The behavior is undefined unless 0 <= maxLineLength. Note that when maxLineLength is positive, the convert and endConvert methods of this encoder will insert a CRLF to prevent each line of the output from exceeding maxLineLength.

DEPRECATED: Create and pass an options object instead.


The documentation for this class was generated from the following file: