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  02110-1301, USA
00019  *
00020  */
00021 
00032 #ifndef QCA_TEXTFILTER_H
00033 #define QCA_TEXTFILTER_H
00034 
00035 #include "qca_core.h"
00036 
00037 namespace QCA {
00038 
00050 class QCA_EXPORT TextFilter : public Filter
00051 {
00052 public:
00059         TextFilter(Direction dir);
00060 
00067         void setup(Direction dir);
00068 
00072         Direction direction() const;
00073 
00085         MemoryRegion encode(const MemoryRegion &a);
00086 
00098         MemoryRegion decode(const MemoryRegion &a);
00099 
00110         QString arrayToString(const MemoryRegion &a);
00111 
00122         MemoryRegion stringToArray(const QString &s);
00123 
00134         QString encodeString(const QString &s);
00135 
00146         QString decodeString(const QString &s);
00147 
00148 protected:
00153         Direction _dir;
00154 };
00155 
00163 class QCA_EXPORT Hex : public TextFilter
00164 {
00165 public:
00174         Hex(Direction dir = Encode);
00175 
00181         virtual void clear();
00182 
00197         virtual MemoryRegion update(const MemoryRegion &a);
00198 
00207         virtual MemoryRegion final();
00208 
00214         virtual bool ok() const;
00215 
00216 private:
00217         Q_DISABLE_COPY(Hex)
00218 
00219         uchar val;
00220         bool partial;
00221         bool _ok;
00222 };
00223 
00231 class QCA_EXPORT Base64 : public TextFilter
00232 {
00233 public:
00242         Base64(Direction dir = Encode);
00243 
00247         bool lineBreaksEnabled() const;
00248 
00252         int lineBreaksColumn() const;
00253 
00262         void setLineBreaksEnabled(bool b);
00263 
00270         void setLineBreaksColumn(int column);
00271 
00276         virtual void clear();
00277 
00292         virtual MemoryRegion update(const MemoryRegion &a);
00293 
00302         virtual MemoryRegion final();
00303 
00309         virtual bool ok() const;
00310 
00311 private:
00312         Q_DISABLE_COPY(Base64)
00313 
00314         QByteArray partial;
00315         bool _ok;
00316         int col;
00317         bool _lb_enabled;
00318         int _lb_column;
00319 
00320         class Private;
00321         Private *d;
00322 };
00323 
00324 }
00325 
00326 #endif

Generated on Thu Sep 6 19:13:36 2007 for Qt Cryptographic Architecture by  doxygen 1.5.2