Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

bdlde::HexEncoder Class Reference

#include <bdlde_hexencoder.h>

List of all members.

Public Member Functions

 HexEncoder (bool upperCaseLetters=true)
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 reset ()
bool isAcceptable () const
bool isDone () const
bool isError () const
bool isInitialState () const
bool isUpperCase () const
int numOutputPending () const
int outputLength () const

Detailed Description

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

See Component bdlde_hexencoder


Constructor & Destructor Documentation

bdlde::HexEncoder::HexEncoder ( bool  upperCaseLetters = true  )  [explicit]

Create a Hex encoder in the initial state. Optionally specify the upperCaseLetters to indicate if values from 10 to 15 are encoded as uppercase letters(A-'F') or as lowercase letters(a-'f').


Member Function Documentation

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

Append to the buffer addressed by the specified out pending character (if there is such) up to the optionally specified maxNumOut limit (default is negative, meaning no limit). 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. Any resulting output is written to the out buffer up to the (cumulative) maxNumOut limit. If 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 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.

template<class OUTPUT_ITERATOR >
int bdlde::HexEncoder::endConvert ( OUTPUT_ITERATOR  out  ) 
template<class OUTPUT_ITERATOR >
int bdlde::HexEncoder::endConvert ( OUTPUT_ITERATOR  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 output limit 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 (optionally) 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::HexEncoder::reset (  ) 

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

bool bdlde::HexEncoder::isAcceptable (  )  const

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

bool bdlde::HexEncoder::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::HexEncoder::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 the endConvert method after the endConvert method has returned successfully.

bool bdlde::HexEncoder::isInitialState (  )  const

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

bool bdlde::HexEncoder::isUpperCase (  )  const

Return true if this encoder represents values from 10 to 15 as uppercase letters(A-'F'), and false if these values are represented as lowercase letters(a-'f').

int bdlde::HexEncoder::numOutputPending (  )  const

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

int bdlde::HexEncoder::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.


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