LibKEduVocDocument

failedreader.h
1/*
2 * SPDX-FileCopyrightText: 2014 Andreas Xavier <andxav at zoho dot com>
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6#ifndef FAILEDREADER_H
7#define FAILEDREADER_H
8
9#include "readerbase.h"
10
11#include <QDebug>
12
13/**
14 * @brief A fallback reader when the device can't be read or no other reader can parse.
15 @details FailedReader always returns the error message that it was initialized with
16 , unless the error code was NoError. In which case it returns Unknown.
17 *
18 * */
20{
21public:
22 /** @brief When constructed with error code FailedReader will return this error code
23 @param error the error code or defaults to Unknown
24 @param msg a custom message or defaults to \"Error while reading file\"*/
26
27 /**destructor*/
28 ~FailedReader() override {};
29
30 /** @brief Can this reader parse this file
31 *
32 Read a small portion of the header of the file
33 and decide if it is a suitable type.
34 @return true if parsable
35 */
36 bool isParsable() Q_DECL_OVERRIDE;
37
38 /** @brief returns the KEduVocDocument::FileType that this reader handles
39 @return KEduVocDocument::FileType handled
40 */
41 KEduVocDocument::FileType fileTypeHandled() Q_DECL_OVERRIDE;
42
43 /** @brief Parse file and write into doc
44 @param doc to be written
45 @return error status of the read.*/
46 KEduVocDocument::ErrorCode read(KEduVocDocument &doc) Q_DECL_OVERRIDE;
47
48 /** an error message.
49 @return the error message
50 */
51 QString errorMessage() const Q_DECL_OVERRIDE;
52
53private:
54 KEduVocDocument::ErrorCode m_error; ///< The error code to always return;
55 QString m_errorMessage; ///< The error message
56};
57
58#endif // FAILEDREADER_H
A fallback reader when the device can't be read or no other reader can parse.
~FailedReader() override
destructor
FailedReader(KEduVocDocument::ErrorCode error=KEduVocDocument::Unknown, const QString &msg=QString())
When constructed with error code FailedReader will return this error code.
QString errorMessage() const override
an error message.
KEduVocDocument::FileType fileTypeHandled() override
returns the KEduVocDocument::FileType that this reader handles
bool isParsable() override
Can this reader parse this file.
KEduVocDocument::ErrorCode read(KEduVocDocument &doc) override
Parse file and write into doc.
The primary entry point to the hierarchy of objects describing vocabularies.
ErrorCode
the return code when opening/saving
@ Unknown
unspecified error
a base class for readers of various lexicon formats
Definition readerbase.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.