KCodecs::IdentityCodec
#include <kcodecsidentity.h>

Public Member Functions | |
IdentityCodec () | |
~IdentityCodec () override | |
virtual bool | decode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, NewlineType newline=NewlineLF) const |
QByteArray | decode (const QByteArray &src, Codec::NewlineType newline=Codec::NewlineLF) const override |
virtual QByteArray | decode (const QByteArray &src, NewlineType newline=NewlineLF) const |
virtual bool | encode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, NewlineType newline=NewlineLF) const |
QByteArray | encode (const QByteArray &src, Codec::NewlineType newline=Codec::NewlineLF) const override |
virtual QByteArray | encode (const QByteArray &src, NewlineType newline=NewlineLF) const |
Decoder * | makeDecoder (Codec::NewlineType newline=Codec::NewlineCRLF) const override |
Encoder * | makeEncoder (Codec::NewlineType newline=Codec::NewlineCRLF) const override |
int | maxDecodedSizeFor (int insize, Codec::NewlineType newline) const override |
int | maxEncodedSizeFor (int insize, Codec::NewlineType newline=Codec::NewlineLF) const override |
![]() | |
virtual | ~Codec () |
virtual bool | decode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, NewlineType newline=NewlineLF) const |
virtual bool | encode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, NewlineType newline=NewlineLF) const |
virtual const char * | name () const =0 |
Additional Inherited Members | |
![]() | |
enum | NewlineType { NewlineLF, NewlineCRLF } |
![]() | |
static Codec * | codecForName (const char *name) |
static Codec * | codecForName (const QByteArray &name) |
![]() | |
Codec () | |
Detailed Description
A class representing the Identify codec.
Definition at line 32 of file kcodecsidentity.h.
Constructor & Destructor Documentation
◆ IdentityCodec()
|
inline |
Constructs the Identity codec.
Definition at line 38 of file kcodecsidentity.h.
◆ ~IdentityCodec()
|
inlineoverride |
Destroys the codec.
Definition at line 46 of file kcodecsidentity.h.
Member Function Documentation
◆ decode() [1/3]
bool KCodecs::Codec::decode |
Convenience wrapper that can be used for small chunks of data when you can provide a large enough buffer.
The default implementation creates a Decoder and uses it.
Decodes a chunk of bytes starting at scursor
and extending to send
into the buffer described by dcursor
and dend
.
This function doesn't support chaining of blocks. The returned block cannot be added to, but you don't need to finalize it, too.
Example usage (in
contains the input data):
KCodecs::Codec *codec = KCodecs::Codec::codecForName("base64"); if (!codec) { qFatal() << "no base64 codec found!?"; } QByteArray out(in.size()); // good guess for any encoding... QByteArray::Iterator iit = in.begin(); QByteArray::Iterator oit = out.begin(); if (!codec->decode(iit, in.end(), oit, out.end())) { qDebug() << "output buffer too small"; return; } qDebug() << "Size of decoded data:" << oit - out.begin();
- Parameters
-
scursor is a pointer to the start of the input buffer. send is a pointer to the end of the input buffer. dcursor is a pointer to the start of the output buffer. dend is a pointer to the end of the output buffer. newline whether make new lines using CRLF, or LF (default is LF).
- Returns
- false if the decoded data didn't fit into the output buffer; true otherwise.
Definition at line 682 of file kcodecs.cpp.
◆ decode() [2/3]
|
overridevirtual |
Reimplemented from KCodecs::Codec.
Definition at line 94 of file kcodecsidentity.cpp.
◆ decode() [3/3]
QByteArray KCodecs::Codec::decode |
Even more convenient, but also a bit slower and more memory intensive, since it allocates storage for the worst case and then shrinks the result QByteArray to the actual size again.
For use with small src
.
- Parameters
-
src is a QByteArray containing the data to decode. newline whether make new lines using CRLF, or LF (default is LF).
Definition at line 659 of file kcodecs.cpp.
◆ encode() [1/3]
bool KCodecs::Codec::encode |
Convenience wrapper that can be used for small chunks of data when you can provide a large enough buffer.
The default implementation creates an Encoder and uses it.
Encodes a chunk of bytes starting at scursor
and extending to send
into the buffer described by dcursor
and dend
.
This function doesn't support chaining of blocks. The returned block cannot be added to, but you don't need to finalize it, too.
Example usage (in
contains the input data):
KCodecs::Codec *codec = KCodecs::Codec::codecForName("base64"); if (!codec) { qFatal() << "no base64 codec found!?"; } QByteArray out(in.size() * 1.4); // crude maximal size of b64 encoding QByteArray::Iterator iit = in.begin(); QByteArray::Iterator oit = out.begin(); if (!codec->encode(iit, in.end(), oit, out.end())) { qDebug() << "output buffer too small"; return; } qDebug() << "Size of encoded data:" << oit - out.begin();
- Parameters
-
scursor is a pointer to the start of the input buffer. send is a pointer to the end of the input buffer. dcursor is a pointer to the start of the output buffer. dend is a pointer to the end of the output buffer. newline whether make new lines using CRLF, or LF (default is LF).
- Returns
- false if the encoded data didn't fit into the output buffer; true otherwise.
Definition at line 610 of file kcodecs.cpp.
◆ encode() [2/3]
|
overridevirtual |
Reimplemented from KCodecs::Codec.
Definition at line 86 of file kcodecsidentity.cpp.
◆ encode() [3/3]
QByteArray KCodecs::Codec::encode |
Even more convenient, but also a bit slower and more memory intensive, since it allocates storage for the worst case and then shrinks the result QByteArray to the actual size again.
For use with small src
.
- Parameters
-
src is a QByteArray containing the data to encode. newline whether make new lines using CRLF, or LF (default is LF).
Definition at line 636 of file kcodecs.cpp.
◆ makeDecoder()
|
overridevirtual |
◆ makeEncoder()
|
overridevirtual |
◆ maxDecodedSizeFor()
|
inlineoverridevirtual |
Implements KCodecs::Codec.
Reimplemented in KCodecs::BinaryCodec.
Definition at line 82 of file kcodecsidentity.h.
◆ maxEncodedSizeFor()
|
inlineoverridevirtual |
Implements KCodecs::Codec.
Reimplemented in KCodecs::BinaryCodec.
Definition at line 69 of file kcodecsidentity.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:10:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.