ThinSQLite++
A thin, safe and convenient modern C++ wrapper for 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/main/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{
22#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 10, 0) && THINSQLITEPP_ENABLE_EXPIREMENTAL
23
24
41 class snapshot final : public handle<sqlite3_snapshot, snapshot>
42 {
43 public:
45 ~snapshot() noexcept
47
48
54 friend int compare(const snapshot & lhs, const snapshot & rhs) noexcept
55 { return sqlite3_snapshot_cmp(lhs.c_ptr(), rhs.c_ptr()); }
56
57 friend bool operator==(const snapshot & lhs, const snapshot & rhs) noexcept
58 { return compare(lhs, rhs) == 0; }
59 friend bool operator!=(const snapshot & lhs, const snapshot & rhs) noexcept
60 { return compare(lhs, rhs) != 0; }
61
62 #if defined(DOXYGEN) || __cpp_impl_three_way_comparison >= 201907
65 friend std::strong_ordering operator<=>(const snapshot & lhs, const snapshot & rhs) noexcept
66 { return strong_ordering_from_int(compare(lhs, rhs)); }
68 #endif
69 #if defined(DOXYGEN) || __cpp_impl_three_way_comparison < 201907
72 friend bool operator<(const snapshot & lhs, const snapshot & rhs) noexcept
73 { return compare(lhs, rhs) < 0; }
74 friend bool operator<=(const snapshot & lhs, const snapshot & rhs) noexcept
75 { return compare(lhs, rhs) <= 0; }
76 friend bool operator>(const snapshot & lhs, const snapshot & rhs) noexcept
77 { return compare(lhs, rhs) > 0; }
78 friend bool operator>=(const snapshot & lhs, const snapshot & rhs) noexcept
79 { return compare(lhs, rhs) >= 0; }
81 #endif
82 };
83
84#endif
85
87}
88
89#endif
Base functionality for all fake wrapper classes
Definition handle.hpp:27
sqlite3_snapshot * c_ptr() const noexcept
Definition handle.hpp:45
A database snapshot.
Definition snapshot_iface.hpp:42
~snapshot() noexcept
Equivalent to sqlite3_snapshot_free.
Definition snapshot_iface.hpp:45
friend int compare(const snapshot &lhs, const snapshot &rhs) noexcept
Compare the ages of two snapshots.
Definition snapshot_iface.hpp:54
ThinSQLite++ namespace.
Definition backup_iface.hpp:17
sqlite3_snapshot_cmp
sqlite3_snapshot_free