Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
9 changes: 4 additions & 5 deletions dev/ast/group_by.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#pragma once

#include <tuple> // std::tuple, std::make_tuple
#include <type_traits> // std::true_type, std::false_type
#include <utility> // std::forward, std::move

#include "../functional/cxx_type_traits_polyfill.h"
#include "../functional/tuple.h"

namespace sqlite_orm {
namespace internal {

template<class T, class... Args>
struct group_by_with_having {
using args_type = std::tuple<Args...>;
using args_type = mpl::tuple<Args...>;
using expression_type = T;

args_type args;
Expand All @@ -23,7 +22,7 @@ namespace sqlite_orm {
*/
template<class... Args>
struct group_by_t {
using args_type = std::tuple<Args...>;
using args_type = mpl::tuple<Args...>;

args_type args;

Expand Down Expand Up @@ -58,7 +57,7 @@ namespace sqlite_orm {
*/
template<class... Args>
internal::group_by_t<Args...> group_by(Args&&... args) {
return {std::make_tuple(std::forward<Args>(args)...)};
return {mpl::make_tuple(std::forward<Args>(args)...)};
}

/**
Expand Down
21 changes: 10 additions & 11 deletions dev/ast/upsert_clause.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include <tuple> // std::tuple, std::make_tuple
#include <type_traits> // std::false_type, std::true_type
#include <utility> // std::forward, std::move

#include "../functional/cxx_type_traits_polyfill.h"
#include "../functional/tuple.h"

namespace sqlite_orm {
namespace internal {
Expand All @@ -14,24 +13,24 @@ namespace sqlite_orm {

template<class... Args>
struct conflict_target {
using args_tuple = std::tuple<Args...>;
using args_tuple = mpl::tuple<Args...>;

args_tuple args;

upsert_clause<args_tuple, std::tuple<>> do_nothing() {
return {move(this->args), {}};
upsert_clause<args_tuple, mpl::tuple<>> do_nothing() {
return {std::move(this->args), {}};
}

template<class... ActionsArgs>
upsert_clause<args_tuple, std::tuple<ActionsArgs...>> do_update(ActionsArgs... actions) {
return {move(this->args), {std::make_tuple(std::forward<ActionsArgs>(actions)...)}};
upsert_clause<args_tuple, mpl::tuple<ActionsArgs...>> do_update(ActionsArgs... actions) {
return {std::move(this->args), {std::forward<ActionsArgs>(actions)...}};
}
};

template<class... TargetArgs, class... ActionsArgs>
struct upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>> {
using target_args_tuple = std::tuple<TargetArgs...>;
using actions_tuple = std::tuple<ActionsArgs...>;
struct upsert_clause<mpl::tuple<TargetArgs...>, mpl::tuple<ActionsArgs...>> {
using target_args_tuple = mpl::tuple<TargetArgs...>;
using actions_tuple = mpl::tuple<ActionsArgs...>;

target_args_tuple target_args;

Expand All @@ -56,7 +55,7 @@ namespace sqlite_orm {
*/
template<class... Args>
internal::conflict_target<Args...> on_conflict(Args... args) {
return {std::tuple<Args...>(std::forward<Args>(args)...)};
return {{std::forward<Args>(args)...}};
}
#endif
}
16 changes: 14 additions & 2 deletions dev/ast_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ namespace sqlite_orm {
};

template<class... TargetArgs, class... ActionsArgs>
struct ast_iterator<upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>, void> {
using node_type = upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>;
struct ast_iterator<upsert_clause<mpl::tuple<TargetArgs...>, mpl::tuple<ActionsArgs...>>, void> {
using node_type = upsert_clause<mpl::tuple<TargetArgs...>, mpl::tuple<ActionsArgs...>>;

template<class L>
void operator()(const node_type& expression, L& lambda) const {
Expand Down Expand Up @@ -318,6 +318,18 @@ namespace sqlite_orm {
}
};

template<class... Args>
struct ast_iterator<mpl::tuple<Args...>, void> {
using node_type = mpl::tuple<Args...>;

template<class L>
void operator()(const node_type& node, L& lambda) const {
iterate_tuple(node, [&lambda](auto& v) {
iterate_ast(v, lambda);
});
}
};

template<class T, class... Args>
struct ast_iterator<group_by_with_having<T, Args...>, void> {
using node_type = group_by_with_having<T, Args...>;
Expand Down
31 changes: 16 additions & 15 deletions dev/column.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

#include <tuple> // std::tuple
#include <string> // std::string
#include <memory> // std::unique_ptr
#include <type_traits> // std::is_same, std::is_member_object_pointer

#include "functional/cxx_universal.h"
#include "functional/cxx_type_traits_polyfill.h"
#include "functional/fast_and.h"
#include "functional/unique_tuple.h"
#include "tuple_helper/tuple_traits.h"
#include "tuple_helper/tuple_filter.h"
#include "type_traits.h"
Expand Down Expand Up @@ -46,13 +47,12 @@ namespace sqlite_orm {
* Member pointer used to read a field value.
* If it is a object member pointer it is also used to write a field value.
*/
const member_pointer_t member_pointer;
member_pointer_t member_pointer;

/**
* Setter member function to write a field value
*/
SQLITE_ORM_NOUNIQUEADDRESS
const setter_type setter;
SQLITE_ORM_NOUNIQUEADDRESS const setter_type setter;

/**
* Simplified interface for `NOT NULL` constraint
Expand All @@ -69,10 +69,9 @@ namespace sqlite_orm {
*/
template<class... Op>
struct column_constraints {
using constraints_type = std::tuple<Op...>;
using constraints_type = mpl::uple<Op...>;

SQLITE_ORM_NOUNIQUEADDRESS
constraints_type constraints;
SQLITE_ORM_NOUNIQUEADDRESS constraints_type constraints;

/**
* Checks whether contraints are of trait `Trait`
Expand Down Expand Up @@ -105,9 +104,9 @@ namespace sqlite_orm {
template<class G, class S, class... Op>
struct column_t : column_identifier, column_field<G, S>, column_constraints<Op...> {
#ifndef SQLITE_ORM_AGGREGATE_BASES_SUPPORTED
column_t(std::string name, G memberPointer, S setter, std::tuple<Op...> op) :
column_t(std::string name, G memberPointer, S setter, mpl::uple<Op...> op) :
column_identifier{move(name)}, column_field<G, S>{memberPointer, setter}, column_constraints<Op...>{
move(op)} {}
std::move(op)} {}
#endif
};

Expand Down Expand Up @@ -142,9 +141,9 @@ namespace sqlite_orm {
*/
template<class M, class... Op, internal::satisfies<std::is_member_object_pointer, M> = true>
internal::column_t<M, internal::empty_setter, Op...> make_column(std::string name, M m, Op... constraints) {
static_assert(polyfill::conjunction_v<internal::is_constraint<Op>...>, "Incorrect constraints pack");
static_assert(SQLITE_ORM_FAST_AND(internal::is_constraint<Op>), "Incorrect constraints pack");

SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), m, {}, std::make_tuple(constraints...)});
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), m, {}, mpl::make_unique_tuple(constraints...)});
}

/**
Expand All @@ -158,9 +157,10 @@ namespace sqlite_orm {
internal::column_t<G, S, Op...> make_column(std::string name, S setter, G getter, Op... constraints) {
static_assert(std::is_same<internal::setter_field_type_t<S>, internal::getter_field_type_t<G>>::value,
"Getter and setter must get and set same data type");
static_assert(polyfill::conjunction_v<internal::is_constraint<Op>...>, "Incorrect constraints pack");
static_assert(SQLITE_ORM_FAST_AND(internal::is_constraint<Op>), "Incorrect constraints pack");

SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), getter, setter, std::make_tuple(constraints...)});
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {move(name), getter, setter, mpl::make_unique_tuple(constraints...)});
}

/**
Expand All @@ -175,8 +175,9 @@ namespace sqlite_orm {
internal::column_t<G, S, Op...> make_column(std::string name, G getter, S setter, Op... constraints) {
static_assert(std::is_same<internal::setter_field_type_t<S>, internal::getter_field_type_t<G>>::value,
"Getter and setter must get and set same data type");
static_assert(polyfill::conjunction_v<internal::is_constraint<Op>...>, "Incorrect constraints pack");
static_assert(SQLITE_ORM_FAST_AND(internal::is_constraint<Op>), "Incorrect constraints pack");

SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(return {move(name), getter, setter, std::make_tuple(constraints...)});
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {move(name), getter, setter, mpl::make_unique_tuple(constraints...)});
}
}
14 changes: 8 additions & 6 deletions dev/conditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#include <string> // std::string
#include <type_traits> // std::enable_if, std::is_same
#include <vector> // std::vector
#include <tuple> // std::tuple, std::tuple_size
#include <sstream> // std::stringstream
#include <utility> // std::move

#include "functional/cxx_universal.h"
#include "functional/cxx_type_traits_polyfill.h"
#include "functional/pack.h"
#include "functional/tuple.h"
#include "type_traits.h"
#include "collate_argument.h"
#include "constraints.h"
Expand Down Expand Up @@ -376,7 +378,7 @@ namespace sqlite_orm {
template<class L, class... Args>
struct in_t : condition_t, in_base, negatable_t {
L left;
std::tuple<Args...> argument;
mpl::tuple<Args...> argument;

in_t(L left_, decltype(argument) argument_, bool negative_) :
in_base{negative_}, left(std::move(left_)), argument(std::move(argument_)) {}
Expand Down Expand Up @@ -497,7 +499,7 @@ namespace sqlite_orm {
*/
template<class... Args>
struct multi_order_by_t : order_by_string {
using args_type = std::tuple<Args...>;
using args_type = mpl::tuple<Args...>;

args_type args;

Expand Down Expand Up @@ -796,7 +798,7 @@ namespace sqlite_orm {

template<class... Args>
struct from_t {
using tuple_type = std::tuple<Args...>;
using pack_type = mpl::pack<Args...>;
};

template<class T>
Expand All @@ -809,7 +811,7 @@ namespace sqlite_orm {
*/
template<class... Args>
internal::from_t<Args...> from() {
static_assert(std::tuple_size<std::tuple<Args...>>::value > 0, "");
static_assert(sizeof...(Args) > 0, "");
return {};
}

Expand Down Expand Up @@ -1196,7 +1198,7 @@ namespace sqlite_orm {
*/
template<class... Args>
internal::multi_order_by_t<Args...> multi_order_by(Args&&... args) {
return {std::make_tuple(std::forward<Args>(args)...)};
return {mpl::make_tuple(std::forward<Args>(args)...)};
}

/**
Expand Down
32 changes: 16 additions & 16 deletions dev/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <system_error> // std::system_error
#include <ostream> // std::ostream
#include <string> // std::string
#include <tuple> // std::tuple, std::make_tuple
#include <type_traits> // std::is_base_of, std::false_type, std::true_type
#include <type_traits> // std::is_base_of, std::false_type

#include "functional/cxx_universal.h"
#include "functional/cxx_type_traits_polyfill.h"
#include "functional/mpl.h"
#include "functional/tuple.h"
#include "tuple_helper/same_or_void.h"
#include "tuple_helper/tuple_traits.h"
#include "tuple_helper/tuple_filter.h"
Expand Down Expand Up @@ -60,11 +60,11 @@ namespace sqlite_orm {
template<class... Cs>
struct primary_key_t : primary_key_base {
using order_by = primary_key_base::order_by;
using columns_tuple = std::tuple<Cs...>;
using columns_tuple = mpl::tuple<Cs...>;

columns_tuple columns;

primary_key_t(decltype(columns) c) : columns(move(c)) {}
primary_key_t(decltype(columns) c) : columns(std::move(c)) {}

primary_key_t<Cs...> asc() const {
auto res = *this;
Expand All @@ -90,11 +90,11 @@ namespace sqlite_orm {
*/
template<class... Args>
struct unique_t : unique_base {
using columns_tuple = std::tuple<Args...>;
using columns_tuple = mpl::tuple<Args...>;

columns_tuple columns;

unique_t(columns_tuple columns_) : columns(move(columns_)) {}
unique_t(columns_tuple columns_) : columns(std::move(columns_)) {}
};

/**
Expand Down Expand Up @@ -243,9 +243,9 @@ namespace sqlite_orm {
}

template<class... Cs, class... Rs>
struct foreign_key_t<std::tuple<Cs...>, std::tuple<Rs...>> {
using columns_type = std::tuple<Cs...>;
using references_type = std::tuple<Rs...>;
struct foreign_key_t<mpl::tuple<Cs...>, mpl::tuple<Rs...>> {
using columns_type = mpl::tuple<Cs...>;
using references_type = mpl::tuple<Rs...>;
using self = foreign_key_t<columns_type, references_type>;

/**
Expand All @@ -269,7 +269,7 @@ namespace sqlite_orm {
static_assert(!std::is_same<target_type, void>::value, "All references must have the same type");

foreign_key_t(columns_type columns_, references_type references_) :
columns(move(columns_)), references(move(references_)),
columns(std::move(columns_)), references(std::move(references_)),
on_update(*this, true, foreign_key_action::none), on_delete(*this, false, foreign_key_action::none) {}

foreign_key_t(const self& other) :
Expand Down Expand Up @@ -298,13 +298,13 @@ namespace sqlite_orm {
*/
template<class... Cs>
struct foreign_key_intermediate_t {
using tuple_type = std::tuple<Cs...>;
using tuple_type = mpl::tuple<Cs...>;

tuple_type columns;

template<class... Rs>
foreign_key_t<std::tuple<Cs...>, std::tuple<Rs...>> references(Rs... refs) {
return {std::move(this->columns), std::make_tuple(std::forward<Rs>(refs)...)};
foreign_key_t<mpl::tuple<Cs...>, mpl::tuple<Rs...>> references(Rs... refs) {
return {std::move(this->columns), mpl::make_tuple(std::forward<Rs>(refs)...)};
}
};
#endif
Expand Down Expand Up @@ -449,7 +449,7 @@ namespace sqlite_orm {
*/
template<class... Cs>
internal::foreign_key_intermediate_t<Cs...> foreign_key(Cs... columns) {
return {std::make_tuple(std::forward<Cs>(columns)...)};
return {mpl::make_tuple(std::forward<Cs>(columns)...)};
}
#endif

Expand All @@ -458,7 +458,7 @@ namespace sqlite_orm {
*/
template<class... Args>
internal::unique_t<Args...> unique(Args... args) {
return {std::make_tuple(std::forward<Args>(args)...)};
return {mpl::make_tuple(std::forward<Args>(args)...)};
}

inline internal::unique_t<> unique() {
Expand All @@ -471,7 +471,7 @@ namespace sqlite_orm {

template<class... Cs>
internal::primary_key_t<Cs...> primary_key(Cs... cs) {
return {std::make_tuple(std::forward<Cs>(cs)...)};
return {mpl::make_tuple(std::forward<Cs>(cs)...)};
}

inline internal::primary_key_t<> primary_key() {
Expand Down
Loading