qca_textfilter.h
Go to the documentation of this file.
/*
* qca_textfilter.h - Qt Cryptographic Architecture
* Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef QCA_TEXTFILTER_H
#define QCA_TEXTFILTER_H
#include "qca_core.h"
namespace QCA {
class QCA_EXPORT TextFilter : public Filter
{
public:
TextFilter(Direction dir);
void setup(Direction dir);
Direction direction() const;
MemoryRegion encode(const MemoryRegion &a);
MemoryRegion decode(const MemoryRegion &a);
QString arrayToString(const MemoryRegion &a);
MemoryRegion stringToArray(const QString &s);
QString encodeString(const QString &s);
QString decodeString(const QString &s);
protected:
Direction _dir;
};
class QCA_EXPORT Hex : public TextFilter
{
public:
Hex(Direction dir = Encode);
void clear() override;
MemoryRegion update(const MemoryRegion &a) override;
MemoryRegion final() override;
bool ok() const override;
private:
Q_DISABLE_COPY(Hex)
uchar val;
bool partial;
bool _ok;
};
class QCA_EXPORT Base64 : public TextFilter
{
public:
Base64(Direction dir = Encode);
bool lineBreaksEnabled() const;
int lineBreaksColumn() const;
void setLineBreaksEnabled(bool b);
void setLineBreaksColumn(int column);
void clear() override;
MemoryRegion update(const MemoryRegion &a) override;
MemoryRegion final() override;
bool ok() const override;
private:
Q_DISABLE_COPY(Base64)
QByteArray partial;
bool _ok;
int col;
bool _lb_enabled;
int _lb_column;
class Private;
Private *d;
};
}
#endif
QCA::Base64::ok
bool ok() const override
Test if an update() or final() call succeeded.
QCA::Base64::lineBreaksEnabled
bool lineBreaksEnabled() const
Returns true if line breaks are enabled.
QCA::Base64::setLineBreaksColumn
void setLineBreaksColumn(int column)
Sets the column that linebreaks should be inserted at when encoding.
QCA::Base64::clear
void clear() override
Reset the internal state.
QCA::Base64::Base64
Base64(Direction dir=Encode)
Standard constructor.
QCA::Base64::setLineBreaksEnabled
void setLineBreaksEnabled(bool b)
Sets line break mode.
QCA::Base64::lineBreaksColumn
int lineBreaksColumn() const
Returns the line break column.
QCA::Base64::update
MemoryRegion update(const MemoryRegion &a) override
Process more data, returning the corresponding encoded or decoded (depending on the Direction set in ...
QCA::Filter
General superclass for filtering transformation algorithms.
Definition qca_core.h:1108
QCA::Hex::clear
void clear() override
Reset the internal state.
QCA::Hex::Hex
Hex(Direction dir=Encode)
Standard constructor.
QCA::Hex::update
MemoryRegion update(const MemoryRegion &a) override
Process more data, returning the corresponding encoded or decoded (depending on the Direction set in ...
QCA::Hex::ok
bool ok() const override
Test if an update() or final() call succeeded.
QCA::MemoryRegion
Array of bytes that may be optionally secured.
Definition qca_tools.h:91
QCA::TextFilter::encode
MemoryRegion encode(const MemoryRegion &a)
Process an array in the "forward" direction, returning an array.
QCA::TextFilter::arrayToString
QString arrayToString(const MemoryRegion &a)
Process an array in the "forward" direction, returning a QString.
QCA::TextFilter::direction
Direction direction() const
The direction the TextFilter is set up to use.
QCA::TextFilter::_dir
Direction _dir
Internal state variable for the Direction that the filter operates in.
Definition qca_textfilter.h:154
QCA::TextFilter::decodeString
QString decodeString(const QString &s)
Process a string in the "reverse" direction, returning a string.
QCA::TextFilter::encodeString
QString encodeString(const QString &s)
Process a string in the "forward" direction, returning a string.
QCA::TextFilter::setup
void setup(Direction dir)
Reset the TextFilter.
QCA::TextFilter::TextFilter
TextFilter(Direction dir)
Standard constructor.
QCA::TextFilter::decode
MemoryRegion decode(const MemoryRegion &a)
Process an array in the "reverse" direction, returning an array.
QCA::TextFilter::stringToArray
MemoryRegion stringToArray(const QString &s)
Process an string in the "reverse" direction, returning a byte array.
QCA
QCA - the Qt Cryptographic Architecture.
Definition qca_basic.h:41
QCA::Direction
Direction
Direction settings for symmetric algorithms.
Definition qca_core.h:141
QCA::Encode
@ Encode
Operate in the "forward" direction; for example, encrypting.
Definition qca_core.h:142
qca_core.h
Header file for core QCA infrastructure.