Quick Links:

bal | bbl | bdl | bsl

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

bdlde::Base64Decoder Class Reference

#include <bdlde_base64decoder.h>

List of all members.

Public Types

typedef Base64Alphabet::Enum Alphabet

Public Member Functions

 Base64Decoder (const Base64DecoderOptions &options)
 Base64Decoder (bool unrecognizedNonWhitespaceIsErrorFlag, Alphabet alphabet=e_BASIC)
 ~Base64Decoder ()
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
IgnoreMode::Enum ignoreMode () const
bool isAcceptable () const
bool isDone () const
bool isError () const
bool isInitialState () const
bool isMaximal () const
bool isPadded () const
bool isUnrecognizedAnError () const
DecoderOptions options () const
int outputLength () const

Static Public Member Functions

static int maxDecodedLength (int inputLength)

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 from its corresponding Base64 representation.

See Component bdlde_base64decoder


Member Typedef Documentation


Constructor & Destructor Documentation

bdlde::Base64Decoder::Base64Decoder ( const Base64DecoderOptions options  )  [explicit]

Create a Base64 decoder with options determined by the specfied options.

bdlde::Base64Decoder::Base64Decoder ( bool  unrecognizedNonWhitespaceIsErrorFlag,
Alphabet  alphabet = e_BASIC 
) [explicit]

Create a Base64 decoder in the initial state. Unrecognized characters (i.e., non-base64 characters other than whitespace) will be treated as errors if the specified unrecognizedNonWhitespaceIsErrorFlag is true, and ignored otherwise. Optionally specify an alphabet used to decode input characters. If alphabet is not specified, then the basic alphabet, "base64", is used. Padded input is assumed.

DEPRECATED: Use the overload that takes options instead.

bdlde::Base64Decoder::~Base64Decoder (  ) 

Destroy this object.


Member Function Documentation

static int bdlde::Base64Decoder::maxDecodedLength ( int  inputLength  )  [static]

Return the maximum number of decoded bytes that could result from an input byte sequence of the specified inputLength provided to the convert and endConvert methods of this decoder. The behavior is undefined unless 0 <= inputLength. Note that the result is independent of which options are provided to the decoder.

template<class OUTPUT_ITERATOR , class INPUT_ITERATOR >
int bdlde::Base64Decoder::convert ( OUTPUT_ITERATOR  out,
INPUT_ITERATOR  begin,
INPUT_ITERATOR  end 
)
template<class OUTPUT_ITERATOR , class INPUT_ITERATOR >
int bdlde::Base64Decoder::convert ( OUTPUT_ITERATOR  out,
int *  numOut,
int *  numIn,
INPUT_ITERATOR  begin,
INPUT_ITERATOR  end,
int  maxNumOut = -1 
)

Decode 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, -1 on an input error, and -2 if the endConvert method has already been called without an intervening resetState call. A return status of -1 indicates that the data at begin + numIn constitutes an irrecoverably undecodable input sequence (i.e., the data cannot be extended to form any valid encoding). A positive return status indicates the number of valid processed output bytes retained by this decoder 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 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::Base64Decoder::endConvert ( OUTPUT_ITERATOR  out  ) 
template<class OUTPUT_ITERATOR >
int bdlde::Base64Decoder::endConvert ( OUTPUT_ITERATOR  out,
int *  numOut,
int  maxNumOut = -1 
)

Terminate decoding for this decoder; write any retained output (e.g., from a previous call to convert with a non-zero optionally specified maxNumOut argument) to the specified out buffer; encode any unprocessed input characters that do not complete a 3-byte sequence. The argument maxNumOut is the 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 on success, the positive number of bytes still retained by this decoder if the maxNumOut limit was reached, and a negative 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 decoder in the error state, and return an error status.

void bdlde::Base64Decoder::resetState (  ) 

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

Alphabet bdlde::Base64Decoder::alphabet (  )  const

Return the alphabet supplied at construction of this object.

IgnoreMode::Enum bdlde::Base64Decoder::ignoreMode (  )  const

Return the ignoreMode state of this decoder.

bool bdlde::Base64Decoder::isAcceptable (  )  const

Return true if the input read so far is considered syntactically complete, and false otherwise. Note that the number of relevant input characters must be divisible by 4.

bool bdlde::Base64Decoder::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::Base64Decoder::isError (  )  const

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

bool bdlde::Base64Decoder::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::Base64Decoder::isMaximal (  )  const

Return true if the current input is acceptable and any additional input (other than endConvert) would be an error, and false otherwise.

bool bdlde::Base64Decoder::isPadded (  )  const

Return true if this object is configured for padded input and false otherwise.

bool bdlde::Base64Decoder::isUnrecognizedAnError (  )  const

Return true if this mechanism is currently configured to report an error when an unrecognized character (i.e., a character other than one of the 64 "numeric" base-64 characters, =, or whitespace) is encountered, and false otherwise.

DEPRECATED: use the ignoreMode accessor instead.

DecoderOptions bdlde::Base64Decoder::options (  )  const

Return a Base64DecoderOptions object representing the configuration of this decoder.

int bdlde::Base64Decoder::outputLength (  )  const

Return the total length of the output emitted thus far.


Member Data Documentation

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

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