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 
00048 class QCA_EXPORT TextFilter : public Filter
00049 {
00050 public:
00057         TextFilter(Direction dir);
00058 
00065         void setup(Direction dir);
00066 
00070         Direction direction() const;
00071 
00083         MemoryRegion encode(const MemoryRegion &a);
00084 
00096         MemoryRegion decode(const MemoryRegion &a);
00097 
00108         QString arrayToString(const MemoryRegion &a);
00109 
00120         MemoryRegion stringToArray(const QString &s);
00121 
00132         QString encodeString(const QString &s);
00133 
00144         QString decodeString(const QString &s);
00145 
00146 protected:
00151         Direction _dir;
00152 };
00153 
00159 class QCA_EXPORT Hex : public TextFilter
00160 {
00161 public:
00170         Hex(Direction dir = Encode);
00171 
00177         virtual void clear();
00178 
00193         virtual MemoryRegion update(const MemoryRegion &a);
00194 
00203         virtual MemoryRegion final();
00204 
00210         virtual bool ok() const;
00211 
00212 private:
00213         Q_DISABLE_COPY(Hex)
00214 
00215         uchar val;
00216         bool partial;
00217         bool _ok;
00218 };
00219 
00225 class QCA_EXPORT Base64 : public TextFilter
00226 {
00227 public:
00236         Base64(Direction dir = Encode);
00237 
00241         bool lineBreaksEnabled() const;
00242 
00246         int lineBreaksColumn() const;
00247 
00254         void setLineBreaksEnabled(bool b);
00255 
00260         void setLineBreaksColumn(int column);
00261 
00266         virtual void clear();
00267 
00282         virtual MemoryRegion update(const MemoryRegion &a);
00283 
00292         virtual MemoryRegion final();
00293 
00299         virtual bool ok() const;
00300 
00301 private:
00302         Q_DISABLE_COPY(Base64)
00303 
00304         QByteArray partial;
00305         bool _ok;
00306         int col;
00307         bool _lb_enabled;
00308         int _lb_column;
00309 
00310         class Private;
00311         Private *d;
00312 };
00313 
00314 }
00315 
00316 #endif

Generated on Fri Jul 6 12:14:04 2007 for Qt Cryptographic Architecture by  doxygen 1.4.6