Lightweight
0.20250904.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
namespace
Lightweight
8
{
9
10
/// @brief Helper class, used to represent a real SQL column names as template arguments.
11
///
12
/// @see Field, BelongsTo
13
template
<
size_t
N>
14
struct
SqlRealName
15
{
16
static
constexpr
size_t
length = (N > 0) ? (N - 1) : 0;
17
18
[[nodiscard]]
constexpr
size_t
size()
const
noexcept
19
{
20
return
length;
21
}
22
23
constexpr
~SqlRealName
()
noexcept
=
default
;
24
constexpr
SqlRealName
()
noexcept
=
default
;
25
constexpr
SqlRealName
(
SqlRealName
const
&)
noexcept
=
default
;
26
constexpr
SqlRealName
(
SqlRealName
&&)
noexcept
=
default
;
27
constexpr
SqlRealName
& operator=(
SqlRealName
const
&)
noexcept
=
default
;
28
constexpr
SqlRealName
& operator=(
SqlRealName
&&)
noexcept
=
default
;
29
30
constexpr
SqlRealName
(
char
const
(&str)[N])
noexcept
31
{
32
std::copy_n(str, N, value);
33
}
34
35
char
value[N] {};
36
37
[[nodiscard]]
constexpr
bool
empty()
const
noexcept
38
{
39
return
length == 0;
40
}
41
42
[[nodiscard]]
constexpr
char
const
* begin()
const
noexcept
43
{
44
return
value;
45
}
46
47
[[nodiscard]]
constexpr
char
const
* end()
const
noexcept
48
{
49
return
value + length;
50
}
51
52
[[nodiscard]]
constexpr
auto
operator<=>(
SqlRealName
const
&)
const
=
default
;
53
54
// NOLINTNEXTLINE(readability-identifier-naming)
55
[[nodiscard]]
constexpr
std::string_view sv()
const
noexcept
56
{
57
return
{ value, length };
58
}
59
60
[[nodiscard]]
constexpr
operator
std::string_view()
const
noexcept
61
{
62
return
{ value, length };
63
}
64
};
65
66
}
// namespace Lightweight
Lightweight::SqlRealName
Helper class, used to represent a real SQL column names as template arguments.
Definition
SqlRealName.hpp:15
Lightweight
SqlRealName.hpp
Generated by
1.9.8