/* * This file is part of smolbote. It's copyrighted by the contributors recorded * in the version control history of the file, available from its original * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote * * SPDX-License-Identifier: GPL-3.0 */ #ifndef BOOKMARKFORMAT_H #define BOOKMARKFORMAT_H #include "bookmarkmodel.h" class QIODevice; enum BookmarkFormats { XbelFormat, FirefoxJsonFormat }; template class BookmarkFormat { public: explicit BookmarkFormat(QIODevice *device) { Q_CHECK_PTR(m_device); m_device = device; } ~BookmarkFormat() { m_device->close(); } void read(BookmarkItem *root) const; void write(BookmarkItem *root); protected: QIODevice *m_device; }; template void operator<<(BookmarkModel *model, const BookmarkFormat &format) { format.read(model->root()); } template void operator>>(const BookmarkFormat &format, BookmarkModel *model) { format.read(model->root()); } template void operator<<(BookmarkFormat &format, BookmarkModel *model) { format.write(model->root()); model->resetModified(); } template void operator>>(BookmarkModel *model, BookmarkFormat &format) { format.write(model->root()); model->resetModified(); } #endif // BOOKMARKSFORMAT_H