LCOV - code coverage report
Current view: top level - src/parser - SitemapParser.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 100.0 % 3 3
Test Date: 2026-03-23 10:19:47 Functions: 100.0 % 3 3

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

Generated by: LCOV version 2.0-1