1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 \file UncompressedReader.cpp
23 \brief Class implementing StarDictReader interface and handling
24 reading from uncompressed files
26 \author Mateusz Półrola <mateusz.polrola@comarch.pl>
29 #include "UncompressedReader.h"
33 UncompressedReader::UncompressedReader(QObject *parent) :
34 StarDictReader(parent) {
39 UncompressedReader::UncompressedReader(QString filename, QObject *parent) :
40 StarDictReader(parent) {
45 UncompressedReader::~UncompressedReader() {
51 bool UncompressedReader::open(QString file) {
52 _file.setFileName(file);
53 _stream.setDevice(&_file);
54 return _file.open(QFile::ReadOnly);
58 void UncompressedReader::close() {
63 QChar UncompressedReader::readChar() {
67 _stream.readRawData(c,1);
68 if(((unsigned char)c[0])>239)
69 _stream.readRawData(c+1,3);
70 else if(((unsigned char)c[0])>223)
71 _stream.readRawData(c+1,2);
72 else if(((unsigned char)c[0])>191)
73 _stream.readRawData(c+1,1);
74 else if(((unsigned char)c[0])>127)
75 qDebug()<<"error - starDict - read wordList from UTF-8";
77 cha=QString::fromUtf8(c);
83 QString UncompressedReader::readKeyword() {
96 QByteArray UncompressedReader::readString(qint64 offset, qint32 len) {
101 _stream.readRawData(buf, len);
103 QByteArray result(buf, len);
109 qint32 UncompressedReader::readInt32BigEndian() {
110 _stream.setByteOrder(QDataStream::BigEndian);
113 _stream.setByteOrder(QDataStream::LittleEndian);
118 qint64 UncompressedReader::readInt64BigEndian() {
119 _stream.setByteOrder(QDataStream::BigEndian);
122 _stream.setByteOrder(QDataStream::LittleEndian);