Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Never
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterRequiresInClause: true
AfterRequiresInExpression: false
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clang-format-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: clang-format lint
uses: DoozyX/clang-format-lint-action@v0.16.2
uses: d-griet/clang-format-lint-action@99a106be2f3f1a92d9783ea7c744fde62d8ce1fa
with:
clangFormatVersion: 16
clangFormatVersion: 19
28 changes: 14 additions & 14 deletions dev/alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <utility> // std::make_index_sequence, std::move
#include <string> // std::string
#include <sstream> // std::stringstream
#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#include <array>
#endif

Expand Down Expand Up @@ -101,7 +101,7 @@ namespace sqlite_orm {
return alias_extractor::extract();
}

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
// for CTE monikers -> empty
template<class T = A, satisfies<std::is_same, polyfill::detected_t<type_t, T>, A> = true>
static std::string as_alias() {
Expand Down Expand Up @@ -168,11 +168,11 @@ namespace sqlite_orm {
};
#endif

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
template<size_t n, char... C>
SQLITE_ORM_CONSTEVAL auto n_to_colalias() {
constexpr column_alias<'1' + n % 10, C...> colalias{};
if constexpr(n > 10) {
if constexpr (n > 10) {
return n_to_colalias<n / 10, '1' + n % 10, C...>();
} else {
return colalias;
Expand Down Expand Up @@ -223,7 +223,7 @@ namespace sqlite_orm {
polyfill::conjunction<internal::is_table_alias<A>,
polyfill::negation<internal::is_cte_moniker<internal::type_t<A>>>>::value,
bool> = true>
constexpr auto alias_column(F O::*field) {
constexpr auto alias_column(F O::* field) {
using namespace ::sqlite_orm::internal;
using aliased_type = type_t<A>;
static_assert(is_field_of_v<F O::*, aliased_type>, "Column must be from aliased table");
Expand All @@ -244,16 +244,16 @@ namespace sqlite_orm {
* select(alias_column<als>(&User::id))
*/
template<orm_table_alias auto als, class C>
requires(!orm_cte_moniker<internal::auto_type_t<als>>)
requires (!orm_cte_moniker<internal::auto_type_t<als>>)
constexpr auto alias_column(C field) {
using namespace ::sqlite_orm::internal;
using A = decltype(als);
using aliased_type = type_t<A>;
static_assert(is_field_of_v<C, aliased_type>, "Column must be from aliased table");

if constexpr(is_column_pointer_v<C>) {
if constexpr (is_column_pointer_v<C>) {
return alias_column_t<A, C>{std::move(field)};
} else if constexpr(std::is_same_v<member_object_type_t<C>, aliased_type>) {
} else if constexpr (std::is_same_v<member_object_type_t<C>, aliased_type>) {
return alias_column_t<A, C>{field};
} else {
// wrap in column_pointer
Expand All @@ -275,13 +275,13 @@ namespace sqlite_orm {
* select(als->*&User::id)
*/
template<orm_table_alias A, class F>
requires(!orm_cte_moniker<internal::type_t<A>>)
requires (!orm_cte_moniker<internal::type_t<A>>)
constexpr auto operator->*(const A& /*tableAlias*/, F field) {
return alias_column<A>(std::move(field));
}
#endif

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
/**
* Create a column reference to an aliased CTE column.
*/
Expand All @@ -294,7 +294,7 @@ namespace sqlite_orm {
using namespace ::sqlite_orm::internal;
using cte_moniker_t = type_t<A>;

if constexpr(is_column_pointer_v<C>) {
if constexpr (is_column_pointer_v<C>) {
static_assert(std::is_same<table_type_of_t<C>, cte_moniker_t>::value,
"Column pointer must match aliased CTE");
return alias_column_t<A, C>{c};
Expand All @@ -312,7 +312,7 @@ namespace sqlite_orm {
* because recordset aliases are derived from `sqlite_orm::alias_tag`
*/
template<orm_table_alias A, class C>
requires(orm_cte_moniker<internal::type_t<A>>)
requires (orm_cte_moniker<internal::type_t<A>>)
constexpr auto operator->*(const A& /*tableAlias*/, C c) {
return alias_column<A>(std::move(c));
}
Expand All @@ -321,7 +321,7 @@ namespace sqlite_orm {
* Create a column reference to an aliased CTE column.
*/
template<orm_table_alias auto als, class C>
requires(orm_cte_moniker<internal::auto_type_t<als>>)
requires (orm_cte_moniker<internal::auto_type_t<als>>)
constexpr auto alias_column(C c) {
using A = std::remove_const_t<decltype(als)>;
return alias_column<A>(std::move(c));
Expand Down Expand Up @@ -474,7 +474,7 @@ namespace sqlite_orm {
}
#endif

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
inline namespace literals {
/**
* column_alias<'1'[, ...]> from a numeric literal.
Expand Down
2 changes: 1 addition & 1 deletion dev/alias_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace sqlite_orm {
*/
template<class A>
SQLITE_ORM_INLINE_VAR constexpr bool is_cte_moniker_v =
#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
polyfill::conjunction_v<is_recordset_alias<A>,
std::is_same<polyfill::detected_t<type_t, A>, std::remove_const_t<A>>>;
#else
Expand Down
8 changes: 4 additions & 4 deletions dev/arg_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace sqlite_orm {

iterator& operator++() {
++this->index;
if(this->index < int(this->container.size())) {
if (this->index < int(this->container.size())) {
this->currentValue = this->container[this->index];
} else {
this->currentValue = {};
Expand All @@ -74,7 +74,7 @@ namespace sqlite_orm {
iterator operator++(int) {
auto res = *this;
++this->index;
if(this->index < int(this->container.size())) {
if (this->index < int(this->container.size())) {
this->currentValue = this->container[this->index];
} else {
this->currentValue = {};
Expand All @@ -83,7 +83,7 @@ namespace sqlite_orm {
}

arg_value operator*() const {
if(this->index < int(this->container.size()) && this->index >= 0) {
if (this->index < int(this->container.size()) && this->index >= 0) {
return this->currentValue;
} else {
throw std::system_error{orm_error_code::index_is_out_of_bounds};
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace sqlite_orm {
}

arg_value operator[](int index) const {
if(index < this->argsCount && index >= 0) {
if (index < this->argsCount && index >= 0) {
sqlite3_value* value = this->values[index];
return {value};
} else {
Expand Down
4 changes: 2 additions & 2 deletions dev/ast_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ namespace sqlite_orm {

template<class L>
void operator()(const node_type& vec, L& lambda) const {
for(auto& i: vec) {
for (auto& i: vec) {
iterate_ast(i, lambda);
}
}
Expand All @@ -226,7 +226,7 @@ namespace sqlite_orm {
}
};

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
template<class CTE>
struct ast_iterator<CTE, match_specialization_of<CTE, common_table_expression>> {
using node_type = CTE;
Expand Down
4 changes: 2 additions & 2 deletions dev/backup.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace sqlite_orm {
std::unique_ptr<connection_holder> holder_) :
handle(sqlite3_backup_init(to_.get(), zDestName.c_str(), from_.get(), zSourceName.c_str())),
holder(std::move(holder_)), to(to_), from(from_) {
if(!this->handle) {
if (!this->handle) {
throw std::system_error{orm_error_code::failed_to_init_a_backup};
}
}
Expand All @@ -37,7 +37,7 @@ namespace sqlite_orm {
from(other.from) {}

~backup_t() {
if(this->handle) {
if (this->handle) {
(void)sqlite3_backup_finish(this->handle);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dev/carray.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace sqlite_orm {
template<typename P>
struct note_value_fn {
P operator()(P&& value, carray_pointer_arg<P> pv) const {
if(P* observer = pv) {
if (P* observer = pv) {
*observer = value;
}
return std::move(value);
Expand Down
20 changes: 10 additions & 10 deletions dev/column_names_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ namespace sqlite_orm {
std::vector<std::string>& collect_table_column_names(std::vector<std::string>& collectedExpressions,
bool definedOrder,
const Ctx& context) {
if(definedOrder) {
if (definedOrder) {
auto& table = pick_table<mapped_type_proxy_t<T>>(context.db_objects);
collectedExpressions.reserve(collectedExpressions.size() + table.template count_of<is_column>());
table.for_each_column([qualified = !context.skip_table_name,
&tableName = table.name,
&collectedExpressions](const column_identifier& column) {
if(is_alias<T>::value) {
if (is_alias<T>::value) {
collectedExpressions.push_back(quote_identifier(alias_extractor<T>::extract()) + "." +
quote_identifier(column.name));
} else if(qualified) {
} else if (qualified) {
collectedExpressions.push_back(quote_identifier(tableName) + "." +
quote_identifier(column.name));
} else {
Expand All @@ -46,9 +46,9 @@ namespace sqlite_orm {
});
} else {
collectedExpressions.reserve(collectedExpressions.size() + 1);
if(is_alias<T>::value) {
if (is_alias<T>::value) {
collectedExpressions.push_back(quote_identifier(alias_extractor<T>::extract()) + ".*");
} else if(!context.skip_table_name) {
} else if (!context.skip_table_name) {
const basic_table& table = pick_table<mapped_type_proxy_t<T>>(context.db_objects);
collectedExpressions.push_back(quote_identifier(table.name) + ".*");
} else {
Expand All @@ -68,7 +68,7 @@ namespace sqlite_orm {
template<class E, class Ctx>
std::vector<std::string>& operator()(const E& t, const Ctx& context) {
auto columnExpression = serialize(t, context);
if(columnExpression.empty()) {
if (columnExpression.empty()) {
throw std::system_error{orm_error_code::column_not_found};
}
this->collectedExpressions.reserve(this->collectedExpressions.size() + 1);
Expand Down Expand Up @@ -98,8 +98,8 @@ namespace sqlite_orm {
(*this)(colExpr, context);
});
// note: `capacity() > size()` can occur in case `asterisk_t<>` does spell out the columns in defined order
if(tuple_has_template<typename columns_t<Args...>::columns_type, asterisk_t>::value &&
this->collectedExpressions.capacity() > this->collectedExpressions.size()) {
if (tuple_has_template<typename columns_t<Args...>::columns_type, asterisk_t>::value &&
this->collectedExpressions.capacity() > this->collectedExpressions.size()) {
this->collectedExpressions.shrink_to_fit();
}
return this->collectedExpressions;
Expand All @@ -112,8 +112,8 @@ namespace sqlite_orm {
(*this)(colExpr, context);
});
// note: `capacity() > size()` can occur in case `asterisk_t<>` does spell out the columns in defined order
if(tuple_has_template<typename struct_t<T, Args...>::columns_type, asterisk_t>::value &&
this->collectedExpressions.capacity() > this->collectedExpressions.size()) {
if (tuple_has_template<typename struct_t<T, Args...>::columns_type, asterisk_t>::value &&
this->collectedExpressions.capacity() > this->collectedExpressions.size()) {
this->collectedExpressions.shrink_to_fit();
}
return this->collectedExpressions;
Expand Down
18 changes: 9 additions & 9 deletions dev/column_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace sqlite_orm {
SQLITE_ORM_INLINE_VAR constexpr bool is_operator_argument_v<T, std::enable_if_t<is_column_pointer<T>::value>> =
true;

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
template<class A>
struct alias_holder;
#endif
Expand All @@ -51,7 +51,7 @@ namespace sqlite_orm {
* storage.select(column<MyType>(&BaseType::id));
*/
template<class O, class Base, class F, internal::satisfies_not<internal::is_recordset_alias, O> = true>
constexpr internal::column_pointer<O, F Base::*> column(F Base::*field) {
constexpr internal::column_pointer<O, F Base::*> column(F Base::* field) {
static_assert(std::is_convertible<F Base::*, F O::*>::value, "Field must be from derived class");
return {field};
}
Expand All @@ -61,7 +61,7 @@ namespace sqlite_orm {
* Explicitly refer to a column.
*/
template<orm_table_reference auto table, class O, class F>
constexpr auto column(F O::*field) {
constexpr auto column(F O::* field) {
return column<internal::auto_type_t<table>>(field);
}

Expand All @@ -72,7 +72,7 @@ namespace sqlite_orm {
* Explicitly refer to a column.
*/
template<orm_table_reference R, class O, class F>
constexpr auto operator->*(const R& /*table*/, F O::*field) {
constexpr auto operator->*(const R& /*table*/, F O::* field) {
return column<typename R::type>(field);
}
}
Expand All @@ -81,7 +81,7 @@ namespace sqlite_orm {
* Make a table reference.
*/
template<class O>
requires(!orm_recordset_alias<O>)
requires (!orm_recordset_alias<O>)
consteval internal::table_reference<O> column() {
return {};
}
Expand All @@ -90,13 +90,13 @@ namespace sqlite_orm {
* Make a table reference.
*/
template<class O>
requires(!orm_recordset_alias<O>)
requires (!orm_recordset_alias<O>)
consteval internal::table_reference<O> c() {
return {};
}
#endif

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
/**
* Explicitly refer to a column alias mapped into a CTE or subquery.
*
Expand All @@ -115,10 +115,10 @@ namespace sqlite_orm {

static_assert(is_cte_moniker_v<Moniker>, "`Moniker' must be a CTE moniker");

if constexpr(polyfill::is_specialization_of_v<F, alias_holder>) {
if constexpr (polyfill::is_specialization_of_v<F, alias_holder>) {
static_assert(is_column_alias_v<type_t<F>>);
return column_pointer<Moniker, F>{{}};
} else if constexpr(is_column_alias_v<F>) {
} else if constexpr (is_column_alias_v<F>) {
return column_pointer<Moniker, alias_holder<F>>{{}};
} else {
return column_pointer<Moniker, F>{std::move(field)};
Expand Down
2 changes: 1 addition & 1 deletion dev/column_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ namespace sqlite_orm {
template<class DBOs, class T, class F>
struct column_result_t<DBOs, column_pointer<T, F>, void> : column_result_t<DBOs, F> {};

#if(SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
#if (SQLITE_VERSION_NUMBER >= 3008003) && defined(SQLITE_ORM_WITH_CTE)
template<class DBOs, class Moniker, class ColAlias>
struct column_result_t<DBOs, column_pointer<Moniker, alias_holder<ColAlias>>, void> {
using table_type = storage_pick_table_t<Moniker, DBOs>;
Expand Down
2 changes: 1 addition & 1 deletion dev/conditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ namespace sqlite_orm {
}

template<class F, class O>
internal::using_t<O, F O::*> using_(F O::*field) {
internal::using_t<O, F O::*> using_(F O::* field) {
return {field};
}
template<class T, class M>
Expand Down
Loading