LCOV - code coverage report
Current view: top level - lib/FangFeedDiscovery - SitemapParser.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 100.0 % 3 3
Test Date: 2026-04-19 00:35:54 Functions: 100.0 % 3 3

            Line data    Source code
       1              : #ifndef SITEMAPPARSER_H
       2              : #define SITEMAPPARSER_H
       3              : 
       4              : #include <QByteArray>
       5              : #include <QDateTime>
       6              : #include <QList>
       7              : #include <QString>
       8              : #include <QUrl>
       9              : 
      10              : class QXmlStreamReader;
      11              : 
      12              : struct SitemapEntry {
      13              :     QUrl url;
      14              :     QDateTime lastmod;         // from <lastmod>, may be invalid
      15              :     QString newsTitle;         // from <news:title>, may be empty
      16              :     QDateTime publicationDate; // from <news:publication_date>, may be invalid
      17              :     QString language;          // from <news:language>, e.g. "en", "eng"
      18              :     QString publicationName;   // from <news:name>, e.g. "Associated Press"
      19              :     QUrl imageUrl;             // from <image:loc>, may be empty
      20              : };
      21              : 
      22              : struct SubSitemap {
      23              :     QUrl url;
      24              :     QDateTime lastmod; // may be invalid
      25              : };
      26              : 
      27              : class SitemapParser
      28              : {
      29              : public:
      30              :     enum SitemapType { UrlSet, SitemapIndex, Invalid };
      31              : 
      32              :     SitemapParser();
      33              : 
      34              :     SitemapType parse(const QString& xml);
      35              :     SitemapType parse(const QByteArray& data);
      36              : 
      37           31 :     QList<SitemapEntry> entries() const { return _entries; }
      38            4 :     QList<SubSitemap> subSitemaps() const { return _subSitemaps; }
      39            5 :     bool hasNewsEntries() const { return _hasNewsEntries; }
      40              : 
      41              : private:
      42              :     SitemapType parseImpl(QXmlStreamReader& reader);
      43              :     void parseUrlSet(QXmlStreamReader& xml);
      44              :     void parseSitemapIndex(QXmlStreamReader& xml);
      45              : 
      46              :     QList<SitemapEntry> _entries;
      47              :     QList<SubSitemap> _subSitemaps;
      48              :     bool _hasNewsEntries;
      49              : };
      50              : 
      51              : #endif // SITEMAPPARSER_H
        

Generated by: LCOV version 2.0-1