#pragma once #include #include #include #include #include "config.h" class Storage { public: Storage(const Config& config); ~Storage(); uint64_t getNumberOfDocuments(); bool exists(const std::string& id); std::string getDocument(const std::string& id); int getRevision(const std::string& id); int getCursorPos(const std::string& id); std::tuple getRow(const std::string& id); void setDocument(const std::string& id, const std::string& document); void setRevision(const std::string& id, int rev); void setCursorPos(const std::string& id, int cursorPos); void setRow(const std::string& id, const std::string& document, int rev, int cursorPos); void cleanup(); private: SQLite::Database m_db; uint64_t m_maxage; // shared_ptr to work around initialization in constructor std::shared_ptr m_stmt_create; std::shared_ptr m_stmt_getNumberOfDocuments; std::shared_ptr m_stmt_cleanup; std::shared_ptr m_stmt_exists; std::shared_ptr m_stmt_getDocument; std::shared_ptr m_stmt_getRevision; std::shared_ptr m_stmt_getCursorPos; std::shared_ptr m_stmt_getRow; std::shared_ptr m_stmt_setDocument; std::shared_ptr m_stmt_setDocument_new; std::shared_ptr m_stmt_setRevision; std::shared_ptr m_stmt_setCursorPos; std::shared_ptr m_stmt_setRow; };