ThinSQLite++
A thin, safe and convenient modern C++ wrapper for SQLite API.
Loading...
Searching...
No Matches
handle.hpp
1/*
2 Copyright 2019 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_HANDLE_INCLUDED
10#define HEADER_SQLITEPP_HANDLE_INCLUDED
11
12#include "config.hpp"
13
14namespace thinsqlitepp
15{
25 template<class T, class Derived>
26 class handle
27 {
28 public:
30 void operator delete(void *) noexcept
31 {}
32
34 handle() = delete;
36 handle(const handle &) = delete;
38 handle & operator=(const handle &) = delete;
39
41 static Derived * from(T * obj) noexcept
42 { return (Derived *)obj; }
43
45 T * c_ptr() const noexcept
46 { return (T *)this; }
47
49 friend T * c_ptr(const handle<T, Derived> & obj) noexcept
50 { return (T *)&obj; }
51
53 friend T * c_ptr(const handle<T, Derived> * obj) noexcept
54 { return (T *)obj; }
55
56 protected:
57 ~handle() noexcept
58 {}
59 };
60
61}
62
63#endif
64
Base functionality for all fake wrapper classes
Definition handle.hpp:27
friend T * c_ptr(const handle< T, Derived > &obj) noexcept
Access the real underlying SQLite type.
Definition handle.hpp:49
T * c_ptr() const noexcept
Access the real underlying SQLite type.
Definition handle.hpp:45
handle(const handle &)=delete
You cannot copy (or move) it.
handle & operator=(const handle &)=delete
You cannot assign it.
handle()=delete
You cannot construct it.
static Derived * from(T *obj) noexcept
Create fake pointer from the underlying SQLite one.
Definition handle.hpp:41
friend T * c_ptr(const handle< T, Derived > *obj) noexcept
Access the real underlying SQLite type.
Definition handle.hpp:53
ThinSQLite++ namespace.
Definition backup_iface.hpp:17