BloombergLP::bdlde::Base64Decoder::convert

Decode Base64 characters from [begin, end)] into out with limits.

Synopsis

Declared in <bdlde_base64decoder.h>

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);

Description

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 decoding of any unprocessed input characters that do not complete a 3-byte sequence.

Specializations

NameDescription
convert<char*, char const*> Decode Base64 input for char * / const char * iterators.
convert<unsigned char*, unsigned char const*> Decode Base64 input for unsigned char * iterators.

Return Value

non-negative value on success (positive count of retained output bytes if maxNumOut was reached), -1 on input error, and -2 if endConvert has already been called without an intervening resetState

Parameters

NameDescription
outdestination for decoded output bytes
numOutif non-null, receives the number of bytes written
numInif non-null, receives the number of input bytes consumed
beginbeginning of the Base64 input range
endend of the Base64 input range (exclusive)
maxNumOutmaximum bytes to write; negative means no limit