# qca_textfilter.h

Go to the documentation of this file.

    00001 /*
    00002  * qca_textfilter.h - Qt Cryptographic Architecture
    00003  * Copyright (C) 2003-2005  Justin Karneges <justin@affinix.com>
    00004  * Copyright (C) 2004,2005  Brad Hards <bradh@frogmouth.net>
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the GNU Lesser General Public
    00008  * License as published by the Free Software Foundation; either
    00009  * version 2.1 of the License, or (at your option) any later version.
    00010  *
    00011  * This library is distributed in the hope that it will be useful,
    00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  * Lesser General Public License for more details.
    00015  *
    00016  * You should have received a copy of the GNU Lesser General Public
    00017  * License along with this library; if not, write to the Free Software
    00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    00019  * 02110-1301  USA
    00020  *
    00021  */
    00022
    00033 #ifndef QCA_TEXTFILTER_H
    00034 #define QCA_TEXTFILTER_H
    00035
    00036 #include "qca_core.h"
    00037
    00038 namespace QCA {
    00039
    00051 class QCA_EXPORT TextFilter : public Filter
    00052 {
    00053 public:
    00060         TextFilter(Direction dir);
    00061
    00068         void setup(Direction dir);
    00069
    00073         Direction direction() const;
    00074
    00086         MemoryRegion encode(const MemoryRegion &a);
    00087
    00099         MemoryRegion decode(const MemoryRegion &a);
    00100
    00111         QString arrayToString(const MemoryRegion &a);
    00112
    00123         MemoryRegion stringToArray(const QString &s);
    00124
    00135         QString encodeString(const QString &s);
    00136
    00147         QString decodeString(const QString &s);
    00148
    00149 protected:
    00154         Direction _dir;
    00155 };
    00156
    00164 class QCA_EXPORT Hex : public TextFilter
    00165 {
    00166 public:
    00175         Hex(Direction dir = Encode);
    00176
    00182         virtual void clear();
    00183
    00198         virtual MemoryRegion update(const MemoryRegion &a);
    00199
    00208         virtual MemoryRegion final();
    00209
    00215         virtual bool ok() const;
    00216
    00217 private:
    00218         Q_DISABLE_COPY(Hex)
    00219
    00220         uchar val;
    00221         bool partial;
    00222         bool _ok;
    00223 };
    00224
    00232 class QCA_EXPORT Base64 : public TextFilter
    00233 {
    00234 public:
    00243         Base64(Direction dir = Encode);
    00244
    00248         bool lineBreaksEnabled() const;
    00249
    00253         int lineBreaksColumn() const;
    00254
    00263         void setLineBreaksEnabled(bool b);
    00264
    00271         void setLineBreaksColumn(int column);
    00272
    00277         virtual void clear();
    00278
    00293         virtual MemoryRegion update(const MemoryRegion &a);
    00294
    00303         virtual MemoryRegion final();
    00304
    00310         virtual bool ok() const;
    00311
    00312 private:
    00313         Q_DISABLE_COPY(Base64)
    00314
    00315         QByteArray partial;
    00316         bool _ok;
    00317         int col;
    00318         bool _lb_enabled;
    00319         int _lb_column;
    00320
    00321         class Private;
    00322         Private *d;
    00323 };
    00324
    00325 }
    00326
    00327 #endif