File indexing completed on 2024-04-14 03:46:37
0001 /* 0002 * create a KEduVocDocument from a XDXF file 0003 * SPDX-FileCopyrightText: 2007 Peter Hedlund <peter.hedlund@kdemail.net> 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KEDUVOCXDXFREADER_H 0008 #define KEDUVOCXDXFREADER_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 XDXF format*/ 0018 class KEduVocXdxfReader : public ReaderBase, private QXmlStreamReader 0019 { 0020 public: 0021 /** constructor 0022 @param file an device open for read 0023 */ 0024 explicit KEduVocXdxfReader(QIODevice &file); 0025 0026 /**destructor*/ 0027 ~KEduVocXdxfReader() override{}; 0028 0029 /** @brief Can this reader parse this file 0030 * 0031 Read a small portion of the header of the file 0032 and decide if it is a suitable type. 0033 @return true if parsable 0034 */ 0035 bool isParsable() Q_DECL_OVERRIDE; 0036 0037 /** @brief returns the KEduVocDocument::FileType that this reader handles 0038 @return KEduVocDocument::FileType handled 0039 */ 0040 KEduVocDocument::FileType fileTypeHandled() Q_DECL_OVERRIDE; 0041 0042 /** @brief Parse file and write into doc 0043 @param doc to be written 0044 @return error status of the read.*/ 0045 KEduVocDocument::ErrorCode read(KEduVocDocument &doc) Q_DECL_OVERRIDE; 0046 0047 /** an error message. 0048 @return the error message 0049 */ 0050 QString errorMessage() const Q_DECL_OVERRIDE; 0051 0052 private: 0053 /** Skip unknown tags */ 0054 void readUnknownElement(); 0055 /** Read xdxf tag */ 0056 void readXdxf(); 0057 /** Read ar tag which is the word pair with "<ar><k>key</k>text</ar>" format */ 0058 void readEntry(); 0059 0060 KEduVocDocument *m_doc; ///< output doc 0061 QIODevice &m_dev; ///< input device 0062 }; 0063 0064 #endif