diff options
| author | Nikita Kostovsky <nikita@kostovsky.me> | 2025-06-22 16:54:02 +0200 |
|---|---|---|
| committer | Nikita Kostovsky <nikita@kostovsky.me> | 2025-06-22 16:54:02 +0200 |
| commit | f674e179d602d3ccb9818d28fe06f371059449dc (patch) | |
| tree | 996fb624986512de91581a18332f004d34220ba2 /src/atomitem.h | |
parse and insert feeds and items
Diffstat (limited to 'src/atomitem.h')
| -rw-r--r-- | src/atomitem.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/atomitem.h b/src/atomitem.h new file mode 100644 index 0000000..39917b5 --- /dev/null +++ b/src/atomitem.h @@ -0,0 +1,66 @@ +#pragma once + +#include <QDateTime> +#include <QDebug> +#include <QString> +#include <QUrl> + +class QXmlStreamReader; + +class AtomChannel; + +struct AtomGuid : public QString +{ + using QString::QString; + + // NOTE: unused + bool isPermalink{false}; +}; + +class AtomItem +{ +public: + // TODO: move to interface + static inline const QString tag{"item"}; + +public: + explicit AtomItem(QXmlStreamReader *xmlReader); + +public: + /*! + * \brief getDbId - check if item with corresponding `link` exists in db + * and return db id if any + * \return id on success, 0 otherwise + */ + int getDbId(); + + /*! + * \brief createInDb - create item in db + * \return new item id on success, 0 otherwise + */ + int createInDb(const int feedId); + + /*! + * \brief getOrInsertDbId - get existing item id or try to create a new + * item and get its id + * \return existing or new item id on success, 0 otherwise + */ + int getOrInsertDbId(const int feedId); + +public: + /*! + * \brief dbId - cache db id + */ + int dbId{0}; + + QString title; + QUrl link; + QString author; + QStringList categories; + AtomGuid guid; + QDateTime pubDate; + QString description; + QString encoded; +}; + +QDebug operator<<(QDebug debug, const AtomItem &item); |
