Lightweight
0.1.0
Loading...
Searching...
No Matches
SqlRealName.hpp
1
// SPDX-License-Identifier: Apache-2.0
2
#pragma once
3
4
#include <algorithm>
5
#include <string_view>
6
7
/// @brief Helper class, used to represent a real SQL column names as template arguments.
8
///
9
/// @see Field, BelongsTo
10
template
<
size_t
N>
11
struct
SqlRealName
12
{
13
static
constexpr
size_t
length = (N > 0) ? (N - 1) : 0;
14
15
[[nodiscard]]
constexpr
size_t
size()
const
noexcept
16
{
17
return
length;
18
}
19
20
constexpr
~SqlRealName
()
noexcept
=
default
;
21
constexpr
SqlRealName
()
noexcept
=
default
;
22
constexpr
SqlRealName
(
SqlRealName
const
&)
noexcept
=
default
;
23
constexpr
SqlRealName
(
SqlRealName
&&)
noexcept
=
default
;
24
constexpr
SqlRealName
& operator=(
SqlRealName
const
&)
noexcept
=
default
;
25
constexpr
SqlRealName
& operator=(
SqlRealName
&&)
noexcept
=
default
;
26
27
constexpr
SqlRealName
(
char
const
(&str)[N])
noexcept
28
{
29
std::copy_n(str, N, value);
30
}
31
32
char
value[N] {};
33
34
[[nodiscard]]
constexpr
bool
empty()
const
noexcept
35
{
36
return
length == 0;
37
}
38
39
[[nodiscard]]
constexpr
char
const
* begin()
const
noexcept
40
{
41
return
value;
42
}
43
44
[[nodiscard]]
constexpr
char
const
* end()
const
noexcept
45
{
46
return
value + length;
47
}
48
49
[[nodiscard]]
constexpr
auto
operator<=>(
const
SqlRealName
&)
const
=
default
;
50
51
[[nodiscard]]
constexpr
std::string_view sv()
const
noexcept
52
{
53
return
{ value, length };
54
}
55
56
[[nodiscard]]
constexpr
operator
std::string_view()
const
noexcept
57
{
58
return
{ value, length };
59
}
60
};
61
SqlRealName
Helper class, used to represent a real SQL column names as template arguments.
Definition
SqlRealName.hpp:12
Lightweight
SqlRealName.hpp
Generated by
1.9.8