Quick Links:

bal | bbl | bdl | bsl

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

bdlde::QuotedPrintableDecoder Class Reference

#include <bdlde_quotedprintabledecoder.h>

List of all members.

Public Types

enum  EquivalenceClasses {
  e_RC_ = 0, e_RC, e_HX_, e_HX,
  e_EQ_, e_EQ, e_WS_, e_WS,
  e_CR_, e_CR, e_LC_, e_LL_,
  e_LC, e_LL, e_UC_, e_UC,
  BDEDE_RC_ = e_RC_, BDEDE_RC = e_RC, BDEDE_HX_ = e_HX_, BDEDE_HX = e_HX,
  BDEDE_EQ_ = e_EQ_, BDEDE_EQ = e_EQ, BDEDE_WS_ = e_WS_, BDEDE_WS = e_WS,
  BDEDE_CR_ = e_CR_, BDEDE_CR = e_CR, BDEDE_LC_ = e_LC_, BDEDE_LL_ = e_LL_,
  BDEDE_LC = e_LC, BDEDE_LL = e_LL, BDEDE_UC_ = e_UC_, BDEDE_UC = e_UC
}
enum  LineBreakMode { e_CRLF_MODE, e_LF_MODE, BDEDE_CRLF_MODE = e_CRLF_MODE, BDEDE_LF_MODE = e_LF_MODE }
 

Configuration governing how line breaks are decoded.

More...

Public Member Functions

 QuotedPrintableDecoder (bool detectError, QuotedPrintableDecoder::LineBreakMode lineBreakMode=QuotedPrintableDecoder::e_CRLF_MODE)
 ~QuotedPrintableDecoder ()
int convert (char *out, int *numOut, int *numIn, const char *begin, const char *end, int maxNumOut=-1)
int endConvert (char *out, int *numOut, int maxNumOut=-1)
void reset ()
bool isAccepting () const
bool isDone () const
bool isError () const
bool isInitialState () const
bool isMaximal () const
bool isUnrecognizedAnError () const
LineBreakMode lineBreakMode () const
int numOutputPending () const
int outputLength () const

Static Public Member Functions

static const char * lineBreakModeToAscii (LineBreakMode mode)

Public Attributes

bool d_unrecognizedIsErrorFlag
LineBreakMode d_lineBreakMode
int d_state
char d_buffer [90]
int d_bufferLength
char d_hexBuffer
int d_outputLength
char * d_equivClass_p

Static Public Attributes

static const char s_componentName []
static const bool s_defaultUnrecognizedIsErrorFlag
static const char * s_defaultEquivClassStrict_p
static const char * s_defaultEquivClassCRLF_p
static const unsigned char *const s_decodingMap_p
static const int s_defaultMaxLineLength
static const char * s_lineBreakModeName []

Detailed Description

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

See Component bdlde_quotedprintabledecoder


Member Enumeration Documentation

This enumeration type enumerates the input equivalence classes. Separate enums are given to variants resulting from different modes of operation to eliminate an extra step of mode checking inside the main decoding loop.

Enumerator:
e_RC_ 

strict mode

e_RC 

relaxed mode

e_HX_ 

strict mode

Hexadecimal digit - numeral only when preceded by =; otherwise a regular character

e_HX 

relaxed mode

e_EQ_ 

= - wait for more input

strict mode

e_EQ 

relaxed mode

e_WS_ 

Whitespace - buffer; wait for more input.

strict mode

e_WS 

relaxed mode

e_CR_ 

Carriage return.

strict mode - wait for further input

e_CR 

relaxed mode - wait for further input

e_LC_ 

Line Feed Strict mode ------------ CRLF_MODE - decode to "\r\n" if preceded by

e_LL_ 

\r; report error otherwise

LF_MODE - decode to \n if preceded by

e_LC 

\r report error otherwise Relaxed mode ------------ CRLF_MODE - decode to "\r\n" if preceded by

e_LL 

\r; ignore otherwise

LF_MODE - decode to "\n" if preceded by

e_UC_ 

\r; ignore otherwise

Unrecognized char - halt and report error strict mode - Ignore and halt decoding

e_UC 

relaxed mode - Ignore but continue decoding

BDEDE_RC_ 
BDEDE_RC 
BDEDE_HX_ 
BDEDE_HX 
BDEDE_EQ_ 
BDEDE_EQ 
BDEDE_WS_ 
BDEDE_WS 
BDEDE_CR_ 
BDEDE_CR 
BDEDE_LC_ 
BDEDE_LL_ 
BDEDE_LC 
BDEDE_LL 
BDEDE_UC_ 
BDEDE_UC 
Enumerator:
e_CRLF_MODE 

"\r\n" are decoded to "\r\n".

e_LF_MODE 

"\r\n" are decoded to "\n".

BDEDE_CRLF_MODE 
BDEDE_LF_MODE 

Constructor & Destructor Documentation

bdlde::QuotedPrintableDecoder::QuotedPrintableDecoder ( bool  detectError,
QuotedPrintableDecoder::LineBreakMode  lineBreakMode = QuotedPrintableDecoder::e_CRLF_MODE 
) [explicit]

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\n") are decoded to "\r\n" in e_CRLF_MODE (default) and to \n in e_LF_MODE.

bdlde::QuotedPrintableDecoder::~QuotedPrintableDecoder (  ) 

Destroy this object.


Member Function Documentation

static const char* bdlde::QuotedPrintableDecoder::lineBreakModeToAscii ( LineBreakMode  mode  )  [static]

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

int bdlde::QuotedPrintableDecoder::convert ( char *  out,
int *  numOut,
int *  numIn,
const char *  begin,
const char *  end,
int  maxNumOut = -1 
)

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

int bdlde::QuotedPrintableDecoder::endConvert ( char *  out,
int *  numOut,
int  maxNumOut = -1 
)

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.

void bdlde::QuotedPrintableDecoder::reset (  ) 

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

bool bdlde::QuotedPrintableDecoder::isAccepting (  )  const

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.

bool bdlde::QuotedPrintableDecoder::isDone (  )  const

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.

bool bdlde::QuotedPrintableDecoder::isError (  )  const

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

bool bdlde::QuotedPrintableDecoder::isInitialState (  )  const

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

bool bdlde::QuotedPrintableDecoder::isMaximal (  )  const

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.

bool bdlde::QuotedPrintableDecoder::isUnrecognizedAnError (  )  const

Return true if this decoder is currently configured to detect an error when an unrecognizable encoding is encountered, and false otherwise.

LineBreakMode bdlde::QuotedPrintableDecoder::lineBreakMode (  )  const

Return the line break mode specified for this decoder.

int bdlde::QuotedPrintableDecoder::numOutputPending (  )  const

Return the number of output bytes retained by this decoder and not emitted because maxNumOut has been reached.

int bdlde::QuotedPrintableDecoder::outputLength (  )  const

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.


Member Data Documentation

const unsigned char* const bdlde::QuotedPrintableDecoder::s_decodingMap_p [static]

Default maximum line length

Names of line break mode

If true, fail on "bad" characters

Line break mode

TBD doc

TBD doc

TBD doc

TBD doc

Total number of output characters

Map of unsigned char to input equivalence class;


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