#pragma once #include #include #include #include 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 id - cache db id */ int id{0}; QString title; QUrl link; QString author; QStringList categories; AtomGuid guid; QDateTime pubDate; QString description; QString encoded; }; QDebug operator<<(QDebug debug, const AtomItem &item);