KCodecs::Encoder

#include <KCodecs>

Inherited by IdentityEnDecoder, KCodecs::Base64Encoder, KCodecs::QuotedPrintableEncoder, and KCodecs::Rfc2047QEncodingEncoder.

Public Member Functions

virtual ~Encoder ()
 
virtual bool encode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend)=0
 
virtual bool finish (char *&dcursor, const char *const dend)=0
 

Protected Types

enum  { maxBufferedChars = 8 }
 

Protected Member Functions

 Encoder (Codec::NewlineType newline=Codec::NewlineLF)
 
bool flushOutputBuffer (char *&dcursor, const char *const dend)
 
bool write (char ch, char *&dcursor, const char *const dend)
 
bool writeCRLF (char *&dcursor, const char *const dend)
 

Detailed Description

Stateful encoder class.

Stateful encoder class, modeled after QTextEncoder.

Since
5.5

Definition at line 689 of file kcodecs.h.

Member Enumeration Documentation

anonymous enum
protected

The maximum number of characters permitted in the output buffer.

Enumerator
maxBufferedChars 

Eight.

Definition at line 734 of file kcodecs.h.

Constructor & Destructor Documentation

KCodecs::Encoder::Encoder ( Codec::NewlineType  newline = Codec::NewlineLF)
explicitprotected

Protected constructor.

Use KCodecs::Codec::makeEncoder if you want one.

Parameters
newlinewhether make new lines using CRLF, or LF (default is LF).

Definition at line 692 of file kcodecs.cpp.

KCodecs::Encoder::~Encoder ( )
virtual

Destroys the encoder.

Definition at line 697 of file kcodecs.cpp.

Member Function Documentation

virtual bool KCodecs::Encoder::encode ( const char *&  scursor,
const char *const  send,
char *&  dcursor,
const char *const  dend 
)
pure virtual

Encodes a chunk of data, maintaining state information between calls.

See KCodecs::Codec for calling conventions.

Parameters
scursoris a pointer to the start of the input buffer.
sendis a pointer to the end of the input buffer.
dcursoris a pointer to the start of the output buffer.
dendis a pointer to the end of the output buffer.
virtual bool KCodecs::Encoder::finish ( char *&  dcursor,
const char *const  dend 
)
pure virtual

Call this method to finalize the output stream.

Writes all remaining data and resets the encoder. See KCodecs::Codec for calling conventions.

Parameters
dcursoris a pointer to the start of the output buffer.
dendis a pointer to the end of the output buffer.
bool KCodecs::Encoder::flushOutputBuffer ( char *&  dcursor,
const char *const  dend 
)
protected

Writes characters from the output buffer to the output stream.

Implementations of encode and finish should call this at the very beginning and for each iteration of the while loop.

Parameters
dcursoris a pointer to the start of the output buffer.
dendis a pointer to the end of the output buffer.
Returns
true if all chars could be written, false otherwise

Definition at line 722 of file kcodecs.cpp.

bool KCodecs::Encoder::write ( char  ch,
char *&  dcursor,
const char *const  dend 
)
protected

Writes character ch to the output stream or the output buffer, depending on whether or not the output stream has space left.

Parameters
chis the character to write.
dcursoris a pointer to the start of the output buffer.
dendis a pointer to the end of the output buffer.
Returns
true if written to the output stream; else false if buffered.

Definition at line 702 of file kcodecs.cpp.

bool KCodecs::Encoder::writeCRLF ( char *&  dcursor,
const char *const  dend 
)
protected

Convenience function.

Outputs LF or CRLF, based on the state of mWithCRLF.

Parameters
dcursoris a pointer to the start of the output buffer.
dendis a pointer to the end of the output buffer.

Definition at line 742 of file kcodecs.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 14 2020 22:43:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.