Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit f30c993

Browse files
committed
Introduced a configuration header, made universally available
1 parent 99c3404 commit f30c993

20 files changed

+1366
-1324
lines changed

dev/alias.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace sqlite_orm {
1515

1616
namespace internal {
1717

18-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
18+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
1919
/*
2020
* Helper class to facilitate user-defined string literal operator template
2121
*/
@@ -126,7 +126,7 @@ namespace sqlite_orm {
126126
alias_holder() = default;
127127
};
128128

129-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
129+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
130130
template<char A, char... C>
131131
struct table_alias_builder {
132132
static_assert(sizeof...(C) == 0 && ((A >= 'A' && 'Z' <= A) || (A >= 'a' && 'z' <= A)),
@@ -158,7 +158,7 @@ namespace sqlite_orm {
158158
return {c};
159159
}
160160

161-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
161+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
162162
template<auto als,
163163
class C,
164164
class A = std::remove_const_t<decltype(als)>,
@@ -184,7 +184,7 @@ namespace sqlite_orm {
184184
return {std::move(expression)};
185185
}
186186

187-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
187+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
188188
template<auto als, class E, internal::satisfies<internal::is_column_alias, decltype(als)> = true>
189189
auto as(E expression) {
190190
return internal::as_t<std::remove_const_t<decltype(als)>, E>{std::move(expression)};
@@ -204,7 +204,7 @@ namespace sqlite_orm {
204204
return {};
205205
}
206206

207-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
207+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
208208
template<auto als, internal::satisfies<internal::is_column_alias, decltype(als)> = true>
209209
auto get() {
210210
return internal::alias_holder<std::remove_const_t<decltype(als)>>{};
@@ -274,7 +274,7 @@ namespace sqlite_orm {
274274
using colalias_h = internal::column_alias<'h'>;
275275
using colalias_i = internal::column_alias<'i'>;
276276

277-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
277+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
278278
/** @short Create aliased tables e.g. `constexpr auto z_alias = alias_<'z'>.for_<User>()`.
279279
*/
280280
template<char A>

dev/column_result.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "tuple_helper/tuple_filter.h"
1111
#include "type_traits.h"
1212
#include "member_traits/member_traits.h"
13+
#include "mapped_type_proxy.h"
1314
#include "core_functions.h"
1415
#include "select_constraints.h"
1516
#include "operators.h"

dev/conditions.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ namespace sqlite_orm {
819819
return {};
820820
}
821821

822-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
822+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
823823
/**
824824
* Explicit FROM function. Usage:
825825
* `storage.select(&User::id, from<"a"_alias.for_<User>>());`
@@ -1028,7 +1028,7 @@ namespace sqlite_orm {
10281028
return {std::move(o)};
10291029
}
10301030

1031-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
1031+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
10321032
template<auto als, class O, internal::satisfies<internal::is_recordset_alias, decltype(als)> = true>
10331033
auto left_join(O o) {
10341034
return internal::left_join_t<std::remove_const_t<decltype(als)>, O>{std::move(o)};
@@ -1040,7 +1040,7 @@ namespace sqlite_orm {
10401040
return {std::move(o)};
10411041
}
10421042

1043-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
1043+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
10441044
template<auto als, class O, internal::satisfies<internal::is_recordset_alias, decltype(als)> = true>
10451045
auto join(O o) {
10461046
return internal::join_t<std::remove_const_t<decltype(als)>, O>{std::move(o)};
@@ -1052,7 +1052,7 @@ namespace sqlite_orm {
10521052
return {std::move(o)};
10531053
}
10541054

1055-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
1055+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
10561056
template<auto als, class O, internal::satisfies<internal::is_recordset_alias, decltype(als)> = true>
10571057
auto left_outer_join(O o) {
10581058
return internal::left_outer_join_t<std::remove_const_t<decltype(als)>, O>{std::move(o)};
@@ -1064,7 +1064,7 @@ namespace sqlite_orm {
10641064
return {std::move(o)};
10651065
}
10661066

1067-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
1067+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
10681068
template<auto als, class O, internal::satisfies<internal::is_recordset_alias, decltype(als)> = true>
10691069
auto inner_join(O o) {
10701070
return internal::inner_join_t<std::remove_const_t<decltype(als)>, O>{std::move(o)};

dev/functional/config.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include "cxx_universal.h"
4+
5+
#if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && defined(SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED) && \
6+
defined(SQLITE_ORM_INLINE_VARIABLES_SUPPORTED)
7+
#define SQLITE_ORM_WITH_CPP20_ALIASES
8+
#endif

dev/functional/cxx_compiler_quirks.h

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#pragma once
22

3+
/*
4+
* This header defines macros for circumventing compiler quirks on which sqlite_orm depends.
5+
* May amend cxx_core_features.h
6+
*/
7+
38
#ifdef __clang__
49
#define SQLITE_ORM_DO_PRAGMA(...) _Pragma(#__VA_ARGS__)
510
#endif

dev/functional/cxx_core_features.h

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#pragma once
22

3+
/*
4+
* This header detects core C++ language features on which sqlite_orm depends.
5+
* May be updated/overwritten by cxx_compiler_quirks.h
6+
*/
7+
38
#ifdef __has_cpp_attribute
49
#define SQLITE_ORM_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr)
510
#else

dev/functional/cxx_universal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This header makes central C++ functionality on which sqlite_orm depends universally available:
55
* - alternative operator representations
66
* - ::size_t, ::ptrdiff_t, ::nullptr_t
7-
* - C++ core feature macros
7+
* - C++ core language feature macros
88
* - macros for dealing with compiler quirks
99
*/
1010

dev/get_prepared_statement.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#pragma once
22

33
#include <type_traits> // std::is_same, std::decay, std::remove_reference
4+
#include <tuple> // std::get
45

6+
#include "functional/cxx_universal.h" // ::size_t
57
#include "functional/static_magic.h"
68
#include "prepared_statement.h"
79
#include "ast_iterator.h"
10+
#include "node_tuple.h"
811
#include "expression_object_type.h"
912

1013
namespace sqlite_orm {

dev/select_constraints.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ namespace sqlite_orm {
409409
return {definedOrder};
410410
}
411411

412-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
412+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
413413
template<auto als, internal::satisfies<internal::is_recordset_alias, decltype(als)> = true>
414414
auto asterisk(bool definedOrder = false) {
415415
return internal::asterisk_t<std::remove_const_t<decltype(als)>>{definedOrder};

examples/column_aliases.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void marvel_hero_ordered_by_o_pos() {
5858
}
5959
}
6060
cout << endl;
61-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
61+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
6262
{
6363
// SELECT name, instr(abilities, 'o') i
6464
// FROM marvel

examples/custom_aliases.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int main(int, char** argv) {
104104
// SELECT C.ID, C.NAME, C.AGE, D.DEPT
105105
// FROM COMPANY AS C, DEPARTMENT AS D
106106
// WHERE C.ID = D.EMP_ID;
107-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
107+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
108108
constexpr auto c_als = "c"_alias.for_<Employee>();
109109
constexpr auto d = "d"_alias.for_<Department>();
110110
static_assert(std::is_empty_v<EmployeeIdAlias>);

examples/exists.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int main(int, char**) {
475475
// )
476476
// ORDER BY 'c'."PAYMENT_AMT"
477477

478-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
478+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
479479
constexpr auto c_als = "c"_alias.for_<Customer>();
480480
constexpr auto d = "d"_alias.for_<Customer>();
481481

examples/self_join.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ int main() {
199199
// FROM employees
200200
// INNER JOIN employees m
201201
// ON m.ReportsTo = employees.EmployeeId
202-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
202+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
203203
constexpr auto m = "m"_alias.for_<Employee>();
204204
auto firstNames = storage.select(columns(m->*&Employee::firstName || c(" ") || m->*&Employee::lastName,
205205
&Employee::firstName || c(" ") || &Employee::lastName),
@@ -230,7 +230,7 @@ int main() {
230230
// FROM employees
231231
// INNER JOIN employees emp
232232
// ON emp.ReportsTo = employees.EmployeeId
233-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
233+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
234234
static_assert(std::is_empty_v<custom_alias<Employee>>);
235235
constexpr auto emp = custom_alias<Employee>{};
236236
auto firstNames = storage.select(columns(emp->*&Employee::firstName || c(" ") || emp->*&Employee::lastName,

examples/subquery.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ int main(int, char**) {
13461346
// WHERE salary >(SELECT AVG(salary)
13471347
// FROM employees
13481348
// WHERE department_id = e.department_id);
1349-
#ifdef SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
1349+
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
13501350
constexpr auto e = "e"_alias.for_<Employee>();
13511351
auto rows = storage.select(
13521352
columns(e->*&Employee::lastName, e->*&Employee::salary, e->*&Employee::departmentId),

0 commit comments

Comments
 (0)