LCOV - code coverage report
Current view: top level - src/parser - NewsParser.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 0.0 % 3 0
Test Date: 2026-01-27 22:31:25 Functions: 0.0 % 3 0

            Line data    Source code
       1              : #ifndef PARSER_H
       2              : #define PARSER_H
       3              : 
       4              : #include <QObject>
       5              : 
       6              : #include <QString>
       7              : #include <QNetworkReply>
       8              : #include <QThread>
       9              : 
      10              : #include "../network/FangNetworkAccessManager.h"
      11              : #include "ParserInterface.h"
      12              : 
      13              : // PaRSSes RSS/Atom feeds into RawFeed/RawNews objects.
      14              : class NewsParser : public ParserInterface
      15              : {
      16              :     Q_OBJECT
      17              :     
      18              : public:
      19              :     explicit NewsParser(QObject *parent = nullptr);
      20              :     virtual ~NewsParser();
      21              :     
      22              : public slots:
      23              :     virtual void parse(const QUrl& url, bool noParseIfCached = false); // Override.
      24              :     
      25              :     // For testing purposes.
      26              :     void parseFile(const QString& filename);
      27              :     
      28              :     virtual ParseResult getResult(); // Override.
      29            0 :     virtual QNetworkReply::NetworkError getNetworkError() { return networkError; }
      30              :     virtual RawFeed* getFeed(); // Override.
      31            0 :     virtual inline QUrl getURL() { return finalFeedURL; } // Override.
      32              :     
      33            0 :     virtual bool isFromCache() { return fromCache; } // Override
      34              :     
      35              :     // These are used internally.
      36              : signals:
      37              :     
      38              :     // Call this prior to adding XML.
      39              :     void triggerDocStart();
      40              :     
      41              :     // Call this when you're done adding XML.
      42              :     void triggerDocEnd();
      43              :     
      44              :     // Add a blurb of XML to parse.
      45              :     void triggerAddXML(QByteArray data);
      46              :     
      47              : protected slots:
      48              :     void readyRead();
      49              :     void metaDataChanged();
      50              :     void error(QNetworkReply::NetworkError);
      51              :     void netFinished(QNetworkReply *reply);
      52              :     
      53              :     // When the worker thread thinks the document is complete, or an error occured.
      54              :     void workerDone(RawFeed* rawFeed);
      55              :     
      56              : private:
      57              :     void initParse(const QUrl& url = QUrl("")); // called prior to parse.
      58              :     
      59              :     RawFeed* feed;
      60              :     ParseResult result;
      61              :     QNetworkReply::NetworkError networkError;
      62              :     
      63              :     FangNetworkAccessManager manager;
      64              :     QNetworkReply *currentReply;
      65              :     QUrl finalFeedURL;
      66              :     QNetworkReply *redirectReply;
      67              :     
      68              :     bool fromCache;
      69              :     bool noParseIfCached;
      70              :     
      71              :     QThread workerThread;
      72              : };
      73              : 
      74              : #endif // PARSER_H
        

Generated by: LCOV version 2.0-1