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 \author Mateusz Półrola <mateusz.polrola@comarch.pl>
26 #include "UncompressedReader.h"
30 UncompressedReader::UncompressedReader(QObject *parent) :
31 StarDictReader(parent) {
36 UncompressedReader::UncompressedReader(QString filename, QObject *parent) :
37 StarDictReader(parent) {
42 UncompressedReader::~UncompressedReader() {
48 bool UncompressedReader::open(QString file) {
49 _file.setFileName(file);
50 _stream.setDevice(&_file);
51 return _file.open(QFile::ReadOnly);
55 void UncompressedReader::close() {
60 QChar UncompressedReader::readChar() {
64 _stream.readRawData(c,1);
65 if(((unsigned char)c[0])>239)
66 _stream.readRawData(c+1,3);
67 else if(((unsigned char)c[0])>223)
68 _stream.readRawData(c+1,2);
69 else if(((unsigned char)c[0])>191)
70 _stream.readRawData(c+1,1);
71 else if(((unsigned char)c[0])>127)
72 qDebug()<<"error - starDict - read wordList from UTF-8";
74 cha=QString::fromUtf8(c);
80 QString UncompressedReader::readKeyword() {
93 QByteArray UncompressedReader::readString(qint64 offset, qint32 len) {
98 _stream.readRawData(buf, len);
100 QByteArray result(buf, len);
106 qint32 UncompressedReader::readInt32BigEndian() {
107 _stream.setByteOrder(QDataStream::BigEndian);
110 _stream.setByteOrder(QDataStream::LittleEndian);
115 qint64 UncompressedReader::readInt64BigEndian() {
116 _stream.setByteOrder(QDataStream::BigEndian);
119 _stream.setByteOrder(QDataStream::LittleEndian);