ThinSQLite++
A thin, safe and convenient modern C++ wrapper for the SQLite API.
Loading...
Searching...
No Matches
snapshot_iface.hpp
1/*
2 Copyright 2024 Eugene Gershnik
3
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://github.com/gershnik/thinsqlitepp/blob/master/LICENSE
7*/
8
9#ifndef HEADER_SQLITEPP_SNAPSHOT_IFACE_INCLUDED
10#define HEADER_SQLITEPP_SNAPSHOT_IFACE_INCLUDED
11
12#include "handle.hpp"
13#include "meta.hpp"
14
15namespace thinsqlitepp
16{
21
22#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 10, 0) && (THINSQLITEPP_ENABLE_EXPERIMENTAL || THINSQLITEPP_ENABLE_EXPIREMENTAL)
23
24
41 SQLITEPP_EXPORTED
42 class snapshot final : public handle<sqlite3_snapshot, snapshot>
43 {
44 public:
46 ~snapshot() noexcept
48
49
55 friend int compare(const snapshot & lhs, const snapshot & rhs) noexcept
56 { return sqlite3_snapshot_cmp(lhs.c_ptr(), rhs.c_ptr()); }
57
58 friend bool operator==(const snapshot & lhs, const snapshot & rhs) noexcept
59 { return compare(lhs, rhs) == 0; }
60 friend bool operator!=(const snapshot & lhs, const snapshot & rhs) noexcept
61 { return compare(lhs, rhs) != 0; }
62
63 #if defined(DOXYGEN) || __cpp_impl_three_way_comparison >= 201907
66 friend std::strong_ordering operator<=>(const snapshot & lhs, const snapshot & rhs) noexcept
67 { return strong_ordering_from_int(compare(lhs, rhs)); }
69 #endif
70 #if defined(DOXYGEN) || __cpp_impl_three_way_comparison < 201907
73 friend bool operator<(const snapshot & lhs, const snapshot & rhs) noexcept
74 { return compare(lhs, rhs) < 0; }
75 friend bool operator<=(const snapshot & lhs, const snapshot & rhs) noexcept
76 { return compare(lhs, rhs) <= 0; }
77 friend bool operator>(const snapshot & lhs, const snapshot & rhs) noexcept
78 { return compare(lhs, rhs) > 0; }
79 friend bool operator>=(const snapshot & lhs, const snapshot & rhs) noexcept
80 { return compare(lhs, rhs) >= 0; }
82 #endif
83 };
84
85#endif
86
88}
89
90#endif
sqlite3_snapshot * c_ptr() const noexcept
Definition handle.hpp:45
A database snapshot.
Definition snapshot_iface.hpp:43
~snapshot() noexcept
Equivalent to sqlite3_snapshot_free.
Definition snapshot_iface.hpp:46
friend int compare(const snapshot &lhs, const snapshot &rhs) noexcept
Compare the ages of two snapshots.
Definition snapshot_iface.hpp:55
ThinSQLite++ namespace.
Definition backup_iface.hpp:17
sqlite3_snapshot_cmp
sqlite3_snapshot_free