VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Table.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <sqlpp23/sqlpp23.h>
4
#include <type_traits>
5
6
namespace
VoltMod
7
{
8
9
/** @p HasDefault argument of @ref VOLTMOD_COLUMN: the insert may leave this column out. */
10
using
HasDefault
= std::true_type;
11
12
/** @p HasDefault argument of @ref VOLTMOD_COLUMN: every insert must supply this column. */
13
using
Required
= std::false_type;
14
15
}
// namespace VoltMod
16
17
/**
18
* @brief Declare one column of a sqlpp23 table spec.
19
*
20
* @p Member is the C++ member name, @p SqlName the unquoted column name, @p DataType a sqlpp23
21
* data type (wrap it in `std::optional` when the column is nullable), and @p HasDefault
22
* @ref VoltMod::HasDefault or @ref VoltMod::Required.
23
*
24
* Most tables are generated from the schema by `sqlpp23-ddl2cpp`; reach for this only when
25
* hand-writing a spec.
26
*
27
* @code
28
* struct Bans_
29
* {
30
* VOLTMOD_COLUMN(id, id, sqlpp::integral, VoltMod::HasDefault);
31
* VOLTMOD_COLUMN(steamId, steam_id, sqlpp::integral, VoltMod::Required);
32
* VOLTMOD_COLUMN(reason, reason, std::optional<sqlpp::text>, VoltMod::HasDefault);
33
*
34
* SQLPP_CREATE_NAME_TAG_FOR_SQL_AND_CPP(bans, bans);
35
* template <typename T>
36
* using _table_columns = sqlpp::table_columns<T, id, steamId, reason>;
37
* using _required_insert_columns = sqlpp::detail::type_set<sqlpp::column_t<sqlpp::table_t<Bans_>, steamId>>;
38
* };
39
* using Bans = sqlpp::table_t<Bans_>;
40
* @endcode
41
*/
42
#define VOLTMOD_COLUMN(Member, SqlName, DataType, HasDefault) \
43
struct Member \
44
{ \
45
SQLPP_CREATE_NAME_TAG_FOR_SQL_AND_CPP(SqlName, Member); \
46
using data_type = DataType; \
47
using has_default = HasDefault; \
48
}
VoltMod
Definition
Options.hpp:13
VoltMod::HasDefault
std::true_type HasDefault
Definition
Table.hpp:10
VoltMod::Required
std::false_type Required
Definition
Table.hpp:13
include
VoltMod
Database
Table.hpp
Generated by
1.9.8