Added comments for StarDictReaders
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 5 Oct 2010 12:50:37 +0000 (14:50 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 5 Oct 2010 12:50:37 +0000 (14:50 +0200)
src/plugins/stardict/CompressedReader.h
src/plugins/stardict/StarDictReader.h
src/plugins/stardict/StarDictReaderFactory.h
src/plugins/stardict/UncompressedReader.h

index d4fe10b..ab5caba 100644 (file)
 #include <zlib.h>
 #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;
 };
index 9e1ddf6..035d5e5 100644 (file)
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+/*!
+    \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+ */
 
 #ifndef STARDICTREADER_H
 #define STARDICTREADER_H
 
 #include <QObject>
 
+/*!
+  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
index e5f5e93..a6e12e3 100644 (file)
 #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);
 };
 
index eeb8582..462e08d 100644 (file)
 #include <QString>
 #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;