File indexing completed on 2024-04-28 07:36:27

0001 /*
0002  * create a KEduVocDocument from a Pauker file
0003  * SPDX-FileCopyrightText: 2004, 2007 Peter Hedlund <peter.hedlund@kdemail.net>
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KEDUVOCPAUKERREADER_H
0008 #define KEDUVOCPAUKERREADER_H
0009 
0010 #include "keduvocdocument.h"
0011 #include "readerbase.h"
0012 #include <QXmlStreamReader>
0013 
0014 class QIODevice;
0015 class KEduVocDocument;
0016 
0017 /**  @brief Reader for the Pauker format*/
0018 class KEduVocPaukerReader : public ReaderBase, private QXmlStreamReader
0019 {
0020 public:
0021     /** constructor
0022      @param file an device open for read
0023     */
0024     explicit KEduVocPaukerReader(QIODevice &file);
0025     /**destructor*/
0026     ~KEduVocPaukerReader() override{};
0027 
0028     /** @brief Can this reader parse this file
0029      *
0030      Read a small portion of the header of the file
0031      and decide if it is a suitable type.
0032      @return true if parsable
0033      */
0034     bool isParsable() Q_DECL_OVERRIDE;
0035 
0036     /** @brief returns the KEduVocDocument::FileType that this reader handles
0037         @return KEduVocDocument::FileType handled
0038      */
0039     KEduVocDocument::FileType fileTypeHandled() Q_DECL_OVERRIDE;
0040 
0041     /**  @brief Parse file and write into doc
0042      @param doc to be written
0043      @return error status of the read.*/
0044     KEduVocDocument::ErrorCode read(KEduVocDocument &doc) Q_DECL_OVERRIDE;
0045 
0046     /** an error message.
0047         @return the error message
0048     */
0049     QString errorMessage() const Q_DECL_OVERRIDE;
0050 
0051 private:
0052     /** Skip unknown tags*/
0053     void readUnknownElement();
0054     /** Read Pauker tag*/
0055     void readPauker();
0056     /** Read a batch tag*/
0057     void readBatch();
0058     /** Read a card tag*/
0059     void readCard();
0060     /** Read a Text tag
0061      @return the tag */
0062     QString readText();
0063 
0064     KEduVocDocument *m_doc; ///< output doc
0065     QIODevice &m_dev; ///< input device/file
0066 };
0067 
0068 #endif