Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Static Public Member Functions

bdlde::QuotedPrintableEncoder Class Reference

#include <bdlde_quotedprintableencoder.h>

List of all members.

Public Types

enum  EquivalenceClass {
  e_PC = 0, e_CR, e_LF, e_WS,
  e_CC, BDEDE_PC = e_PC, BDEDE_CR = e_CR, BDEDE_LF = e_LF,
  BDEDE_WS = e_WS, BDEDE_CC = e_CC
}
 

The input equivalence classes.

More...
enum  LineBreakMode {
  e_CRLF_MODE = 0, e_LF_MODE, e_MIXED_MODE, e_BINARY_MODE,
  BDEDE_CRLF_MODE = e_CRLF_MODE, BDEDE_LF_MODE = e_LF_MODE, BDEDE_MIXED_MODE = e_MIXED_MODE
}

Public Member Functions

 QuotedPrintableEncoder (LineBreakMode lineBreakMode=e_CRLF_MODE, int maxLineLength=k_DEFAULT_MAX_LINELEN, bslma::Allocator *basicAllocator=0)
 QuotedPrintableEncoder (const char *extraCharsToEncode, LineBreakMode lineBreakMode=e_CRLF_MODE, int maxLineLength=k_DEFAULT_MAX_LINELEN, bslma::Allocator *basicAllocator=0)
 ~QuotedPrintableEncoder ()
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
LineBreakMode lineBreakMode () const
int maxLineLength () const
int numOutputPending () const
int outputLength () const

Static Public Member Functions

static const char * lineBreakModeToAscii (QuotedPrintableEncoder::LineBreakMode mode)

Detailed Description

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

See Component bdlde_quotedprintableencoder


Member Enumeration Documentation

Enumerator:
e_PC 

printable character - copy straight to output

e_CR 

carriage return - wait for more input

e_LF 

line feed - complete linebreak

e_WS 

whitespace - buffer; wait for more input

e_CC 

control character - encode to Quoted Printable

BDEDE_PC 
BDEDE_CR 
BDEDE_LF 
BDEDE_WS 
BDEDE_CC 

Configuration governing how various forms of line breaks are to be interpreted

Enumerator:
e_CRLF_MODE 

allow "\r\n" as linebreaks

e_LF_MODE 

allow \n as linebreaks (without the \r prefix)

e_MIXED_MODE 

allow "\r\n" and \n as linebreaks

e_BINARY_MODE 

allow no linebreaks

BDEDE_CRLF_MODE 
BDEDE_LF_MODE 
BDEDE_MIXED_MODE 

Constructor & Destructor Documentation

bdlde::QuotedPrintableEncoder::QuotedPrintableEncoder ( LineBreakMode  lineBreakMode = e_CRLF_MODE,
int  maxLineLength = k_DEFAULT_MAX_LINELEN,
bslma::Allocator basicAllocator = 0 
) [explicit]

Create a Quoted-Printable encoder in the initial state, configured to accept hard line breaks based on the optionally specified lineBreakMode, and to insert soft line breaks when the line length exceeds the optionally specified maxLineLength (default is the RFC 2045 maximum 76). Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 4 <= maxLineLength <= 76. Note that BDEDE_CRLF_MODE passes "\r\n" straight to output and converts \n; BDEDE_LF_MODE passes \n and converts \r; BDEDE_MIXED_MODE passes both "\r\n" and \n.

bdlde::QuotedPrintableEncoder::QuotedPrintableEncoder ( const char *  extraCharsToEncode,
LineBreakMode  lineBreakMode = e_CRLF_MODE,
int  maxLineLength = k_DEFAULT_MAX_LINELEN,
bslma::Allocator basicAllocator = 0 
) [explicit]

Create a Quoted-Printable encoder in the initial state, configured to convert to the form "=XX" any input character matching a printable or whitespace character in the specified extraCharsToEncode array (as opposed to the default setting of passing the input character straight to output), to accept hard linebreaks based on the optionally specified lineBreakMode, and to insert soft linebreaks when the line length exceeds the optionally specified maxLineLength (default is the RFC 2045 maximum 76). Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 4 <= 'maxLineLength <= 76. Note that BDEDE_CRLF_MODE passes "\r\n" straight to output and converts \n; BDEDE_LF_MODE passes \n and converts \r; BDEDE_MIXED_MODE passes both "\r\n" and \n.

bdlde::QuotedPrintableEncoder::~QuotedPrintableEncoder (  ) 

Destroy this object.


Member Function Documentation

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

Return the string representation exactly matching the enumerator name corresponding to the specified enumerator mode.

int bdlde::QuotedPrintableEncoder::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 encode 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 out 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 subsequently with no output limit. These bytes may be 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 encoding of any unprocessed input characters.

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

Terminate encoding for this encoder; 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 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 subsequently with no output limit. 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 encoder in the error state, and return an error status.

void bdlde::QuotedPrintableEncoder::reset (  ) 

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

bool bdlde::QuotedPrintableEncoder::isAccepting (  )  const

Return true if the input read so far by this encoder is considered syntactically complete, and false otherwise.

bool bdlde::QuotedPrintableEncoder::isDone (  )  const

Return true if this encoder 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, and false otherwise.

bool bdlde::QuotedPrintableEncoder::isError (  )  const

Return true if there is no possibility of achieving an "acceptable" result, and false otherwise. Note that for an encoder, no input can cause an error; the possible errors result either from a call to the convert method after the endConvert method is called the first time, or from a call to either the convert or the endConvert methods after the endConvert method has returned successfully.

bool bdlde::QuotedPrintableEncoder::isInitialState (  )  const

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

LineBreakMode bdlde::QuotedPrintableEncoder::lineBreakMode (  )  const

Return the line break mode configured at the construction of this encoder.

int bdlde::QuotedPrintableEncoder::maxLineLength (  )  const

Return the value for the maximum line length configured at the construction of this encoder.

int bdlde::QuotedPrintableEncoder::numOutputPending (  )  const

Return the number of characters that would be output if endConvert were called with no output limit.

int bdlde::QuotedPrintableEncoder::outputLength (  )  const

Return the total length of the output emitted by this encoder (possibly after one or more calls to the convert or the input methods) since its initial construction or the latest reset. Note that soft line breaks are included in the counts if added.


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