VSQLite++
0.3
Toggle main menu visibility
Loading...
Searching...
No Matches
include
sqlite
detail
type_helpers.hpp
Go to the documentation of this file.
1
/*##############################################################################
2
VSQLite++ - virtuosic bytes SQLite3 C++ wrapper
3
4
Copyright (c) 2006-2024 Vinzenz Feenstra
5
and contributors
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without modification,
9
are permitted provided that the following conditions are met:
10
11
* Redistributions of source code must retain the above copyright notice,
12
this list of conditions and the following disclaimer.
13
* Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
* Neither the name of virtuosic bytes nor the names of its contributors may
17
be used to endorse or promote products derived from this software without
18
specific prior written permission.
19
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
POSSIBILITY OF SUCH DAMAGE.
31
32
##############################################################################*/
33
#ifndef GUARD_SQLITE_DETAIL_TYPE_HELPERS_HPP_INCLUDED
34
#define GUARD_SQLITE_DETAIL_TYPE_HELPERS_HPP_INCLUDED
35
36
#include <chrono>
37
#include <optional>
38
#include <span>
39
#include <string_view>
40
#include <tuple>
41
#include <type_traits>
42
#include <vector>
43
44
namespace
sqlite
{
45
inline
namespace
v2
{
46
namespace
detail
{
47
48
template
<
typename
T>
inline
constexpr
bool
always_false_v
=
false
;
49
50
template
<
typename
T>
struct
always_false
: std::false_type {};
51
52
template
<
typename
T>
using
decay_t
= std::remove_cvref_t<T>;
53
54
template
<
typename
T>
inline
constexpr
bool
is_optional_v
=
false
;
55
56
template
<
typename
T>
inline
constexpr
bool
is_optional_v<std::optional<T>
> =
true
;
57
58
template
<
typename
T>
struct
optional_value
{
59
using
type
= T;
60
};
61
62
template
<
typename
T>
struct
optional_value
<std::optional<T>> {
63
using
type
= T;
64
};
65
66
template
<
typename
T>
inline
constexpr
bool
is_duration_v
=
false
;
67
68
template
<
typename
Rep,
typename
Period>
69
inline
constexpr
bool
is_duration_v<std::chrono::duration<Rep, Period>
> =
true
;
70
71
template
<
typename
T>
inline
constexpr
bool
is_time_point_v
=
false
;
72
73
template
<
typename
Clock,
typename
Duration>
74
inline
constexpr
bool
is_time_point_v<std::chrono::time_point<Clock, Duration>
> =
true
;
75
76
template
<
typename
T>
77
inline
constexpr
bool
is_string_like_v
= std::is_convertible_v<T, std::string_view>;
78
79
template
<
typename
T>
80
inline
constexpr
bool
is_byte_vector_v
=
81
std::is_same_v<decay_t<T>, std::vector<unsigned char>>;
82
83
template
<
typename
T>
84
inline
constexpr
bool
is_unsigned_char_span_v
=
85
std::is_same_v<decay_t<T>, std::span<const unsigned char>>;
86
87
template
<
typename
T>
88
inline
constexpr
bool
is_byte_span_v
=
89
std::is_same_v<decay_t<T>, std::span<const std::byte>>;
90
91
template
<
typename
T>
92
inline
constexpr
bool
needs_generic_binding_v
=
93
is_optional_v<decay_t<T>
> ||
is_duration_v<decay_t<T>
> ||
is_time_point_v<decay_t<T>
> ||
94
std::is_enum_v<decay_t<T>>;
95
96
template
<
typename
... Ts>
struct
pack_size
;
97
98
template
<
typename
... Ts>
99
struct
pack_size
<std::tuple<Ts...>> : std::integral_constant<std::size_t, sizeof...(Ts)> {};
100
101
}
// namespace detail
102
}
// namespace v2
103
}
// namespace sqlite
104
105
#endif
// GUARD_SQLITE_DETAIL_TYPE_HELPERS_HPP_INCLUDED
sqlite::detail
Definition
type_helpers.hpp:46
sqlite::v2::detail::decay_t
std::remove_cvref_t< T > decay_t
Definition
type_helpers.hpp:52
sqlite::v2::detail::needs_generic_binding_v
constexpr bool needs_generic_binding_v
Definition
type_helpers.hpp:92
sqlite::v2::detail::is_time_point_v
constexpr bool is_time_point_v
Definition
type_helpers.hpp:71
sqlite::v2::detail::is_byte_vector_v
constexpr bool is_byte_vector_v
Definition
type_helpers.hpp:80
sqlite::v2::detail::is_optional_v
constexpr bool is_optional_v
Definition
type_helpers.hpp:54
sqlite::v2::detail::is_unsigned_char_span_v
constexpr bool is_unsigned_char_span_v
Definition
type_helpers.hpp:84
sqlite::v2::detail::always_false_v
constexpr bool always_false_v
Definition
type_helpers.hpp:48
sqlite::v2::detail::is_string_like_v
constexpr bool is_string_like_v
Definition
type_helpers.hpp:77
sqlite::v2::detail::is_duration_v
constexpr bool is_duration_v
Definition
type_helpers.hpp:66
sqlite::v2::detail::is_byte_span_v
constexpr bool is_byte_span_v
Definition
type_helpers.hpp:88
sqlite::v2
Definition
backup.hpp:18
sqlite
Definition
backup.hpp:17
sqlite::v2::detail::always_false
Definition
type_helpers.hpp:50
sqlite::v2::detail::optional_value< std::optional< T > >::type
T type
Definition
type_helpers.hpp:63
sqlite::v2::detail::optional_value
Definition
type_helpers.hpp:58
sqlite::v2::detail::optional_value::type
T type
Definition
type_helpers.hpp:59
sqlite::v2::detail::pack_size
Definition
type_helpers.hpp:96
Generated by
1.17.0