LibKEduVocDocument

readermanager.cpp
1/*
2 * SPDX-FileCopyrightText: 2014 Andreas Xavier <andxav at zoho dot com>
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6#include "readermanager.h"
7
8#include "readerwriters/dummyreader.h"
9#include "readerwriters/failedreader.h"
10#include "readerwriters/readerbase.h"
11
12#include "readerwriters/keduvoccsvreader.h"
13#include "readerwriters/keduvockvtml2reader.h"
14#include "readerwriters/keduvocpaukerreader.h"
15#include "readerwriters/keduvocvokabelnreader.h"
16#include "readerwriters/keduvocwqlreader.h"
17#include "readerwriters/keduvocxdxfreader.h"
18
19#include <QDebug>
20
22{
23 if (!dev.isReadable()) {
24 //@todo add a useful error message
26 }
27
28 if (dev.isSequential()) {
29 //@todo add a useful error message
31 }
32
34
35 reader = ReaderPtr(new DummyReader(dev));
36 if (reader->isParsable()) {
37 return reader;
38 }
39 dev.seek(0);
40
42 if (reader->isParsable()) {
43 return reader;
44 }
45 dev.seek(0);
46
48 if (reader->isParsable()) {
49 return reader;
50 }
51 dev.seek(0);
52
54 if (reader->isParsable()) {
55 return reader;
56 }
57 dev.seek(0);
58
60 if (reader->isParsable()) {
61 return reader;
62 }
63 dev.seek(0);
64
66 if (reader->isParsable()) {
67 return reader;
68 }
69 dev.seek(0);
70
72 if (reader->isParsable()) {
73 return reader;
74 }
75 dev.seek(0);
76
78}
A dummy reader to be used in unit tests.
Definition dummyreader.h:24
A fallback reader when the device can't be read or no other reader can parse.
CSV Reader, the default reader.
@ FileTypeUnknown
unknown file type
@ FileCannotRead
unreadable file
class to read kvtml2 data files into keduvocdocument
Reader for the Pauker format.
Reader for WordQuiz files.
Reader for the XDXF format.
QSharedPointer< ReaderBase > ReaderPtr
a QSharedPointer to the ReaderBase class.
static ReaderPtr reader(QIODevice &device)
returns a reader that can read this device.
bool isReadable() const const
virtual bool isSequential() const const
virtual bool seek(qint64 pos)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.