From 4975721a5cc360a223cdfff15853e5d3e6d9bb66 Mon Sep 17 00:00:00 2001 From: blue Date: Fri, 14 Apr 2023 11:44:46 -0300 Subject: [PATCH] 0.3.1 fix qt5 build, exception docs --- CHANGELOG.md | 18 +++++++++ CMakeLists.txt | 2 +- packaging/Archlinux/PKGBUILD | 6 +-- src/exceptions.h | 75 ++++++++++++++++++++++++++++++++++-- src/operators.hpp | 32 +++++++-------- 5 files changed, 111 insertions(+), 22 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a0c3db7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +## LMDBAL 0.3.1 (April 14, 2023) +### Bug fixes +- build with qt5 now is possible again + +### Improvements +- exception documentation + +## LMDBAL 0.3.0 (April 12, 2023) +### New features +- transaction functions + +### Improvements +- initial documentation +- cache unit testing +- transactions unit testing +- serialization unit testing diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d719ce..81c12f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) project(LMDBAL - VERSION 0.3.0 + VERSION 0.3.1 DESCRIPTION "LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer" LANGUAGES CXX ) diff --git a/packaging/Archlinux/PKGBUILD b/packaging/Archlinux/PKGBUILD index f5d1431..63457c6 100644 --- a/packaging/Archlinux/PKGBUILD +++ b/packaging/Archlinux/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Yury Gubich pkgname=lmdbal -pkgver=0.3.0 +pkgver=0.3.1 pkgrel=1 pkgdesc="LMDB Abstraction Layer, qt5 version" arch=('i686' 'x86_64') @@ -11,7 +11,7 @@ makedepends=('cmake>=3.16') optdepends=() source=("$pkgname-$pkgver.tar.gz::https://git.macaw.me/blue/lmdbal/archive/$pkgver.tar.gz") -sha256sums=('SKIP') +sha256sums=('df1a9687d81d609d160754285f2613d7e07fc6deb781d0fb0084e4857ea82e95') build() { cd "$srcdir/$pkgname" cmake . -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_BUILD_TYPE=Release -D QT_VERSION_MAJOR=5 @@ -19,5 +19,5 @@ build() { } package() { cd "$srcdir/$pkgname" - cmake --install . --prefix $pkgdir/ + DESTDIR="$pkgdir/" cmake --install . } diff --git a/src/exceptions.h b/src/exceptions.h index 88eb510..c583c9b 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -25,18 +25,29 @@ namespace LMDBAL { +/** + * \brief Parent abstract class for all LMDBAL exceptions + */ class Exception : public std::exception { public: Exception(); virtual ~Exception(); - virtual std::string getMessage() const = 0; + virtual std::string getMessage() const = 0; /**<\brief returns exception message*/ - const char* what() const noexcept( true ); + const char* what() const noexcept( true ) override; }; +/** + * \brief Thrown if LMDBAL had issues creating or opening database directory + */ class Directory: public Exception { public: + /** + * \brief Creates exception + * + * \param path - path of the directory that was supposed to be used to store the database + */ Directory(const std::string& path); std::string getMessage() const; @@ -44,9 +55,19 @@ private: std::string path; }; +/** + * \brief Thrown if something in the database was called on closed state and it is not supported + */ class Closed : public Exception { public: - Closed(const std::string& p_operation, const std::string& dbName, const std::optional& tableName = std::nullopt); + /** + * \brief Creates exception + * + * \param operation - text name of the method that was called on closed database + * \param dbName - name of the database + * \param tableName - name of the storage which called that method, abscent if it's untracable or if it's thrown by the database + */ + Closed(const std::string& operation, const std::string& dbName, const std::optional& tableName = std::nullopt); std::string getMessage() const; private: @@ -55,8 +76,17 @@ private: std::optional tableName; }; +/** + * \brief Thrown if something in the database was called on opened state and it is not supported + */ class Opened : Exception { public: + /** + * \brief Creates exception + * + * \param action - text name of the method that was called on opened database + * \param dbName - name of the database + */ Opened(const std::string& dbName, const std::string& action); std::string getMessage() const; @@ -65,8 +95,18 @@ private: std::string action; }; +/** + * \brief Thrown if something in the database was not found + */ class NotFound : public Exception { public: + /** + * \brief Creates exception + * + * \param key - record key that was not found + * \param dbName - name of the database + * \param tableName - name of the storage that was looked for a record + */ NotFound(const std::string& key, const std::string& dbName, const std::string& tableName); std::string getMessage() const; @@ -76,8 +116,17 @@ private: std::string tableName; }; +/** + * \brief Thrown if there was attempt to define storages with conflicting names + */ class StorageDuplicate : public Exception { public: + /** + * \brief Creates exception + * + * \param dbName - name of the database + * \param tableName - that name that was conflicting + */ StorageDuplicate(const std::string& dbName, const std::string& tableName); std::string getMessage() const; @@ -86,8 +135,18 @@ private: std::string tableName; }; +/** + * \brief Thrown if there was a key conflict in one of the storages + */ class Exist : public Exception { public: + /** + * \brief Creates exception + * + * \param key - record key that caused the conflict + * \param dbName - name of the database + * \param tableName - name of the storage that was operated with + */ Exist(const std::string& key, const std::string& dbName, const std::string& tableName); std::string getMessage() const; @@ -97,8 +156,18 @@ private: std::string tableName; }; +/** + * \brief Thrown if something unexpected happened + */ class Unknown : public Exception { public: + /** + * \brief Creates exception + * + * \param message - text description of the error, most of the times contains the result of mdb_strerror + * \param dbName - name of the database + * \param tableName - name of the storage that was operated with, abscent if the operation was with the database itself + */ Unknown(const std::string& dbName, const std::string& message, const std::optional& tableName = std::nullopt); std::string getMessage() const; diff --git a/src/operators.hpp b/src/operators.hpp index 8adea66..80353ac 100644 --- a/src/operators.hpp +++ b/src/operators.hpp @@ -75,21 +75,23 @@ QDataStream& operator >> (QDataStream &in, std::multimap& container) { return in; } -// template -// QDataStream& operator << (QDataStream &out, const std::pair& pair) { -// out << pair.first; -// out << pair.second; -// -// return out; -// } -// -// template -// QDataStream& operator >> (QDataStream &in, std::pair& container) { -// in >> container.first; -// in >> container.second; -// -// return in; -// } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +template +QDataStream& operator << (QDataStream &out, const std::pair& pair) { + out << pair.first; + out << pair.second; + + return out; +} + +template +QDataStream& operator >> (QDataStream &in, std::pair& container) { + in >> container.first; + in >> container.second; + + return in; +} +#endif template QDataStream& operator << (QDataStream &out, const std::set& container) {