From 8e81889b93754bbeedaa674a2f6d35cbed79a16c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mateusz=20P=C3=B3=C5=82rola?= Date: Tue, 5 Oct 2010 14:50:37 +0200 Subject: [PATCH] Added comments for StarDictReaders --- src/plugins/stardict/CompressedReader.h | 58 ++++++++++++++++++++++++- src/plugins/stardict/StarDictReader.h | 53 +++++++++++++++++++++-- src/plugins/stardict/StarDictReaderFactory.h | 5 +++ src/plugins/stardict/UncompressedReader.h | 59 +++++++++++++++++++++++++- 4 files changed, 168 insertions(+), 7 deletions(-) diff --git a/src/plugins/stardict/CompressedReader.h b/src/plugins/stardict/CompressedReader.h index d4fe10b..ab5caba 100644 --- a/src/plugins/stardict/CompressedReader.h +++ b/src/plugins/stardict/CompressedReader.h @@ -30,22 +30,76 @@ #include #include "StarDictReader.h" +/*! + Class implementing StarDictReader interface and handling rading from compressed + files like .gz or .dz, using zlib + */ class CompressedReader : public StarDictReader { Q_OBJECT public: CompressedReader(QObject *parent = 0); + /*! + Creates new compressed reader and open file with passed filename + */ CompressedReader(QString filename, QObject *parent = 0); + /*! + Destructs object and closing file + */ ~CompressedReader(); + /*! + Reads translations text from compressed dict file. + \param offset 32-bit offset of translation in uncompressed file, readed + from idx file + \param len length of uncompressed translation, readed from idx file too + */ QString readString(qint32 offset, qint32 len); + + /*! + Reads translations text from compressed dict file. + \param offset 64-bit offset of translation in uncompressed file, readed + from idx file + \param len length of uncompressed translation, readed from idx file too + */ QString readString(qint64 offset, qint32 len); - QChar readChar(); + + /*! + Reads 32-bits integer value from compressed file and convert it from + BigEndian to Little Endian + */ qint32 readInt32BigEndian(); + + /*! + Reads 64-bits integer value from compressed file and convert it from + BigEndian to Little Endian + */ qint64 readInt64BigEndian(); + + /*! + Reads single string from compressed file, end of string is marked as '\0' + in file. + */ QString readKeyword(); - bool open(QString file); + + + /*! + Closing file; + */ void close(); + +protected: + /*! + Opens file + \returns true if file is opened or false otherwise + */ + bool open(QString file); + + /*! + Reads single char from compressed. + */ + QChar readChar(); + private: gzFile _file; }; diff --git a/src/plugins/stardict/StarDictReader.h b/src/plugins/stardict/StarDictReader.h index 9e1ddf6..035d5e5 100644 --- a/src/plugins/stardict/StarDictReader.h +++ b/src/plugins/stardict/StarDictReader.h @@ -19,27 +19,74 @@ *******************************************************************************/ -//Created by Mateusz Półrola +/*! + \author Mateusz Półrola + */ #ifndef STARDICTREADER_H #define STARDICTREADER_H #include +/*! + Abstract class used for reading stardict dict and idx files. + It allows to read all necessary data types used in parsing stardict files. + */ class StarDictReader : public QObject { Q_OBJECT public: StarDictReader(QObject *parent = 0) : QObject(parent) {} virtual ~StarDictReader() {} + /*! + Reads translations text from dict file. + \param offset 32-bit offset of translation in file, readed from idx file + \param len length of translation, readed from idx file too + */ virtual QString readString(qint32 offset, qint32 len)=0; + + /*! + Reads translations text from dict file. + \param offset 64-bit offset of translation in file, readed from idx file + \param len length of translation, readed from idx file too + */ virtual QString readString(qint64 offset, qint32 len)=0; - virtual QChar readChar()=0; + + /*! + Reads 32-bits integer value from file and convert it from BigEndian + to Little Endian + */ virtual qint32 readInt32BigEndian()=0; + + /*! + Reads 64-bits integer value from file and convert it from BigEndian + to Little Endian + */ virtual qint64 readInt64BigEndian()=0; + + /*! + Reads single string from file, end of string is marked as '\0' in file. + */ virtual QString readKeyword()=0; - virtual bool open(QString file)=0; + + + /*! + Closing file; + */ virtual void close()=0; + +protected: + /*! + Opens file + \returns true if file is opened or false otherwise + */ + virtual bool open(QString file)=0; + + /*! + Reads single char from file. + */ + virtual QChar readChar()=0; + }; #endif // STARDICTREADER_H diff --git a/src/plugins/stardict/StarDictReaderFactory.h b/src/plugins/stardict/StarDictReaderFactory.h index e5f5e93..a6e12e3 100644 --- a/src/plugins/stardict/StarDictReaderFactory.h +++ b/src/plugins/stardict/StarDictReaderFactory.h @@ -25,9 +25,14 @@ #define STARDICTREADERFACTORY_H #include "StarDictReader.h" +/*! + Class used to creating StarDictReader objects, based on filename it creates + compressed or uncompressed reader. + */ class StarDictReaderFactory { public: + //! Creates new StarDictReader suitable for passed file static StarDictReader* createReader(QString file); }; diff --git a/src/plugins/stardict/UncompressedReader.h b/src/plugins/stardict/UncompressedReader.h index eeb8582..462e08d 100644 --- a/src/plugins/stardict/UncompressedReader.h +++ b/src/plugins/stardict/UncompressedReader.h @@ -30,23 +30,78 @@ #include #include "StarDictReader.h" + +/*! + Class implementing StarDictReader interface and handling rading from uncompressed files + */ class UncompressedReader : public StarDictReader { Q_OBJECT public: UncompressedReader(QObject *parent = 0); + + /*! + Creates new reader and open file with passed filename + */ UncompressedReader(QString filename, QObject *parent = 0); + + /*! + Destructs object and closing file + */ ~UncompressedReader(); + /*! + Reads translations text from file + \param offset 32-bit offset of translation in file, readed + from idx file + \param len length of translation, readed from idx file too + */ QString readString(qint32 offset, qint32 len); + + /*! + Reads translations text from file + \param offset 64-bit offset of translation in file, readed + from idx file + \param len length of translation, readed from idx file too + */ QString readString(qint64 offset, qint32 len); - QChar readChar(); + + /*! + Reads 32-bits integer value from file and convert it from + BigEndian to Little Endian + */ qint32 readInt32BigEndian(); + + /*! + Reads 64-bits integer value from file and convert it from + BigEndian to Little Endian + */ qint64 readInt64BigEndian(); + + /*! + Reads single string from file, end of string is marked as '\0' + in file. + */ QString readKeyword(); - bool open(QString file); + + + /*! + Closing file; + */ void close(); +protected: + /*! + Opens file + \returns true if file is opened or false otherwise + */ + bool open(QString file); + + /*! + Reads single char from compressed. + */ + QChar readChar(); + private: QFile _file; QDataStream _stream; -- 1.7.9.5