File indexing completed on 2024-05-12 16:59:02

0001 /*
0002     SPDX-FileCopyrightText: 2019 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef JOBDOUBLE_H
0008 #define JOBDOUBLE_H
0009 
0010 #include <QFile>
0011 #include <QTextStream>
0012 
0013 #include <apijob.h>
0014 
0015 namespace Bugzilla
0016 {
0017 class JobDouble : public APIJob
0018 {
0019 public:
0020     using APIJob::APIJob;
0021 
0022     JobDouble(const QString &fixture)
0023         : m_fixture(fixture)
0024     {
0025     }
0026 
0027     QByteArray data() const override
0028     {
0029         Q_ASSERT(!m_fixture.isEmpty());
0030         QFile file(m_fixture);
0031         if (!file.open(QFile::ReadOnly | QFile::Text)) {
0032             return {};
0033         }
0034         QTextStream in(&file);
0035         return in.readAll().toUtf8();
0036     }
0037 
0038     QString m_fixture;
0039 };
0040 
0041 } // namespace Bugzilla
0042 
0043 #endif // JOBDOUBLE_H