SilentEye 0.4.1

sef/encodeddata.h

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye. If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #ifndef ENCODEDDATA_H_
00017 #define ENCODEDDATA_H_
00018 
00019 #include <QPointer>
00020 #include <QString>
00021 #include <QByteArray>
00022 #include <QFile>
00023 
00024 #include "data.h"
00025 
00026 namespace SilentEyeFramework {
00027 
00029 
00034     class EncodedData : public QObject
00035     {
00036     private:
00038         QPointer<Data> _data;
00040         QByteArray _buffer;
00042         unsigned short int _andOperator;
00044         unsigned short int _swap;
00046         unsigned int _arrayCount;
00048         char _car;
00050         unsigned short int _bitCount;
00052         bool _compressed;
00054         bool _partialData;
00055 
00056     public:
00057         EncodedData(Data::DataFormat=Data::F_UNDEF, bool=false);
00058         EncodedData(const QByteArray, Data::DataFormat=Data::BYTES, bool=false);
00059         EncodedData(const quint32, bool=false);
00060         EncodedData(const QString&, Data::DataFormat=Data::UTF8, bool=true);
00061         EncodedData(QFile&, bool=true);
00062         ~EncodedData();
00063 
00064         void initialize(unsigned short int = 2);
00065         bool hasNext();
00066         int read();
00067         void append(int);
00068         
00069         Data::DataFormat format();
00070         quint32 size() const;
00071         QByteArray bytes();
00072         void clear();
00073 
00074         bool isCompressed() const;
00075         void setCompressed(const bool, const bool=false);
00076 
00077         QString toString(Data::DataFormat=Data::F_UNDEF);       
00078         quint32 toUInt32();
00079         QPointer<Data> toData();
00080 
00081         static unsigned short int andOperator(unsigned short int);
00082     private:
00083         void checkPartialData();
00084     };
00085 
00086 }
00087 
00088 #endif