BloombergLP::bdlde::QuotedPrintableDecoder

This class implements a mechanism capable of converting data of arbitrary length from its corresponding Quoted-Printable representation.

Synopsis

Declared in <bdlde_quotedprintabledecoder.h>

class QuotedPrintableDecoder;

Enums

NameDescription
EquivalenceClasses Input character equivalence classes used by the decoder state machine. Underscored enumerators apply in strict mode; others apply in relaxed mode where noted.
LineBreakMode Configuration governing how hard line breaks ("rn") are decoded.

Member Functions

NameDescription
QuotedPrintableDecoder [constructor]Create a Quoted-Printable decoder in the initial state, set to the strict or relaxed error-reporting mode according to whether the specified detectError flag is true or false, respectively, and also configured to the specified lineBreakMode. The behavior is undefined unless lineBreakMode is either e_CRLF_MODE or e_LF_MODE. Note that the decoder reports errors in the strict mode and output offending characters in the relaxed mode. Hard line breaks (`\r `) are decoded to `\r in e_CRLF_MODE (default) and to ` in e_LF_MODE.
~QuotedPrintableDecoder [destructor]Destroy this object.
convert Append to the buffer addressed by the specified out all pending output (if there is any) up to the optionally specified maxNumOut limit (default is negative, meaning no limit) and, when there is no pending output and maxNumOut is still not reached, begin to consume and decode a sequence of input characters starting at the specified begin position, up to but not including the specified end position, writing any resulting output in the specified output buffer up to the (cumulative) maxNumOut limit. If maxNumOut limit is reached, no further input will be consumed. Load into the 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 successful return status indicates the number of characters that would be output if endConvert were called with no output limit immediately upon exit from this method. These bytes are also available for output if this method is called with a sufficiently large maxNumOut. Note that calling this method after endConvert has been invoked without an intervening reset 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 decoding of any unprocessed input characters (e.g., whitespace).
endConvert Terminate encoding for this decoder; write any retained output (e.g., from a previous call to convert with a non-zero maxNumOut argument) 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 specified numOut the number of output bytes produced. Return 0 on success with no pending output, the positive number of bytes (if any) that would be output if endConvert were called with no output limit immediately upon exit from this method, 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 reset; once this method returns a zero status, a subsequent call will place this decoder in the error state, and return an error status.
isAccepting Return true if the input read so far by this decoder is considered syntactically complete and all resulting output has been emitted; return false otherwise. Note that there must not be any unprocessed characters accumulated in the input buffer of this decoder.
isDone Return true if this decoder is in the done state (i.e., endConvert has been called and any additional input will result in an error), and if there is no pending output; return false otherwise.
isError Return true if this decoder has encountered an irrecoverable error and false otherwise. An irrecoverable error is one for which there is no subsequent possibility of achieving an "acceptable" result (as defined by the isAccepting method).
isInitialState Return true if this decoder is in the initial state (i.e., as if no input had been consumed) and false otherwise.
isMaximal Return true if the input to this decoder is maximal (i.e., the input contains an end-of-input sentinel, signaling that no further input should be expected). Always returns false for Quoted-Printable decoders since the encoding scheme does not specify an end-of-input sentinel.
isUnrecognizedAnError Return true if this decoder is currently configured to detect an error when an unrecognizable encoding is encountered, and false otherwise.
lineBreakMode Return the line break mode specified for this decoder.
numOutputPending Return the number of output bytes retained by this decoder and not emitted because maxNumOut has been reached.
outputLength Return the total length of the output emitted by this decoder (possibly after several calls to the convert or the input methods) since its initial construction or the latest reset.
reset Reset this decoder to its initial state (i.e., as if no input had been consumed).

Static Member Functions

NameDescription
lineBreakModeToAscii Return the ASCII string describing the specified mode governing the decoding of hard linebreaks ("rn"). The behavior is undefined unless mode is either e_CRLF_MODE or e_LF_MODE.

Data Members

NameDescription
d_buffer Pending input characters awaiting further decoding.
d_bufferLength Number of valid characters currently stored in d_buffer.
d_equivClass_p Map of unsigned char to input equivalence class; dynamically allocated because there is no default complete configuration.
d_hexBuffer First hex digit buffered while decoding an =XX escape sequence.
d_lineBreakMode How hard line breaks are decoded.
d_outputLength Total number of output characters produced so far.
d_state Current decoder state-machine state.
d_unrecognizedIsErrorFlag If true, unrecognized characters are treated as errors.

Static Data Members

NameDescription
s_componentName Name of component used when reporting errors.
s_decodingMap_p Character map used for converting an ASCII character to the hexadecimal value it is representing.
s_defaultEquivClassCRLF_p Default map of unsigned char to equivalence class for CRLF line break mode
s_defaultEquivClassStrict_p Default map of unsigned char to equivalence class for strict mode
s_defaultMaxLineLength Default maximum line length used when configuring the decoder.
s_defaultUnrecognizedIsErrorFlag Default error reporting mode
s_lineBreakModeName ASCII names corresponding to LineBreakMode enumerators.