From 1eaff430ca00d4448cdb3515355216de970bf93d Mon Sep 17 00:00:00 2001 From: fnc12 Date: Sat, 21 Nov 2020 23:38:15 +0600 Subject: [PATCH] changed PointerAlignment from Right to Left --- .clang-format | 2 +- dev/ast_iterator.h | 108 +- dev/backup.h | 8 +- dev/column.h | 10 +- dev/column_names_getter.h | 16 +- dev/column_result.h | 2 +- dev/conditions.h | 12 +- dev/connection_holder.h | 14 +- dev/constraints.h | 10 +- dev/core_functions.h | 2 +- dev/default_value_extractor.h | 6 +- dev/error_code.h | 12 +- dev/expression_object_type.h | 14 +- dev/field_printer.h | 20 +- dev/field_value_holder.h | 2 +- dev/get_prepared_statement.h | 56 +- dev/getter_traits.h | 12 +- dev/index.h | 4 +- dev/is_base_of_template.h | 8 +- dev/is_std_ptr.h | 4 +- dev/iterator.h | 34 +- dev/join_iterator.h | 18 +- dev/journal_mode.h | 4 +- dev/mapped_row_extractor.h | 6 +- dev/object_from_column_builder.h | 8 +- dev/optional_container.h | 4 +- dev/order_by_serializator.h | 8 +- dev/pragma.h | 10 +- dev/prepared_statement.h | 4 +- dev/row_extractor.h | 74 +- dev/row_extractor_builder.h | 6 +- dev/select_constraints.h | 4 +- dev/serializator_context.h | 8 +- dev/statement_binder.h | 44 +- dev/statement_finalizer.h | 2 +- dev/statement_serializator.h | 260 ++-- dev/static_magic.h | 10 +- dev/storage.h | 194 +-- dev/storage_base.h | 76 +- dev/storage_impl.h | 72 +- dev/sync_schema_result.h | 2 +- dev/table.h | 58 +- dev/table_name_collector.h | 18 +- dev/tuple_helper.h | 16 +- dev/type_is_nullable.h | 8 +- dev/type_printer.h | 10 +- dev/typed_comparator.h | 6 +- dev/util.h | 4 +- dev/view.h | 8 +- examples/blob.cpp | 2 +- examples/case.cpp | 8 +- examples/check.cpp | 6 +- examples/collate.cpp | 2 +- examples/composite_key.cpp | 2 +- examples/core_functions.cpp | 26 +- examples/cross_join.cpp | 4 +- examples/custom_aliases.cpp | 8 +- examples/distinct.cpp | 10 +- examples/enum_binding.cpp | 20 +- examples/exists.cpp | 8 +- examples/foreign_key.cpp | 26 +- examples/group_by.cpp | 10 +- examples/having.cpp | 4 +- examples/in_memory.cpp | 2 +- examples/index.cpp | 4 +- examples/insert.cpp | 6 +- examples/iteration.cpp | 8 +- examples/key_value.cpp | 8 +- examples/left_and_inner_join.cpp | 28 +- examples/multi_table_select.cpp | 6 +- examples/natural_join.cpp | 4 +- examples/nullable_enum_binding.cpp | 22 +- examples/prepared_statement.cpp | 16 +- examples/private_class_members.cpp | 4 +- examples/select.cpp | 10 +- examples/self_join.cpp | 6 +- examples/subentities.cpp | 10 +- examples/subquery.cpp | 14 +- examples/synchronous.cpp | 2 +- examples/union.cpp | 6 +- examples/unique.cpp | 4 +- examples/update.cpp | 10 +- include/sqlite_orm/sqlite_orm.h | 1296 ++++++++--------- tests/backup_tests.cpp | 6 +- tests/constraints/default.cpp | 2 +- tests/constraints/unique.cpp | 4 +- tests/core_functions_tests.cpp | 8 +- tests/datetime_function_tests.cpp | 2 +- tests/dynamic_order_by.cpp | 2 +- tests/get_all_custom_containers.cpp | 12 +- tests/operators/arithmetic_operators.cpp | 28 +- tests/operators/cast.cpp | 4 +- tests/operators/glob.cpp | 4 +- tests/pragma_tests.cpp | 4 +- tests/prepared_statement_tests/get.cpp | 8 +- .../prepared_statement_tests/get_optional.cpp | 6 +- .../prepared_statement_tests/get_pointer.cpp | 6 +- tests/prepared_statement_tests/insert.cpp | 2 +- .../insert_explicit.cpp | 4 +- .../prepared_statement_tests/insert_range.cpp | 8 +- .../prepared_common.h | 8 +- tests/prepared_statement_tests/remove.cpp | 2 +- tests/prepared_statement_tests/replace.cpp | 2 +- .../replace_range.cpp | 2 +- tests/prepared_statement_tests/select.cpp | 16 +- tests/prepared_statement_tests/update.cpp | 2 +- tests/prepared_statement_tests/update_all.cpp | 2 +- tests/row_id.cpp | 2 +- tests/select_asterisk.cpp | 2 +- .../base_types.cpp | 2 +- .../column_names.cpp | 2 +- tests/static_tests.cpp | 28 +- tests/static_tests/is_bindable.cpp | 4 +- tests/static_tests/member_traits_tests.cpp | 8 +- tests/static_tests/node_tuple.cpp | 46 +- tests/static_tests/static_tests_common.h | 8 +- tests/storage_tests.cpp | 2 +- tests/sync_schema_tests.cpp | 32 +- tests/table_tests.cpp | 6 +- tests/tests.cpp | 24 +- tests/tests2.cpp | 16 +- tests/tests3.cpp | 18 +- tests/tests4.cpp | 6 +- tests/tests5.cpp | 18 +- .../unique_cases/get_all_with_two_tables.cpp | 2 +- 125 files changed, 1631 insertions(+), 1639 deletions(-) diff --git a/.clang-format b/.clang-format index 4606f173b..89dad597f 100644 --- a/.clang-format +++ b/.clang-format @@ -94,7 +94,7 @@ PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right +PointerAlignment: Left ReflowComments: false SortIncludes: false SortUsingDeclarations: true diff --git a/dev/ast_iterator.h b/dev/ast_iterator.h index 30c35020f..68363479a 100644 --- a/dev/ast_iterator.h +++ b/dev/ast_iterator.h @@ -32,7 +32,7 @@ namespace sqlite_orm { * L is a callable type. Mostly is a templated lambda */ template - void operator()(const T &t, const L &l) const { + void operator()(const T& t, const L& l) const { l(t); } }; @@ -41,7 +41,7 @@ namespace sqlite_orm { * Simplified API */ template - void iterate_ast(const T &t, const L &l) { + void iterate_ast(const T& t, const L& l) { ast_iterator iterator; iterator(t, l); } @@ -51,7 +51,7 @@ namespace sqlite_orm { using node_type = std::reference_wrapper; template - void operator()(const node_type &r, const L &l) const { + void operator()(const node_type& r, const L& l) const { iterate_ast(r.get(), l); } }; @@ -61,7 +61,7 @@ namespace sqlite_orm { using node_type = where_t; template - void operator()(const node_type &where, const L &l) const { + void operator()(const node_type& where, const L& l) const { iterate_ast(where.c, l); } }; @@ -71,7 +71,7 @@ namespace sqlite_orm { using node_type = T; template - void operator()(const node_type &binaryCondition, const L &l) const { + void operator()(const node_type& binaryCondition, const L& l) const { iterate_ast(binaryCondition.l, l); iterate_ast(binaryCondition.r, l); } @@ -82,7 +82,7 @@ namespace sqlite_orm { using node_type = binary_operator; template - void operator()(const node_type &binaryOperator, const C &l) const { + void operator()(const node_type& binaryOperator, const C& l) const { iterate_ast(binaryOperator.lhs, l); iterate_ast(binaryOperator.rhs, l); } @@ -93,7 +93,7 @@ namespace sqlite_orm { using node_type = columns_t; template - void operator()(const node_type &cols, const L &l) const { + void operator()(const node_type& cols, const L& l) const { iterate_ast(cols.columns, l); } }; @@ -103,7 +103,7 @@ namespace sqlite_orm { using node_type = in_t; template - void operator()(const node_type &in, const C &l) const { + void operator()(const node_type& in, const C& l) const { iterate_ast(in.l, l); iterate_ast(in.arg, l); } @@ -114,8 +114,8 @@ namespace sqlite_orm { using node_type = std::vector; template - void operator()(const node_type &vec, const L &l) const { - for(auto &i: vec) { + void operator()(const node_type& vec, const L& l) const { + for(auto& i: vec) { iterate_ast(i, l); } } @@ -126,7 +126,7 @@ namespace sqlite_orm { using node_type = std::vector; template - void operator()(const node_type &vec, const L &l) const { + void operator()(const node_type& vec, const L& l) const { l(vec); } }; @@ -136,7 +136,7 @@ namespace sqlite_orm { using node_type = T; template - void operator()(const node_type &c, const L &l) const { + void operator()(const node_type& c, const L& l) const { iterate_ast(c.left, l); iterate_ast(c.right, l); } @@ -147,7 +147,7 @@ namespace sqlite_orm { using node_type = select_t; template - void operator()(const node_type &sel, const L &l) const { + void operator()(const node_type& sel, const L& l) const { iterate_ast(sel.col, l); iterate_ast(sel.conditions, l); } @@ -158,7 +158,7 @@ namespace sqlite_orm { using node_type = get_all_t; template - void operator()(const node_type &get, const L &l) const { + void operator()(const node_type& get, const L& l) const { iterate_ast(get.conditions, l); } }; @@ -168,7 +168,7 @@ namespace sqlite_orm { using node_type = get_all_pointer_t; template - void operator()(const node_type &get, const L &l) const { + void operator()(const node_type& get, const L& l) const { iterate_ast(get.conditions, l); } }; @@ -179,7 +179,7 @@ namespace sqlite_orm { using node_type = get_all_optional_t; template - void operator()(const node_type &get, const L &l) const { + void operator()(const node_type& get, const L& l) const { iterate_ast(get.conditions, l); } }; @@ -190,7 +190,7 @@ namespace sqlite_orm { using node_type = update_all_t, Wargs...>; template - void operator()(const node_type &u, const L &l) const { + void operator()(const node_type& u, const L& l) const { iterate_ast(u.set, l); iterate_ast(u.conditions, l); } @@ -201,7 +201,7 @@ namespace sqlite_orm { using node_type = remove_all_t; template - void operator()(const node_type &r, const L &l) const { + void operator()(const node_type& r, const L& l) const { iterate_ast(r.conditions, l); } }; @@ -211,7 +211,7 @@ namespace sqlite_orm { using node_type = set_t; template - void operator()(const node_type &s, const L &l) const { + void operator()(const node_type& s, const L& l) const { iterate_ast(s.assigns, l); } }; @@ -221,8 +221,8 @@ namespace sqlite_orm { using node_type = std::tuple; template - void operator()(const node_type &tuple, const L &l) const { - iterate_tuple(tuple, [&l](auto &v) { + void operator()(const node_type& tuple, const L& l) const { + iterate_tuple(tuple, [&l](auto& v) { iterate_ast(v, l); }); } @@ -233,7 +233,7 @@ namespace sqlite_orm { using node_type = having_t; template - void operator()(const node_type &hav, const L &l) const { + void operator()(const node_type& hav, const L& l) const { iterate_ast(hav.t, l); } }; @@ -243,7 +243,7 @@ namespace sqlite_orm { using node_type = cast_t; template - void operator()(const node_type &c, const L &l) const { + void operator()(const node_type& c, const L& l) const { iterate_ast(c.expression, l); } }; @@ -253,7 +253,7 @@ namespace sqlite_orm { using node_type = exists_t; template - void operator()(const node_type &e, const L &l) const { + void operator()(const node_type& e, const L& l) const { iterate_ast(e.t, l); } }; @@ -263,10 +263,10 @@ namespace sqlite_orm { using node_type = like_t; template - void operator()(const node_type &lk, const L &l) const { + void operator()(const node_type& lk, const L& l) const { iterate_ast(lk.arg, l); iterate_ast(lk.pattern, l); - lk.arg3.apply([&l](auto &value) { + lk.arg3.apply([&l](auto& value) { iterate_ast(value, l); }); } @@ -277,7 +277,7 @@ namespace sqlite_orm { using node_type = glob_t; template - void operator()(const node_type &lk, const L &l) const { + void operator()(const node_type& lk, const L& l) const { iterate_ast(lk.arg, l); iterate_ast(lk.pattern, l); } @@ -288,7 +288,7 @@ namespace sqlite_orm { using node_type = between_t; template - void operator()(const node_type &b, const L &l) const { + void operator()(const node_type& b, const L& l) const { iterate_ast(b.expr, l); iterate_ast(b.b1, l); iterate_ast(b.b2, l); @@ -300,7 +300,7 @@ namespace sqlite_orm { using node_type = named_collate; template - void operator()(const node_type &col, const L &l) const { + void operator()(const node_type& col, const L& l) const { iterate_ast(col.expr, l); } }; @@ -310,7 +310,7 @@ namespace sqlite_orm { using node_type = negated_condition_t; template - void operator()(const node_type &neg, const L &l) const { + void operator()(const node_type& neg, const L& l) const { iterate_ast(neg.c, l); } }; @@ -320,7 +320,7 @@ namespace sqlite_orm { using node_type = is_null_t; template - void operator()(const node_type &i, const L &l) const { + void operator()(const node_type& i, const L& l) const { iterate_ast(i.t, l); } }; @@ -330,7 +330,7 @@ namespace sqlite_orm { using node_type = is_not_null_t; template - void operator()(const node_type &i, const L &l) const { + void operator()(const node_type& i, const L& l) const { iterate_ast(i.t, l); } }; @@ -340,7 +340,7 @@ namespace sqlite_orm { using node_type = core_function_t; template - void operator()(const node_type &f, const L &l) const { + void operator()(const node_type& f, const L& l) const { iterate_ast(f.args, l); } }; @@ -350,7 +350,7 @@ namespace sqlite_orm { using node_type = left_join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -360,7 +360,7 @@ namespace sqlite_orm { using node_type = on_t; template - void operator()(const node_type &o, const L &l) const { + void operator()(const node_type& o, const L& l) const { iterate_ast(o.arg, l); } }; @@ -370,7 +370,7 @@ namespace sqlite_orm { using node_type = join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -380,7 +380,7 @@ namespace sqlite_orm { using node_type = left_outer_join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -390,7 +390,7 @@ namespace sqlite_orm { using node_type = inner_join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -400,15 +400,15 @@ namespace sqlite_orm { using node_type = simple_case_t; template - void operator()(const node_type &c, const L &l) const { - c.case_expression.apply([&l](auto &c_) { + void operator()(const node_type& c, const L& l) const { + c.case_expression.apply([&l](auto& c_) { iterate_ast(c_, l); }); - iterate_tuple(c.args, [&l](auto &pair) { + iterate_tuple(c.args, [&l](auto& pair) { iterate_ast(pair.first, l); iterate_ast(pair.second, l); }); - c.else_expression.apply([&l](auto &el) { + c.else_expression.apply([&l](auto& el) { iterate_ast(el, l); }); } @@ -419,7 +419,7 @@ namespace sqlite_orm { using node_type = as_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.expression, l); } }; @@ -429,7 +429,7 @@ namespace sqlite_orm { using node_type = limit_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.lim, l); } }; @@ -439,9 +439,9 @@ namespace sqlite_orm { using node_type = limit_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.lim, l); - a.off.apply([&l](auto &value) { + a.off.apply([&l](auto& value) { iterate_ast(value, l); }); } @@ -452,8 +452,8 @@ namespace sqlite_orm { using node_type = limit_t; template - void operator()(const node_type &a, const L &l) const { - a.off.apply([&l](auto &value) { + void operator()(const node_type& a, const L& l) const { + a.off.apply([&l](auto& value) { iterate_ast(value, l); }); iterate_ast(a.lim, l); @@ -465,7 +465,7 @@ namespace sqlite_orm { using node_type = distinct_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.t, l); } }; @@ -475,7 +475,7 @@ namespace sqlite_orm { using node_type = all_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.t, l); } }; @@ -485,7 +485,7 @@ namespace sqlite_orm { using node_type = bitwise_not_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.argument, l); } }; @@ -495,7 +495,7 @@ namespace sqlite_orm { using node_type = values_t; template - void operator()(const node_type &node, const L &l) const { + void operator()(const node_type& node, const L& l) const { iterate_ast(node.tuple, l); } }; @@ -505,7 +505,7 @@ namespace sqlite_orm { using node_type = dynamic_values_t; template - void operator()(const node_type &node, const L &l) const { + void operator()(const node_type& node, const L& l) const { iterate_ast(node.vector, l); } }; @@ -515,7 +515,7 @@ namespace sqlite_orm { using node_type = collate_t; template - void operator()(const node_type &node, const L &l) const { + void operator()(const node_type& node, const L& l) const { iterate_ast(node.expr, l); } }; diff --git a/dev/backup.h b/dev/backup.h index 0459b0a4c..e1de8481f 100644 --- a/dev/backup.h +++ b/dev/backup.h @@ -19,9 +19,9 @@ namespace sqlite_orm { */ struct backup_t { backup_t(connection_ref to_, - const std::string &zDestName, + const std::string& zDestName, connection_ref from_, - const std::string &zSourceName, + const std::string& zSourceName, std::unique_ptr holder_) : handle(sqlite3_backup_init(to_.get(), zDestName.c_str(), from_.get(), zSourceName.c_str())), to(to_), from(from_), holder(move(holder_)) { @@ -30,7 +30,7 @@ namespace sqlite_orm { } } - backup_t(backup_t &&other) : + backup_t(backup_t&& other) : handle(other.handle), to(other.to), from(other.from), holder(move(other.holder)) { other.handle = nullptr; } @@ -64,7 +64,7 @@ namespace sqlite_orm { } protected: - sqlite3_backup *handle = nullptr; + sqlite3_backup* handle = nullptr; connection_ref to; connection_ref from; std::unique_ptr holder; diff --git a/dev/column.h b/dev/column.h index 2293ede03..ed43ba58f 100644 --- a/dev/column.h +++ b/dev/column.h @@ -99,7 +99,7 @@ namespace sqlite_orm { */ std::unique_ptr default_value() const { std::unique_ptr res; - iterate_tuple(this->constraints, [&res](auto &v) { + iterate_tuple(this->constraints, [&res](auto& v) { auto dft = internal::default_value_extractor()(v); if(dft) { res = std::move(dft); @@ -150,8 +150,8 @@ namespace sqlite_orm { class T, typename = typename std::enable_if::value>::type, class... Op> - internal::column_t - make_column(const std::string &name, T O::*m, Op... constraints) { + internal::column_t + make_column(const std::string& name, T O::*m, Op... constraints) { static_assert(constraints::template constraints_size::value == std::tuple_size>::value, "Incorrect constraints pack"); static_assert(internal::is_field_member_pointer::value, @@ -172,7 +172,7 @@ namespace sqlite_orm { G, S, Op...> - make_column(const std::string &name, S setter, G getter, Op... constraints) { + make_column(const std::string& name, S setter, G getter, Op... constraints) { static_assert(std::is_same::field_type, typename internal::getter_traits::field_type>::value, "Getter and setter must get and set same data type"); @@ -195,7 +195,7 @@ namespace sqlite_orm { G, S, Op...> - make_column(const std::string &name, G getter, S setter, Op... constraints) { + make_column(const std::string& name, G getter, S setter, Op... constraints) { static_assert(std::is_same::field_type, typename internal::getter_traits::field_type>::value, "Getter and setter must get and set same data type"); diff --git a/dev/column_names_getter.h b/dev/column_names_getter.h index 26e43481c..c516d70a9 100644 --- a/dev/column_names_getter.h +++ b/dev/column_names_getter.h @@ -12,14 +12,14 @@ namespace sqlite_orm { namespace internal { template - std::string serialize(const T &t, const C &context); + std::string serialize(const T& t, const C& context); template struct column_names_getter { using expression_type = T; template - std::vector operator()(const expression_type &t, const C &context) { + std::vector operator()(const expression_type& t, const C& context) { auto newContext = context; newContext.skip_table_name = false; auto columnName = serialize(t, newContext); @@ -32,7 +32,7 @@ namespace sqlite_orm { }; template - std::vector get_column_names(const T &t, const C &context) { + std::vector get_column_names(const T& t, const C& context) { column_names_getter serializator; return serializator(t, context); } @@ -42,7 +42,7 @@ namespace sqlite_orm { using expression_type = std::reference_wrapper; template - std::vector operator()(const expression_type &expression, const C &context) { + std::vector operator()(const expression_type& expression, const C& context) { return get_column_names(expression.get(), context); } }; @@ -52,7 +52,7 @@ namespace sqlite_orm { using expression_type = asterisk_t; template - std::vector operator()(const expression_type &, const C &) { + std::vector operator()(const expression_type&, const C&) { std::vector res; res.push_back("*"); return res; @@ -64,7 +64,7 @@ namespace sqlite_orm { using expression_type = object_t; template - std::vector operator()(const expression_type &, const C &) { + std::vector operator()(const expression_type&, const C&) { std::vector res; res.push_back("*"); return res; @@ -76,12 +76,12 @@ namespace sqlite_orm { using expression_type = columns_t; template - std::vector operator()(const expression_type &cols, const C &context) { + std::vector operator()(const expression_type& cols, const C& context) { std::vector columnNames; columnNames.reserve(static_cast(cols.count)); auto newContext = context; newContext.skip_table_name = false; - iterate_tuple(cols.columns, [&columnNames, &newContext](auto &m) { + iterate_tuple(cols.columns, [&columnNames, &newContext](auto& m) { auto columnName = serialize(m, newContext); if(columnName.length()) { columnNames.push_back(columnName); diff --git a/dev/column_result.h b/dev/column_result.h index 3f3cd54b1..0ea37b3b2 100644 --- a/dev/column_result.h +++ b/dev/column_result.h @@ -206,7 +206,7 @@ namespace sqlite_orm { * Result for the most simple queries like `SELECT 'ototo'` */ template - struct column_result_t { + struct column_result_t { using type = std::string; }; diff --git a/dev/conditions.h b/dev/conditions.h index cf09c3e08..97f054d03 100644 --- a/dev/conditions.h +++ b/dev/conditions.h @@ -488,7 +488,7 @@ namespace sqlite_orm { args_type args; - multi_order_by_t(args_type &&args_) : args(std::move(args_)) {} + multi_order_by_t(args_type&& args_) : args(std::move(args_)) {} }; struct dynamic_order_by_entry_t : order_by_base { @@ -507,7 +507,7 @@ namespace sqlite_orm { using entry_t = dynamic_order_by_entry_t; using const_iterator = typename std::vector::const_iterator; - dynamic_order_by_t(const context_t &context_) : context(context_) {} + dynamic_order_by_t(const context_t& context_) : context(context_) {} template void push_back(order_by_t order_by) { @@ -560,7 +560,7 @@ namespace sqlite_orm { using args_type = std::tuple; args_type args; - group_by_t(args_type &&args_) : args(std::move(args_)) {} + group_by_t(args_type&& args_) : args(std::move(args_)) {} }; template @@ -1205,7 +1205,7 @@ namespace sqlite_orm { * Example: storage.get_all(multi_order_by(order_by(&Singer::name).asc(), order_by(&Singer::gender).desc()) */ template - internal::multi_order_by_t multi_order_by(Args &&... args) { + internal::multi_order_by_t multi_order_by(Args&&... args) { return {std::make_tuple(std::forward(args)...)}; } @@ -1223,7 +1223,7 @@ namespace sqlite_orm { */ template internal::dynamic_order_by_t> - dynamic_order_by(const S &storage) { + dynamic_order_by(const S& storage) { internal::serializator_context_builder builder(storage); return builder(); } @@ -1233,7 +1233,7 @@ namespace sqlite_orm { * Example: storage.get_all(group_by(&Employee::name)) */ template - internal::group_by_t group_by(Args &&... args) { + internal::group_by_t group_by(Args&&... args) { return {std::make_tuple(std::forward(args)...)}; } diff --git a/dev/connection_holder.h b/dev/connection_holder.h index d76e82279..e1857a759 100644 --- a/dev/connection_holder.h +++ b/dev/connection_holder.h @@ -36,7 +36,7 @@ namespace sqlite_orm { } } - sqlite3 *get() const { + sqlite3* get() const { return this->db; } @@ -47,20 +47,20 @@ namespace sqlite_orm { const std::string filename; protected: - sqlite3 *db = nullptr; + sqlite3* db = nullptr; int _retain_count = 0; }; struct connection_ref { - connection_ref(connection_holder &holder_) : holder(holder_) { + connection_ref(connection_holder& holder_) : holder(holder_) { this->holder.retain(); } - connection_ref(const connection_ref &other) : holder(other.holder) { + connection_ref(const connection_ref& other) : holder(other.holder) { this->holder.retain(); } - connection_ref(connection_ref &&other) : holder(other.holder) { + connection_ref(connection_ref&& other) : holder(other.holder) { this->holder.retain(); } @@ -68,12 +68,12 @@ namespace sqlite_orm { this->holder.release(); } - sqlite3 *get() const { + sqlite3* get() const { return this->holder.get(); } protected: - connection_holder &holder; + connection_holder& holder; }; } } diff --git a/dev/constraints.h b/dev/constraints.h index 1b21964a1..4039b1992 100644 --- a/dev/constraints.h +++ b/dev/constraints.h @@ -126,7 +126,7 @@ namespace sqlite_orm { cascade, }; - inline std::ostream &operator<<(std::ostream &os, foreign_key_action action) { + inline std::ostream& operator<<(std::ostream& os, foreign_key_action action) { switch(action) { case decltype(action)::no_action: os << "NO ACTION"; @@ -168,7 +168,7 @@ namespace sqlite_orm { struct on_update_delete_t : on_update_delete_base { using foreign_key_type = F; - const foreign_key_type &fk; + const foreign_key_type& fk; on_update_delete_t(decltype(fk) fk_, decltype(update) update_, foreign_key_action action_) : on_update_delete_base{update_}, fk(fk_), _action(action_) {} @@ -249,11 +249,11 @@ namespace sqlite_orm { 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) : + foreign_key_t(const self& other) : columns(other.columns), references(other.references), on_update(*this, true, other.on_update._action), on_delete(*this, false, other.on_delete._action) {} - self &operator=(const self &other) { + self& operator=(const self& other) { this->columns = other.columns; this->references = other.references; this->on_update = {*this, true, other.on_update._action}; @@ -262,7 +262,7 @@ namespace sqlite_orm { } template - void for_each_column(const L &) {} + void for_each_column(const L&) {} template constexpr bool has_every() const { diff --git a/dev/core_functions.h b/dev/core_functions.h index f22da035b..ea1766d46 100644 --- a/dev/core_functions.h +++ b/dev/core_functions.h @@ -36,7 +36,7 @@ namespace sqlite_orm { args_type args; - core_function_t(args_type &&args_) : args(std::move(args_)) {} + core_function_t(args_type&& args_) : args(std::move(args_)) {} }; struct typeof_string { diff --git a/dev/default_value_extractor.h b/dev/default_value_extractor.h index 1c231e140..d92c7c41b 100644 --- a/dev/default_value_extractor.h +++ b/dev/default_value_extractor.h @@ -12,7 +12,7 @@ namespace sqlite_orm { namespace internal { template - std::string serialize(const T &t); + std::string serialize(const T& t); /** * This class is used in tuple interation to know whether tuple constains `default_value_t` @@ -21,12 +21,12 @@ namespace sqlite_orm { struct default_value_extractor { template - std::unique_ptr operator()(const A &) { + std::unique_ptr operator()(const A&) { return {}; } template - std::unique_ptr operator()(const constraints::default_t &t) { + std::unique_ptr operator()(const constraints::default_t& t) { serializator_context_base context; return std::make_unique(serialize(t.value, context)); } diff --git a/dev/error_code.h b/dev/error_code.h index 706bc4d26..b527a7d90 100644 --- a/dev/error_code.h +++ b/dev/error_code.h @@ -31,7 +31,7 @@ namespace sqlite_orm { class orm_error_category : public std::error_category { public: - const char *name() const noexcept override final { + const char* name() const noexcept override final { return "ORM error"; } @@ -71,7 +71,7 @@ namespace sqlite_orm { class sqlite_error_category : public std::error_category { public: - const char *name() const noexcept override final { + const char* name() const noexcept override final { return "SQLite error"; } @@ -80,18 +80,18 @@ namespace sqlite_orm { } }; - inline const orm_error_category &get_orm_error_category() { + inline const orm_error_category& get_orm_error_category() { static orm_error_category res; return res; } - inline const sqlite_error_category &get_sqlite_error_category() { + inline const sqlite_error_category& get_sqlite_error_category() { static sqlite_error_category res; return res; } template - std::string get_error_message(sqlite3 *db, T &&... args) { + std::string get_error_message(sqlite3* db, T&&... args) { std::ostringstream stream; using unpack = int[]; static_cast(unpack{0, (static_cast(static_cast(stream << args)), 0)...}); @@ -100,7 +100,7 @@ namespace sqlite_orm { } template - [[noreturn]] void throw_error(sqlite3 *db, T &&... args) { + [[noreturn]] void throw_error(sqlite3* db, T&&... args) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), get_error_message(db, std::forward(args)...)); } diff --git a/dev/expression_object_type.h b/dev/expression_object_type.h index 83e69d5da..3e01a0063 100644 --- a/dev/expression_object_type.h +++ b/dev/expression_object_type.h @@ -56,7 +56,7 @@ namespace sqlite_orm { struct get_ref_t { template - auto &operator()(O &t) const { + auto& operator()(O& t) const { return t; } }; @@ -65,13 +65,13 @@ namespace sqlite_orm { struct get_ref_t> { template - auto &operator()(O &t) const { + auto& operator()(O& t) const { return t.get(); } }; template - auto &get_ref(T &t) { + auto& get_ref(T& t) { using arg_type = typename std::decay::type; get_ref_t g; return g(t); @@ -84,7 +84,7 @@ namespace sqlite_orm { struct get_object_t : get_object_t {}; template - auto &get_object(T &t) { + auto& get_object(T& t) { using expression_type = typename std::decay::type; get_object_t obj; return obj(t); @@ -95,7 +95,7 @@ namespace sqlite_orm { using expression_type = replace_t; template - auto &operator()(O &e) const { + auto& operator()(O& e) const { return get_ref(e.obj); } }; @@ -105,7 +105,7 @@ namespace sqlite_orm { using expression_type = insert_t; template - auto &operator()(O &e) const { + auto& operator()(O& e) const { return get_ref(e.obj); } }; @@ -115,7 +115,7 @@ namespace sqlite_orm { using expression_type = update_t; template - auto &operator()(O &e) const { + auto& operator()(O& e) const { return get_ref(e.obj); } }; diff --git a/dev/field_printer.h b/dev/field_printer.h index e79ac8d1d..33aa4168a 100644 --- a/dev/field_printer.h +++ b/dev/field_printer.h @@ -17,7 +17,7 @@ namespace sqlite_orm { */ template struct field_printer { - std::string operator()(const T &t) const { + std::string operator()(const T& t) const { std::stringstream stream; stream << t; return stream.str(); @@ -29,7 +29,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const unsigned char &t) const { + std::string operator()(const unsigned char& t) const { std::stringstream stream; stream << +t; return stream.str(); @@ -41,7 +41,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const signed char &t) const { + std::string operator()(const signed char& t) const { std::stringstream stream; stream << +t; return stream.str(); @@ -53,7 +53,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const char &t) const { + std::string operator()(const char& t) const { std::stringstream stream; stream << +t; return stream.str(); @@ -62,14 +62,14 @@ namespace sqlite_orm { template<> struct field_printer { - std::string operator()(const std::string &t) const { + std::string operator()(const std::string& t) const { return t; } }; template<> struct field_printer> { - std::string operator()(const std::vector &t) const { + std::string operator()(const std::vector& t) const { std::stringstream ss; ss << std::hex; for(auto c: t) { @@ -81,14 +81,14 @@ namespace sqlite_orm { template<> struct field_printer { - std::string operator()(const std::nullptr_t &) const { + std::string operator()(const std::nullptr_t&) const { return "null"; } }; template struct field_printer> { - std::string operator()(const std::shared_ptr &t) const { + std::string operator()(const std::shared_ptr& t) const { if(t) { return field_printer()(*t); } else { @@ -99,7 +99,7 @@ namespace sqlite_orm { template struct field_printer> { - std::string operator()(const std::unique_ptr &t) const { + std::string operator()(const std::unique_ptr& t) const { if(t) { return field_printer()(*t); } else { @@ -111,7 +111,7 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template struct field_printer> { - std::string operator()(const std::optional &t) const { + std::string operator()(const std::optional& t) const { if(t.has_value()) { return field_printer()(*t); } else { diff --git a/dev/field_value_holder.h b/dev/field_value_holder.h index 80432dd1d..6dd96ad07 100644 --- a/dev/field_value_holder.h +++ b/dev/field_value_holder.h @@ -14,7 +14,7 @@ namespace sqlite_orm { struct field_value_holder::returns_lvalue>::type> { using type = typename getter_traits::field_type; - const type &value; + const type& value; }; template diff --git a/dev/get_prepared_statement.h b/dev/get_prepared_statement.h index 1b2ee1e08..433c8de1f 100644 --- a/dev/get_prepared_statement.h +++ b/dev/get_prepared_statement.h @@ -10,131 +10,131 @@ namespace sqlite_orm { template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } #endif // SQLITE_ORM_OPTIONAL_SUPPORTED template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for update statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for update statement"); return internal::get_ref(statement.t.obj); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for replace statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for replace statement"); return internal::get_ref(statement.t.obj); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t &statement) { + const auto& get(const internal::prepared_statement_t& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using node_tuple = typename internal::node_tuple::type; using bind_tuple = typename internal::bindable_filter::type; using result_tupe = typename std::tuple_element::type; - const result_tupe *result = nullptr; + const result_tupe* result = nullptr; auto index = -1; - internal::iterate_ast(statement.t, [&result, &index](auto &node) { + internal::iterate_ast(statement.t, [&result, &index](auto& node) { using node_type = typename std::decay::type; if(internal::is_bindable::value) { ++index; } if(index == N) { - internal::static_if{}>([](auto &r, auto &n) { + internal::static_if{}>([](auto& r, auto& n) { r = const_cast::type>(&n); })(result, node); } @@ -143,21 +143,21 @@ namespace sqlite_orm { } template - auto &get(internal::prepared_statement_t &statement) { + auto& get(internal::prepared_statement_t& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using node_tuple = typename internal::node_tuple::type; using bind_tuple = typename internal::bindable_filter::type; using result_tupe = typename std::tuple_element::type; - result_tupe *result = nullptr; + result_tupe* result = nullptr; auto index = -1; - internal::iterate_ast(statement.t, [&result, &index](auto &node) { + internal::iterate_ast(statement.t, [&result, &index](auto& node) { using node_type = typename std::decay::type; if(internal::is_bindable::value) { ++index; } if(index == N) { - internal::static_if{}>([](auto &r, auto &n) { + internal::static_if{}>([](auto& r, auto& n) { r = const_cast::type>(&n); })(result, node); } diff --git a/dev/getter_traits.h b/dev/getter_traits.h index 07b1b7585..ae862e4e5 100644 --- a/dev/getter_traits.h +++ b/dev/getter_traits.h @@ -32,16 +32,16 @@ namespace sqlite_orm { using getter_by_value = T (O::*)(); template - using getter_by_ref_const = T &(O::*)() const; + using getter_by_ref_const = T& (O::*)() const; template - using getter_by_ref = T &(O::*)(); + using getter_by_ref = T& (O::*)(); template - using getter_by_const_ref_const = const T &(O::*)() const; + using getter_by_const_ref_const = const T& (O::*)() const; template - using getter_by_const_ref = const T &(O::*)(); + using getter_by_const_ref = const T& (O::*)(); /** * Setters aliases @@ -50,10 +50,10 @@ namespace sqlite_orm { using setter_by_value = void (O::*)(T); template - using setter_by_ref = void (O::*)(T &); + using setter_by_ref = void (O::*)(T&); template - using setter_by_const_ref = void (O::*)(const T &); + using setter_by_const_ref = void (O::*)(const T&); template struct is_getter : std::false_type {}; diff --git a/dev/index.h b/dev/index.h index b509ede47..dec22ab33 100644 --- a/dev/index.h +++ b/dev/index.h @@ -28,13 +28,13 @@ namespace sqlite_orm { } template - internal::index_t::type...> make_index(const std::string &name, + internal::index_t::type...> make_index(const std::string& name, Cols... cols) { return {name, false, std::make_tuple(internal::make_indexed_column(cols)...)}; } template - internal::index_t::type...> make_unique_index(const std::string &name, + internal::index_t::type...> make_unique_index(const std::string& name, Cols... cols) { return {name, true, std::make_tuple(internal::make_indexed_column(cols)...)}; } diff --git a/dev/is_base_of_template.h b/dev/is_base_of_template.h index b349d77b2..87a0540c9 100644 --- a/dev/is_base_of_template.h +++ b/dev/is_base_of_template.h @@ -14,11 +14,11 @@ namespace sqlite_orm { template class Base, typename Derived> struct is_base_of_template_impl { template - static constexpr std::true_type test(const Base *); + static constexpr std::true_type test(const Base*); static constexpr std::false_type test(...); - using type = decltype(test(std::declval())); + using type = decltype(test(std::declval())); }; template class Base> @@ -26,13 +26,13 @@ namespace sqlite_orm { #else template class C, typename... Ts> - std::true_type is_base_of_template_impl(const C *); + std::true_type is_base_of_template_impl(const C*); template class C> std::false_type is_base_of_template_impl(...); template class C> - using is_base_of_template = decltype(is_base_of_template_impl(std::declval())); + using is_base_of_template = decltype(is_base_of_template_impl(std::declval())); #endif } } diff --git a/dev/is_std_ptr.h b/dev/is_std_ptr.h index 42302c76f..31003cdf2 100644 --- a/dev/is_std_ptr.h +++ b/dev/is_std_ptr.h @@ -12,7 +12,7 @@ namespace sqlite_orm { struct is_std_ptr> : std::true_type { using element_type = T; - static std::shared_ptr make(const T &v) { + static std::shared_ptr make(const T& v) { return std::make_shared(v); } }; @@ -21,7 +21,7 @@ namespace sqlite_orm { struct is_std_ptr> : std::true_type { using element_type = T; - static std::unique_ptr make(const T &v) { + static std::unique_ptr make(const T& v) { return std::make_unique(v); } }; diff --git a/dev/iterator.h b/dev/iterator.h index 187d082e9..4c8a3835e 100644 --- a/dev/iterator.h +++ b/dev/iterator.h @@ -30,8 +30,8 @@ namespace sqlite_orm { * call. When one finishes iterating it the pointer * inside the shared_ptr is nulled out in all copies. */ - std::shared_ptr stmt; - view_type &view; + std::shared_ptr stmt; + view_type& view; /** * shared_ptr is used over unique_ptr here @@ -39,32 +39,32 @@ namespace sqlite_orm { */ std::shared_ptr current; - void extract_value(std::unique_ptr &temp) { + void extract_value(std::unique_ptr& temp) { temp = std::make_unique(); - auto &storage = this->view.storage; - auto &impl = storage.template get_impl(); + auto& storage = this->view.storage; + auto& impl = storage.template get_impl(); object_from_column_builder builder{*temp, *this->stmt}; impl.table.for_each_column(builder); } public: using difference_type = std::ptrdiff_t; - using pointer = value_type *; - using reference = value_type &; + using pointer = value_type*; + using reference = value_type&; using iterator_category = std::input_iterator_tag; - iterator_t(sqlite3_stmt *stmt_, view_type &view_) : - stmt(std::make_shared(stmt_)), view(view_) { + iterator_t(sqlite3_stmt* stmt_, view_type& view_) : + stmt(std::make_shared(stmt_)), view(view_) { this->operator++(); } - iterator_t(const iterator_t &) = default; + iterator_t(const iterator_t&) = default; - iterator_t(iterator_t &&) = default; + iterator_t(iterator_t&&) = default; - iterator_t &operator=(iterator_t &&) = default; + iterator_t& operator=(iterator_t&&) = default; - iterator_t &operator=(const iterator_t &) = default; + iterator_t& operator=(const iterator_t&) = default; ~iterator_t() { if(this->stmt) { @@ -72,7 +72,7 @@ namespace sqlite_orm { } } - value_type &operator*() { + value_type& operator*() { if(!this->stmt) { throw std::system_error(std::make_error_code(orm_error_code::trying_to_dereference_null_iterator)); } @@ -84,7 +84,7 @@ namespace sqlite_orm { return *this->current; } - value_type *operator->() { + value_type* operator->() { return &(this->operator*()); } @@ -112,7 +112,7 @@ namespace sqlite_orm { this->operator++(); } - bool operator==(const iterator_t &other) const { + bool operator==(const iterator_t& other) const { if(this->stmt && other.stmt) { return *this->stmt == *other.stmt; } else { @@ -124,7 +124,7 @@ namespace sqlite_orm { } } - bool operator!=(const iterator_t &other) const { + bool operator!=(const iterator_t& other) const { return !(*this == other); } }; diff --git a/dev/join_iterator.h b/dev/join_iterator.h index 4d9777d1a..2e2c5fb02 100644 --- a/dev/join_iterator.h +++ b/dev/join_iterator.h @@ -10,7 +10,7 @@ namespace sqlite_orm { struct join_iterator { template - void operator()(const L &) { + void operator()(const L&) { //.. } }; @@ -19,7 +19,7 @@ namespace sqlite_orm { struct join_iterator<> { template - void operator()(const L &) { + void operator()(const L&) { //.. } }; @@ -29,7 +29,7 @@ namespace sqlite_orm { using super = join_iterator; template - void operator()(const L &l) { + void operator()(const L& l) { this->super::operator()(l); } }; @@ -40,7 +40,7 @@ namespace sqlite_orm { using join_type = cross_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -52,7 +52,7 @@ namespace sqlite_orm { using join_type = natural_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -64,7 +64,7 @@ namespace sqlite_orm { using join_type = left_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -76,7 +76,7 @@ namespace sqlite_orm { using join_type = join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -88,7 +88,7 @@ namespace sqlite_orm { using join_type = left_outer_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -100,7 +100,7 @@ namespace sqlite_orm { using join_type = inner_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } diff --git a/dev/journal_mode.h b/dev/journal_mode.h index 6226a7d81..70b0f6c08 100644 --- a/dev/journal_mode.h +++ b/dev/journal_mode.h @@ -25,7 +25,7 @@ namespace sqlite_orm { namespace internal { - inline const std::string &to_string(journal_mode j) { + inline const std::string& to_string(journal_mode j) { static std::string res[] = { "DELETE", "TRUNCATE", @@ -37,7 +37,7 @@ namespace sqlite_orm { return res[static_cast(j)]; } - inline std::unique_ptr journal_mode_from_string(const std::string &str) { + inline std::unique_ptr journal_mode_from_string(const std::string& str) { std::string upper_str; std::transform(str.begin(), str.end(), std::back_inserter(upper_str), [](char c) { return static_cast(std::toupper(static_cast(c))); diff --git a/dev/mapped_row_extractor.h b/dev/mapped_row_extractor.h index 5a50e7d14..a48e219e6 100644 --- a/dev/mapped_row_extractor.h +++ b/dev/mapped_row_extractor.h @@ -20,16 +20,16 @@ namespace sqlite_orm { struct mapped_row_extractor { using table_info_t = T; - mapped_row_extractor(const table_info_t &tableInfo_) : tableInfo(tableInfo_) {} + mapped_row_extractor(const table_info_t& tableInfo_) : tableInfo(tableInfo_) {} - V extract(sqlite3_stmt *stmt, int /*columnIndex*/) { + V extract(sqlite3_stmt* stmt, int /*columnIndex*/) { V res; object_from_column_builder builder{res, stmt}; this->tableInfo.for_each_column(builder); return res; } - const table_info_t &tableInfo; + const table_info_t& tableInfo; }; } diff --git a/dev/object_from_column_builder.h b/dev/object_from_column_builder.h index 6c45e2739..eb86437e6 100644 --- a/dev/object_from_column_builder.h +++ b/dev/object_from_column_builder.h @@ -9,7 +9,7 @@ namespace sqlite_orm { namespace internal { struct object_from_column_builder_base { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; mutable int index = 0; }; @@ -20,13 +20,13 @@ namespace sqlite_orm { struct object_from_column_builder : object_from_column_builder_base { using object_type = O; - object_type &object; + object_type& object; - object_from_column_builder(object_type &object_, sqlite3_stmt *stmt_) : + object_from_column_builder(object_type& object_, sqlite3_stmt* stmt_) : object_from_column_builder_base{stmt_}, object(object_) {} template - void operator()(const C &c) const { + void operator()(const C& c) const { using field_type = typename C::field_type; auto value = row_extractor().extract(this->stmt, this->index++); if(c.member_pointer) { diff --git a/dev/optional_container.h b/dev/optional_container.h index 12b5b2446..adc6a10eb 100644 --- a/dev/optional_container.h +++ b/dev/optional_container.h @@ -15,7 +15,7 @@ namespace sqlite_orm { type field; template - void apply(const L &l) const { + void apply(const L& l) const { l(this->field); } }; @@ -25,7 +25,7 @@ namespace sqlite_orm { using type = void; template - void apply(const L &) const { + void apply(const L&) const { //.. } }; diff --git a/dev/order_by_serializator.h b/dev/order_by_serializator.h index 082b61647..39be5081f 100644 --- a/dev/order_by_serializator.h +++ b/dev/order_by_serializator.h @@ -12,7 +12,7 @@ namespace sqlite_orm { struct order_by_serializator; template - std::string serialize_order_by(const T &t, const C &context) { + std::string serialize_order_by(const T& t, const C& context) { order_by_serializator serializator; return serializator(t, context); } @@ -22,7 +22,7 @@ namespace sqlite_orm { using statement_type = order_by_t; template - std::string operator()(const statement_type &orderBy, const C &context) const { + std::string operator()(const statement_type& orderBy, const C& context) const { std::stringstream ss; auto newContext = context; newContext.skip_table_name = false; @@ -48,9 +48,9 @@ namespace sqlite_orm { using statement_type = dynamic_order_by_t; template - std::string operator()(const statement_type &orderBy, const C &) const { + std::string operator()(const statement_type& orderBy, const C&) const { std::vector expressions; - for(auto &entry: orderBy) { + for(auto& entry: orderBy) { std::string entryString; { std::stringstream ss; diff --git a/dev/pragma.h b/dev/pragma.h index 9a35d51c9..f6013d023 100644 --- a/dev/pragma.h +++ b/dev/pragma.h @@ -75,7 +75,7 @@ namespace sqlite_orm { get_connection_t get_connection; template - T get_pragma(const std::string &name) { + T get_pragma(const std::string& name) { auto connection = this->get_connection(); auto query = "PRAGMA " + name; T result; @@ -83,8 +83,8 @@ namespace sqlite_orm { auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(T *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(T*)data; if(argc) { res = row_extractor().extract(argv[0]); } @@ -105,7 +105,7 @@ namespace sqlite_orm { * but it turns out that bindings in pragma statements are not supported. */ template - void set_pragma(const std::string &name, const T &value, sqlite3 *db = nullptr) { + void set_pragma(const std::string& name, const T& value, sqlite3* db = nullptr) { auto con = this->get_connection(); if(!db) { db = con.get(); @@ -115,7 +115,7 @@ namespace sqlite_orm { internal::perform_void_exec(db, ss.str()); } - void set_pragma(const std::string &name, const sqlite_orm::journal_mode &value, sqlite3 *db = nullptr) { + void set_pragma(const std::string& name, const sqlite_orm::journal_mode& value, sqlite3* db = nullptr) { auto con = this->get_connection(); if(!db) { db = con.get(); diff --git a/dev/prepared_statement.h b/dev/prepared_statement.h index 630a1d27b..4ba477a3c 100644 --- a/dev/prepared_statement.h +++ b/dev/prepared_statement.h @@ -14,7 +14,7 @@ namespace sqlite_orm { namespace internal { struct prepared_statement_base { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; connection_ref con; ~prepared_statement_base() { @@ -72,7 +72,7 @@ namespace sqlite_orm { expression_type t; - prepared_statement_t(T t_, sqlite3_stmt *stmt_, connection_ref con_) : + prepared_statement_t(T t_, sqlite3_stmt* stmt_, connection_ref con_) : prepared_statement_base{stmt_, std::move(con_)}, t(std::move(t_)) {} }; diff --git a/dev/row_extractor.h b/dev/row_extractor.h index 41027d0ee..d1553df05 100644 --- a/dev/row_extractor.h +++ b/dev/row_extractor.h @@ -27,10 +27,10 @@ namespace sqlite_orm { template struct row_extractor { // used in sqlite3_exec (select) - V extract(const char *row_value); + V extract(const char* row_value); // used in sqlite_column (iteration, get_all) - V extract(sqlite3_stmt *stmt, int columnIndex); + V extract(sqlite3_stmt* stmt, int columnIndex); }; /** @@ -38,38 +38,38 @@ namespace sqlite_orm { */ template struct row_extractor::value>> { - V extract(const char *row_value) { + V extract(const char* row_value) { return extract(row_value, tag()); } - V extract(sqlite3_stmt *stmt, int columnIndex) { + V extract(sqlite3_stmt* stmt, int columnIndex) { return extract(stmt, columnIndex, tag()); } private: using tag = arithmetic_tag_t; - V extract(const char *row_value, const int_or_smaller_tag &) { + V extract(const char* row_value, const int_or_smaller_tag&) { return static_cast(atoi(row_value)); } - V extract(sqlite3_stmt *stmt, int columnIndex, const int_or_smaller_tag &) { + V extract(sqlite3_stmt* stmt, int columnIndex, const int_or_smaller_tag&) { return static_cast(sqlite3_column_int(stmt, columnIndex)); } - V extract(const char *row_value, const bigint_tag &) { + V extract(const char* row_value, const bigint_tag&) { return static_cast(atoll(row_value)); } - V extract(sqlite3_stmt *stmt, int columnIndex, const bigint_tag &) { + V extract(sqlite3_stmt* stmt, int columnIndex, const bigint_tag&) { return static_cast(sqlite3_column_int64(stmt, columnIndex)); } - V extract(const char *row_value, const real_tag &) { + V extract(const char* row_value, const real_tag&) { return static_cast(atof(row_value)); } - V extract(sqlite3_stmt *stmt, int columnIndex, const real_tag &) { + V extract(sqlite3_stmt* stmt, int columnIndex, const real_tag&) { return static_cast(sqlite3_column_double(stmt, columnIndex)); } }; @@ -79,7 +79,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - std::string extract(const char *row_value) { + std::string extract(const char* row_value) { if(row_value) { return row_value; } else { @@ -87,8 +87,8 @@ namespace sqlite_orm { } } - std::string extract(sqlite3_stmt *stmt, int columnIndex) { - auto cStr = (const char *)sqlite3_column_text(stmt, columnIndex); + std::string extract(sqlite3_stmt* stmt, int columnIndex) { + auto cStr = (const char*)sqlite3_column_text(stmt, columnIndex); if(cStr) { return cStr; } else { @@ -102,7 +102,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - std::wstring extract(const char *row_value) { + std::wstring extract(const char* row_value) { if(row_value) { std::wstring_convert> converter; return converter.from_bytes(row_value); @@ -111,8 +111,8 @@ namespace sqlite_orm { } } - std::wstring extract(sqlite3_stmt *stmt, int columnIndex) { - auto cStr = (const char *)sqlite3_column_text(stmt, columnIndex); + std::wstring extract(sqlite3_stmt* stmt, int columnIndex) { + auto cStr = (const char*)sqlite3_column_text(stmt, columnIndex); if(cStr) { std::wstring_convert> converter; return converter.from_bytes(cStr); @@ -127,7 +127,7 @@ namespace sqlite_orm { struct row_extractor::value>> { using value_type = typename is_std_ptr::element_type; - V extract(const char *row_value) { + V extract(const char* row_value) { if(row_value) { return is_std_ptr::make(row_extractor().extract(row_value)); } else { @@ -135,7 +135,7 @@ namespace sqlite_orm { } } - V extract(sqlite3_stmt *stmt, int columnIndex) { + V extract(sqlite3_stmt* stmt, int columnIndex) { auto type = sqlite3_column_type(stmt, columnIndex); if(type != SQLITE_NULL) { return is_std_ptr::make(row_extractor().extract(stmt, columnIndex)); @@ -150,7 +150,7 @@ namespace sqlite_orm { struct row_extractor, void> { using value_type = T; - std::optional extract(const char *row_value) { + std::optional extract(const char* row_value) { if(row_value) { return std::make_optional(row_extractor().extract(row_value)); } else { @@ -158,7 +158,7 @@ namespace sqlite_orm { } } - std::optional extract(sqlite3_stmt *stmt, int columnIndex) { + std::optional extract(sqlite3_stmt* stmt, int columnIndex) { auto type = sqlite3_column_type(stmt, columnIndex); if(type != SQLITE_NULL) { return std::make_optional(row_extractor().extract(stmt, columnIndex)); @@ -173,7 +173,7 @@ namespace sqlite_orm { */ template<> struct row_extractor> { - std::vector extract(const char *row_value) { + std::vector extract(const char* row_value) { if(row_value) { auto len = ::strlen(row_value); return this->go(row_value, len); @@ -182,14 +182,14 @@ namespace sqlite_orm { } } - std::vector extract(sqlite3_stmt *stmt, int columnIndex) { - auto bytes = static_cast(sqlite3_column_blob(stmt, columnIndex)); + std::vector extract(sqlite3_stmt* stmt, int columnIndex) { + auto bytes = static_cast(sqlite3_column_blob(stmt, columnIndex)); auto len = static_cast(sqlite3_column_bytes(stmt, columnIndex)); return this->go(bytes, len); } protected: - std::vector go(const char *bytes, size_t len) { + std::vector go(const char* bytes, size_t len) { if(len) { std::vector res; res.reserve(len); @@ -204,40 +204,40 @@ namespace sqlite_orm { template struct row_extractor> { - std::tuple extract(char **argv) { + std::tuple extract(char** argv) { std::tuple res; this->extract::value>(res, argv); return res; } - std::tuple extract(sqlite3_stmt *stmt, int /*columnIndex*/) { + std::tuple extract(sqlite3_stmt* stmt, int /*columnIndex*/) { std::tuple res; this->extract::value>(res, stmt); return res; } protected: - template::type * = nullptr> - void extract(std::tuple &t, sqlite3_stmt *stmt) { + template::type* = nullptr> + void extract(std::tuple& t, sqlite3_stmt* stmt) { using tuple_type = typename std::tuple_element>::type; std::get(t) = row_extractor().extract(stmt, I - 1); this->extract(t, stmt); } - template::type * = nullptr> - void extract(std::tuple &, sqlite3_stmt *) { + template::type* = nullptr> + void extract(std::tuple&, sqlite3_stmt*) { //.. } - template::type * = nullptr> - void extract(std::tuple &t, char **argv) { + template::type* = nullptr> + void extract(std::tuple& t, char** argv) { using tuple_type = typename std::tuple_element>::type; std::get(t) = row_extractor().extract(argv[I - 1]); this->extract(t, argv); } - template::type * = nullptr> - void extract(std::tuple &, char **) { + template::type* = nullptr> + void extract(std::tuple&, char**) { //.. } }; @@ -247,7 +247,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - journal_mode extract(const char *row_value) { + journal_mode extract(const char* row_value) { if(row_value) { if(auto res = internal::journal_mode_from_string(row_value)) { return std::move(*res); @@ -259,8 +259,8 @@ namespace sqlite_orm { } } - journal_mode extract(sqlite3_stmt *stmt, int columnIndex) { - auto cStr = (const char *)sqlite3_column_text(stmt, columnIndex); + journal_mode extract(sqlite3_stmt* stmt, int columnIndex) { + auto cStr = (const char*)sqlite3_column_text(stmt, columnIndex); return this->extract(cStr); } }; diff --git a/dev/row_extractor_builder.h b/dev/row_extractor_builder.h index 20c20b764..0835e26d7 100644 --- a/dev/row_extractor_builder.h +++ b/dev/row_extractor_builder.h @@ -19,7 +19,7 @@ namespace sqlite_orm { template struct row_extractor_builder { - row_extractor operator()(const I * /*tableInfo*/) const { + row_extractor operator()(const I* /*tableInfo*/) const { return {}; } }; @@ -27,13 +27,13 @@ namespace sqlite_orm { template struct row_extractor_builder { - mapped_row_extractor operator()(const I *tableInfo) const { + mapped_row_extractor operator()(const I* tableInfo) const { return {*tableInfo}; } }; template - auto make_row_extractor(const I *tableInfo) { + auto make_row_extractor(const I* tableInfo) { using builder_t = row_extractor_builder; return builder_t{}(tableInfo); } diff --git a/dev/select_constraints.h b/dev/select_constraints.h index 406ded4b1..a205fcdcb 100644 --- a/dev/select_constraints.h +++ b/dev/select_constraints.h @@ -165,12 +165,12 @@ namespace sqlite_orm { * Generic way to get DISTINCT value from any type. */ template - bool get_distinct(const T &) { + bool get_distinct(const T&) { return false; } template - bool get_distinct(const columns_t &cols) { + bool get_distinct(const columns_t& cols) { return cols.distinct; } diff --git a/dev/serializator_context.h b/dev/serializator_context.h index e568eed75..27398952d 100644 --- a/dev/serializator_context.h +++ b/dev/serializator_context.h @@ -19,9 +19,9 @@ namespace sqlite_orm { struct serializator_context : serializator_context_base { using impl_type = I; - const impl_type &impl; + const impl_type& impl; - serializator_context(const impl_type &impl_) : impl(impl_) {} + serializator_context(const impl_type& impl_) : impl(impl_) {} template std::string column_name(F O::*m) const { @@ -34,13 +34,13 @@ namespace sqlite_orm { using storage_type = S; using impl_type = typename storage_type::impl_type; - serializator_context_builder(const storage_type &storage_) : storage(storage_) {} + serializator_context_builder(const storage_type& storage_) : storage(storage_) {} serializator_context operator()() const { return {this->storage.impl}; } - const storage_type &storage; + const storage_type& storage; }; } diff --git a/dev/statement_binder.h b/dev/statement_binder.h index b9895702e..3ec3936ae 100644 --- a/dev/statement_binder.h +++ b/dev/statement_binder.h @@ -26,22 +26,22 @@ namespace sqlite_orm { */ template struct statement_binder::value>> { - int bind(sqlite3_stmt *stmt, int index, const V &value) { + int bind(sqlite3_stmt* stmt, int index, const V& value) { return bind(stmt, index, value, tag()); } private: using tag = arithmetic_tag_t; - int bind(sqlite3_stmt *stmt, int index, const V &value, const int_or_smaller_tag &) { + int bind(sqlite3_stmt* stmt, int index, const V& value, const int_or_smaller_tag&) { return sqlite3_bind_int(stmt, index, static_cast(value)); } - int bind(sqlite3_stmt *stmt, int index, const V &value, const bigint_tag &) { + int bind(sqlite3_stmt* stmt, int index, const V& value, const bigint_tag&) { return sqlite3_bind_int64(stmt, index, static_cast(value)); } - int bind(sqlite3_stmt *stmt, int index, const V &value, const real_tag &) { + int bind(sqlite3_stmt* stmt, int index, const V& value, const real_tag&) { return sqlite3_bind_double(stmt, index, static_cast(value)); } }; @@ -52,17 +52,17 @@ namespace sqlite_orm { template struct statement_binder< V, - std::enable_if_t::value || std::is_same::value>> { - int bind(sqlite3_stmt *stmt, int index, const V &value) { + std::enable_if_t::value || std::is_same::value>> { + int bind(sqlite3_stmt* stmt, int index, const V& value) { return sqlite3_bind_text(stmt, index, string_data(value), -1, SQLITE_TRANSIENT); } private: - const char *string_data(const std::string &s) const { + const char* string_data(const std::string& s) const { return s.c_str(); } - const char *string_data(const char *s) const { + const char* string_data(const char* s) const { return s; } }; @@ -74,8 +74,8 @@ namespace sqlite_orm { template struct statement_binder< V, - std::enable_if_t::value || std::is_same::value>> { - int bind(sqlite3_stmt *stmt, int index, const V &value) { + std::enable_if_t::value || std::is_same::value>> { + int bind(sqlite3_stmt* stmt, int index, const V& value) { std::wstring_convert> converter; std::string utf8Str = converter.to_bytes(value); return statement_binder().bind(stmt, index, utf8Str); @@ -88,7 +88,7 @@ namespace sqlite_orm { */ template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const std::nullptr_t &) { + int bind(sqlite3_stmt* stmt, int index, const std::nullptr_t&) { return sqlite3_bind_null(stmt, index); } }; @@ -96,7 +96,7 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const std::nullopt_t &) { + int bind(sqlite3_stmt* stmt, int index, const std::nullopt_t&) { return sqlite3_bind_null(stmt, index); } }; @@ -106,7 +106,7 @@ namespace sqlite_orm { struct statement_binder::value>> { using value_type = typename is_std_ptr::element_type; - int bind(sqlite3_stmt *stmt, int index, const V &value) { + int bind(sqlite3_stmt* stmt, int index, const V& value) { if(value) { return statement_binder().bind(stmt, index, *value); } else { @@ -120,13 +120,9 @@ namespace sqlite_orm { */ template<> struct statement_binder, void> { - int bind(sqlite3_stmt *stmt, int index, const std::vector &value) { + int bind(sqlite3_stmt* stmt, int index, const std::vector& value) { if(value.size()) { - return sqlite3_bind_blob(stmt, - index, - (const void *)&value.front(), - int(value.size()), - SQLITE_TRANSIENT); + return sqlite3_bind_blob(stmt, index, (const void*)&value.front(), int(value.size()), SQLITE_TRANSIENT); } else { return sqlite3_bind_blob(stmt, index, "", 0, SQLITE_TRANSIENT); } @@ -138,7 +134,7 @@ namespace sqlite_orm { struct statement_binder, void> { using value_type = T; - int bind(sqlite3_stmt *stmt, int index, const std::optional &value) { + int bind(sqlite3_stmt* stmt, int index, const std::optional& value) { if(value) { return statement_binder().bind(stmt, index, *value); } else { @@ -154,8 +150,8 @@ namespace sqlite_orm { using is_bindable = std::integral_constant>::value>; struct conditional_binder_base { - sqlite3_stmt *stmt = nullptr; - int &index; + sqlite3_stmt* stmt = nullptr; + int& index; conditional_binder_base(decltype(stmt) stmt_, decltype(index) index_) : stmt(stmt_), index(index_) {} }; @@ -168,7 +164,7 @@ namespace sqlite_orm { using conditional_binder_base::conditional_binder_base; - int operator()(const T &t) const { + int operator()(const T& t) const { return statement_binder().bind(this->stmt, this->index++, t); } }; @@ -177,7 +173,7 @@ namespace sqlite_orm { struct conditional_binder : conditional_binder_base { using conditional_binder_base::conditional_binder_base; - int operator()(const T &) const { + int operator()(const T&) const { return SQLITE_OK; } }; diff --git a/dev/statement_finalizer.h b/dev/statement_finalizer.h index cbeebe609..2b53b4354 100644 --- a/dev/statement_finalizer.h +++ b/dev/statement_finalizer.h @@ -8,7 +8,7 @@ namespace sqlite_orm { * Guard class which finalizes `sqlite3_stmt` in dtor */ struct statement_finalizer { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; statement_finalizer(decltype(stmt) stmt_) : stmt(stmt_) {} diff --git a/dev/statement_serializator.h b/dev/statement_serializator.h index be74d38c7..45e3e51cc 100644 --- a/dev/statement_serializator.h +++ b/dev/statement_serializator.h @@ -27,7 +27,7 @@ namespace sqlite_orm { struct statement_serializator; template - std::string serialize(const T &t, const C &context) { + std::string serialize(const T& t, const C& context) { statement_serializator serializator; return serializator(t, context); } @@ -37,7 +37,7 @@ namespace sqlite_orm { using statement_type = T; template - std::string operator()(const statement_type &statement, const C &context) { + std::string operator()(const statement_type& statement, const C& context) { if(context.replace_bindable_with_question) { return "?"; } else { @@ -51,7 +51,7 @@ namespace sqlite_orm { using statement_type = std::reference_wrapper; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { return serialize(s.get(), context); } }; @@ -61,7 +61,7 @@ namespace sqlite_orm { using statement_type = std::nullptr_t; template - std::string operator()(const statement_type &, const C &) { + std::string operator()(const statement_type&, const C&) { return "?"; } }; @@ -71,7 +71,7 @@ namespace sqlite_orm { using statement_type = alias_holder; template - std::string operator()(const statement_type &, const C &) { + std::string operator()(const statement_type&, const C&) { return T::get(); } }; @@ -81,13 +81,13 @@ namespace sqlite_orm { using statement_type = core_function_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << "("; std::vector args; using args_type = typename std::decay::type::args_type; args.reserve(std::tuple_size::value); - iterate_tuple(c.args, [&args, &context](auto &v) { + iterate_tuple(c.args, [&args, &context](auto& v) { args.push_back(serialize(v, context)); }); for(size_t i = 0; i < args.size(); ++i) { @@ -106,7 +106,7 @@ namespace sqlite_orm { using statement_type = as_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto tableAliasString = alias_extractor::get(); return serialize(c.expression, context) + " AS " + tableAliasString; } @@ -117,7 +117,7 @@ namespace sqlite_orm { using statement_type = alias_column_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << T::get() << "'."; @@ -134,7 +134,7 @@ namespace sqlite_orm { using statement_type = std::string; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { if(context.replace_bindable_with_question) { return "?"; } else { @@ -144,11 +144,11 @@ namespace sqlite_orm { }; template<> - struct statement_serializator { - using statement_type = const char *; + struct statement_serializator { + using statement_type = const char*; template - std::string operator()(const char *c, const C &context) const { + std::string operator()(const char* c, const C& context) const { if(context.replace_bindable_with_question) { return "?"; } else { @@ -162,7 +162,7 @@ namespace sqlite_orm { using statement_type = F O::*; template - std::string operator()(const statement_type &m, const C &context) const { + std::string operator()(const statement_type& m, const C& context) const { std::stringstream ss; if(!context.skip_table_name) { ss << "\"" << context.impl.find_table_name(typeid(O)) << "\"."; @@ -177,7 +177,7 @@ namespace sqlite_orm { using statement_type = rowid_t; template - std::string operator()(const statement_type &s, const C &) { + std::string operator()(const statement_type& s, const C&) { return static_cast(s); } }; @@ -187,7 +187,7 @@ namespace sqlite_orm { using statement_type = oid_t; template - std::string operator()(const statement_type &s, const C &) { + std::string operator()(const statement_type& s, const C&) { return static_cast(s); } }; @@ -197,7 +197,7 @@ namespace sqlite_orm { using statement_type = _rowid_t; template - std::string operator()(const statement_type &s, const C &) { + std::string operator()(const statement_type& s, const C&) { return static_cast(s); } }; @@ -207,7 +207,7 @@ namespace sqlite_orm { using statement_type = table_rowid_t; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(O)) << "'."; @@ -222,7 +222,7 @@ namespace sqlite_orm { using statement_type = table_oid_t; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(O)) << "'."; @@ -237,7 +237,7 @@ namespace sqlite_orm { using statement_type = table__rowid_t; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(O)) << "'."; @@ -252,7 +252,7 @@ namespace sqlite_orm { using statement_type = binary_operator; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto lhs = serialize(c.lhs, context); auto rhs = serialize(c.rhs, context); std::stringstream ss; @@ -266,7 +266,7 @@ namespace sqlite_orm { using statement_type = count_asterisk_t; template - std::string operator()(const statement_type &, const C &context) const { + std::string operator()(const statement_type&, const C& context) const { return serialize(count_asterisk_without_type{}, context); } }; @@ -276,7 +276,7 @@ namespace sqlite_orm { using statement_type = count_asterisk_without_type; template - std::string operator()(const statement_type &c, const C &) const { + std::string operator()(const statement_type& c, const C&) const { std::stringstream ss; ss << static_cast(c) << "(*)"; return ss.str(); @@ -288,7 +288,7 @@ namespace sqlite_orm { using statement_type = distinct_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto expr = serialize(c.t, context); ss << static_cast(c) << "(" << expr << ")"; @@ -301,7 +301,7 @@ namespace sqlite_orm { using statement_type = all_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto expr = serialize(c.t, context); ss << static_cast(c) << "(" << expr << ")"; @@ -314,7 +314,7 @@ namespace sqlite_orm { using statement_type = column_pointer; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(T)) << "'."; @@ -329,7 +329,7 @@ namespace sqlite_orm { using statement_type = cast_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " ("; ss << serialize(c.expression, context) << " AS " << type_printer().print() << ")"; @@ -343,7 +343,7 @@ namespace sqlite_orm { using statement_type = T; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.left, context) << " "; ss << static_cast(c) << " "; @@ -357,17 +357,17 @@ namespace sqlite_orm { using statement_type = simple_case_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << "CASE "; - c.case_expression.apply([&ss, context](auto &c_) { + c.case_expression.apply([&ss, context](auto& c_) { ss << serialize(c_, context) << " "; }); - iterate_tuple(c.args, [&ss, context](auto &pair) { + iterate_tuple(c.args, [&ss, context](auto& pair) { ss << "WHEN " << serialize(pair.first, context) << " "; ss << "THEN " << serialize(pair.second, context) << " "; }); - c.else_expression.apply([&ss, context](auto &el) { + c.else_expression.apply([&ss, context](auto& el) { ss << "ELSE " << serialize(el, context) << " "; }); ss << "END"; @@ -380,7 +380,7 @@ namespace sqlite_orm { using statement_type = is_null_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.t, context) << " " << static_cast(c); return ss.str(); @@ -392,7 +392,7 @@ namespace sqlite_orm { using statement_type = is_not_null_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.t, context) << " " << static_cast(c); return ss.str(); @@ -404,7 +404,7 @@ namespace sqlite_orm { using statement_type = bitwise_not_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; auto cString = serialize(c.argument, context); @@ -418,7 +418,7 @@ namespace sqlite_orm { using statement_type = negated_condition_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; auto cString = serialize(c.c, context); @@ -433,7 +433,7 @@ namespace sqlite_orm { using statement_type = T; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto leftString = serialize(c.l, context); auto rightString = serialize(c.r, context); std::stringstream ss; @@ -453,7 +453,7 @@ namespace sqlite_orm { using statement_type = named_collate; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto newContext = context; newContext.use_parentheses = false; auto res = serialize(c.expr, newContext); @@ -466,7 +466,7 @@ namespace sqlite_orm { using statement_type = collate_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto newContext = context; newContext.use_parentheses = false; auto res = serialize(c.expr, newContext); @@ -479,7 +479,7 @@ namespace sqlite_orm { using statement_type = in_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto leftString = serialize(c.l, context); ss << leftString << " " << static_cast(c) << " "; @@ -495,12 +495,12 @@ namespace sqlite_orm { using statement_type = in_t>; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto leftString = serialize(c.l, context); ss << leftString << " " << static_cast(c) << " ( "; for(size_t index = 0; index < c.arg.size(); ++index) { - auto &value = c.arg[index]; + auto& value = c.arg[index]; ss << " " << serialize(value, context); if(index < c.arg.size() - 1) { ss << ", "; @@ -516,12 +516,12 @@ namespace sqlite_orm { using statement_type = like_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.arg, context) << " "; ss << static_cast(c) << " "; ss << serialize(c.pattern, context); - c.arg3.apply([&ss, &context](auto &value) { + c.arg3.apply([&ss, &context](auto& value) { ss << " ESCAPE " << serialize(value, context); }); return ss.str(); @@ -533,7 +533,7 @@ namespace sqlite_orm { using statement_type = glob_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.arg, context) << " "; ss << static_cast(c) << " "; @@ -547,7 +547,7 @@ namespace sqlite_orm { using statement_type = between_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto expr = serialize(c.expr, context); ss << expr << " " << static_cast(c) << " "; @@ -563,7 +563,7 @@ namespace sqlite_orm { using statement_type = exists_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; ss << serialize(c.t, context); @@ -576,7 +576,7 @@ namespace sqlite_orm { using statement_type = constraints::autoincrement_t; template - std::string operator()(const statement_type &c, const C &) const { + std::string operator()(const statement_type& c, const C&) const { return static_cast(c); } }; @@ -586,14 +586,14 @@ namespace sqlite_orm { using statement_type = constraints::primary_key_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto res = static_cast(c); using columns_tuple = typename statement_type::columns_tuple; auto columnsCount = std::tuple_size::value; if(columnsCount) { res += "("; decltype(columnsCount) columnIndex = 0; - iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto &column) { + iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto& column) { res += context.column_name(column); if(columnIndex < columnsCount - 1) { res += ", "; @@ -611,14 +611,14 @@ namespace sqlite_orm { using statement_type = constraints::unique_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto res = static_cast(c); using columns_tuple = typename statement_type::columns_tuple; auto columnsCount = std::tuple_size::value; if(columnsCount) { res += "("; decltype(columnsCount) columnIndex = 0; - iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto &column) { + iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto& column) { res += context.column_name(column); if(columnIndex < columnsCount - 1) { res += ", "; @@ -636,7 +636,7 @@ namespace sqlite_orm { using statement_type = constraints::collate_t; template - std::string operator()(const statement_type &c, const C &) const { + std::string operator()(const statement_type& c, const C&) const { return static_cast(c); } }; @@ -646,7 +646,7 @@ namespace sqlite_orm { using statement_type = constraints::default_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { return static_cast(c) + " (" + serialize(c.value, context) + ")"; } }; @@ -656,13 +656,13 @@ namespace sqlite_orm { using statement_type = constraints::foreign_key_t, std::tuple>; template - std::string operator()(const statement_type &fk, const C &context) const { + std::string operator()(const statement_type& fk, const C& context) const { std::stringstream ss; std::vector columnNames; using columns_type_t = typename std::decay::type::columns_type; constexpr const size_t columnsCount = std::tuple_size::value; columnNames.reserve(columnsCount); - iterate_tuple(fk.columns, [&columnNames, &context](auto &v) { + iterate_tuple(fk.columns, [&columnNames, &context](auto& v) { columnNames.push_back(context.impl.column_name(v)); }); ss << "FOREIGN KEY("; @@ -683,7 +683,7 @@ namespace sqlite_orm { auto refTableName = context.impl.find_table_name(typeid(first_reference_mapped_type)); ss << '\'' << refTableName << '\''; } - iterate_tuple(fk.references, [&referencesNames, &context](auto &v) { + iterate_tuple(fk.references, [&referencesNames, &context](auto& v) { referencesNames.push_back(context.impl.column_name(v)); }); ss << "("; @@ -709,7 +709,7 @@ namespace sqlite_orm { using statement_type = constraints::check_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { return static_cast(c) + " " + serialize(c.expression, context); } }; @@ -719,7 +719,7 @@ namespace sqlite_orm { using statement_type = column_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << "'" << c.name << "' "; using column_type = typename std::decay::type; @@ -735,7 +735,7 @@ namespace sqlite_orm { int tupleIndex = 0; iterate_tuple( c.constraints, - [&constraintsStrings, &primaryKeyIndex, &autoincrementIndex, &tupleIndex, &context](auto &v) { + [&constraintsStrings, &primaryKeyIndex, &autoincrementIndex, &tupleIndex, &context](auto& v) { using constraint_type = typename std::decay::type; constraintsStrings.push_back(serialize(v, context)); if(is_primary_key::value) { @@ -749,7 +749,7 @@ namespace sqlite_orm { iter_swap(constraintsStrings.begin() + primaryKeyIndex, constraintsStrings.begin() + autoincrementIndex); } - for(auto &str: constraintsStrings) { + for(auto& str: constraintsStrings) { ss << str << ' '; } } @@ -765,11 +765,11 @@ namespace sqlite_orm { using statement_type = remove_all_t; template - std::string operator()(const statement_type &rem, const C &context) const { - auto &tImpl = context.impl.template get_impl(); + std::string operator()(const statement_type& rem, const C& context) const { + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "DELETE FROM '" << tImpl.table.name << "' "; - iterate_tuple(rem.conditions, [&context, &ss](auto &v) { + iterate_tuple(rem.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); return ss.str(); @@ -781,10 +781,10 @@ namespace sqlite_orm { using statement_type = replace_t; template - std::string operator()(const statement_type &rep, const C &context) const { + std::string operator()(const statement_type& rep, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "REPLACE INTO '" << tImpl.table.name << "' ("; auto columnNames = tImpl.table.column_names(); @@ -816,12 +816,12 @@ namespace sqlite_orm { using statement_type = insert_explicit; template - std::string operator()(const statement_type &ins, const C &context) const { + std::string operator()(const statement_type& ins, const C& context) const { constexpr const size_t colsCount = std::tuple_size>::value; static_assert(colsCount > 0, "Use insert or replace with 1 argument instead"); using expression_type = typename std::decay::type; using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "INSERT INTO '" << tImpl.table.name << "' "; std::vector columnNames; @@ -829,7 +829,7 @@ namespace sqlite_orm { { auto columnsContext = context; columnsContext.skip_table_name = true; - iterate_tuple(ins.columns.columns, [&columnNames, &columnsContext](auto &m) { + iterate_tuple(ins.columns.columns, [&columnNames, &columnsContext](auto& m) { auto columnName = serialize(m, columnsContext); if(!columnName.empty()) { columnNames.push_back(columnName); @@ -867,15 +867,15 @@ namespace sqlite_orm { using statement_type = update_t; template - std::string operator()(const statement_type &upd, const C &context) const { + std::string operator()(const statement_type& upd, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "UPDATE '" << tImpl.table.name << "' SET "; std::vector setColumnNames; - tImpl.table.for_each_column([&setColumnNames](auto &c) { + tImpl.table.for_each_column([&setColumnNames](auto& c) { if(!c.template has>()) { setColumnNames.emplace_back(c.name); } @@ -907,7 +907,7 @@ namespace sqlite_orm { using statement_type = update_all_t, Wargs...>; template - std::string operator()(const statement_type &upd, const C &context) const { + std::string operator()(const statement_type& upd, const C& context) const { std::stringstream ss; ss << "UPDATE "; table_name_collector collector{[&context](std::type_index ti) { @@ -921,7 +921,7 @@ namespace sqlite_orm { std::vector setPairs; auto leftContext = context; leftContext.skip_table_name = true; - iterate_tuple(upd.set.assigns, [&context, &leftContext, &setPairs](auto &asgn) { + iterate_tuple(upd.set.assigns, [&context, &leftContext, &setPairs](auto& asgn) { std::stringstream sss; sss << serialize(asgn.lhs, leftContext); sss << " " << static_cast(asgn) << " "; @@ -935,7 +935,7 @@ namespace sqlite_orm { ss << ", "; } } - iterate_tuple(upd.conditions, [&context, &ss](auto &v) { + iterate_tuple(upd.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); return ss.str(); @@ -953,15 +953,15 @@ namespace sqlite_orm { using statement_type = insert_t; template - std::string operator()(const statement_type &, const C &context) const { + std::string operator()(const statement_type&, const C& context) const { using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "INSERT INTO '" << tImpl.table.name << "' "; std::vector columnNames; auto compositeKeyColumnNames = tImpl.table.composite_key_columns_names(); - tImpl.table.for_each_column([&tImpl, &columnNames, &compositeKeyColumnNames](auto &c) { + tImpl.table.for_each_column([&tImpl, &columnNames, &compositeKeyColumnNames](auto& c) { if(tImpl.table._without_rowid || !c.template has>()) { auto it = find(compositeKeyColumnNames.begin(), compositeKeyColumnNames.end(), c.name); if(it == compositeKeyColumnNames.end()) { @@ -1006,8 +1006,8 @@ namespace sqlite_orm { using statement_type = remove_t; template - std::string operator()(const statement_type &, const C &context) const { - auto &tImpl = context.impl.template get_impl(); + std::string operator()(const statement_type&, const C& context) const { + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "DELETE FROM '" << tImpl.table.name << "' "; ss << "WHERE "; @@ -1028,10 +1028,10 @@ namespace sqlite_orm { using statement_type = replace_range_t; template - std::string operator()(const statement_type &rep, const C &context) const { + std::string operator()(const statement_type& rep, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_type::object_type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "REPLACE INTO '" << tImpl.table.name << "' ("; auto columnNames = tImpl.table.column_names(); @@ -1075,15 +1075,15 @@ namespace sqlite_orm { using statement_type = insert_range_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_type::object_type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "INSERT INTO '" << tImpl.table.name << "' ("; std::vector columnNames; - tImpl.table.for_each_column([&columnNames](auto &c) { + tImpl.table.for_each_column([&columnNames](auto& c) { if(!c.template has>()) { columnNames.emplace_back(c.name); } @@ -1126,7 +1126,7 @@ namespace sqlite_orm { }; template - std::string serialize_get_all_impl(const T &get, const C &context) { + std::string serialize_get_all_impl(const T& get, const C& context) { using primary_type = typename T::type; table_name_collector collector; @@ -1135,7 +1135,7 @@ namespace sqlite_orm { iterate_ast(get.conditions, collector); std::stringstream ss; ss << "SELECT "; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); auto columnNames = tImpl.table.column_names(); for(size_t i = 0; i < columnNames.size(); ++i) { ss << "\"" << tImpl.table.name << "\"." @@ -1150,7 +1150,7 @@ namespace sqlite_orm { std::vector> tableNames(collector.table_names.begin(), collector.table_names.end()); for(size_t i = 0; i < tableNames.size(); ++i) { - auto &tableNamePair = tableNames[i]; + auto& tableNamePair = tableNames[i]; ss << "'" << tableNamePair.first << "' "; if(!tableNamePair.second.empty()) { ss << tableNamePair.second << " "; @@ -1160,7 +1160,7 @@ namespace sqlite_orm { } ss << " "; } - iterate_tuple(get.conditions, [&context, &ss](auto &v) { + iterate_tuple(get.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); return ss.str(); @@ -1172,7 +1172,7 @@ namespace sqlite_orm { using statement_type = get_all_optional_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_all_impl(get, context); } }; @@ -1183,7 +1183,7 @@ namespace sqlite_orm { using statement_type = get_all_pointer_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_all_impl(get, context); } }; @@ -1193,15 +1193,15 @@ namespace sqlite_orm { using statement_type = get_all_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_all_impl(get, context); } }; template - std::string serialize_get_impl(const T &, const C &context) { + std::string serialize_get_impl(const T&, const C& context) { using primary_type = typename T::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "SELECT "; auto columnNames = tImpl.table.column_names(); @@ -1234,7 +1234,7 @@ namespace sqlite_orm { using statement_type = get_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_impl(get, context); } }; @@ -1244,7 +1244,7 @@ namespace sqlite_orm { using statement_type = get_pointer_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_impl(get, context); } }; @@ -1255,7 +1255,7 @@ namespace sqlite_orm { using statement_type = get_optional_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_impl(get, context); } }; @@ -1265,7 +1265,7 @@ namespace sqlite_orm { using statement_type = select_t; template - std::string operator()(const statement_type &sel, const C &context) const { + std::string operator()(const statement_type& sel, const C& context) const { std::stringstream ss; if(!is_base_of_template::value) { if(!sel.highest_level) { @@ -1289,7 +1289,7 @@ namespace sqlite_orm { }}; iterate_ast(sel.col, collector); iterate_ast(sel.conditions, collector); - internal::join_iterator()([&collector, &context](const auto &c) { + internal::join_iterator()([&collector, &context](const auto& c) { using original_join_type = typename std::decay::type::join_type::type; using cross_join_type = typename internal::mapped_type_proxy::type; auto crossJoinedTableName = context.impl.find_table_name(typeid(cross_join_type)); @@ -1303,7 +1303,7 @@ namespace sqlite_orm { std::vector> tableNames(collector.table_names.begin(), collector.table_names.end()); for(size_t i = 0; i < tableNames.size(); ++i) { - auto &tableNamePair = tableNames[i]; + auto& tableNamePair = tableNames[i]; ss << "'" << tableNamePair.first << "' "; if(!tableNamePair.second.empty()) { ss << tableNamePair.second << " "; @@ -1314,7 +1314,7 @@ namespace sqlite_orm { ss << " "; } } - iterate_tuple(sel.conditions, [&context, &ss](auto &v) { + iterate_tuple(sel.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); if(!is_base_of_template::value) { @@ -1331,7 +1331,7 @@ namespace sqlite_orm { using statement_type = indexed_column_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; ss << serialize(statement.column_or_expression, context); if(!statement._collation_name.empty()) { @@ -1358,7 +1358,7 @@ namespace sqlite_orm { using statement_type = index_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; ss << "CREATE "; if(statement.unique) { @@ -1370,7 +1370,7 @@ namespace sqlite_orm { ss << "INDEX IF NOT EXISTS '" << statement.name << "' ON '" << context.impl.find_table_name(typeid(indexed_type)) << "' ("; std::vector columnNames; - iterate_tuple(statement.columns, [&columnNames, &context](auto &v) { + iterate_tuple(statement.columns, [&columnNames, &context](auto& v) { columnNames.push_back(context.column_name(v.column_or_expression)); }); for(size_t i = 0; i < columnNames.size(); ++i) { @@ -1389,7 +1389,7 @@ namespace sqlite_orm { using statement_type = where_t; template - std::string operator()(const statement_type &w, const C &context) const { + std::string operator()(const statement_type& w, const C& context) const { std::stringstream ss; ss << static_cast(w) << " "; auto whereString = serialize(w.c, context); @@ -1403,7 +1403,7 @@ namespace sqlite_orm { using statement_type = order_by_t; template - std::string operator()(const statement_type &orderBy, const C &context) const { + std::string operator()(const statement_type& orderBy, const C& context) const { std::stringstream ss; ss << static_cast(orderBy) << " "; auto orderByString = serialize_order_by(orderBy, context); @@ -1417,7 +1417,7 @@ namespace sqlite_orm { using statement_type = dynamic_order_by_t; template - std::string operator()(const statement_type &orderBy, const CC &context) const { + std::string operator()(const statement_type& orderBy, const CC& context) const { return serialize_order_by(orderBy, context); } }; @@ -1427,10 +1427,10 @@ namespace sqlite_orm { using statement_type = multi_order_by_t; template - std::string operator()(const statement_type &orderBy, const C &context) const { + std::string operator()(const statement_type& orderBy, const C& context) const { std::stringstream ss; std::vector expressions; - iterate_tuple(orderBy.args, [&expressions, &context](auto &v) { + iterate_tuple(orderBy.args, [&expressions, &context](auto& v) { auto expression = serialize_order_by(v, context); expressions.push_back(move(expression)); }); @@ -1451,7 +1451,7 @@ namespace sqlite_orm { using statement_type = cross_join_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; ss << " '" << context.impl.find_table_name(typeid(O)) << "'"; @@ -1464,7 +1464,7 @@ namespace sqlite_orm { using statement_type = inner_join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -1482,7 +1482,7 @@ namespace sqlite_orm { using statement_type = on_t; template - std::string operator()(const statement_type &t, const C &context) const { + std::string operator()(const statement_type& t, const C& context) const { std::stringstream ss; auto newContext = context; newContext.skip_table_name = false; @@ -1496,7 +1496,7 @@ namespace sqlite_orm { using statement_type = join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -1514,7 +1514,7 @@ namespace sqlite_orm { using statement_type = left_join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -1532,7 +1532,7 @@ namespace sqlite_orm { using statement_type = left_outer_join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -1550,7 +1550,7 @@ namespace sqlite_orm { using statement_type = natural_join_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; ss << " '" << context.impl.find_table_name(typeid(O)) << "'"; @@ -1563,12 +1563,12 @@ namespace sqlite_orm { using statement_type = group_by_t; template - std::string operator()(const statement_type &groupBy, const C &context) const { + std::string operator()(const statement_type& groupBy, const C& context) const { std::stringstream ss; std::vector expressions; auto newContext = context; newContext.skip_table_name = false; - iterate_tuple(groupBy.args, [&expressions, &newContext](auto &v) { + iterate_tuple(groupBy.args, [&expressions, &newContext](auto& v) { auto expression = serialize(v, newContext); expressions.push_back(expression); }); @@ -1589,7 +1589,7 @@ namespace sqlite_orm { using statement_type = having_t; template - std::string operator()(const statement_type &hav, const C &context) const { + std::string operator()(const statement_type& hav, const C& context) const { std::stringstream ss; auto newContext = context; newContext.skip_table_name = false; @@ -1608,21 +1608,21 @@ namespace sqlite_orm { using statement_type = limit_t; template - std::string operator()(const statement_type &limt, const C &context) const { + std::string operator()(const statement_type& limt, const C& context) const { auto newContext = context; newContext.skip_table_name = false; std::stringstream ss; ss << static_cast(limt) << " "; if(HO) { if(OI) { - limt.off.apply([&newContext, &ss](auto &value) { + limt.off.apply([&newContext, &ss](auto& value) { ss << serialize(value, newContext); }); ss << ", "; ss << serialize(limt.lim, newContext); } else { ss << serialize(limt.lim, newContext) << " OFFSET "; - limt.off.apply([&newContext, &ss](auto &value) { + limt.off.apply([&newContext, &ss](auto& value) { ss << serialize(value, newContext); }); } @@ -1638,7 +1638,7 @@ namespace sqlite_orm { using statement_type = using_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { auto newContext = context; newContext.skip_table_name = true; return static_cast(statement) + " (" + serialize(statement.column, newContext) + " )"; @@ -1650,12 +1650,12 @@ namespace sqlite_orm { using statement_type = std::tuple; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; ss << '('; auto index = 0; using TupleSize = std::tuple_size; - iterate_tuple(statement, [&context, &index, &ss](auto &value) { + iterate_tuple(statement, [&context, &index, &ss](auto& value) { ss << serialize(value, context); if(index < TupleSize::value - 1) { ss << ", "; @@ -1672,7 +1672,7 @@ namespace sqlite_orm { using statement_type = values_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; if(context.use_parentheses) { ss << '('; @@ -1680,10 +1680,10 @@ namespace sqlite_orm { ss << "VALUES "; { auto index = 0; - auto &tuple = statement.tuple; + auto& tuple = statement.tuple; using tuple_type = typename std::decay::type; using TupleSize = std::tuple_size; - iterate_tuple(tuple, [&context, &index, &ss](auto &value) { + iterate_tuple(tuple, [&context, &index, &ss](auto& value) { ss << serialize(value, context); if(index < TupleSize::value - 1) { ss << ", "; @@ -1703,7 +1703,7 @@ namespace sqlite_orm { using statement_type = dynamic_values_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; if(context.use_parentheses) { ss << '('; @@ -1712,7 +1712,7 @@ namespace sqlite_orm { { auto vectorSize = statement.vector.size(); for(decltype(vectorSize) index = 0; index < vectorSize; ++index) { - auto &value = statement.vector[index]; + auto& value = statement.vector[index]; ss << serialize(value, context); if(index < vectorSize - 1) { ss << ", "; diff --git a/dev/static_magic.h b/dev/static_magic.h index 23fe1b84d..369bdc694 100644 --- a/dev/static_magic.h +++ b/dev/static_magic.h @@ -9,27 +9,27 @@ namespace sqlite_orm { namespace internal { static inline decltype(auto) empty_callable() { - static auto res = [](auto &&...) {}; + static auto res = [](auto&&...) {}; return (res); } template - decltype(auto) static_if(std::true_type, const T &t, const F &) { + decltype(auto) static_if(std::true_type, const T& t, const F&) { return (t); } template - decltype(auto) static_if(std::false_type, const T &, const F &f) { + decltype(auto) static_if(std::false_type, const T&, const F& f) { return (f); } template - decltype(auto) static_if(const T &t, const F &f) { + decltype(auto) static_if(const T& t, const F& f) { return static_if(std::integral_constant{}, t, f); } template - decltype(auto) static_if(const T &t) { + decltype(auto) static_if(const T& t) { return static_if(std::integral_constant{}, t, empty_callable()); } diff --git a/dev/storage.h b/dev/storage.h index 6613bb93b..4f91f42ee 100644 --- a/dev/storage.h +++ b/dev/storage.h @@ -65,10 +65,10 @@ namespace sqlite_orm { * @param filename database filename. * @param impl_ storage_impl head */ - storage_t(const std::string &filename, impl_type impl_) : + storage_t(const std::string& filename, impl_type impl_) : storage_base{filename, foreign_keys_count(impl_)}, impl(std::move(impl_)) {} - storage_t(const storage_t &other) : storage_base(other), impl(other.impl) {} + storage_t(const storage_t& other) : storage_base(other), impl(other.impl) {} protected: impl_type impl; @@ -86,14 +86,14 @@ namespace sqlite_orm { friend struct serializator_context_builder; template - void create_table(sqlite3 *db, const std::string &tableName, const I &tableImpl) { + void create_table(sqlite3* db, const std::string& tableName, const I& tableImpl) { std::stringstream ss; ss << "CREATE TABLE '" << tableName << "' ( "; auto columnsCount = tableImpl.table.columns_count; auto index = 0; using context_t = serializator_context; context_t context{this->impl}; - iterate_tuple(tableImpl.table.columns, [columnsCount, &index, &ss, &context](auto &c) { + iterate_tuple(tableImpl.table.columns, [columnsCount, &index, &ss, &context](auto& c) { ss << serialize(c, context); if(index < columnsCount - 1) { ss << ", "; @@ -108,7 +108,7 @@ namespace sqlite_orm { } template - void backup_table(sqlite3 *db, const I &tableImpl, const std::vector &columnsToIgnore) { + void backup_table(sqlite3* db, const I& tableImpl, const std::vector& columnsToIgnore) { // here we copy source table to another with a name with '_backup' suffix, but in case table with such // a name already exists we append suffix 1, then 2, etc until we find a free name.. @@ -143,18 +143,18 @@ namespace sqlite_orm { } template - auto &get_impl() const { + auto& get_impl() const { return this->impl.template get_impl(); } template - auto &get_impl() { + auto& get_impl() { return this->impl.template get_impl(); } public: template - view_t iterate(Args &&... args) { + view_t iterate(Args&&... args) { this->assert_mapped_type(); auto con = this->get_connection(); @@ -169,7 +169,7 @@ namespace sqlite_orm { * @example: storage.remove_all(where(in(&User::id, {5, 6, 7}))); - DELETE FROM users WHERE id IN (5, 6, 7) */ template - void remove_all(Args &&... args) { + void remove_all(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::remove_all(std::forward(args)...)); this->execute(statement); @@ -194,7 +194,7 @@ namespace sqlite_orm { * @param o object to be updated. */ template - void update(const O &o) { + void update(const O& o) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::update(std::ref(o))); this->execute(statement); @@ -208,7 +208,7 @@ namespace sqlite_orm { protected: template - std::string group_concat_internal(F O::*m, std::unique_ptr y, Args &&... args) { + std::string group_concat_internal(F O::*m, std::unique_ptr y, Args&&... args) { this->assert_mapped_type(); std::vector rows; if(y) { @@ -233,7 +233,7 @@ namespace sqlite_orm { * @example: storage.get_all(where(like(&User::name, "N%")), order_by(&User::id)); - SELECT * FROM users WHERE name LIKE 'N%' ORDER BY id */ template - auto get_all(Args &&... args) { + auto get_all(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all(std::forward(args)...)); return this->execute(statement); @@ -248,7 +248,7 @@ namespace sqlite_orm { * @example: storage.get_all>(where(like(&User::name, "N%")), order_by(&User::id)); - SELECT * FROM users WHERE name LIKE 'N%' ORDER BY id */ template - auto get_all(Args &&... args) { + auto get_all(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all(std::forward(args)...)); return this->execute(statement); @@ -263,7 +263,7 @@ namespace sqlite_orm { * @example: storage.get_all_pointer(where(length(&User::name) > 6)); - SELECT * FROM users WHERE LENGTH(name) > 6 */ template - auto get_all_pointer(Args &&... args) { + auto get_all_pointer(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all_pointer(std::forward(args)...)); return this->execute(statement); @@ -278,7 +278,7 @@ namespace sqlite_orm { * @example: storage.get_all_pointer>(where(length(&User::name) > 6)); - SELECT * FROM users WHERE LENGTH(name) > 6 */ template - auto get_all_pointer(Args &&... args) { + auto get_all_pointer(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all_pointer(std::forward(args)...)); return this->execute(statement); @@ -346,7 +346,7 @@ namespace sqlite_orm { * @return Number of O object in table. */ template::type> - int count(Args &&... args) { + int count(Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::count(), std::forward(args)...); if(!rows.empty()) { @@ -361,7 +361,7 @@ namespace sqlite_orm { * @param m member pointer to class mapped to the storage. */ template - int count(F O::*m, Args &&... args) { + int count(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::count(m), std::forward(args)...); if(!rows.empty()) { @@ -377,7 +377,7 @@ namespace sqlite_orm { * @return average value from db. */ template - double avg(F O::*m, Args &&... args) { + double avg(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::avg(m), std::forward(args)...); if(!rows.empty()) { @@ -402,7 +402,7 @@ namespace sqlite_orm { class... Args, class Tuple = std::tuple, typename sfinae = typename std::enable_if::value >= 1>::type> - std::string group_concat(F O::*m, Args &&... args) { + std::string group_concat(F O::*m, Args&&... args) { return this->group_concat_internal(m, {}, std::forward(args)...); } @@ -412,14 +412,14 @@ namespace sqlite_orm { * @return group_concat query result. */ template - std::string group_concat(F O::*m, std::string y, Args &&... args) { + std::string group_concat(F O::*m, std::string y, Args&&... args) { return this->group_concat_internal(m, std::make_unique(move(y)), std::forward(args)...); } template - std::string group_concat(F O::*m, const char *y, Args &&... args) { + std::string group_concat(F O::*m, const char* y, Args&&... args) { std::unique_ptr str; if(y) { str = std::make_unique(y); @@ -435,7 +435,7 @@ namespace sqlite_orm { * @return std::unique_ptr with max value or null if sqlite engine returned null. */ template::type> - std::unique_ptr max(F O::*m, Args &&... args) { + std::unique_ptr max(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::max(m), std::forward(args)...); if(!rows.empty()) { @@ -451,7 +451,7 @@ namespace sqlite_orm { * @return std::unique_ptr with min value or null if sqlite engine returned null. */ template::type> - std::unique_ptr min(F O::*m, Args &&... args) { + std::unique_ptr min(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::min(m), std::forward(args)...); if(!rows.empty()) { @@ -467,7 +467,7 @@ namespace sqlite_orm { * @return std::unique_ptr with sum value or null if sqlite engine returned null. */ template::type> - std::unique_ptr sum(F O::*m, Args &&... args) { + std::unique_ptr sum(F O::*m, Args&&... args) { this->assert_mapped_type(); std::vector> rows = this->select(sqlite_orm::sum(m), std::forward(args)...); @@ -489,7 +489,7 @@ namespace sqlite_orm { * https://www.sqlite.org/lang_aggfunc.html) */ template - double total(F O::*m, Args &&... args) { + double total(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::total(m), std::forward(args)...); if(!rows.empty()) { @@ -515,7 +515,7 @@ namespace sqlite_orm { template typename std::enable_if::value, std::string>::type - dump(const T &preparedStatement) const { + dump(const T& preparedStatement) const { using context_t = serializator_context; context_t context{this->impl}; return serialize(preparedStatement.t, context); @@ -527,13 +527,13 @@ namespace sqlite_orm { */ template typename std::enable_if::value, std::string>::type - dump(const O &o) { - auto &tImpl = this->get_impl(); + dump(const O& o) { + auto& tImpl = this->get_impl(); std::stringstream ss; ss << "{ "; using pair = std::pair; std::vector pairs; - tImpl.table.for_each_column([&pairs, &o](auto &c) { + tImpl.table.for_each_column([&pairs, &o](auto& c) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; pair p{c.name, std::string()}; @@ -547,7 +547,7 @@ namespace sqlite_orm { pairs.push_back(move(p)); }); for(size_t i = 0; i < pairs.size(); ++i) { - auto &p = pairs[i]; + auto& p = pairs[i]; ss << p.first << " : '" << p.second << "'"; if(i < pairs.size() - 1) { ss << ", "; @@ -565,7 +565,7 @@ namespace sqlite_orm { * id and creates own one. */ template - void replace(const O &o) { + void replace(const O& o) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::replace(std::ref(o))); this->execute(statement); @@ -584,7 +584,7 @@ namespace sqlite_orm { } template - int insert(const O &o, columns_t cols) { + int insert(const O& o, columns_t cols) { constexpr const size_t colsCount = std::tuple_size>::value; static_assert(colsCount > 0, "Use insert or replace with 1 argument instead"); this->assert_mapped_type(); @@ -598,7 +598,7 @@ namespace sqlite_orm { * @return id of just created object. */ template - int insert(const O &o) { + int insert(const O& o) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::insert(std::ref(o))); return int(this->execute(statement)); @@ -623,7 +623,7 @@ namespace sqlite_orm { template void rename_table(std::string name) { this->assert_mapped_type(); - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); tImpl.table.name = move(name); } @@ -634,15 +634,15 @@ namespace sqlite_orm { * any SQLite queries */ template - const std::string &tablename() const { + const std::string& tablename() const { this->assert_mapped_type(); - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); return tImpl.table.name; } protected: template - sync_schema_result sync_table(const storage_impl, Tss...> &tableImpl, sqlite3 *db, bool) { + sync_schema_result sync_table(const storage_impl, Tss...>& tableImpl, sqlite3* db, bool) { auto res = sync_schema_result::already_in_sync; using context_t = serializator_context; context_t context{this->impl}; @@ -653,7 +653,7 @@ namespace sqlite_orm { template sync_schema_result - sync_table(const storage_impl, Tss...> &tImpl, sqlite3 *db, bool preserve) { + sync_table(const storage_impl, Tss...>& tImpl, sqlite3* db, bool preserve) { auto res = sync_schema_result::already_in_sync; auto schema_stat = tImpl.schema_status(db, preserve); @@ -673,7 +673,7 @@ namespace sqlite_orm { auto dbTableInfo = tImpl.get_table_info(tImpl.table.name, db); // this vector will contain pointers to columns that gotta be added.. - std::vector columnsToAdd; + std::vector columnsToAdd; tImpl.get_remove_add_columns(columnsToAdd, storageTableInfo, dbTableInfo); @@ -710,7 +710,7 @@ namespace sqlite_orm { template prepared_statement_t prepare_impl(S statement) { auto con = this->get_connection(); - sqlite3_stmt *stmt; + sqlite3_stmt* stmt; auto db = con.get(); using context_t = serializator_context; context_t context{this->impl}; @@ -757,7 +757,7 @@ namespace sqlite_orm { auto con = this->get_connection(); std::map result; auto db = con.get(); - this->impl.for_each([&result, db, preserve, this](auto &tableImpl) { + this->impl.for_each([&result, db, preserve, this](auto& tableImpl) { auto res = this->sync_table(tableImpl, db, preserve); result.insert({tableImpl.table.name, res}); }); @@ -784,7 +784,7 @@ namespace sqlite_orm { * Note: table can be not mapped to a storage * @return true if table with a given name exists in db, false otherwise. */ - bool table_exists(const std::string &tableName) { + bool table_exists(const std::string& tableName) { auto con = this->get_connection(); return this->impl.table_exists(tableName, con.get()); } @@ -882,7 +882,7 @@ namespace sqlite_orm { } template - int64 execute(const prepared_statement_t> &statement) { + int64 execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; @@ -890,13 +890,13 @@ namespace sqlite_orm { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; - auto &tImpl = this->get_impl(); - auto &o = statement.t.obj; + auto& tImpl = this->get_impl(); + auto& o = statement.t.obj; sqlite3_reset(stmt); - iterate_tuple(statement.t.columns.columns, [&o, &index, &stmt, &tImpl, db](auto &m) { + iterate_tuple(statement.t.columns.columns, [&o, &index, &stmt, &tImpl, db](auto& m) { using column_type = typename std::decay::type; using field_type = typename column_result_t::type; - const field_type *value = tImpl.table.template get_object_field_pointer(o, m); + const field_type* value = tImpl.table.template get_object_field_pointer(o, m); if(SQLITE_OK != statement_binder().bind(stmt, index++, *value)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), sqlite3_errmsg(db)); @@ -907,19 +907,19 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_type::object_type; - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); auto index = 1; auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; sqlite3_reset(stmt); for(auto it = statement.t.range.first; it != statement.t.range.second; ++it) { - auto &o = *it; - tImpl.table.for_each_column([&o, &index, &stmt, db](auto &c) { + auto& o = *it; + tImpl.table.for_each_column([&o, &index, &stmt, db](auto& c) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; if(c.member_pointer) { @@ -943,7 +943,7 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_type::object_type; @@ -951,11 +951,11 @@ namespace sqlite_orm { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); sqlite3_reset(stmt); for(auto it = statement.t.range.first; it != statement.t.range.second; ++it) { - auto &o = *it; - tImpl.table.for_each_column([&o, &index, &stmt, db](auto &c) { + auto& o = *it; + tImpl.table.for_each_column([&o, &index, &stmt, db](auto& c) { if(!c.template has>()) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; @@ -982,7 +982,7 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; @@ -990,10 +990,10 @@ namespace sqlite_orm { auto db = con.get(); auto stmt = statement.stmt; auto index = 1; - auto &o = get_object(statement.t); - auto &tImpl = this->get_impl(); + auto& o = get_object(statement.t); + auto& tImpl = this->get_impl(); sqlite3_reset(stmt); - tImpl.table.for_each_column([&o, &index, &stmt, db](auto &c) { + tImpl.table.for_each_column([&o, &index, &stmt, db](auto& c) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; if(c.member_pointer) { @@ -1014,7 +1014,7 @@ namespace sqlite_orm { } template - int64 execute(const prepared_statement_t> &statement) { + int64 execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; @@ -1022,11 +1022,11 @@ namespace sqlite_orm { auto db = con.get(); auto stmt = statement.stmt; auto index = 1; - auto &tImpl = this->get_impl(); - auto &o = get_object(statement.t); + auto& tImpl = this->get_impl(); + auto& o = get_object(statement.t); auto compositeKeyColumnNames = tImpl.table.composite_key_columns_names(); sqlite3_reset(stmt); - tImpl.table.for_each_column([&o, &index, &stmt, &tImpl, &compositeKeyColumnNames, db](auto &c) { + tImpl.table.for_each_column([&o, &index, &stmt, &tImpl, &compositeKeyColumnNames, db](auto& c) { if(tImpl.table._without_rowid || !c.template has>()) { auto it = std::find(compositeKeyColumnNames.begin(), compositeKeyColumnNames.end(), c.name); if(it == compositeKeyColumnNames.end()) { @@ -1056,13 +1056,13 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -1073,18 +1073,18 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; auto con = this->get_connection(); auto db = con.get(); - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); auto stmt = statement.stmt; auto index = 1; - auto &o = get_object(statement.t); + auto& o = get_object(statement.t); sqlite3_reset(stmt); - tImpl.table.for_each_column([&o, stmt, &index, db](auto &c) { + tImpl.table.for_each_column([&o, stmt, &index, db](auto& c) { if(!c.template has>()) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; @@ -1106,7 +1106,7 @@ namespace sqlite_orm { } } }); - tImpl.table.for_each_column([&o, stmt, &index, db](auto &c) { + tImpl.table.for_each_column([&o, stmt, &index, db](auto& c) { if(c.template has>()) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; @@ -1131,14 +1131,14 @@ namespace sqlite_orm { } template - std::unique_ptr execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + std::unique_ptr execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -1165,14 +1165,14 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template - std::optional execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + std::optional execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -1199,14 +1199,14 @@ namespace sqlite_orm { #endif // SQLITE_ORM_OPTIONAL_SUPPORTED template - T execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + T execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -1232,13 +1232,13 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.conditions, [stmt, &index, db](auto &node) { + iterate_ast(statement.t.conditions, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1250,14 +1250,14 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t, Wargs...>> &statement) { + void execute(const prepared_statement_t, Wargs...>>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_tuple(statement.t.set.assigns, [&index, stmt, db](auto &setArg) { - iterate_ast(setArg, [&index, stmt, db](auto &node) { + iterate_tuple(statement.t.set.assigns, [&index, stmt, db](auto& setArg) { + iterate_ast(setArg, [&index, stmt, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1266,7 +1266,7 @@ namespace sqlite_orm { } }); }); - iterate_ast(statement.t.conditions, [stmt, &index, db](auto &node) { + iterate_ast(statement.t.conditions, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1278,13 +1278,13 @@ namespace sqlite_orm { } template::type> - std::vector execute(const prepared_statement_t> &statement) { + std::vector execute(const prepared_statement_t>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1318,14 +1318,14 @@ namespace sqlite_orm { } template - R execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + R execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1356,14 +1356,14 @@ namespace sqlite_orm { } template - R execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + R execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1395,14 +1395,14 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template - R execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + R execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -1442,7 +1442,7 @@ namespace sqlite_orm { } template - internal::storage_t make_storage(const std::string &filename, Ts... tables) { + internal::storage_t make_storage(const std::string& filename, Ts... tables) { return {filename, internal::storage_impl(tables...)}; } diff --git a/dev/storage_base.h b/dev/storage_base.h index c20dea5d6..b238809e5 100644 --- a/dev/storage_base.h +++ b/dev/storage_base.h @@ -28,9 +28,9 @@ namespace sqlite_orm { namespace internal { struct storage_base { - using collating_function = std::function; + using collating_function = std::function; - std::function on_open; + std::function on_open; pragma_t pragma; limit_accesor limit; @@ -41,7 +41,7 @@ namespace sqlite_orm { return {this->get_connection(), move(commitFunc), move(rollbackFunc)}; } - void drop_index(const std::string &indexName) { + void drop_index(const std::string& indexName) { std::stringstream ss; ss << "DROP INDEX '" << indexName + "'"; perform_void_exec(get_connection().get(), ss.str()); @@ -54,7 +54,7 @@ namespace sqlite_orm { /** * Drops table with given name. */ - void drop_table(const std::string &tableName) { + void drop_table(const std::string& tableName) { auto con = this->get_connection(); this->drop_table_internal(tableName, con.get()); } @@ -62,7 +62,7 @@ namespace sqlite_orm { /** * Rename table named `from` to `to`. */ - void rename_table(const std::string &from, const std::string &to) { + void rename_table(const std::string& from, const std::string& to) { std::stringstream ss; ss << "ALTER TABLE '" << from << "' RENAME TO '" << to << "'"; perform_void_exec(get_connection().get(), ss.str()); @@ -101,7 +101,7 @@ namespace sqlite_orm { return sqlite3_libversion(); } - bool transaction(const std::function &f) { + bool transaction(const std::function& f) { this->begin_transaction(); auto shouldCommit = f(); if(shouldCommit) { @@ -144,8 +144,8 @@ namespace sqlite_orm { int res = sqlite3_exec( db, sql.c_str(), - [](void *data, int argc, char **argv, char * * /*columnName*/) -> int { - auto &tableNames_ = *(data_t *)data; + [](void* data, int argc, char** argv, char* * /*columnName*/) -> int { + auto& tableNames_ = *(data_t*)data; for(int i = 0; i < argc; i++) { if(argv[i]) { tableNames_.push_back(argv[i]); @@ -171,8 +171,8 @@ namespace sqlite_orm { } } - void create_collation(const std::string &name, collating_function f) { - collating_function *functionPointer = nullptr; + void create_collation(const std::string& name, collating_function f) { + collating_function* functionPointer = nullptr; if(f) { functionPointer = &(collatingFunctions[name] = std::move(f)); } else { @@ -220,47 +220,47 @@ namespace sqlite_orm { } } - void backup_to(const std::string &filename) { + void backup_to(const std::string& filename) { auto backup = this->make_backup_to(filename); backup.step(-1); } - void backup_to(storage_base &other) { + void backup_to(storage_base& other) { auto backup = this->make_backup_to(other); backup.step(-1); } - void backup_from(const std::string &filename) { + void backup_from(const std::string& filename) { auto backup = this->make_backup_from(filename); backup.step(-1); } - void backup_from(storage_base &other) { + void backup_from(storage_base& other) { auto backup = this->make_backup_from(other); backup.step(-1); } - backup_t make_backup_to(const std::string &filename) { + backup_t make_backup_to(const std::string& filename) { auto holder = std::make_unique(filename); connection_ref conRef{*holder}; return {conRef, "main", this->get_connection(), "main", move(holder)}; } - backup_t make_backup_to(storage_base &other) { + backup_t make_backup_to(storage_base& other) { return {other.get_connection(), "main", this->get_connection(), "main", {}}; } - backup_t make_backup_from(const std::string &filename) { + backup_t make_backup_from(const std::string& filename) { auto holder = std::make_unique(filename); connection_ref conRef{*holder}; return {this->get_connection(), "main", conRef, "main", move(holder)}; } - backup_t make_backup_from(storage_base &other) { + backup_t make_backup_from(storage_base& other) { return {this->get_connection(), "main", other.get_connection(), "main", {}}; } - const std::string &filename() const { + const std::string& filename() const { return this->connection->filename; } @@ -286,7 +286,7 @@ namespace sqlite_orm { } protected: - storage_base(const std::string &filename_, int foreignKeysCount) : + storage_base(const std::string& filename_, int foreignKeysCount) : pragma(std::bind(&storage_base::get_connection, this)), limit(std::bind(&storage_base::get_connection, this)), inMemory(filename_.empty() || filename_ == ":memory:"), @@ -297,7 +297,7 @@ namespace sqlite_orm { } } - storage_base(const storage_base &other) : + storage_base(const storage_base& other) : on_open(other.on_open), pragma(std::bind(&storage_base::get_connection, this)), limit(std::bind(&storage_base::get_connection, this)), inMemory(other.inMemory), connection(std::make_unique(other.connection->filename)), @@ -334,20 +334,20 @@ namespace sqlite_orm { #if SQLITE_VERSION_NUMBER >= 3006019 - void foreign_keys(sqlite3 *db, bool value) { + void foreign_keys(sqlite3* db, bool value) { std::stringstream ss; ss << "PRAGMA foreign_keys = " << value; perform_void_exec(db, ss.str()); } - bool foreign_keys(sqlite3 *db) { + bool foreign_keys(sqlite3* db) { std::string query = "PRAGMA foreign_keys"; auto result = false; auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(bool *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(bool*)data; if(argc) { res = row_extractor().extract(argv[0]); } @@ -363,7 +363,7 @@ namespace sqlite_orm { } #endif - void on_open_internal(sqlite3 *db) { + void on_open_internal(sqlite3* db) { #if SQLITE_VERSION_NUMBER >= 3006019 if(this->cachedForeignKeysCount) { @@ -378,7 +378,7 @@ namespace sqlite_orm { this->pragma.set_pragma("journal_mode", static_cast(this->pragma._journal_mode), db); } - for(auto &p: this->collatingFunctions) { + for(auto& p: this->collatingFunctions) { if(sqlite3_create_collation(db, p.first.c_str(), SQLITE_UTF8, &p.second, collate_callback) != SQLITE_OK) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -386,7 +386,7 @@ namespace sqlite_orm { } } - for(auto &p: this->limit.limits) { + for(auto& p: this->limit.limits) { sqlite3_limit(db, p.first, p.second); } @@ -399,7 +399,7 @@ namespace sqlite_orm { } } - std::string current_timestamp(sqlite3 *db) { + std::string current_timestamp(sqlite3* db) { std::string result; std::stringstream ss; ss << "SELECT CURRENT_TIMESTAMP"; @@ -407,8 +407,8 @@ namespace sqlite_orm { auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(std::string *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(std::string*)data; if(argc) { if(argv[0]) { res = row_extractor().extract(argv[0]); @@ -425,19 +425,19 @@ namespace sqlite_orm { return result; } - void drop_table_internal(const std::string &tableName, sqlite3 *db) { + void drop_table_internal(const std::string& tableName, sqlite3* db) { std::stringstream ss; ss << "DROP TABLE '" << tableName + "'"; perform_void_exec(db, ss.str()); } - static int collate_callback(void *arg, int leftLen, const void *lhs, int rightLen, const void *rhs) { - auto &f = *(collating_function *)arg; + static int collate_callback(void* arg, int leftLen, const void* lhs, int rightLen, const void* rhs) { + auto& f = *(collating_function*)arg; return f(leftLen, lhs, rightLen, rhs); } - static int busy_handler_callback(void *selfPointer, int triesCount) { - auto &storage = *static_cast(selfPointer); + static int busy_handler_callback(void* selfPointer, int triesCount) { + auto& storage = *static_cast(selfPointer); if(storage._busy_handler) { return storage._busy_handler(triesCount); } else { @@ -447,9 +447,9 @@ namespace sqlite_orm { // returns foreign keys count in storage definition template - static int foreign_keys_count(T &storageImpl) { + static int foreign_keys_count(T& storageImpl) { auto res = 0; - storageImpl.for_each([&res](auto &impl) { + storageImpl.for_each([&res](auto& impl) { res += impl.foreign_keys_count(); }); return res; diff --git a/dev/storage_impl.h b/dev/storage_impl.h index 554cbbd0e..3abb35b29 100644 --- a/dev/storage_impl.h +++ b/dev/storage_impl.h @@ -29,7 +29,7 @@ namespace sqlite_orm { struct storage_impl_base { - bool table_exists(const std::string &tableName, sqlite3 *db) const { + bool table_exists(const std::string& tableName, sqlite3* db) const { auto result = false; std::stringstream ss; ss << "SELECT COUNT(*) FROM sqlite_master WHERE type = '" @@ -39,8 +39,8 @@ namespace sqlite_orm { auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char * * /*azColName*/) -> int { - auto &res = *(bool *)data; + [](void* data, int argc, char** argv, char* * /*azColName*/) -> int { + auto& res = *(bool*)data; if(argc) { res = !!std::atoi(argv[0]); } @@ -55,15 +55,15 @@ namespace sqlite_orm { return result; } - void rename_table(sqlite3 *db, const std::string &oldName, const std::string &newName) const { + void rename_table(sqlite3* db, const std::string& oldName, const std::string& newName) const { std::stringstream ss; ss << "ALTER TABLE " << oldName << " RENAME TO " << newName; perform_void_exec(db, ss.str()); } - static bool get_remove_add_columns(std::vector &columnsToAdd, - std::vector &storageTableInfo, - std::vector &dbTableInfo) { + static bool get_remove_add_columns(std::vector& columnsToAdd, + std::vector& storageTableInfo, + std::vector& dbTableInfo) { bool notEqual = false; // iterate through storage columns @@ -71,15 +71,15 @@ namespace sqlite_orm { ++storageColumnInfoIndex) { // get storage's column info - auto &storageColumnInfo = storageTableInfo[storageColumnInfoIndex]; - auto &columnName = storageColumnInfo.name; + auto& storageColumnInfo = storageTableInfo[storageColumnInfoIndex]; + auto& columnName = storageColumnInfo.name; // search for a column in db eith the same name - auto dbColumnInfoIt = std::find_if(dbTableInfo.begin(), dbTableInfo.end(), [&columnName](auto &ti) { + auto dbColumnInfoIt = std::find_if(dbTableInfo.begin(), dbTableInfo.end(), [&columnName](auto& ti) { return ti.name == columnName; }); if(dbColumnInfoIt != dbTableInfo.end()) { - auto &dbColumnInfo = *dbColumnInfoIt; + auto& dbColumnInfo = *dbColumnInfoIt; auto columnsAreEqual = dbColumnInfo.name == storageColumnInfo.name && dbColumnInfo.notnull == storageColumnInfo.notnull && @@ -100,14 +100,14 @@ namespace sqlite_orm { return notEqual; } - std::vector get_table_info(const std::string &tableName, sqlite3 *db) const { + std::vector get_table_info(const std::string& tableName, sqlite3* db) const { std::vector result; auto query = "PRAGMA table_info('" + tableName + "')"; auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(std::vector *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(std::vector*)data; if(argc) { auto index = 0; auto cid = std::atoi(argv[index++]); @@ -147,7 +147,7 @@ namespace sqlite_orm { table_type table; template - void for_each(const L &l) { + void for_each(const L& l) { this->super::for_each(l); l(*this); } @@ -159,7 +159,7 @@ namespace sqlite_orm { */ int foreign_keys_count() { auto res = 0; - iterate_tuple(this->table.columns, [&res](auto &c) { + iterate_tuple(this->table.columns, [&res](auto& c) { if(internal::is_foreign_key::type>::value) { ++res; } @@ -185,7 +185,7 @@ namespace sqlite_orm { */ template std::string column_name(F O::*m, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { return this->table.find_column_name(m); } @@ -194,49 +194,49 @@ namespace sqlite_orm { */ template std::string column_name(F O::*m, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { return this->super::column_name(m); } template - std::string column_name(const column_pointer &c, - typename std::enable_if::value>::type * = nullptr) const { + std::string column_name(const column_pointer& c, + typename std::enable_if::value>::type* = nullptr) const { return this->column_name_simple(c.field); } template - std::string column_name(const column_pointer &c, - typename std::enable_if::value>::type * = nullptr) const { + std::string column_name(const column_pointer& c, + typename std::enable_if::value>::type* = nullptr) const { return this->super::column_name(c); } template - const auto &get_impl(typename std::enable_if::value>::type * = nullptr) const { + const auto& get_impl(typename std::enable_if::value>::type* = nullptr) const { return *this; } template - const auto &get_impl(typename std::enable_if::value>::type * = nullptr) const { + const auto& get_impl(typename std::enable_if::value>::type* = nullptr) const { return this->super::template get_impl(); } template - auto &get_impl(typename std::enable_if::value>::type * = nullptr) { + auto& get_impl(typename std::enable_if::value>::type* = nullptr) { return *this; } template - auto &get_impl(typename std::enable_if::value>::type * = nullptr) { + auto& get_impl(typename std::enable_if::value>::type* = nullptr) { return this->super::template get_impl(); } template - const auto *find_table(typename std::enable_if::value>::type * = nullptr) const { + const auto* find_table(typename std::enable_if::value>::type* = nullptr) const { return &this->table; } template - const auto *find_table(typename std::enable_if::value>::type * = nullptr) const { + const auto* find_table(typename std::enable_if::value>::type* = nullptr) const { return this->super::template find_table(); } @@ -249,7 +249,7 @@ namespace sqlite_orm { } } - void add_column(const table_info &ti, sqlite3 *db) const { + void add_column(const table_info& ti, sqlite3* db) const { std::stringstream ss; ss << "ALTER TABLE " << this->table.name << " ADD COLUMN " << ti.name << " "; ss << ti.type << " "; @@ -270,13 +270,13 @@ namespace sqlite_orm { * Performs CREATE TABLE %name% AS SELECT %this->table.columns_names()% FROM &this->table.name%; */ void - copy_table(sqlite3 *db, const std::string &name, const std::vector &columnsToIgnore) const { + copy_table(sqlite3* db, const std::string& name, const std::vector& columnsToIgnore) const { std::ignore = columnsToIgnore; std::stringstream ss; std::vector columnNames; - this->table.for_each_column([&columnNames, &columnsToIgnore](auto &c) { - auto &columnName = c.name; + this->table.for_each_column([&columnNames, &columnsToIgnore](auto& c) { + auto& columnName = c.name; auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), columnsToIgnore.end(), [&columnName](auto tableInfoPointer) { @@ -308,7 +308,7 @@ namespace sqlite_orm { perform_void_exec(db, ss.str()); } - sync_schema_result schema_status(sqlite3 *db, bool preserve) const { + sync_schema_result schema_status(sqlite3* db, bool preserve) const { auto res = sync_schema_result::already_in_sync; @@ -323,7 +323,7 @@ namespace sqlite_orm { auto dbTableInfo = this->get_table_info(this->table.name, db); // this vector will contain pointers to columns that gotta be added.. - std::vector columnsToAdd; + std::vector columnsToAdd; if(this->get_remove_add_columns(columnsToAdd, storageTableInfo, dbTableInfo)) { gottaCreateTable = true; @@ -384,14 +384,14 @@ namespace sqlite_orm { } template - void for_each(const L &) {} + void for_each(const L&) {} int foreign_keys_count() { return 0; } template - const void *find_table() const { + const void* find_table() const { return nullptr; } }; diff --git a/dev/sync_schema_result.h b/dev/sync_schema_result.h index 3fd8255a0..e4df5cc96 100644 --- a/dev/sync_schema_result.h +++ b/dev/sync_schema_result.h @@ -41,7 +41,7 @@ namespace sqlite_orm { dropped_and_recreated, }; - inline std::ostream &operator<<(std::ostream &os, sync_schema_result value) { + inline std::ostream& operator<<(std::ostream& os, sync_schema_result value) { switch(value) { case sync_schema_result::new_table_created: return os << "new table created"; diff --git a/dev/table.h b/dev/table.h index 151238127..e19c7994d 100644 --- a/dev/table.h +++ b/dev/table.h @@ -54,9 +54,9 @@ namespace sqlite_orm { * Function used to get field value from object by mapped member pointer/setter/getter */ template - const F *get_object_field_pointer(const object_type &obj, C c) const { - const F *res = nullptr; - this->for_each_column_with_field_type([&res, &c, &obj](auto &col) { + const F* get_object_field_pointer(const object_type& obj, C c) const { + const F* res = nullptr; + this->for_each_column_with_field_type([&res, &c, &obj](auto& col) { using column_type = typename std::remove_reference::type; using member_pointer_t = typename column_type::member_pointer_t; using getter_type = typename column_type::getter_type; @@ -64,21 +64,21 @@ namespace sqlite_orm { // Make static_if have at least one input as a workaround for GCC bug: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64095 if(!res) { - static_if{}>([&res, &obj, &col](const C &c_) { + static_if{}>([&res, &obj, &col](const C& c_) { if(compare_any(col.member_pointer, c_)) { res = &(obj.*col.member_pointer); } })(c); } if(!res) { - static_if{}>([&res, &obj, &col](const C &c_) { + static_if{}>([&res, &obj, &col](const C& c_) { if(compare_any(col.getter, c_)) { res = &((obj).*(col.getter))(); } })(c); } if(!res) { - static_if{}>([&res, &obj, &col](const C &c_) { + static_if{}>([&res, &obj, &col](const C& c_) { if(compare_any(col.setter, c_)) { res = &((obj).*(col.getter))(); } @@ -93,7 +93,7 @@ namespace sqlite_orm { */ std::vector column_names() const { std::vector res; - this->for_each_column([&res](auto &c) { + this->for_each_column([&res](auto& c) { res.push_back(c.name); }); return res; @@ -103,8 +103,8 @@ namespace sqlite_orm { * Calls **l** with every primary key dedicated constraint */ template - void for_each_primary_key(const L &l) const { - iterate_tuple(this->columns, [&l](auto &column) { + void for_each_primary_key(const L& l) const { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; static_if{}>(l)(column); }); @@ -112,7 +112,7 @@ namespace sqlite_orm { std::vector composite_key_columns_names() const { std::vector res; - this->for_each_primary_key([this, &res](auto &c) { + this->for_each_primary_key([this, &res](auto& c) { res = this->composite_key_columns_names(c); }); return res; @@ -120,7 +120,7 @@ namespace sqlite_orm { std::vector primary_key_column_names() const { std::vector res; - this->for_each_column_with>([&res](auto &c) { + this->for_each_column_with>([&res](auto& c) { res.push_back(c.name); }); if(!res.size()) { @@ -130,11 +130,11 @@ namespace sqlite_orm { } template - std::vector composite_key_columns_names(const constraints::primary_key_t &pk) const { + std::vector composite_key_columns_names(const constraints::primary_key_t& pk) const { std::vector res; using pk_columns_tuple = decltype(pk.columns); res.reserve(std::tuple_size::value); - iterate_tuple(pk.columns, [this, &res](auto &v) { + iterate_tuple(pk.columns, [this, &res](auto& v) { res.push_back(this->find_column_name(v)); }); return res; @@ -150,7 +150,7 @@ namespace sqlite_orm { !std::is_member_function_pointer::value>::type> std::string find_column_name(F O::*m) const { std::string res; - this->template for_each_column_with_field_type([&res, m](auto &c) { + this->template for_each_column_with_field_type([&res, m](auto& c) { if(c.member_pointer == m) { res = c.name; } @@ -164,10 +164,10 @@ namespace sqlite_orm { */ template std::string find_column_name(G getter, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { std::string res; using field_type = typename getter_traits::field_type; - this->template for_each_column_with_field_type([&res, getter](auto &c) { + this->template for_each_column_with_field_type([&res, getter](auto& c) { if(compare_any(c.getter, getter)) { res = c.name; } @@ -181,10 +181,10 @@ namespace sqlite_orm { */ template std::string find_column_name(S setter, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { std::string res; using field_type = typename setter_traits::field_type; - this->template for_each_column_with_field_type([&res, setter](auto &c) { + this->template for_each_column_with_field_type([&res, setter](auto& c) { if(compare_any(c.setter, setter)) { res = c.name; } @@ -200,16 +200,16 @@ namespace sqlite_orm { * @param l Lambda to be called per column itself. Must have signature like this [] (auto col) -> void {} */ template - void for_each_column(const L &l) const { - iterate_tuple(this->columns, [&l](auto &column) { + void for_each_column(const L& l) const { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; static_if{}>(l)(column); }); } template - void for_each_column_with_field_type(const L &l) const { - iterate_tuple(this->columns, [&l](auto &column) { + void for_each_column_with_field_type(const L& l) const { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; using field_type = typename column_field_type::type; static_if{}>(l)(column); @@ -223,9 +223,9 @@ namespace sqlite_orm { * @param l Lambda to be called per column itself. Must have signature like this [] (auto col) -> void {} */ template - void for_each_column_with(const L &l) const { + void for_each_column_with(const L& l) const { using tuple_helper::tuple_contains_type; - iterate_tuple(this->columns, [&l](auto &column) { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; using constraints_type = typename column_constraints_type::type; static_if{}>(l)(column); @@ -235,7 +235,7 @@ namespace sqlite_orm { std::vector get_table_info() const { std::vector res; res.reserve(size_t(this->columns_count)); - this->for_each_column([&res](auto &col) { + this->for_each_column([&res](auto& col) { std::string dft; using field_type = typename std::decay::type::field_type; if(auto d = col.default_value()) { @@ -253,8 +253,8 @@ namespace sqlite_orm { }); auto compositeKeyColumnNames = this->composite_key_columns_names(); for(size_t i = 0; i < compositeKeyColumnNames.size(); ++i) { - auto &columnName = compositeKeyColumnNames[i]; - auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_info &ti) { + auto& columnName = compositeKeyColumnNames[i]; + auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_info& ti) { return ti.name == columnName; }); if(it != res.end()) { @@ -271,12 +271,12 @@ namespace sqlite_orm { * cause table class is templated and its constructing too (just like std::make_unique or std::make_pair). */ template>::type::object_type> - internal::table_t make_table(const std::string &name, Cs... args) { + internal::table_t make_table(const std::string& name, Cs... args) { return {name, std::make_tuple(std::forward(args)...)}; } template - internal::table_t make_table(const std::string &name, Cs... args) { + internal::table_t make_table(const std::string& name, Cs... args) { return {name, std::make_tuple(std::forward(args)...)}; } } diff --git a/dev/table_name_collector.h b/dev/table_name_collector.h index c2037e7ad..d4ca7bace 100644 --- a/dev/table_name_collector.h +++ b/dev/table_name_collector.h @@ -21,7 +21,7 @@ namespace sqlite_orm { mutable table_name_set table_names; template - table_name_set operator()(const T &) const { + table_name_set operator()(const T&) const { return {}; } @@ -33,19 +33,19 @@ namespace sqlite_orm { } template - void operator()(const column_pointer &) const { + void operator()(const column_pointer&) const { if(this->find_table_name) { table_names.insert({this->find_table_name(typeid(T)), ""}); } } template - void operator()(const alias_column_t &a) const { + void operator()(const alias_column_t& a) const { (*this)(a.column, alias_extractor::get()); } template - void operator()(const count_asterisk_t &) const { + void operator()(const count_asterisk_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); if(!tableName.empty()) { @@ -55,7 +55,7 @@ namespace sqlite_orm { } template - void operator()(const asterisk_t &) const { + void operator()(const asterisk_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -63,7 +63,7 @@ namespace sqlite_orm { } template - void operator()(const object_t &) const { + void operator()(const object_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -71,7 +71,7 @@ namespace sqlite_orm { } template - void operator()(const table_rowid_t &) const { + void operator()(const table_rowid_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -79,7 +79,7 @@ namespace sqlite_orm { } template - void operator()(const table_oid_t &) const { + void operator()(const table_oid_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -87,7 +87,7 @@ namespace sqlite_orm { } template - void operator()(const table__rowid_t &) const { + void operator()(const table__rowid_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); diff --git a/dev/tuple_helper.h b/dev/tuple_helper.h index b1535521d..3ed73c4c7 100644 --- a/dev/tuple_helper.h +++ b/dev/tuple_helper.h @@ -29,7 +29,7 @@ namespace sqlite_orm { struct iterator { template - void operator()(const std::tuple &t, const L &l, bool reverse = true) { + void operator()(const std::tuple& t, const L& l, bool reverse = true) { if(reverse) { l(std::get(t)); iterator()(t, l, reverse); @@ -44,7 +44,7 @@ namespace sqlite_orm { struct iterator<0, Args...> { template - void operator()(const std::tuple &t, const L &l, bool /*reverse*/ = true) { + void operator()(const std::tuple& t, const L& l, bool /*reverse*/ = true) { l(std::get<0>(t)); } }; @@ -53,15 +53,15 @@ namespace sqlite_orm { struct iterator { template - void operator()(const std::tuple<> &, const L &, bool /*reverse*/ = true) { + void operator()(const std::tuple<>&, const L&, bool /*reverse*/ = true) { //.. } }; template - void move_tuple_impl(L &lhs, R &rhs) { + void move_tuple_impl(L& lhs, R& rhs) { std::get(lhs) = std::move(std::get(rhs)); - internal::static_if{}>([](auto &l, auto &r) { + internal::static_if{}>([](auto& l, auto& r) { move_tuple_impl(l, r); })(lhs, rhs); } @@ -70,15 +70,15 @@ namespace sqlite_orm { namespace internal { template - void move_tuple(L &lhs, R &rhs) { + void move_tuple(L& lhs, R& rhs) { using bool_type = std::integral_constant; - static_if([](auto &l, auto &r) { + static_if([](auto& l, auto& r) { tuple_helper::move_tuple_impl(l, r); })(lhs, rhs); } template - void iterate_tuple(const std::tuple &t, const L &l) { + void iterate_tuple(const std::tuple& t, const L& l) { using tuple_type = std::tuple; tuple_helper::iterator::value - 1, Args...>()(t, l, false); } diff --git a/dev/type_is_nullable.h b/dev/type_is_nullable.h index 56aa59909..a835b47c5 100644 --- a/dev/type_is_nullable.h +++ b/dev/type_is_nullable.h @@ -17,7 +17,7 @@ namespace sqlite_orm { */ template struct type_is_nullable : public std::false_type { - bool operator()(const T &) const { + bool operator()(const T&) const { return true; } }; @@ -27,7 +27,7 @@ namespace sqlite_orm { */ template struct type_is_nullable> : public std::true_type { - bool operator()(const std::shared_ptr &t) const { + bool operator()(const std::shared_ptr& t) const { return static_cast(t); } }; @@ -37,7 +37,7 @@ namespace sqlite_orm { */ template struct type_is_nullable> : public std::true_type { - bool operator()(const std::unique_ptr &t) const { + bool operator()(const std::unique_ptr& t) const { return static_cast(t); } }; @@ -48,7 +48,7 @@ namespace sqlite_orm { */ template struct type_is_nullable> : public std::true_type { - bool operator()(const std::optional &t) const { + bool operator()(const std::optional& t) const { return t.has_value(); } }; diff --git a/dev/type_printer.h b/dev/type_printer.h index 764d9081c..2ae90f87b 100644 --- a/dev/type_printer.h +++ b/dev/type_printer.h @@ -16,28 +16,28 @@ namespace sqlite_orm { struct type_printer; struct integer_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "INTEGER"; return res; } }; struct text_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "TEXT"; return res; } }; struct real_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "REAL"; return res; } }; struct blob_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "BLOB"; return res; } @@ -87,7 +87,7 @@ namespace sqlite_orm { struct type_printer : public text_printer {}; template<> - struct type_printer : public text_printer {}; + struct type_printer : public text_printer {}; template<> struct type_printer : public real_printer {}; diff --git a/dev/typed_comparator.h b/dev/typed_comparator.h index 9691e9cfa..288ed1cb2 100644 --- a/dev/typed_comparator.h +++ b/dev/typed_comparator.h @@ -9,20 +9,20 @@ namespace sqlite_orm { */ template struct typed_comparator { - bool operator()(const L &, const R &) const { + bool operator()(const L&, const R&) const { return false; } }; template struct typed_comparator { - bool operator()(const O &lhs, const O &rhs) const { + bool operator()(const O& lhs, const O& rhs) const { return lhs == rhs; } }; template - bool compare_any(const L &lhs, const R &rhs) { + bool compare_any(const L& lhs, const R& rhs) { return typed_comparator()(lhs, rhs); } } diff --git a/dev/util.h b/dev/util.h index cef07ea6a..41fb70ae3 100644 --- a/dev/util.h +++ b/dev/util.h @@ -7,7 +7,7 @@ namespace sqlite_orm { namespace internal { - inline void perform_step(sqlite3 *db, sqlite3_stmt *stmt) { + inline void perform_step(sqlite3* db, sqlite3_stmt* stmt) { if(sqlite3_step(stmt) == SQLITE_DONE) { // done.. } else { @@ -16,7 +16,7 @@ namespace sqlite_orm { } } - static void perform_void_exec(sqlite3 *db, const std::string &query) { + static void perform_void_exec(sqlite3* db, const std::string& query) { int rc = sqlite3_exec(db, query.c_str(), nullptr, nullptr, nullptr); if(rc != SQLITE_OK) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), diff --git a/dev/view.h b/dev/view.h index 418a76870..af4d9f164 100644 --- a/dev/view.h +++ b/dev/view.h @@ -34,11 +34,11 @@ namespace sqlite_orm { using storage_type = S; using self = view_t; - storage_type &storage; + storage_type& storage; connection_ref connection; get_all_t, Args...> args; - view_t(storage_type &stor, decltype(connection) conn, Args &&... args_) : + view_t(storage_type& stor, decltype(connection) conn, Args&&... args_) : storage(stor), connection(std::move(conn)), args{std::make_tuple(std::forward(args_)...)} {} size_t size() { @@ -50,7 +50,7 @@ namespace sqlite_orm { } iterator_t begin() { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; auto db = this->connection.get(); using context_t = serializator_context; context_t context{this->storage.impl}; @@ -60,7 +60,7 @@ namespace sqlite_orm { auto ret = sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr); if(ret == SQLITE_OK) { auto index = 1; - iterate_ast(this->args.conditions, [&index, stmt, db](auto &node) { + iterate_ast(this->args.conditions, [&index, stmt, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { diff --git a/examples/blob.cpp b/examples/blob.cpp index dfb5418df..279ef842d 100644 --- a/examples/blob.cpp +++ b/examples/blob.cpp @@ -14,7 +14,7 @@ struct User { std::vector hash; // binary format }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("blob.sqlite", make_table("users", diff --git a/examples/case.cpp b/examples/case.cpp index 2bc3a565d..f2e0d6a14 100644 --- a/examples/case.cpp +++ b/examples/case.cpp @@ -34,7 +34,7 @@ int main() { }); // list all students - for(auto &student: storage.iterate()) { + for(auto& student: storage.iterate()) { cout << storage.dump(student) << endl; } cout << endl; @@ -60,7 +60,7 @@ int main() { .when(greater_or_equal(&Student::marks, 50), then("C")) .else_("Sorry!! Failed") .end())); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << ' ' << std::get<1>(row) << ' ' << std::get<2>(row) << ' ' << std::get<3>(row) << endl; } @@ -69,7 +69,7 @@ int main() { { // with alias struct GradeAlias : alias_tag { - static const std::string &get() { + static const std::string& get() { static const std::string res = "Grade"; return res; } @@ -94,7 +94,7 @@ int main() { .when(greater_or_equal(&Student::marks, 50), then("C")) .else_("Sorry!! Failed") .end()))); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << ' ' << std::get<1>(row) << ' ' << std::get<2>(row) << ' ' << std::get<3>(row) << endl; } diff --git a/examples/check.cpp b/examples/check.cpp index 865a6f16a..f6b2841f0 100644 --- a/examples/check.cpp +++ b/examples/check.cpp @@ -41,20 +41,20 @@ int main() { try { storage.insert(Contact{0, "John", "Doe", {}, "408123456"}); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } storage.insert(Contact{0, "John", "Doe", {}, "(408)-123-456"}); try { storage.insert(Product{0, "New Product", 900, 1000}); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } try { storage.insert(Product{0, "New XFactor", 1000, -10}); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } diff --git a/examples/collate.cpp b/examples/collate.cpp index e925f6f28..426790019 100644 --- a/examples/collate.cpp +++ b/examples/collate.cpp @@ -19,7 +19,7 @@ struct Foo { int baz; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage( diff --git a/examples/composite_key.cpp b/examples/composite_key.cpp index df7f7aee2..e128f0efb 100644 --- a/examples/composite_key.cpp +++ b/examples/composite_key.cpp @@ -53,7 +53,7 @@ int main() { try { // 2 and 'Drake' values will be ignored cause they are primary keys storage.insert(User{2, "Drake", "Singer"}); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << "exception = " << e.what() << endl; } storage.replace(User{2, "The Weeknd", "Singer"}); diff --git a/examples/core_functions.cpp b/examples/core_functions.cpp index 1558e47c3..d2620b131 100644 --- a/examples/core_functions.cpp +++ b/examples/core_functions.cpp @@ -20,7 +20,7 @@ struct Contact { std::string phone; }; -int main(int, char **argv) { +int main(int, char** argv) { cout << "path = " << argv[0] << endl; using namespace sqlite_orm; @@ -65,7 +65,7 @@ int main(int, char **argv) { // FROM marvel auto nameLengths = storage.select(length(&MarvelHero::name)); // nameLengths is std::vector cout << "nameLengths.size = " << nameLengths.size() << endl; - for(auto &len: nameLengths) { + for(auto& len: nameLengths) { cout << len << " "; } cout << endl; @@ -76,7 +76,7 @@ int main(int, char **argv) { columns(&MarvelHero::name, length(&MarvelHero::name))); // namesWithLengths is std::vector> cout << "namesWithLengths.size = " << namesWithLengths.size() << endl; - for(auto &row: namesWithLengths) { + for(auto& row: namesWithLengths) { cout << "LENGTH(" << std::get<0>(row) << ") = " << std::get<1>(row) << endl; } @@ -86,7 +86,7 @@ int main(int, char **argv) { auto namesWithLengthGreaterThan5 = storage.select(&MarvelHero::name, where(length(&MarvelHero::name) > 5)); // std::vector cout << "namesWithLengthGreaterThan5.size = " << namesWithLengthGreaterThan5.size() << endl; - for(auto &name: namesWithLengthGreaterThan5) { + for(auto& name: namesWithLengthGreaterThan5) { cout << "name = " << name << endl; } @@ -102,7 +102,7 @@ int main(int, char **argv) { // FROM marvel auto absPoints = storage.select(abs(&MarvelHero::points)); // std::vector> cout << "absPoints: "; - for(auto &value: absPoints) { + for(auto& value: absPoints) { if(value) { cout << *value; } else { @@ -117,7 +117,7 @@ int main(int, char **argv) { // WHERE ABS(points) < 5 auto namesByAbs = storage.select(&MarvelHero::name, where(abs(&MarvelHero::points) < 5)); cout << "namesByAbs.size = " << namesByAbs.size() << endl; - for(auto &name: namesByAbs) { + for(auto& name: namesByAbs) { cout << name << endl; } cout << endl; @@ -132,7 +132,7 @@ int main(int, char **argv) { // FROM marvel auto lowerNames = storage.select(lower(&MarvelHero::name)); cout << "lowerNames.size = " << lowerNames.size() << endl; - for(auto &name: lowerNames) { + for(auto& name: lowerNames) { cout << name << endl; } cout << endl; @@ -141,7 +141,7 @@ int main(int, char **argv) { // FROM marvel auto upperAbilities = storage.select(upper(&MarvelHero::abilities)); cout << "upperAbilities.size = " << upperAbilities.size() << endl; - for(auto &abilities: upperAbilities) { + for(auto& abilities: upperAbilities) { cout << abilities << endl; } cout << endl; @@ -175,7 +175,7 @@ int main(int, char **argv) { // FROM marvel auto emails = storage.select(lower(&MarvelHero::name) || c("@marvel.com")); cout << "emails.size = " << emails.size() << endl; - for(auto &email: emails) { + for(auto& email: emails) { cout << email << endl; } cout << endl; @@ -203,7 +203,7 @@ int main(int, char **argv) { } // SELECT * FROM marvel ORDER BY RANDOM() - for(auto &hero: storage.iterate(order_by(sqlite_orm::random()))) { + for(auto& hero: storage.iterate(order_by(sqlite_orm::random()))) { cout << "hero = " << storage.dump(hero) << endl; } @@ -302,7 +302,7 @@ int main(int, char **argv) { { cout << endl; struct o_pos : alias_tag { - static const std::string &get() { + static const std::string& get() { static const std::string res = "o_pos"; return res; } @@ -313,7 +313,7 @@ int main(int, char **argv) { // WHERE o_pos > 0 auto rows = storage.select(columns(&MarvelHero::name, as(instr(&MarvelHero::abilities, "o"))), where(greater_than(get(), 0))); - for(auto &row: rows) { + for(auto& row: rows) { cout << get<0>(row) << '\t' << get<1>(row) << endl; } cout << endl; @@ -331,7 +331,7 @@ int main(int, char **argv) { // SET phone = REPLACE(phone, '410', '+1-410') storage.update_all(set(c(&Contact::phone) = replace(&Contact::phone, "410", "+1-410"))); cout << "Contacts:" << endl; - for(auto &contact: storage.iterate()) { + for(auto& contact: storage.iterate()) { cout << storage.dump(contact) << endl; } diff --git a/examples/cross_join.cpp b/examples/cross_join.cpp index f8b09ef1f..28b2853ed 100644 --- a/examples/cross_join.cpp +++ b/examples/cross_join.cpp @@ -20,7 +20,7 @@ namespace DataModel { }; } -static auto initStorage(const std::string &path) { +static auto initStorage(const std::string& path) { using namespace DataModel; using namespace sqlite_orm; return make_storage(path, @@ -28,7 +28,7 @@ static auto initStorage(const std::string &path) { make_table("suits", make_column("suit", &Suit::suit))); } -int main(int, char **) { +int main(int, char**) { using namespace DataModel; using Storage = decltype(initStorage("")); diff --git a/examples/custom_aliases.cpp b/examples/custom_aliases.cpp index 1ac89470d..b7ac51e62 100644 --- a/examples/custom_aliases.cpp +++ b/examples/custom_aliases.cpp @@ -28,20 +28,20 @@ struct Department { using namespace sqlite_orm; struct EmployeeIdAlias : alias_tag { - static const std::string &get() { + static const std::string& get() { static const std::string res = "COMPANY_ID"; return res; } }; struct CompanyNameAlias : alias_tag { - static const std::string &get() { + static const std::string& get() { static const std::string res = "COMPANY_NAME"; return res; } }; -int main(int, char **argv) { +int main(int, char** argv) { cout << argv[0] << endl; auto storage = make_storage("custom_aliases.sqlite", @@ -85,7 +85,7 @@ int main(int, char **argv) { cout << "ID" << '\t' << "NAME" << '\t' << "AGE" << '\t' << "DEPT" << endl; cout << "----------" << '\t' << "----------" << '\t' << "----------" << '\t' << "----------" << endl; - for(auto &row: simpleRows) { + for(auto& row: simpleRows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } diff --git a/examples/distinct.cpp b/examples/distinct.cpp index 6813f6ac1..3848e1a86 100644 --- a/examples/distinct.cpp +++ b/examples/distinct.cpp @@ -16,7 +16,7 @@ struct Employee { double salary; }; -auto initStorage(const std::string &path) { +auto initStorage(const std::string& path) { using namespace sqlite_orm; return make_storage(path, make_table("COMPANY", @@ -28,7 +28,7 @@ auto initStorage(const std::string &path) { } using Storage = decltype(initStorage("")); -int main(int, char **) { +int main(int, char**) { Storage storage = initStorage("distinct.sqlite"); @@ -117,7 +117,7 @@ int main(int, char **) { auto pureNames = storage.select(&Employee::name); cout << "NAME" << endl; cout << "----------" << endl; - for(auto &name: pureNames) { + for(auto& name: pureNames) { cout << name << endl; } cout << endl; @@ -127,7 +127,7 @@ int main(int, char **) { auto distinctNames = storage.select(distinct(&Employee::name)); cout << "NAME" << endl; cout << "----------" << endl; - for(auto &name: distinctNames) { + for(auto& name: distinctNames) { cout << name << endl; } cout << endl; @@ -136,7 +136,7 @@ int main(int, char **) { auto severalColumns = storage.select(distinct(columns(&Employee::address, &Employee::name))); cout << "ADDRESS" << '\t' << "NAME" << endl; cout << "----------" << endl; - for(auto &t: severalColumns) { + for(auto& t: severalColumns) { cout << std::get<0>(t) << '\t' << std::get<1>(t) << endl; } return 0; diff --git a/examples/enum_binding.cpp b/examples/enum_binding.cpp index 160dc21f0..e8164f730 100644 --- a/examples/enum_binding.cpp +++ b/examples/enum_binding.cpp @@ -46,7 +46,7 @@ std::string GenderToString(Gender gender) { * that's why I placed it separatedly. You can use any transformation type/form * (for example BETTER_ENUM https://github.com/aantron/better-enums) */ -std::unique_ptr GenderFromString(const std::string &s) { +std::unique_ptr GenderFromString(const std::string& s) { if(s == "female") { return std::make_unique(Gender::Female); } else if(s == "male") { @@ -83,7 +83,7 @@ namespace sqlite_orm { template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const Gender &value) { + int bind(sqlite3_stmt* stmt, int index, const Gender& value) { return statement_binder().bind(stmt, index, GenderToString(value)); // or return sqlite3_bind_text(stmt, index++, GenderToString(value).c_str(), -1, SQLITE_TRANSIENT); } @@ -95,7 +95,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const Gender &t) const { + std::string operator()(const Gender& t) const { return GenderToString(t); } }; @@ -108,7 +108,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - Gender extract(const char *row_value) { + Gender extract(const char* row_value) { if(auto gender = GenderFromString(row_value)) { return *gender; } else { @@ -116,14 +116,14 @@ namespace sqlite_orm { } } - Gender extract(sqlite3_stmt *stmt, int columnIndex) { + Gender extract(sqlite3_stmt* stmt, int columnIndex) { auto str = sqlite3_column_text(stmt, columnIndex); - return this->extract((const char *)str); + return this->extract((const char*)str); } }; } -int main(int /* argc*/, char ** /*argv*/) { +int main(int /* argc*/, char** /*argv*/) { using namespace sqlite_orm; auto storage = make_storage("", make_table("superheros", @@ -150,7 +150,7 @@ int main(int /* argc*/, char ** /*argv*/) { // print all superheros cout << "allSuperHeros = " << allSuperHeros.size() << endl; - for(auto &superHero: allSuperHeros) { + for(auto& superHero: allSuperHeros) { cout << storage.dump(superHero) << endl; } @@ -161,7 +161,7 @@ int main(int /* argc*/, char ** /*argv*/) { auto males = storage.get_all(where(c(&SuperHero::gender) == Gender::Male)); cout << "males = " << males.size() << endl; assert(males.size() == 2); - for(auto &superHero: males) { + for(auto& superHero: males) { cout << storage.dump(superHero) << endl; } @@ -169,7 +169,7 @@ int main(int /* argc*/, char ** /*argv*/) { auto females = storage.get_all(where(c(&SuperHero::gender) == Gender::Female)); assert(females.size() == 1); cout << "females = " << females.size() << endl; - for(auto &superHero: females) { + for(auto& superHero: females) { cout << storage.dump(superHero) << endl; } diff --git a/examples/exists.cpp b/examples/exists.cpp index 6ebeeb3fa..35e947638 100644 --- a/examples/exists.cpp +++ b/examples/exists.cpp @@ -41,7 +41,7 @@ struct Order { std::string agentCode; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("exists.sqlite", @@ -421,7 +421,7 @@ int main(int, char **) { order_by(&Agent::comission)); cout << "AGENT_CODE AGENT_NAME WORKING_AREA COMMISSION" << endl; cout << "---------- ---------------------------------------- ------------ ----------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } @@ -443,7 +443,7 @@ int main(int, char **) { having(greater_than(count(), 2)))))); cout << "CUST_CODE CUST_NAME CUST_CITY GRADE" << endl; cout << "---------- ---------- ----------------------------------- ----------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } @@ -459,7 +459,7 @@ int main(int, char **) { columns(&Order::agentCode, &Order::num, &Order::amount, &Order::custCode), where(not exists(select(&Customer::agentCode, where(is_equal(&Customer::paymentAmt, 1400)))))); cout << "AGENT_CODE ORD_NUM ORD_AMOUNT CUST_CODE" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } diff --git a/examples/foreign_key.cpp b/examples/foreign_key.cpp index 830ccf4b9..b8bb85051 100644 --- a/examples/foreign_key.cpp +++ b/examples/foreign_key.cpp @@ -23,7 +23,7 @@ struct Track { std::unique_ptr trackArtist; // must map to &Artist::artistId }; -int main(int, char **argv) { +int main(int, char** argv) { cout << "path = " << argv[0] << endl; using namespace sqlite_orm; @@ -38,7 +38,7 @@ int main(int, char **argv) { make_column("trackartist", &Track::trackArtist), foreign_key(&Track::trackArtist).references(&Artist::artistId))); auto syncSchemaRes = storage.sync_schema(); - for(auto &p: syncSchemaRes) { + for(auto& p: syncSchemaRes) { cout << p.first << " " << p.second << endl; } @@ -57,7 +57,7 @@ int main(int, char **argv) { // does not correspond to row in the artist table. storage.replace(Track{14, "Mr. Bojangles", std::make_unique(3)}); assert(0); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } @@ -72,7 +72,7 @@ int main(int, char **argv) { storage.update_all(set(assign(&Track::trackArtist, 3)), where(is_equal(&Track::trackName, "Mr. Bojangles"))); assert(0); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } @@ -92,7 +92,7 @@ int main(int, char **argv) { // the track table contains a row that refer to it. storage.remove_all(where(is_equal(&Artist::artistName, "Frank Sinatra"))); assert(0); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } @@ -106,7 +106,7 @@ int main(int, char **argv) { // exists records in the track table that refer to it. storage.update_all(set(assign(&Artist::artistId, 4)), where(is_equal(&Artist::artistName, "Dean Martin"))); assert(0); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } @@ -127,7 +127,7 @@ int main(int, char **argv) { make_column("trackartist", &Track::trackArtist), foreign_key(&Track::trackArtist).references(&Artist::artistId).on_update.cascade())); auto syncSchemaRes = storage.sync_schema(); - for(auto &p: syncSchemaRes) { + for(auto& p: syncSchemaRes) { cout << p.first << " " << p.second << endl; } @@ -150,13 +150,13 @@ int main(int, char **argv) { storage.update_all(set(c(&Artist::artistId) = 100), where(c(&Artist::artistName) == "Dean Martin")); cout << "artists:" << endl; - for(auto &artist: storage.iterate()) { + for(auto& artist: storage.iterate()) { cout << artist.artistId << '\t' << artist.artistName << endl; } cout << endl; cout << "tracks:" << endl; - for(auto &track: storage.iterate()) { + for(auto& track: storage.iterate()) { cout << track.trackId << '\t' << track.trackName << '\t'; if(track.trackArtist) { cout << *track.trackArtist; @@ -179,7 +179,7 @@ int main(int, char **argv) { make_column("trackartist", &Track::trackArtist, default_value(0)), foreign_key(&Track::trackArtist).references(&Artist::artistId).on_delete.set_default())); auto syncSchemaRes = storage.sync_schema(); - for(auto &p: syncSchemaRes) { + for(auto& p: syncSchemaRes) { cout << p.first << " " << p.second << endl; } @@ -198,7 +198,7 @@ int main(int, char **argv) { try { storage.remove_all(where(c(&Artist::artistName) == "Sammy Davis Jr.")); assert(0); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } @@ -211,13 +211,13 @@ int main(int, char **argv) { storage.remove_all(where(c(&Artist::artistName) == "Sammy Davis Jr.")); cout << "artists:" << endl; - for(auto &artist: storage.iterate()) { + for(auto& artist: storage.iterate()) { cout << artist.artistId << '\t' << artist.artistName << endl; } cout << endl; cout << "tracks:" << endl; - for(auto &track: storage.iterate()) { + for(auto& track: storage.iterate()) { cout << track.trackId << '\t' << track.trackName << '\t'; if(track.trackArtist) { cout << *track.trackArtist; diff --git a/examples/group_by.cpp b/examples/group_by.cpp index b56d883df..8be912278 100644 --- a/examples/group_by.cpp +++ b/examples/group_by.cpp @@ -17,7 +17,7 @@ struct Employee { double salary; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("group_by.sqlite", @@ -43,7 +43,7 @@ int main(int, char **) { // FROM COMPANY // GROUP BY NAME; auto salaryName = storage.select(columns(&Employee::name, sum(&Employee::salary)), group_by(&Employee::name)); - for(auto &t: salaryName) { + for(auto& t: salaryName) { cout << std::get<0>(t) << '\t' << *std::get<1>(t) << endl; } @@ -55,7 +55,7 @@ int main(int, char **) { cout << endl << "Now, our table has the following records with duplicate names:" << endl << endl; - for(auto &employee: storage.iterate()) { + for(auto& employee: storage.iterate()) { cout << storage.dump(employee) << endl; } @@ -65,7 +65,7 @@ int main(int, char **) { salaryName = storage.select(columns(&Employee::name, sum(&Employee::salary)), group_by(&Employee::name), order_by(&Employee::name)); - for(auto &t: salaryName) { + for(auto& t: salaryName) { cout << std::get<0>(t) << '\t' << *std::get<1>(t) << endl; } @@ -73,7 +73,7 @@ int main(int, char **) { salaryName = storage.select(columns(&Employee::name, sum(&Employee::salary)), group_by(&Employee::name), order_by(&Employee::name).desc()); - for(auto &t: salaryName) { + for(auto& t: salaryName) { cout << std::get<0>(t) << '\t' << *std::get<1>(t) << endl; } diff --git a/examples/having.cpp b/examples/having.cpp index e32eb8789..82f7c395f 100644 --- a/examples/having.cpp +++ b/examples/having.cpp @@ -49,7 +49,7 @@ int main() { // HAVING count(name) < 2; auto rows = storage.get_all(group_by(&Employee::name), having(lesser_than(count(&Employee::name), 2))); - for(auto &employee: rows) { + for(auto& employee: rows) { cout << storage.dump(employee) << endl; } cout << endl; @@ -61,7 +61,7 @@ int main() { // HAVING count(name) > 2; auto rows = storage.get_all(group_by(&Employee::name), having(greater_than(count(&Employee::name), 2))); - for(auto &employee: rows) { + for(auto& employee: rows) { cout << storage.dump(employee) << endl; } cout << endl; diff --git a/examples/in_memory.cpp b/examples/in_memory.cpp index f3f534aff..5799f967a 100644 --- a/examples/in_memory.cpp +++ b/examples/in_memory.cpp @@ -14,7 +14,7 @@ struct RapArtist { std::string name; }; -int main(int, char **) { +int main(int, char**) { auto storage = make_storage(":memory:", make_table("rap_artists", diff --git a/examples/index.cpp b/examples/index.cpp index fd45ec6a1..709af0a17 100644 --- a/examples/index.cpp +++ b/examples/index.cpp @@ -26,7 +26,7 @@ auto storage = make_column("last_name", &Contract::lastName), make_column("email", &Contract::email))); -int main(int, char **) { +int main(int, char**) { storage.sync_schema(); storage.remove_all(); @@ -42,7 +42,7 @@ int main(int, char **) { "Doe", "john.doe@sqlitetutorial.net", }); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cout << e.what() << endl; } std::vector moreContracts = { diff --git a/examples/insert.cpp b/examples/insert.cpp index f29bb899c..7c4eeb72d 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -23,7 +23,7 @@ struct DetailedEmployee : public Employee { std::string birthDate; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("insert.sqlite", @@ -90,7 +90,7 @@ int main(int, char **) { // and closes database. So triple insert will open and close the db three times. // Transaction openes and closes the db only once. storage.transaction([&] { - for(auto &employee: otherEmployees) { + for(auto& employee: otherEmployees) { storage.insert(employee); } return true; // commit @@ -106,7 +106,7 @@ int main(int, char **) { james.id = storage.insert(james); cout << "---------------------" << endl; - for(auto &employee: storage.iterate()) { + for(auto& employee: storage.iterate()) { cout << storage.dump(employee) << endl; } diff --git a/examples/iteration.cpp b/examples/iteration.cpp index 4aa4aeb28..f7bc9ec23 100644 --- a/examples/iteration.cpp +++ b/examples/iteration.cpp @@ -12,7 +12,7 @@ struct MarvelHero { std::string abilities; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("iteration.sqlite", make_table("marvel", @@ -40,19 +40,19 @@ int main(int, char **) { // iterate through heros - iteration takes less memory than `get_all` because // iteration fetches row by row once it is needed. If you break at any iteration // statement will be cleared without fetching remaining rows. - for(auto &hero: storage.iterate()) { + for(auto& hero: storage.iterate()) { cout << "hero = " << storage.dump(hero) << endl; } cout << "====" << endl; // one can iterate with custom WHERE conditions.. - for(auto &hero: storage.iterate(where(c(&MarvelHero::name) == "Thor"))) { + for(auto& hero: storage.iterate(where(c(&MarvelHero::name) == "Thor"))) { cout << "hero = " << storage.dump(hero) << endl; } cout << "Heros with LENGTH(name) < 6 :" << endl; - for(auto &hero: storage.iterate(where(length(&MarvelHero::name) < 6))) { + for(auto& hero: storage.iterate(where(length(&MarvelHero::name) < 6))) { cout << "hero = " << storage.dump(hero) << endl; } diff --git a/examples/key_value.cpp b/examples/key_value.cpp index 238694f59..7658fe1e4 100644 --- a/examples/key_value.cpp +++ b/examples/key_value.cpp @@ -29,7 +29,7 @@ struct KeyValue { std::string value; }; -auto &getStorage() { +auto& getStorage() { using namespace sqlite_orm; static auto storage = make_storage("key_value_example.sqlite", make_table("key_value", @@ -38,13 +38,13 @@ auto &getStorage() { return storage; } -void setValue(const std::string &key, const std::string &value) { +void setValue(const std::string& key, const std::string& value) { using namespace sqlite_orm; KeyValue kv{key, value}; getStorage().replace(kv); } -std::string getValue(const std::string &key) { +std::string getValue(const std::string& key) { using namespace sqlite_orm; if(auto kv = getStorage().get_pointer(key)) { return kv->value; @@ -57,7 +57,7 @@ int storedKeysCount() { return getStorage().count(); } -int main(int, char **argv) { +int main(int, char** argv) { cout << argv[0] << endl; // to know executable path in case if you need to access sqlite directly from sqlite client diff --git a/examples/left_and_inner_join.cpp b/examples/left_and_inner_join.cpp index 8004a84e4..6f5e90a34 100644 --- a/examples/left_and_inner_join.cpp +++ b/examples/left_and_inner_join.cpp @@ -35,7 +35,7 @@ struct Track { double unitPrice; }; -inline auto initStorage(const std::string &path) { +inline auto initStorage(const std::string& path) { using namespace sqlite_orm; return make_storage(path, make_table("artists", @@ -57,7 +57,7 @@ inline auto initStorage(const std::string &path) { make_column("UnitPrice", &Track::unitPrice))); } -int main(int, char **) { +int main(int, char**) { auto storage = initStorage("chinook.db"); @@ -75,15 +75,15 @@ int main(int, char **) { left_join(on(c(&Album::artistId) == &Artist::artistId)), order_by(&Album::albumId)); cout << "rows count = " << rows.size() << endl; - for(auto &row: rows) { - auto &artistId = std::get<0>(row); + for(auto& row: rows) { + auto& artistId = std::get<0>(row); if(artistId) { cout << *artistId; } else { cout << "null"; } cout << '\t'; - auto &albumId = std::get<1>(row); + auto& albumId = std::get<1>(row); if(albumId) { cout << *albumId; } else { @@ -106,15 +106,15 @@ int main(int, char **) { left_join(on(c(&Album::artistId) == &Artist::artistId)), where(is_null(&Album::albumId))); cout << "rows count = " << rows.size() << endl; - for(auto &row: rows) { - auto &artistId = std::get<0>(row); + for(auto& row: rows) { + auto& artistId = std::get<0>(row); if(artistId) { cout << *artistId; } else { cout << "null"; } cout << '\t'; - auto &albumId = std::get<1>(row); + auto& albumId = std::get<1>(row); if(albumId) { cout << *albumId; } else { @@ -135,7 +135,7 @@ int main(int, char **) { auto innerJoinRows0 = storage.select(columns(&Track::trackId, &Track::name, &Album::title), inner_join(on(c(&Track::albumId) == &Album::albumId))); cout << "innerJoinRows0 count = " << innerJoinRows0.size() << endl; - for(auto &row: innerJoinRows0) { + for(auto& row: innerJoinRows0) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t'; if(std::get<2>(row)) { cout << *std::get<2>(row); @@ -159,7 +159,7 @@ int main(int, char **) { storage.select(columns(&Track::trackId, &Track::name, &Track::albumId, &Album::albumId, &Album::title), inner_join(on(c(&Album::albumId) == &Track::trackId))); cout << "innerJoinRows1 count = " << innerJoinRows1.size() << endl; - for(auto &row: innerJoinRows1) { + for(auto& row: innerJoinRows1) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t'; if(std::get<2>(row)) { cout << *std::get<2>(row); @@ -196,7 +196,7 @@ int main(int, char **) { inner_join(on(c(&Album::albumId) == &Track::albumId)), inner_join(on(c(&Artist::artistId) == &Album::artistId))); cout << "innerJoinRows2 count = " << innerJoinRows2.size() << endl; - for(auto &row: innerJoinRows2) { + for(auto& row: innerJoinRows2) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t'; if(std::get<2>(row)) { cout << *std::get<2>(row); @@ -293,7 +293,7 @@ int main(int, char **) { // ON a.doctor_id=c.doctor_id; auto rows = storage2.select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate), left_join(on(c(&Doctor::id) == &Visit::doctorId))); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } @@ -306,7 +306,7 @@ int main(int, char **) { // ON a.doctor_id=c.doctor_id; rows = storage2.select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate), join(on(c(&Doctor::id) == &Visit::doctorId))); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } @@ -319,7 +319,7 @@ int main(int, char **) { // USING(doctor_id); rows = storage2.select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate), left_join(using_(&Visit::doctorId))); // or using_(&Doctor::id) - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } diff --git a/examples/multi_table_select.cpp b/examples/multi_table_select.cpp index c9d1ca729..e3c1d2700 100644 --- a/examples/multi_table_select.cpp +++ b/examples/multi_table_select.cpp @@ -23,7 +23,7 @@ struct ReqDetail { double itemCost; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("multi_table_select.sqlite", @@ -62,7 +62,7 @@ int main(int, char **) { auto rows = storage.select( columns(&ReqEquip::reqNumber, &ReqEquip::requestor, &ReqDetail::quantity, &ReqDetail::stockNumber), where(c(&ReqEquip::reqNumber) == &ReqDetail::reqNumber)); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t'; cout << std::get<1>(row) << '\t'; cout << std::get<2>(row) << '\t'; @@ -79,7 +79,7 @@ int main(int, char **) { rows = storage.select( columns(&ReqEquip::reqNumber, &ReqEquip::requestor, &ReqDetail::quantity, &ReqDetail::stockNumber), where(c(&ReqEquip::reqNumber) == &ReqDetail::reqNumber and c(&ReqEquip::reqNumber) == 1000)); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t'; cout << std::get<1>(row) << '\t'; cout << std::get<2>(row) << '\t'; diff --git a/examples/natural_join.cpp b/examples/natural_join.cpp index dcfe37e05..f66ca2b65 100644 --- a/examples/natural_join.cpp +++ b/examples/natural_join.cpp @@ -74,7 +74,7 @@ int main() { natural_join(), where(c(&Doctor::degree) == "MD")); cout << "rows count = " << rows.size() << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << '\t' << std::get<4>(row) << endl; } @@ -96,7 +96,7 @@ int main() { natural_join(), where(c(&Doctor::degree) == "MD")); cout << "rows count = " << rows.size() << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << '\t' << std::get<4>(row) << '\t' << std::get<5>(row) << endl; } diff --git a/examples/nullable_enum_binding.cpp b/examples/nullable_enum_binding.cpp index 24c0db618..46d360cc8 100644 --- a/examples/nullable_enum_binding.cpp +++ b/examples/nullable_enum_binding.cpp @@ -31,7 +31,7 @@ std::unique_ptr GenderToString(Gender gender) { throw std::domain_error("Invalid Gender enum"); } -std::unique_ptr GenderFromString(const std::string &s) { +std::unique_ptr GenderFromString(const std::string& s) { if(s == "female") { return std::make_unique(Gender::Female); } else if(s == "male") { @@ -54,7 +54,7 @@ namespace sqlite_orm { template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const Gender &value) { + int bind(sqlite3_stmt* stmt, int index, const Gender& value) { if(auto str = GenderToString(value)) { return statement_binder().bind(stmt, index, *str); } else { @@ -65,7 +65,7 @@ namespace sqlite_orm { template<> struct field_printer { - std::string operator()(const Gender &t) const { + std::string operator()(const Gender& t) const { if(auto res = GenderToString(t)) { return *res; } else { @@ -76,7 +76,7 @@ namespace sqlite_orm { template<> struct row_extractor { - Gender extract(const char *row_value) { + Gender extract(const char* row_value) { if(row_value) { if(auto gender = GenderFromString(row_value)) { return *gender; @@ -88,9 +88,9 @@ namespace sqlite_orm { } } - Gender extract(sqlite3_stmt *stmt, int columnIndex) { + Gender extract(sqlite3_stmt* stmt, int columnIndex) { auto str = sqlite3_column_text(stmt, columnIndex); - return this->extract((const char *)str); + return this->extract((const char*)str); } }; @@ -102,13 +102,13 @@ namespace sqlite_orm { struct type_is_nullable : public std::true_type { // this function must return whether value null or not (false is null). Don't forget to implement it - bool operator()(const Gender &g) const { + bool operator()(const Gender& g) const { return g != Gender::None; } }; } -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("nullable_enum.sqlite", make_table("users", @@ -135,19 +135,19 @@ int main(int, char **) { }); cout << "All users :" << endl; - for(auto &user: storage.iterate()) { + for(auto& user: storage.iterate()) { cout << storage.dump(user) << endl; } auto allWithNoneGender = storage.get_all(where(is_null(&User::gender))); cout << "allWithNoneGender = " << allWithNoneGender.size() << endl; - for(auto &user: allWithNoneGender) { + for(auto& user: allWithNoneGender) { cout << storage.dump(user) << endl; } auto allWithGender = storage.get_all(where(is_not_null(&User::gender))); cout << "allWithGender = " << allWithGender.size() << endl; - for(auto &user: allWithGender) { + for(auto& user: allWithGender) { cout << storage.dump(user) << endl; } diff --git a/examples/prepared_statement.cpp b/examples/prepared_statement.cpp index f6121cfdb..0ac8c7648 100644 --- a/examples/prepared_statement.cpp +++ b/examples/prepared_statement.cpp @@ -70,7 +70,7 @@ int main() { // now 'doctors' table has two rows. // Next we shall reuse the statement again with member assignment - auto &doctor = get<0>(replaceStatement); // doctor is Doctor & + auto& doctor = get<0>(replaceStatement); // doctor is Doctor & doctor.doctor_id = 212; doctor.doctor_name = "Dr. Ke Gee"; doctor.degree = "MD"; @@ -99,7 +99,7 @@ int main() { } cout << "Doctors count = " << storage.count() << endl; - for(auto &doctor: storage.iterate()) { + for(auto& doctor: storage.iterate()) { cout << storage.dump(doctor) << endl; } @@ -116,7 +116,7 @@ int main() { } cout << "Specialities count = " << storage.count() << endl; - for(auto &speciality: storage.iterate()) { + for(auto& speciality: storage.iterate()) { cout << storage.dump(speciality) << endl; } { @@ -147,7 +147,7 @@ int main() { storage.replace(Visit{212, "Jason Mallin", "2013-10-12"}); } cout << "Visits count = " << storage.count() << endl; - for(auto &visit: storage.iterate()) { + for(auto& visit: storage.iterate()) { cout << storage.dump(visit) << endl; } { @@ -159,7 +159,7 @@ int main() { { auto rows = storage.execute(selectStatement); cout << "rows count = " << rows.size() << endl; - for(auto &id: rows) { + for(auto& id: rows) { cout << id << endl; } } @@ -172,7 +172,7 @@ int main() { get<0>(selectStatement) = 11; auto rows = storage.execute(selectStatement); cout << "rows count = " << rows.size() << endl; - for(auto &id: rows) { + for(auto& id: rows) { cout << id << endl; } } @@ -187,7 +187,7 @@ int main() { { auto rows = storage.execute(selectStatement); cout << "rows count = " << rows.size() << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << get<0>(row) << '\t' << get<1>(row) << endl; } } @@ -199,7 +199,7 @@ int main() { { auto rows = storage.execute(selectStatement); cout << "rows count = " << rows.size() << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << get<0>(row) << '\t' << get<1>(row) << endl; } } diff --git a/examples/private_class_members.cpp b/examples/private_class_members.cpp index 779f14269..00a4294ef 100644 --- a/examples/private_class_members.cpp +++ b/examples/private_class_members.cpp @@ -43,7 +43,7 @@ class Player { } }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage( "private.sqlite", @@ -81,7 +81,7 @@ int main(int, char **) { auto somePlayers = storage.get_all(where(lesser_than(length(&Player::getName), 5))); cout << "players with length(name) < 5 = " << somePlayers.size() << endl; assert(somePlayers.size() == 1); - for(auto &player: somePlayers) { + for(auto& player: somePlayers) { cout << storage.dump(player) << endl; } } diff --git a/examples/select.cpp b/examples/select.cpp index 02b4c28af..d8632e5e0 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -19,7 +19,7 @@ using namespace sqlite_orm; using std::cout; using std::endl; -int main(int, char **) { +int main(int, char**) { auto storage = make_storage("select.sqlite", make_table("COMPANY", make_column("ID", &Employee::id, primary_key()), @@ -66,7 +66,7 @@ int main(int, char **) { // now let's select id, name and salary.. auto idsNamesSalarys = storage.select(columns(&Employee::id, &Employee::name, &Employee::salary)); // decltype(idsNamesSalarys) = vector>> - for(auto &tpl: idsNamesSalarys) { + for(auto& tpl: idsNamesSalarys) { cout << "id = " << std::get<0>(tpl) << ", name = " << std::get<1>(tpl) << ", salary = "; if(std::get<2>(tpl)) { cout << *std::get<2>(tpl); @@ -80,16 +80,16 @@ int main(int, char **) { auto allEmployeesTuples = storage.select(asterisk()); cout << "allEmployeesTuples count = " << allEmployeesTuples.size() << endl; - for(auto &row: allEmployeesTuples) { // row is std::tuple, + for(auto& row: allEmployeesTuples) { // row is std::tuple, // std::unique_ptr> cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t'; - if(auto &value = std::get<3>(row)) { + if(auto& value = std::get<3>(row)) { cout << *value; } else { cout << "null"; } cout << '\t'; - if(auto &value = std::get<4>(row)) { + if(auto& value = std::get<4>(row)) { cout << *value; } else { cout << "null"; diff --git a/examples/self_join.cpp b/examples/self_join.cpp index c450b78df..51fc6d950 100644 --- a/examples/self_join.cpp +++ b/examples/self_join.cpp @@ -36,7 +36,7 @@ template struct custom_alias : sqlite_orm::alias_tag { using type = T; - static const std::string &get() { + static const std::string& get() { static const std::string res = "emp"; return res; } @@ -205,7 +205,7 @@ int main() { c(&Employee::firstName) || " " || c(&Employee::lastName)), inner_join(on(alias_column(&Employee::reportsTo) == c(&Employee::employeeId)))); cout << "firstNames count = " << firstNames.size() << endl; - for(auto &row: firstNames) { + for(auto& row: firstNames) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << endl; } @@ -225,7 +225,7 @@ int main() { c(&Employee::firstName) || " " || c(&Employee::lastName)), inner_join(on(alias_column(&Employee::reportsTo) == c(&Employee::employeeId)))); cout << "firstNames count = " << firstNames.size() << endl; - for(auto &row: firstNames) { + for(auto& row: firstNames) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << endl; } } diff --git a/examples/subentities.cpp b/examples/subentities.cpp index cfb5fb863..c27d67c38 100644 --- a/examples/subentities.cpp +++ b/examples/subentities.cpp @@ -42,7 +42,7 @@ auto storage = make_table("marks", make_column("mark", &Mark::value), make_column("student_id", &Mark::student_id))); // inserts or updates student and does the same with marks -int addStudent(const Student &student) { +int addStudent(const Student& student) { auto studentId = student.id; if(storage.count(where(c(&Student::id) == student.id))) { storage.update(student); @@ -52,7 +52,7 @@ int addStudent(const Student &student) { // insert all marks within a transaction storage.transaction([&] { storage.remove_all(where(c(&Mark::student_id) == studentId)); - for(auto &mark: student.marks) { + for(auto& mark: student.marks) { storage.insert(Mark{mark, studentId}); } return true; @@ -71,7 +71,7 @@ Student getStudent(int studentId) { return res; // must be moved automatically by compiler } -int main(int, char **) { +int main(int, char**) { decltype(Student::id) mikeId; decltype(Student::id) annaId; @@ -97,7 +97,7 @@ int main(int, char **) { auto mike = getStudent(mikeId); cout << "mike = " << storage.dump(mike) << endl; cout << "mike.marks = "; - for(auto &m: mike.marks) { + for(auto& m: mike.marks) { cout << m << " "; } cout << endl; @@ -105,7 +105,7 @@ int main(int, char **) { auto anna = getStudent(annaId); cout << "anna = " << storage.dump(anna) << endl; cout << "anna.marks = "; - for(auto &m: anna.marks) { + for(auto& m: anna.marks) { cout << m << " "; } cout << endl; diff --git a/examples/subquery.cpp b/examples/subquery.cpp index 76d49d4d2..4bc5f5d61 100644 --- a/examples/subquery.cpp +++ b/examples/subquery.cpp @@ -38,7 +38,7 @@ struct JobHistory { decltype(Employee::departmentId) departmentId; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("subquery.sqlite", make_table("employees", @@ -1288,7 +1288,7 @@ int main(int, char **) { select(&Employee::salary, where(is_equal(&Employee::firstName, "Alexander")))))); cout << "first_name last_name salary" << endl; cout << "---------- ---------- ----------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << endl; } } @@ -1300,7 +1300,7 @@ int main(int, char **) { where(greater_than(&Employee::salary, select(avg(&Employee::salary))))); cout << "employee_id first_name last_name salary" << endl; cout << "----------- ---------- ---------- ----------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } @@ -1316,7 +1316,7 @@ int main(int, char **) { where(in(&Employee::departmentId, select(&Department::id, where(c(&Department::locationId) == 1700))))); cout << "first_name last_name department_id" << endl; cout << "---------- ---------- -------------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << endl; } } @@ -1334,7 +1334,7 @@ int main(int, char **) { select(&Department::id, where(between(&Department::managerId, 100, 200)))))); cout << "first_name last_name department_id" << endl; cout << "---------- ---------- -------------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << endl; } } @@ -1355,7 +1355,7 @@ int main(int, char **) { where(is_equal(&Employee::departmentId, alias_column(&Employee::departmentId))))))); cout << "last_name salary department_id" << endl; cout << "---------- ---------- -------------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << endl; } } @@ -1372,7 +1372,7 @@ int main(int, char **) { select(count(), where(is_equal(&Employee::id, &JobHistory::employeeId)))))); cout << "first_name last_name employee_id job_id" << endl; cout << "---------- ---------- ----------- ----------" << endl; - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl; } diff --git a/examples/synchronous.cpp b/examples/synchronous.cpp index d10da13dd..6147efff2 100644 --- a/examples/synchronous.cpp +++ b/examples/synchronous.cpp @@ -12,7 +12,7 @@ struct Query { uint16_t type; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; diff --git a/examples/union.cpp b/examples/union.cpp index 7a2704874..4c5b588de 100644 --- a/examples/union.cpp +++ b/examples/union.cpp @@ -80,10 +80,10 @@ int main() { left_outer_join(on(is_equal(&Employee::id, &Department::employeeId)))))); assert(rows.size() == 7); - std::sort(rows.begin(), rows.end(), [](auto &lhs, auto &rhs) { + std::sort(rows.begin(), rows.end(), [](auto& lhs, auto& rhs) { return std::get<0>(lhs) < std::get<0>(rhs); }); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << endl; } cout << endl; @@ -103,7 +103,7 @@ int main() { inner_join(on(is_equal(&Employee::id, &Department::employeeId)))), select(columns(&Department::employeeId, &Employee::name, &Department::dept), left_outer_join(on(is_equal(&Employee::id, &Department::employeeId)))))); - for(auto &row: rows) { + for(auto& row: rows) { cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << endl; } cout << endl; diff --git a/examples/unique.cpp b/examples/unique.cpp index 24b3ac81b..2a7b518ec 100644 --- a/examples/unique.cpp +++ b/examples/unique.cpp @@ -14,7 +14,7 @@ struct Entry { std::unique_ptr nullableColumn; }; -int main(int, char **) { +int main(int, char**) { using namespace sqlite_orm; auto storage = make_storage("unique.sqlite", make_table("unique_test", @@ -34,7 +34,7 @@ int main(int, char **) { auto id2 = storage.insert(Entry{0, sameString, std::make_unique("I got you")}); cout << "inserted " << storage.dump(storage.get(id2)) << endl; - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { cerr << e.what() << endl; } diff --git a/examples/update.cpp b/examples/update.cpp index 727cbbedd..ed3a27342 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -17,7 +17,7 @@ struct Employee { double salary; }; -inline auto initStorage(const std::string &path) { +inline auto initStorage(const std::string& path) { using namespace sqlite_orm; return make_storage(path, make_table("COMPANY", @@ -32,7 +32,7 @@ using Storage = decltype(initStorage("")); static std::unique_ptr stor; -int main(int, char **) { +int main(int, char**) { stor = std::make_unique(initStorage("update.sqlite")); stor->sync_schema(); stor->remove_all(); @@ -47,7 +47,7 @@ int main(int, char **) { stor->replace(Employee{7, "James", 24, "Houston", 10000.0}); // show 'COMPANY' table contents - for(auto &employee: stor->iterate()) { + for(auto& employee: stor->iterate()) { cout << stor->dump(employee) << endl; } cout << endl; @@ -60,7 +60,7 @@ int main(int, char **) { employee6); // actually this call updates all non-primary-key columns' values to passed object's fields // show 'COMPANY' table contents again - for(auto &employee: stor->iterate()) { + for(auto& employee: stor->iterate()) { cout << stor->dump(employee) << endl; } cout << endl; @@ -71,7 +71,7 @@ int main(int, char **) { where(c(&Employee::age) < 30)); // show 'COMPANY' table contents one more time - for(auto &employee: stor->iterate()) { + for(auto& employee: stor->iterate()) { cout << stor->dump(employee) << endl; } cout << endl; diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 0c7419ebe..a16fd5908 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -51,7 +51,7 @@ namespace sqlite_orm { class orm_error_category : public std::error_category { public: - const char *name() const noexcept override final { + const char* name() const noexcept override final { return "ORM error"; } @@ -91,7 +91,7 @@ namespace sqlite_orm { class sqlite_error_category : public std::error_category { public: - const char *name() const noexcept override final { + const char* name() const noexcept override final { return "SQLite error"; } @@ -100,18 +100,18 @@ namespace sqlite_orm { } }; - inline const orm_error_category &get_orm_error_category() { + inline const orm_error_category& get_orm_error_category() { static orm_error_category res; return res; } - inline const sqlite_error_category &get_sqlite_error_category() { + inline const sqlite_error_category& get_sqlite_error_category() { static sqlite_error_category res; return res; } template - std::string get_error_message(sqlite3 *db, T &&... args) { + std::string get_error_message(sqlite3* db, T&&... args) { std::ostringstream stream; using unpack = int[]; static_cast(unpack{0, (static_cast(static_cast(stream << args)), 0)...}); @@ -120,7 +120,7 @@ namespace sqlite_orm { } template - [[noreturn]] void throw_error(sqlite3 *db, T &&... args) { + [[noreturn]] void throw_error(sqlite3* db, T&&... args) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), get_error_message(db, std::forward(args)...)); } @@ -150,27 +150,27 @@ namespace sqlite_orm { namespace internal { static inline decltype(auto) empty_callable() { - static auto res = [](auto &&...) {}; + static auto res = [](auto&&...) {}; return (res); } template - decltype(auto) static_if(std::true_type, const T &t, const F &) { + decltype(auto) static_if(std::true_type, const T& t, const F&) { return (t); } template - decltype(auto) static_if(std::false_type, const T &, const F &f) { + decltype(auto) static_if(std::false_type, const T&, const F& f) { return (f); } template - decltype(auto) static_if(const T &t, const F &f) { + decltype(auto) static_if(const T& t, const F& f) { return static_if(std::integral_constant{}, t, f); } template - decltype(auto) static_if(const T &t) { + decltype(auto) static_if(const T& t) { return static_if(std::integral_constant{}, t, empty_callable()); } @@ -204,7 +204,7 @@ namespace sqlite_orm { struct iterator { template - void operator()(const std::tuple &t, const L &l, bool reverse = true) { + void operator()(const std::tuple& t, const L& l, bool reverse = true) { if(reverse) { l(std::get(t)); iterator()(t, l, reverse); @@ -219,7 +219,7 @@ namespace sqlite_orm { struct iterator<0, Args...> { template - void operator()(const std::tuple &t, const L &l, bool /*reverse*/ = true) { + void operator()(const std::tuple& t, const L& l, bool /*reverse*/ = true) { l(std::get<0>(t)); } }; @@ -228,15 +228,15 @@ namespace sqlite_orm { struct iterator { template - void operator()(const std::tuple<> &, const L &, bool /*reverse*/ = true) { + void operator()(const std::tuple<>&, const L&, bool /*reverse*/ = true) { //.. } }; template - void move_tuple_impl(L &lhs, R &rhs) { + void move_tuple_impl(L& lhs, R& rhs) { std::get(lhs) = std::move(std::get(rhs)); - internal::static_if{}>([](auto &l, auto &r) { + internal::static_if{}>([](auto& l, auto& r) { move_tuple_impl(l, r); })(lhs, rhs); } @@ -245,15 +245,15 @@ namespace sqlite_orm { namespace internal { template - void move_tuple(L &lhs, R &rhs) { + void move_tuple(L& lhs, R& rhs) { using bool_type = std::integral_constant; - static_if([](auto &l, auto &r) { + static_if([](auto& l, auto& r) { tuple_helper::move_tuple_impl(l, r); })(lhs, rhs); } template - void iterate_tuple(const std::tuple &t, const L &l) { + void iterate_tuple(const std::tuple& t, const L& l) { using tuple_type = std::tuple; tuple_helper::iterator::value - 1, Args...>()(t, l, false); } @@ -298,28 +298,28 @@ namespace sqlite_orm { struct type_printer; struct integer_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "INTEGER"; return res; } }; struct text_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "TEXT"; return res; } }; struct real_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "REAL"; return res; } }; struct blob_printer { - inline const std::string &print() { + inline const std::string& print() { static const std::string res = "BLOB"; return res; } @@ -369,7 +369,7 @@ namespace sqlite_orm { struct type_printer : public text_printer {}; template<> - struct type_printer : public text_printer {}; + struct type_printer : public text_printer {}; template<> struct type_printer : public real_printer {}; @@ -533,7 +533,7 @@ namespace sqlite_orm { cascade, }; - inline std::ostream &operator<<(std::ostream &os, foreign_key_action action) { + inline std::ostream& operator<<(std::ostream& os, foreign_key_action action) { switch(action) { case decltype(action)::no_action: os << "NO ACTION"; @@ -575,7 +575,7 @@ namespace sqlite_orm { struct on_update_delete_t : on_update_delete_base { using foreign_key_type = F; - const foreign_key_type &fk; + const foreign_key_type& fk; on_update_delete_t(decltype(fk) fk_, decltype(update) update_, foreign_key_action action_) : on_update_delete_base{update_}, fk(fk_), _action(action_) {} @@ -656,11 +656,11 @@ namespace sqlite_orm { 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) : + foreign_key_t(const self& other) : columns(other.columns), references(other.references), on_update(*this, true, other.on_update._action), on_delete(*this, false, other.on_delete._action) {} - self &operator=(const self &other) { + self& operator=(const self& other) { this->columns = other.columns; this->references = other.references; this->on_update = {*this, true, other.on_update._action}; @@ -669,7 +669,7 @@ namespace sqlite_orm { } template - void for_each_column(const L &) {} + void for_each_column(const L&) {} template constexpr bool has_every() const { @@ -879,7 +879,7 @@ namespace sqlite_orm { */ template struct type_is_nullable : public std::false_type { - bool operator()(const T &) const { + bool operator()(const T&) const { return true; } }; @@ -889,7 +889,7 @@ namespace sqlite_orm { */ template struct type_is_nullable> : public std::true_type { - bool operator()(const std::shared_ptr &t) const { + bool operator()(const std::shared_ptr& t) const { return static_cast(t); } }; @@ -899,7 +899,7 @@ namespace sqlite_orm { */ template struct type_is_nullable> : public std::true_type { - bool operator()(const std::unique_ptr &t) const { + bool operator()(const std::unique_ptr& t) const { return static_cast(t); } }; @@ -910,7 +910,7 @@ namespace sqlite_orm { */ template struct type_is_nullable> : public std::true_type { - bool operator()(const std::optional &t) const { + bool operator()(const std::optional& t) const { return t.has_value(); } }; @@ -946,9 +946,9 @@ namespace sqlite_orm { struct serializator_context : serializator_context_base { using impl_type = I; - const impl_type &impl; + const impl_type& impl; - serializator_context(const impl_type &impl_) : impl(impl_) {} + serializator_context(const impl_type& impl_) : impl(impl_) {} template std::string column_name(F O::*m) const { @@ -961,13 +961,13 @@ namespace sqlite_orm { using storage_type = S; using impl_type = typename storage_type::impl_type; - serializator_context_builder(const storage_type &storage_) : storage(storage_) {} + serializator_context_builder(const storage_type& storage_) : storage(storage_) {} serializator_context operator()() const { return {this->storage.impl}; } - const storage_type &storage; + const storage_type& storage; }; } @@ -979,7 +979,7 @@ namespace sqlite_orm { namespace internal { template - std::string serialize(const T &t); + std::string serialize(const T& t); /** * This class is used in tuple interation to know whether tuple constains `default_value_t` @@ -988,12 +988,12 @@ namespace sqlite_orm { struct default_value_extractor { template - std::unique_ptr operator()(const A &) { + std::unique_ptr operator()(const A&) { return {}; } template - std::unique_ptr operator()(const constraints::default_t &t) { + std::unique_ptr operator()(const constraints::default_t& t) { serializator_context_base context; return std::make_unique(serialize(t.value, context)); } @@ -1345,16 +1345,16 @@ namespace sqlite_orm { using getter_by_value = T (O::*)(); template - using getter_by_ref_const = T &(O::*)() const; + using getter_by_ref_const = T& (O::*)() const; template - using getter_by_ref = T &(O::*)(); + using getter_by_ref = T& (O::*)(); template - using getter_by_const_ref_const = const T &(O::*)() const; + using getter_by_const_ref_const = const T& (O::*)() const; template - using getter_by_const_ref = const T &(O::*)(); + using getter_by_const_ref = const T& (O::*)(); /** * Setters aliases @@ -1363,10 +1363,10 @@ namespace sqlite_orm { using setter_by_value = void (O::*)(T); template - using setter_by_ref = void (O::*)(T &); + using setter_by_ref = void (O::*)(T&); template - using setter_by_const_ref = void (O::*)(const T &); + using setter_by_const_ref = void (O::*)(const T&); template struct is_getter : std::false_type {}; @@ -1584,7 +1584,7 @@ namespace sqlite_orm { */ std::unique_ptr default_value() const { std::unique_ptr res; - iterate_tuple(this->constraints, [&res](auto &v) { + iterate_tuple(this->constraints, [&res](auto& v) { auto dft = internal::default_value_extractor()(v); if(dft) { res = std::move(dft); @@ -1635,8 +1635,8 @@ namespace sqlite_orm { class T, typename = typename std::enable_if::value>::type, class... Op> - internal::column_t - make_column(const std::string &name, T O::*m, Op... constraints) { + internal::column_t + make_column(const std::string& name, T O::*m, Op... constraints) { static_assert(constraints::template constraints_size::value == std::tuple_size>::value, "Incorrect constraints pack"); static_assert(internal::is_field_member_pointer::value, @@ -1657,7 +1657,7 @@ namespace sqlite_orm { G, S, Op...> - make_column(const std::string &name, S setter, G getter, Op... constraints) { + make_column(const std::string& name, S setter, G getter, Op... constraints) { static_assert(std::is_same::field_type, typename internal::getter_traits::field_type>::value, "Getter and setter must get and set same data type"); @@ -1680,7 +1680,7 @@ namespace sqlite_orm { G, S, Op...> - make_column(const std::string &name, G getter, S setter, Op... constraints) { + make_column(const std::string& name, G getter, S setter, Op... constraints) { static_assert(std::is_same::field_type, typename internal::getter_traits::field_type>::value, "Getter and setter must get and set same data type"); @@ -1709,7 +1709,7 @@ namespace sqlite_orm { */ template struct field_printer { - std::string operator()(const T &t) const { + std::string operator()(const T& t) const { std::stringstream stream; stream << t; return stream.str(); @@ -1721,7 +1721,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const unsigned char &t) const { + std::string operator()(const unsigned char& t) const { std::stringstream stream; stream << +t; return stream.str(); @@ -1733,7 +1733,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const signed char &t) const { + std::string operator()(const signed char& t) const { std::stringstream stream; stream << +t; return stream.str(); @@ -1745,7 +1745,7 @@ namespace sqlite_orm { */ template<> struct field_printer { - std::string operator()(const char &t) const { + std::string operator()(const char& t) const { std::stringstream stream; stream << +t; return stream.str(); @@ -1754,14 +1754,14 @@ namespace sqlite_orm { template<> struct field_printer { - std::string operator()(const std::string &t) const { + std::string operator()(const std::string& t) const { return t; } }; template<> struct field_printer> { - std::string operator()(const std::vector &t) const { + std::string operator()(const std::vector& t) const { std::stringstream ss; ss << std::hex; for(auto c: t) { @@ -1773,14 +1773,14 @@ namespace sqlite_orm { template<> struct field_printer { - std::string operator()(const std::nullptr_t &) const { + std::string operator()(const std::nullptr_t&) const { return "null"; } }; template struct field_printer> { - std::string operator()(const std::shared_ptr &t) const { + std::string operator()(const std::shared_ptr& t) const { if(t) { return field_printer()(*t); } else { @@ -1791,7 +1791,7 @@ namespace sqlite_orm { template struct field_printer> { - std::string operator()(const std::unique_ptr &t) const { + std::string operator()(const std::unique_ptr& t) const { if(t) { return field_printer()(*t); } else { @@ -1803,7 +1803,7 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template struct field_printer> { - std::string operator()(const std::optional &t) const { + std::string operator()(const std::optional& t) const { if(t.has_value()) { return field_printer()(*t); } else { @@ -1841,7 +1841,7 @@ namespace sqlite_orm { type field; template - void apply(const L &l) const { + void apply(const L& l) const { l(this->field); } }; @@ -1851,7 +1851,7 @@ namespace sqlite_orm { using type = void; template - void apply(const L &) const { + void apply(const L&) const { //.. } }; @@ -2338,7 +2338,7 @@ namespace sqlite_orm { args_type args; - multi_order_by_t(args_type &&args_) : args(std::move(args_)) {} + multi_order_by_t(args_type&& args_) : args(std::move(args_)) {} }; struct dynamic_order_by_entry_t : order_by_base { @@ -2357,7 +2357,7 @@ namespace sqlite_orm { using entry_t = dynamic_order_by_entry_t; using const_iterator = typename std::vector::const_iterator; - dynamic_order_by_t(const context_t &context_) : context(context_) {} + dynamic_order_by_t(const context_t& context_) : context(context_) {} template void push_back(order_by_t order_by) { @@ -2410,7 +2410,7 @@ namespace sqlite_orm { using args_type = std::tuple; args_type args; - group_by_t(args_type &&args_) : args(std::move(args_)) {} + group_by_t(args_type&& args_) : args(std::move(args_)) {} }; template @@ -3055,7 +3055,7 @@ namespace sqlite_orm { * Example: storage.get_all(multi_order_by(order_by(&Singer::name).asc(), order_by(&Singer::gender).desc()) */ template - internal::multi_order_by_t multi_order_by(Args &&... args) { + internal::multi_order_by_t multi_order_by(Args&&... args) { return {std::make_tuple(std::forward(args)...)}; } @@ -3073,7 +3073,7 @@ namespace sqlite_orm { */ template internal::dynamic_order_by_t> - dynamic_order_by(const S &storage) { + dynamic_order_by(const S& storage) { internal::serializator_context_builder builder(storage); return builder(); } @@ -3083,7 +3083,7 @@ namespace sqlite_orm { * Example: storage.get_all(group_by(&Employee::name)) */ template - internal::group_by_t group_by(Args &&... args) { + internal::group_by_t group_by(Args&&... args) { return {std::make_tuple(std::forward(args)...)}; } @@ -3317,7 +3317,7 @@ namespace sqlite_orm { struct join_iterator { template - void operator()(const L &) { + void operator()(const L&) { //.. } }; @@ -3326,7 +3326,7 @@ namespace sqlite_orm { struct join_iterator<> { template - void operator()(const L &) { + void operator()(const L&) { //.. } }; @@ -3336,7 +3336,7 @@ namespace sqlite_orm { using super = join_iterator; template - void operator()(const L &l) { + void operator()(const L& l) { this->super::operator()(l); } }; @@ -3347,7 +3347,7 @@ namespace sqlite_orm { using join_type = cross_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -3359,7 +3359,7 @@ namespace sqlite_orm { using join_type = natural_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -3371,7 +3371,7 @@ namespace sqlite_orm { using join_type = left_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -3383,7 +3383,7 @@ namespace sqlite_orm { using join_type = join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -3395,7 +3395,7 @@ namespace sqlite_orm { using join_type = left_outer_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -3407,7 +3407,7 @@ namespace sqlite_orm { using join_type = inner_join_t; template - void operator()(const L &l) { + void operator()(const L& l) { l(*this); this->super::operator()(l); } @@ -3442,11 +3442,11 @@ namespace sqlite_orm { template class Base, typename Derived> struct is_base_of_template_impl { template - static constexpr std::true_type test(const Base *); + static constexpr std::true_type test(const Base*); static constexpr std::false_type test(...); - using type = decltype(test(std::declval())); + using type = decltype(test(std::declval())); }; template class Base> @@ -3454,13 +3454,13 @@ namespace sqlite_orm { #else template class C, typename... Ts> - std::true_type is_base_of_template_impl(const C *); + std::true_type is_base_of_template_impl(const C*); template class C> std::false_type is_base_of_template_impl(...); template class C> - using is_base_of_template = decltype(is_base_of_template_impl(std::declval())); + using is_base_of_template = decltype(is_base_of_template_impl(std::declval())); #endif } } @@ -3491,7 +3491,7 @@ namespace sqlite_orm { args_type args; - core_function_t(args_type &&args_) : args(std::move(args_)) {} + core_function_t(args_type&& args_) : args(std::move(args_)) {} }; struct typeof_string { @@ -4246,20 +4246,20 @@ namespace sqlite_orm { */ template struct typed_comparator { - bool operator()(const L &, const R &) const { + bool operator()(const L&, const R&) const { return false; } }; template struct typed_comparator { - bool operator()(const O &lhs, const O &rhs) const { + bool operator()(const O& lhs, const O& rhs) const { return lhs == rhs; } }; template - bool compare_any(const L &lhs, const R &rhs) { + bool compare_any(const L& lhs, const R& rhs) { return typed_comparator()(lhs, rhs); } } @@ -4433,12 +4433,12 @@ namespace sqlite_orm { * Generic way to get DISTINCT value from any type. */ template - bool get_distinct(const T &) { + bool get_distinct(const T&) { return false; } template - bool get_distinct(const columns_t &cols) { + bool get_distinct(const columns_t& cols) { return cols.distinct; } @@ -4717,7 +4717,7 @@ namespace sqlite_orm { * Guard class which finalizes `sqlite3_stmt` in dtor */ struct statement_finalizer { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; statement_finalizer(decltype(stmt) stmt_) : stmt(stmt_) {} @@ -4776,7 +4776,7 @@ namespace sqlite_orm { struct is_std_ptr> : std::true_type { using element_type = T; - static std::shared_ptr make(const T &v) { + static std::shared_ptr make(const T& v) { return std::make_shared(v); } }; @@ -4785,7 +4785,7 @@ namespace sqlite_orm { struct is_std_ptr> : std::true_type { using element_type = T; - static std::unique_ptr make(const T &v) { + static std::unique_ptr make(const T& v) { return std::make_unique(v); } }; @@ -4804,22 +4804,22 @@ namespace sqlite_orm { */ template struct statement_binder::value>> { - int bind(sqlite3_stmt *stmt, int index, const V &value) { + int bind(sqlite3_stmt* stmt, int index, const V& value) { return bind(stmt, index, value, tag()); } private: using tag = arithmetic_tag_t; - int bind(sqlite3_stmt *stmt, int index, const V &value, const int_or_smaller_tag &) { + int bind(sqlite3_stmt* stmt, int index, const V& value, const int_or_smaller_tag&) { return sqlite3_bind_int(stmt, index, static_cast(value)); } - int bind(sqlite3_stmt *stmt, int index, const V &value, const bigint_tag &) { + int bind(sqlite3_stmt* stmt, int index, const V& value, const bigint_tag&) { return sqlite3_bind_int64(stmt, index, static_cast(value)); } - int bind(sqlite3_stmt *stmt, int index, const V &value, const real_tag &) { + int bind(sqlite3_stmt* stmt, int index, const V& value, const real_tag&) { return sqlite3_bind_double(stmt, index, static_cast(value)); } }; @@ -4830,17 +4830,17 @@ namespace sqlite_orm { template struct statement_binder< V, - std::enable_if_t::value || std::is_same::value>> { - int bind(sqlite3_stmt *stmt, int index, const V &value) { + std::enable_if_t::value || std::is_same::value>> { + int bind(sqlite3_stmt* stmt, int index, const V& value) { return sqlite3_bind_text(stmt, index, string_data(value), -1, SQLITE_TRANSIENT); } private: - const char *string_data(const std::string &s) const { + const char* string_data(const std::string& s) const { return s.c_str(); } - const char *string_data(const char *s) const { + const char* string_data(const char* s) const { return s; } }; @@ -4852,8 +4852,8 @@ namespace sqlite_orm { template struct statement_binder< V, - std::enable_if_t::value || std::is_same::value>> { - int bind(sqlite3_stmt *stmt, int index, const V &value) { + std::enable_if_t::value || std::is_same::value>> { + int bind(sqlite3_stmt* stmt, int index, const V& value) { std::wstring_convert> converter; std::string utf8Str = converter.to_bytes(value); return statement_binder().bind(stmt, index, utf8Str); @@ -4866,7 +4866,7 @@ namespace sqlite_orm { */ template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const std::nullptr_t &) { + int bind(sqlite3_stmt* stmt, int index, const std::nullptr_t&) { return sqlite3_bind_null(stmt, index); } }; @@ -4874,7 +4874,7 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template<> struct statement_binder { - int bind(sqlite3_stmt *stmt, int index, const std::nullopt_t &) { + int bind(sqlite3_stmt* stmt, int index, const std::nullopt_t&) { return sqlite3_bind_null(stmt, index); } }; @@ -4884,7 +4884,7 @@ namespace sqlite_orm { struct statement_binder::value>> { using value_type = typename is_std_ptr::element_type; - int bind(sqlite3_stmt *stmt, int index, const V &value) { + int bind(sqlite3_stmt* stmt, int index, const V& value) { if(value) { return statement_binder().bind(stmt, index, *value); } else { @@ -4898,13 +4898,9 @@ namespace sqlite_orm { */ template<> struct statement_binder, void> { - int bind(sqlite3_stmt *stmt, int index, const std::vector &value) { + int bind(sqlite3_stmt* stmt, int index, const std::vector& value) { if(value.size()) { - return sqlite3_bind_blob(stmt, - index, - (const void *)&value.front(), - int(value.size()), - SQLITE_TRANSIENT); + return sqlite3_bind_blob(stmt, index, (const void*)&value.front(), int(value.size()), SQLITE_TRANSIENT); } else { return sqlite3_bind_blob(stmt, index, "", 0, SQLITE_TRANSIENT); } @@ -4916,7 +4912,7 @@ namespace sqlite_orm { struct statement_binder, void> { using value_type = T; - int bind(sqlite3_stmt *stmt, int index, const std::optional &value) { + int bind(sqlite3_stmt* stmt, int index, const std::optional& value) { if(value) { return statement_binder().bind(stmt, index, *value); } else { @@ -4932,8 +4928,8 @@ namespace sqlite_orm { using is_bindable = std::integral_constant>::value>; struct conditional_binder_base { - sqlite3_stmt *stmt = nullptr; - int &index; + sqlite3_stmt* stmt = nullptr; + int& index; conditional_binder_base(decltype(stmt) stmt_, decltype(index) index_) : stmt(stmt_), index(index_) {} }; @@ -4946,7 +4942,7 @@ namespace sqlite_orm { using conditional_binder_base::conditional_binder_base; - int operator()(const T &t) const { + int operator()(const T& t) const { return statement_binder().bind(this->stmt, this->index++, t); } }; @@ -4955,7 +4951,7 @@ namespace sqlite_orm { struct conditional_binder : conditional_binder_base { using conditional_binder_base::conditional_binder_base; - int operator()(const T &) const { + int operator()(const T&) const { return SQLITE_OK; } }; @@ -5026,7 +5022,7 @@ namespace sqlite_orm { namespace internal { - inline const std::string &to_string(journal_mode j) { + inline const std::string& to_string(journal_mode j) { static std::string res[] = { "DELETE", "TRUNCATE", @@ -5038,7 +5034,7 @@ namespace sqlite_orm { return res[static_cast(j)]; } - inline std::unique_ptr journal_mode_from_string(const std::string &str) { + inline std::unique_ptr journal_mode_from_string(const std::string& str) { std::string upper_str; std::transform(str.begin(), str.end(), std::back_inserter(upper_str), [](char c) { return static_cast(std::toupper(static_cast(c))); @@ -5073,10 +5069,10 @@ namespace sqlite_orm { template struct row_extractor { // used in sqlite3_exec (select) - V extract(const char *row_value); + V extract(const char* row_value); // used in sqlite_column (iteration, get_all) - V extract(sqlite3_stmt *stmt, int columnIndex); + V extract(sqlite3_stmt* stmt, int columnIndex); }; /** @@ -5084,38 +5080,38 @@ namespace sqlite_orm { */ template struct row_extractor::value>> { - V extract(const char *row_value) { + V extract(const char* row_value) { return extract(row_value, tag()); } - V extract(sqlite3_stmt *stmt, int columnIndex) { + V extract(sqlite3_stmt* stmt, int columnIndex) { return extract(stmt, columnIndex, tag()); } private: using tag = arithmetic_tag_t; - V extract(const char *row_value, const int_or_smaller_tag &) { + V extract(const char* row_value, const int_or_smaller_tag&) { return static_cast(atoi(row_value)); } - V extract(sqlite3_stmt *stmt, int columnIndex, const int_or_smaller_tag &) { + V extract(sqlite3_stmt* stmt, int columnIndex, const int_or_smaller_tag&) { return static_cast(sqlite3_column_int(stmt, columnIndex)); } - V extract(const char *row_value, const bigint_tag &) { + V extract(const char* row_value, const bigint_tag&) { return static_cast(atoll(row_value)); } - V extract(sqlite3_stmt *stmt, int columnIndex, const bigint_tag &) { + V extract(sqlite3_stmt* stmt, int columnIndex, const bigint_tag&) { return static_cast(sqlite3_column_int64(stmt, columnIndex)); } - V extract(const char *row_value, const real_tag &) { + V extract(const char* row_value, const real_tag&) { return static_cast(atof(row_value)); } - V extract(sqlite3_stmt *stmt, int columnIndex, const real_tag &) { + V extract(sqlite3_stmt* stmt, int columnIndex, const real_tag&) { return static_cast(sqlite3_column_double(stmt, columnIndex)); } }; @@ -5125,7 +5121,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - std::string extract(const char *row_value) { + std::string extract(const char* row_value) { if(row_value) { return row_value; } else { @@ -5133,8 +5129,8 @@ namespace sqlite_orm { } } - std::string extract(sqlite3_stmt *stmt, int columnIndex) { - auto cStr = (const char *)sqlite3_column_text(stmt, columnIndex); + std::string extract(sqlite3_stmt* stmt, int columnIndex) { + auto cStr = (const char*)sqlite3_column_text(stmt, columnIndex); if(cStr) { return cStr; } else { @@ -5148,7 +5144,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - std::wstring extract(const char *row_value) { + std::wstring extract(const char* row_value) { if(row_value) { std::wstring_convert> converter; return converter.from_bytes(row_value); @@ -5157,8 +5153,8 @@ namespace sqlite_orm { } } - std::wstring extract(sqlite3_stmt *stmt, int columnIndex) { - auto cStr = (const char *)sqlite3_column_text(stmt, columnIndex); + std::wstring extract(sqlite3_stmt* stmt, int columnIndex) { + auto cStr = (const char*)sqlite3_column_text(stmt, columnIndex); if(cStr) { std::wstring_convert> converter; return converter.from_bytes(cStr); @@ -5173,7 +5169,7 @@ namespace sqlite_orm { struct row_extractor::value>> { using value_type = typename is_std_ptr::element_type; - V extract(const char *row_value) { + V extract(const char* row_value) { if(row_value) { return is_std_ptr::make(row_extractor().extract(row_value)); } else { @@ -5181,7 +5177,7 @@ namespace sqlite_orm { } } - V extract(sqlite3_stmt *stmt, int columnIndex) { + V extract(sqlite3_stmt* stmt, int columnIndex) { auto type = sqlite3_column_type(stmt, columnIndex); if(type != SQLITE_NULL) { return is_std_ptr::make(row_extractor().extract(stmt, columnIndex)); @@ -5196,7 +5192,7 @@ namespace sqlite_orm { struct row_extractor, void> { using value_type = T; - std::optional extract(const char *row_value) { + std::optional extract(const char* row_value) { if(row_value) { return std::make_optional(row_extractor().extract(row_value)); } else { @@ -5204,7 +5200,7 @@ namespace sqlite_orm { } } - std::optional extract(sqlite3_stmt *stmt, int columnIndex) { + std::optional extract(sqlite3_stmt* stmt, int columnIndex) { auto type = sqlite3_column_type(stmt, columnIndex); if(type != SQLITE_NULL) { return std::make_optional(row_extractor().extract(stmt, columnIndex)); @@ -5219,7 +5215,7 @@ namespace sqlite_orm { */ template<> struct row_extractor> { - std::vector extract(const char *row_value) { + std::vector extract(const char* row_value) { if(row_value) { auto len = ::strlen(row_value); return this->go(row_value, len); @@ -5228,14 +5224,14 @@ namespace sqlite_orm { } } - std::vector extract(sqlite3_stmt *stmt, int columnIndex) { - auto bytes = static_cast(sqlite3_column_blob(stmt, columnIndex)); + std::vector extract(sqlite3_stmt* stmt, int columnIndex) { + auto bytes = static_cast(sqlite3_column_blob(stmt, columnIndex)); auto len = static_cast(sqlite3_column_bytes(stmt, columnIndex)); return this->go(bytes, len); } protected: - std::vector go(const char *bytes, size_t len) { + std::vector go(const char* bytes, size_t len) { if(len) { std::vector res; res.reserve(len); @@ -5250,40 +5246,40 @@ namespace sqlite_orm { template struct row_extractor> { - std::tuple extract(char **argv) { + std::tuple extract(char** argv) { std::tuple res; this->extract::value>(res, argv); return res; } - std::tuple extract(sqlite3_stmt *stmt, int /*columnIndex*/) { + std::tuple extract(sqlite3_stmt* stmt, int /*columnIndex*/) { std::tuple res; this->extract::value>(res, stmt); return res; } protected: - template::type * = nullptr> - void extract(std::tuple &t, sqlite3_stmt *stmt) { + template::type* = nullptr> + void extract(std::tuple& t, sqlite3_stmt* stmt) { using tuple_type = typename std::tuple_element>::type; std::get(t) = row_extractor().extract(stmt, I - 1); this->extract(t, stmt); } - template::type * = nullptr> - void extract(std::tuple &, sqlite3_stmt *) { + template::type* = nullptr> + void extract(std::tuple&, sqlite3_stmt*) { //.. } - template::type * = nullptr> - void extract(std::tuple &t, char **argv) { + template::type* = nullptr> + void extract(std::tuple& t, char** argv) { using tuple_type = typename std::tuple_element>::type; std::get(t) = row_extractor().extract(argv[I - 1]); this->extract(t, argv); } - template::type * = nullptr> - void extract(std::tuple &, char **) { + template::type* = nullptr> + void extract(std::tuple&, char**) { //.. } }; @@ -5293,7 +5289,7 @@ namespace sqlite_orm { */ template<> struct row_extractor { - journal_mode extract(const char *row_value) { + journal_mode extract(const char* row_value) { if(row_value) { if(auto res = internal::journal_mode_from_string(row_value)) { return std::move(*res); @@ -5305,8 +5301,8 @@ namespace sqlite_orm { } } - journal_mode extract(sqlite3_stmt *stmt, int columnIndex) { - auto cStr = (const char *)sqlite3_column_text(stmt, columnIndex); + journal_mode extract(sqlite3_stmt* stmt, int columnIndex) { + auto cStr = (const char*)sqlite3_column_text(stmt, columnIndex); return this->extract(cStr); } }; @@ -5320,7 +5316,7 @@ namespace sqlite_orm { namespace sqlite_orm { namespace internal { - inline void perform_step(sqlite3 *db, sqlite3_stmt *stmt) { + inline void perform_step(sqlite3* db, sqlite3_stmt* stmt) { if(sqlite3_step(stmt) == SQLITE_DONE) { // done.. } else { @@ -5329,7 +5325,7 @@ namespace sqlite_orm { } } - static void perform_void_exec(sqlite3 *db, const std::string &query) { + static void perform_void_exec(sqlite3* db, const std::string& query) { int rc = sqlite3_exec(db, query.c_str(), nullptr, nullptr, nullptr); if(rc != SQLITE_OK) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -5381,7 +5377,7 @@ namespace sqlite_orm { dropped_and_recreated, }; - inline std::ostream &operator<<(std::ostream &os, sync_schema_result value) { + inline std::ostream& operator<<(std::ostream& os, sync_schema_result value) { switch(value) { case sync_schema_result::new_table_created: return os << "new table created"; @@ -5499,13 +5495,13 @@ namespace sqlite_orm { } template - internal::index_t::type...> make_index(const std::string &name, + internal::index_t::type...> make_index(const std::string& name, Cols... cols) { return {name, false, std::make_tuple(internal::make_indexed_column(cols)...)}; } template - internal::index_t::type...> make_unique_index(const std::string &name, + internal::index_t::type...> make_unique_index(const std::string& name, Cols... cols) { return {name, true, std::make_tuple(internal::make_indexed_column(cols)...)}; } @@ -5954,7 +5950,7 @@ namespace sqlite_orm { * Result for the most simple queries like `SELECT 'ototo'` */ template - struct column_result_t { + struct column_result_t { using type = std::string; }; @@ -6068,9 +6064,9 @@ namespace sqlite_orm { * Function used to get field value from object by mapped member pointer/setter/getter */ template - const F *get_object_field_pointer(const object_type &obj, C c) const { - const F *res = nullptr; - this->for_each_column_with_field_type([&res, &c, &obj](auto &col) { + const F* get_object_field_pointer(const object_type& obj, C c) const { + const F* res = nullptr; + this->for_each_column_with_field_type([&res, &c, &obj](auto& col) { using column_type = typename std::remove_reference::type; using member_pointer_t = typename column_type::member_pointer_t; using getter_type = typename column_type::getter_type; @@ -6078,21 +6074,21 @@ namespace sqlite_orm { // Make static_if have at least one input as a workaround for GCC bug: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64095 if(!res) { - static_if{}>([&res, &obj, &col](const C &c_) { + static_if{}>([&res, &obj, &col](const C& c_) { if(compare_any(col.member_pointer, c_)) { res = &(obj.*col.member_pointer); } })(c); } if(!res) { - static_if{}>([&res, &obj, &col](const C &c_) { + static_if{}>([&res, &obj, &col](const C& c_) { if(compare_any(col.getter, c_)) { res = &((obj).*(col.getter))(); } })(c); } if(!res) { - static_if{}>([&res, &obj, &col](const C &c_) { + static_if{}>([&res, &obj, &col](const C& c_) { if(compare_any(col.setter, c_)) { res = &((obj).*(col.getter))(); } @@ -6107,7 +6103,7 @@ namespace sqlite_orm { */ std::vector column_names() const { std::vector res; - this->for_each_column([&res](auto &c) { + this->for_each_column([&res](auto& c) { res.push_back(c.name); }); return res; @@ -6117,8 +6113,8 @@ namespace sqlite_orm { * Calls **l** with every primary key dedicated constraint */ template - void for_each_primary_key(const L &l) const { - iterate_tuple(this->columns, [&l](auto &column) { + void for_each_primary_key(const L& l) const { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; static_if{}>(l)(column); }); @@ -6126,7 +6122,7 @@ namespace sqlite_orm { std::vector composite_key_columns_names() const { std::vector res; - this->for_each_primary_key([this, &res](auto &c) { + this->for_each_primary_key([this, &res](auto& c) { res = this->composite_key_columns_names(c); }); return res; @@ -6134,7 +6130,7 @@ namespace sqlite_orm { std::vector primary_key_column_names() const { std::vector res; - this->for_each_column_with>([&res](auto &c) { + this->for_each_column_with>([&res](auto& c) { res.push_back(c.name); }); if(!res.size()) { @@ -6144,11 +6140,11 @@ namespace sqlite_orm { } template - std::vector composite_key_columns_names(const constraints::primary_key_t &pk) const { + std::vector composite_key_columns_names(const constraints::primary_key_t& pk) const { std::vector res; using pk_columns_tuple = decltype(pk.columns); res.reserve(std::tuple_size::value); - iterate_tuple(pk.columns, [this, &res](auto &v) { + iterate_tuple(pk.columns, [this, &res](auto& v) { res.push_back(this->find_column_name(v)); }); return res; @@ -6164,7 +6160,7 @@ namespace sqlite_orm { !std::is_member_function_pointer::value>::type> std::string find_column_name(F O::*m) const { std::string res; - this->template for_each_column_with_field_type([&res, m](auto &c) { + this->template for_each_column_with_field_type([&res, m](auto& c) { if(c.member_pointer == m) { res = c.name; } @@ -6178,10 +6174,10 @@ namespace sqlite_orm { */ template std::string find_column_name(G getter, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { std::string res; using field_type = typename getter_traits::field_type; - this->template for_each_column_with_field_type([&res, getter](auto &c) { + this->template for_each_column_with_field_type([&res, getter](auto& c) { if(compare_any(c.getter, getter)) { res = c.name; } @@ -6195,10 +6191,10 @@ namespace sqlite_orm { */ template std::string find_column_name(S setter, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { std::string res; using field_type = typename setter_traits::field_type; - this->template for_each_column_with_field_type([&res, setter](auto &c) { + this->template for_each_column_with_field_type([&res, setter](auto& c) { if(compare_any(c.setter, setter)) { res = c.name; } @@ -6214,16 +6210,16 @@ namespace sqlite_orm { * @param l Lambda to be called per column itself. Must have signature like this [] (auto col) -> void {} */ template - void for_each_column(const L &l) const { - iterate_tuple(this->columns, [&l](auto &column) { + void for_each_column(const L& l) const { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; static_if{}>(l)(column); }); } template - void for_each_column_with_field_type(const L &l) const { - iterate_tuple(this->columns, [&l](auto &column) { + void for_each_column_with_field_type(const L& l) const { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; using field_type = typename column_field_type::type; static_if{}>(l)(column); @@ -6237,9 +6233,9 @@ namespace sqlite_orm { * @param l Lambda to be called per column itself. Must have signature like this [] (auto col) -> void {} */ template - void for_each_column_with(const L &l) const { + void for_each_column_with(const L& l) const { using tuple_helper::tuple_contains_type; - iterate_tuple(this->columns, [&l](auto &column) { + iterate_tuple(this->columns, [&l](auto& column) { using column_type = typename std::decay::type; using constraints_type = typename column_constraints_type::type; static_if{}>(l)(column); @@ -6249,7 +6245,7 @@ namespace sqlite_orm { std::vector get_table_info() const { std::vector res; res.reserve(size_t(this->columns_count)); - this->for_each_column([&res](auto &col) { + this->for_each_column([&res](auto& col) { std::string dft; using field_type = typename std::decay::type::field_type; if(auto d = col.default_value()) { @@ -6267,8 +6263,8 @@ namespace sqlite_orm { }); auto compositeKeyColumnNames = this->composite_key_columns_names(); for(size_t i = 0; i < compositeKeyColumnNames.size(); ++i) { - auto &columnName = compositeKeyColumnNames[i]; - auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_info &ti) { + auto& columnName = compositeKeyColumnNames[i]; + auto it = std::find_if(res.begin(), res.end(), [&columnName](const table_info& ti) { return ti.name == columnName; }); if(it != res.end()) { @@ -6285,12 +6281,12 @@ namespace sqlite_orm { * cause table class is templated and its constructing too (just like std::make_unique or std::make_pair). */ template>::type::object_type> - internal::table_t make_table(const std::string &name, Cs... args) { + internal::table_t make_table(const std::string& name, Cs... args) { return {name, std::make_tuple(std::forward(args)...)}; } template - internal::table_t make_table(const std::string &name, Cs... args) { + internal::table_t make_table(const std::string& name, Cs... args) { return {name, std::make_tuple(std::forward(args)...)}; } } @@ -6342,7 +6338,7 @@ namespace sqlite_orm { struct field_value_holder::returns_lvalue>::type> { using type = typename getter_traits::field_type; - const type &value; + const type& value; }; template @@ -6360,7 +6356,7 @@ namespace sqlite_orm { struct storage_impl_base { - bool table_exists(const std::string &tableName, sqlite3 *db) const { + bool table_exists(const std::string& tableName, sqlite3* db) const { auto result = false; std::stringstream ss; ss << "SELECT COUNT(*) FROM sqlite_master WHERE type = '" @@ -6370,8 +6366,8 @@ namespace sqlite_orm { auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char * * /*azColName*/) -> int { - auto &res = *(bool *)data; + [](void* data, int argc, char** argv, char* * /*azColName*/) -> int { + auto& res = *(bool*)data; if(argc) { res = !!std::atoi(argv[0]); } @@ -6386,15 +6382,15 @@ namespace sqlite_orm { return result; } - void rename_table(sqlite3 *db, const std::string &oldName, const std::string &newName) const { + void rename_table(sqlite3* db, const std::string& oldName, const std::string& newName) const { std::stringstream ss; ss << "ALTER TABLE " << oldName << " RENAME TO " << newName; perform_void_exec(db, ss.str()); } - static bool get_remove_add_columns(std::vector &columnsToAdd, - std::vector &storageTableInfo, - std::vector &dbTableInfo) { + static bool get_remove_add_columns(std::vector& columnsToAdd, + std::vector& storageTableInfo, + std::vector& dbTableInfo) { bool notEqual = false; // iterate through storage columns @@ -6402,15 +6398,15 @@ namespace sqlite_orm { ++storageColumnInfoIndex) { // get storage's column info - auto &storageColumnInfo = storageTableInfo[storageColumnInfoIndex]; - auto &columnName = storageColumnInfo.name; + auto& storageColumnInfo = storageTableInfo[storageColumnInfoIndex]; + auto& columnName = storageColumnInfo.name; // search for a column in db eith the same name - auto dbColumnInfoIt = std::find_if(dbTableInfo.begin(), dbTableInfo.end(), [&columnName](auto &ti) { + auto dbColumnInfoIt = std::find_if(dbTableInfo.begin(), dbTableInfo.end(), [&columnName](auto& ti) { return ti.name == columnName; }); if(dbColumnInfoIt != dbTableInfo.end()) { - auto &dbColumnInfo = *dbColumnInfoIt; + auto& dbColumnInfo = *dbColumnInfoIt; auto columnsAreEqual = dbColumnInfo.name == storageColumnInfo.name && dbColumnInfo.notnull == storageColumnInfo.notnull && @@ -6431,14 +6427,14 @@ namespace sqlite_orm { return notEqual; } - std::vector get_table_info(const std::string &tableName, sqlite3 *db) const { + std::vector get_table_info(const std::string& tableName, sqlite3* db) const { std::vector result; auto query = "PRAGMA table_info('" + tableName + "')"; auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(std::vector *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(std::vector*)data; if(argc) { auto index = 0; auto cid = std::atoi(argv[index++]); @@ -6478,7 +6474,7 @@ namespace sqlite_orm { table_type table; template - void for_each(const L &l) { + void for_each(const L& l) { this->super::for_each(l); l(*this); } @@ -6490,7 +6486,7 @@ namespace sqlite_orm { */ int foreign_keys_count() { auto res = 0; - iterate_tuple(this->table.columns, [&res](auto &c) { + iterate_tuple(this->table.columns, [&res](auto& c) { if(internal::is_foreign_key::type>::value) { ++res; } @@ -6516,7 +6512,7 @@ namespace sqlite_orm { */ template std::string column_name(F O::*m, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { return this->table.find_column_name(m); } @@ -6525,49 +6521,49 @@ namespace sqlite_orm { */ template std::string column_name(F O::*m, - typename std::enable_if::value>::type * = nullptr) const { + typename std::enable_if::value>::type* = nullptr) const { return this->super::column_name(m); } template - std::string column_name(const column_pointer &c, - typename std::enable_if::value>::type * = nullptr) const { + std::string column_name(const column_pointer& c, + typename std::enable_if::value>::type* = nullptr) const { return this->column_name_simple(c.field); } template - std::string column_name(const column_pointer &c, - typename std::enable_if::value>::type * = nullptr) const { + std::string column_name(const column_pointer& c, + typename std::enable_if::value>::type* = nullptr) const { return this->super::column_name(c); } template - const auto &get_impl(typename std::enable_if::value>::type * = nullptr) const { + const auto& get_impl(typename std::enable_if::value>::type* = nullptr) const { return *this; } template - const auto &get_impl(typename std::enable_if::value>::type * = nullptr) const { + const auto& get_impl(typename std::enable_if::value>::type* = nullptr) const { return this->super::template get_impl(); } template - auto &get_impl(typename std::enable_if::value>::type * = nullptr) { + auto& get_impl(typename std::enable_if::value>::type* = nullptr) { return *this; } template - auto &get_impl(typename std::enable_if::value>::type * = nullptr) { + auto& get_impl(typename std::enable_if::value>::type* = nullptr) { return this->super::template get_impl(); } template - const auto *find_table(typename std::enable_if::value>::type * = nullptr) const { + const auto* find_table(typename std::enable_if::value>::type* = nullptr) const { return &this->table; } template - const auto *find_table(typename std::enable_if::value>::type * = nullptr) const { + const auto* find_table(typename std::enable_if::value>::type* = nullptr) const { return this->super::template find_table(); } @@ -6580,7 +6576,7 @@ namespace sqlite_orm { } } - void add_column(const table_info &ti, sqlite3 *db) const { + void add_column(const table_info& ti, sqlite3* db) const { std::stringstream ss; ss << "ALTER TABLE " << this->table.name << " ADD COLUMN " << ti.name << " "; ss << ti.type << " "; @@ -6601,13 +6597,13 @@ namespace sqlite_orm { * Performs CREATE TABLE %name% AS SELECT %this->table.columns_names()% FROM &this->table.name%; */ void - copy_table(sqlite3 *db, const std::string &name, const std::vector &columnsToIgnore) const { + copy_table(sqlite3* db, const std::string& name, const std::vector& columnsToIgnore) const { std::ignore = columnsToIgnore; std::stringstream ss; std::vector columnNames; - this->table.for_each_column([&columnNames, &columnsToIgnore](auto &c) { - auto &columnName = c.name; + this->table.for_each_column([&columnNames, &columnsToIgnore](auto& c) { + auto& columnName = c.name; auto columnToIgnoreIt = std::find_if(columnsToIgnore.begin(), columnsToIgnore.end(), [&columnName](auto tableInfoPointer) { @@ -6639,7 +6635,7 @@ namespace sqlite_orm { perform_void_exec(db, ss.str()); } - sync_schema_result schema_status(sqlite3 *db, bool preserve) const { + sync_schema_result schema_status(sqlite3* db, bool preserve) const { auto res = sync_schema_result::already_in_sync; @@ -6654,7 +6650,7 @@ namespace sqlite_orm { auto dbTableInfo = this->get_table_info(this->table.name, db); // this vector will contain pointers to columns that gotta be added.. - std::vector columnsToAdd; + std::vector columnsToAdd; if(this->get_remove_add_columns(columnsToAdd, storageTableInfo, dbTableInfo)) { gottaCreateTable = true; @@ -6715,14 +6711,14 @@ namespace sqlite_orm { } template - void for_each(const L &) {} + void for_each(const L&) {} int foreign_keys_count() { return 0; } template - const void *find_table() const { + const void* find_table() const { return nullptr; } }; @@ -6775,7 +6771,7 @@ namespace sqlite_orm { namespace internal { struct object_from_column_builder_base { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; mutable int index = 0; }; @@ -6786,13 +6782,13 @@ namespace sqlite_orm { struct object_from_column_builder : object_from_column_builder_base { using object_type = O; - object_type &object; + object_type& object; - object_from_column_builder(object_type &object_, sqlite3_stmt *stmt_) : + object_from_column_builder(object_type& object_, sqlite3_stmt* stmt_) : object_from_column_builder_base{stmt_}, object(object_) {} template - void operator()(const C &c) const { + void operator()(const C& c) const { using field_type = typename C::field_type; auto value = row_extractor().extract(this->stmt, this->index++); if(c.member_pointer) { @@ -6822,16 +6818,16 @@ namespace sqlite_orm { struct mapped_row_extractor { using table_info_t = T; - mapped_row_extractor(const table_info_t &tableInfo_) : tableInfo(tableInfo_) {} + mapped_row_extractor(const table_info_t& tableInfo_) : tableInfo(tableInfo_) {} - V extract(sqlite3_stmt *stmt, int /*columnIndex*/) { + V extract(sqlite3_stmt* stmt, int /*columnIndex*/) { V res; object_from_column_builder builder{res, stmt}; this->tableInfo.for_each_column(builder); return res; } - const table_info_t &tableInfo; + const table_info_t& tableInfo; }; } @@ -6854,7 +6850,7 @@ namespace sqlite_orm { template struct row_extractor_builder { - row_extractor operator()(const I * /*tableInfo*/) const { + row_extractor operator()(const I* /*tableInfo*/) const { return {}; } }; @@ -6862,13 +6858,13 @@ namespace sqlite_orm { template struct row_extractor_builder { - mapped_row_extractor operator()(const I *tableInfo) const { + mapped_row_extractor operator()(const I* tableInfo) const { return {*tableInfo}; } }; template - auto make_row_extractor(const I *tableInfo) { + auto make_row_extractor(const I* tableInfo) { using builder_t = row_extractor_builder; return builder_t{}(tableInfo); } @@ -6965,8 +6961,8 @@ namespace sqlite_orm { * call. When one finishes iterating it the pointer * inside the shared_ptr is nulled out in all copies. */ - std::shared_ptr stmt; - view_type &view; + std::shared_ptr stmt; + view_type& view; /** * shared_ptr is used over unique_ptr here @@ -6974,32 +6970,32 @@ namespace sqlite_orm { */ std::shared_ptr current; - void extract_value(std::unique_ptr &temp) { + void extract_value(std::unique_ptr& temp) { temp = std::make_unique(); - auto &storage = this->view.storage; - auto &impl = storage.template get_impl(); + auto& storage = this->view.storage; + auto& impl = storage.template get_impl(); object_from_column_builder builder{*temp, *this->stmt}; impl.table.for_each_column(builder); } public: using difference_type = std::ptrdiff_t; - using pointer = value_type *; - using reference = value_type &; + using pointer = value_type*; + using reference = value_type&; using iterator_category = std::input_iterator_tag; - iterator_t(sqlite3_stmt *stmt_, view_type &view_) : - stmt(std::make_shared(stmt_)), view(view_) { + iterator_t(sqlite3_stmt* stmt_, view_type& view_) : + stmt(std::make_shared(stmt_)), view(view_) { this->operator++(); } - iterator_t(const iterator_t &) = default; + iterator_t(const iterator_t&) = default; - iterator_t(iterator_t &&) = default; + iterator_t(iterator_t&&) = default; - iterator_t &operator=(iterator_t &&) = default; + iterator_t& operator=(iterator_t&&) = default; - iterator_t &operator=(const iterator_t &) = default; + iterator_t& operator=(const iterator_t&) = default; ~iterator_t() { if(this->stmt) { @@ -7007,7 +7003,7 @@ namespace sqlite_orm { } } - value_type &operator*() { + value_type& operator*() { if(!this->stmt) { throw std::system_error(std::make_error_code(orm_error_code::trying_to_dereference_null_iterator)); } @@ -7019,7 +7015,7 @@ namespace sqlite_orm { return *this->current; } - value_type *operator->() { + value_type* operator->() { return &(this->operator*()); } @@ -7047,7 +7043,7 @@ namespace sqlite_orm { this->operator++(); } - bool operator==(const iterator_t &other) const { + bool operator==(const iterator_t& other) const { if(this->stmt && other.stmt) { return *this->stmt == *other.stmt; } else { @@ -7059,7 +7055,7 @@ namespace sqlite_orm { } } - bool operator!=(const iterator_t &other) const { + bool operator!=(const iterator_t& other) const { return !(*this == other); } }; @@ -7127,7 +7123,7 @@ namespace sqlite_orm { } } - sqlite3 *get() const { + sqlite3* get() const { return this->db; } @@ -7138,20 +7134,20 @@ namespace sqlite_orm { const std::string filename; protected: - sqlite3 *db = nullptr; + sqlite3* db = nullptr; int _retain_count = 0; }; struct connection_ref { - connection_ref(connection_holder &holder_) : holder(holder_) { + connection_ref(connection_holder& holder_) : holder(holder_) { this->holder.retain(); } - connection_ref(const connection_ref &other) : holder(other.holder) { + connection_ref(const connection_ref& other) : holder(other.holder) { this->holder.retain(); } - connection_ref(connection_ref &&other) : holder(other.holder) { + connection_ref(connection_ref&& other) : holder(other.holder) { this->holder.retain(); } @@ -7159,12 +7155,12 @@ namespace sqlite_orm { this->holder.release(); } - sqlite3 *get() const { + sqlite3* get() const { return this->holder.get(); } protected: - connection_holder &holder; + connection_holder& holder; }; } } @@ -7176,7 +7172,7 @@ namespace sqlite_orm { namespace internal { struct prepared_statement_base { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; connection_ref con; ~prepared_statement_base() { @@ -7234,7 +7230,7 @@ namespace sqlite_orm { expression_type t; - prepared_statement_t(T t_, sqlite3_stmt *stmt_, connection_ref con_) : + prepared_statement_t(T t_, sqlite3_stmt* stmt_, connection_ref con_) : prepared_statement_base{stmt_, std::move(con_)}, t(std::move(t_)) {} }; @@ -7654,7 +7650,7 @@ namespace sqlite_orm { * L is a callable type. Mostly is a templated lambda */ template - void operator()(const T &t, const L &l) const { + void operator()(const T& t, const L& l) const { l(t); } }; @@ -7663,7 +7659,7 @@ namespace sqlite_orm { * Simplified API */ template - void iterate_ast(const T &t, const L &l) { + void iterate_ast(const T& t, const L& l) { ast_iterator iterator; iterator(t, l); } @@ -7673,7 +7669,7 @@ namespace sqlite_orm { using node_type = std::reference_wrapper; template - void operator()(const node_type &r, const L &l) const { + void operator()(const node_type& r, const L& l) const { iterate_ast(r.get(), l); } }; @@ -7683,7 +7679,7 @@ namespace sqlite_orm { using node_type = where_t; template - void operator()(const node_type &where, const L &l) const { + void operator()(const node_type& where, const L& l) const { iterate_ast(where.c, l); } }; @@ -7693,7 +7689,7 @@ namespace sqlite_orm { using node_type = T; template - void operator()(const node_type &binaryCondition, const L &l) const { + void operator()(const node_type& binaryCondition, const L& l) const { iterate_ast(binaryCondition.l, l); iterate_ast(binaryCondition.r, l); } @@ -7704,7 +7700,7 @@ namespace sqlite_orm { using node_type = binary_operator; template - void operator()(const node_type &binaryOperator, const C &l) const { + void operator()(const node_type& binaryOperator, const C& l) const { iterate_ast(binaryOperator.lhs, l); iterate_ast(binaryOperator.rhs, l); } @@ -7715,7 +7711,7 @@ namespace sqlite_orm { using node_type = columns_t; template - void operator()(const node_type &cols, const L &l) const { + void operator()(const node_type& cols, const L& l) const { iterate_ast(cols.columns, l); } }; @@ -7725,7 +7721,7 @@ namespace sqlite_orm { using node_type = in_t; template - void operator()(const node_type &in, const C &l) const { + void operator()(const node_type& in, const C& l) const { iterate_ast(in.l, l); iterate_ast(in.arg, l); } @@ -7736,8 +7732,8 @@ namespace sqlite_orm { using node_type = std::vector; template - void operator()(const node_type &vec, const L &l) const { - for(auto &i: vec) { + void operator()(const node_type& vec, const L& l) const { + for(auto& i: vec) { iterate_ast(i, l); } } @@ -7748,7 +7744,7 @@ namespace sqlite_orm { using node_type = std::vector; template - void operator()(const node_type &vec, const L &l) const { + void operator()(const node_type& vec, const L& l) const { l(vec); } }; @@ -7758,7 +7754,7 @@ namespace sqlite_orm { using node_type = T; template - void operator()(const node_type &c, const L &l) const { + void operator()(const node_type& c, const L& l) const { iterate_ast(c.left, l); iterate_ast(c.right, l); } @@ -7769,7 +7765,7 @@ namespace sqlite_orm { using node_type = select_t; template - void operator()(const node_type &sel, const L &l) const { + void operator()(const node_type& sel, const L& l) const { iterate_ast(sel.col, l); iterate_ast(sel.conditions, l); } @@ -7780,7 +7776,7 @@ namespace sqlite_orm { using node_type = get_all_t; template - void operator()(const node_type &get, const L &l) const { + void operator()(const node_type& get, const L& l) const { iterate_ast(get.conditions, l); } }; @@ -7790,7 +7786,7 @@ namespace sqlite_orm { using node_type = get_all_pointer_t; template - void operator()(const node_type &get, const L &l) const { + void operator()(const node_type& get, const L& l) const { iterate_ast(get.conditions, l); } }; @@ -7801,7 +7797,7 @@ namespace sqlite_orm { using node_type = get_all_optional_t; template - void operator()(const node_type &get, const L &l) const { + void operator()(const node_type& get, const L& l) const { iterate_ast(get.conditions, l); } }; @@ -7812,7 +7808,7 @@ namespace sqlite_orm { using node_type = update_all_t, Wargs...>; template - void operator()(const node_type &u, const L &l) const { + void operator()(const node_type& u, const L& l) const { iterate_ast(u.set, l); iterate_ast(u.conditions, l); } @@ -7823,7 +7819,7 @@ namespace sqlite_orm { using node_type = remove_all_t; template - void operator()(const node_type &r, const L &l) const { + void operator()(const node_type& r, const L& l) const { iterate_ast(r.conditions, l); } }; @@ -7833,7 +7829,7 @@ namespace sqlite_orm { using node_type = set_t; template - void operator()(const node_type &s, const L &l) const { + void operator()(const node_type& s, const L& l) const { iterate_ast(s.assigns, l); } }; @@ -7843,8 +7839,8 @@ namespace sqlite_orm { using node_type = std::tuple; template - void operator()(const node_type &tuple, const L &l) const { - iterate_tuple(tuple, [&l](auto &v) { + void operator()(const node_type& tuple, const L& l) const { + iterate_tuple(tuple, [&l](auto& v) { iterate_ast(v, l); }); } @@ -7855,7 +7851,7 @@ namespace sqlite_orm { using node_type = having_t; template - void operator()(const node_type &hav, const L &l) const { + void operator()(const node_type& hav, const L& l) const { iterate_ast(hav.t, l); } }; @@ -7865,7 +7861,7 @@ namespace sqlite_orm { using node_type = cast_t; template - void operator()(const node_type &c, const L &l) const { + void operator()(const node_type& c, const L& l) const { iterate_ast(c.expression, l); } }; @@ -7875,7 +7871,7 @@ namespace sqlite_orm { using node_type = exists_t; template - void operator()(const node_type &e, const L &l) const { + void operator()(const node_type& e, const L& l) const { iterate_ast(e.t, l); } }; @@ -7885,10 +7881,10 @@ namespace sqlite_orm { using node_type = like_t; template - void operator()(const node_type &lk, const L &l) const { + void operator()(const node_type& lk, const L& l) const { iterate_ast(lk.arg, l); iterate_ast(lk.pattern, l); - lk.arg3.apply([&l](auto &value) { + lk.arg3.apply([&l](auto& value) { iterate_ast(value, l); }); } @@ -7899,7 +7895,7 @@ namespace sqlite_orm { using node_type = glob_t; template - void operator()(const node_type &lk, const L &l) const { + void operator()(const node_type& lk, const L& l) const { iterate_ast(lk.arg, l); iterate_ast(lk.pattern, l); } @@ -7910,7 +7906,7 @@ namespace sqlite_orm { using node_type = between_t; template - void operator()(const node_type &b, const L &l) const { + void operator()(const node_type& b, const L& l) const { iterate_ast(b.expr, l); iterate_ast(b.b1, l); iterate_ast(b.b2, l); @@ -7922,7 +7918,7 @@ namespace sqlite_orm { using node_type = named_collate; template - void operator()(const node_type &col, const L &l) const { + void operator()(const node_type& col, const L& l) const { iterate_ast(col.expr, l); } }; @@ -7932,7 +7928,7 @@ namespace sqlite_orm { using node_type = negated_condition_t; template - void operator()(const node_type &neg, const L &l) const { + void operator()(const node_type& neg, const L& l) const { iterate_ast(neg.c, l); } }; @@ -7942,7 +7938,7 @@ namespace sqlite_orm { using node_type = is_null_t; template - void operator()(const node_type &i, const L &l) const { + void operator()(const node_type& i, const L& l) const { iterate_ast(i.t, l); } }; @@ -7952,7 +7948,7 @@ namespace sqlite_orm { using node_type = is_not_null_t; template - void operator()(const node_type &i, const L &l) const { + void operator()(const node_type& i, const L& l) const { iterate_ast(i.t, l); } }; @@ -7962,7 +7958,7 @@ namespace sqlite_orm { using node_type = core_function_t; template - void operator()(const node_type &f, const L &l) const { + void operator()(const node_type& f, const L& l) const { iterate_ast(f.args, l); } }; @@ -7972,7 +7968,7 @@ namespace sqlite_orm { using node_type = left_join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -7982,7 +7978,7 @@ namespace sqlite_orm { using node_type = on_t; template - void operator()(const node_type &o, const L &l) const { + void operator()(const node_type& o, const L& l) const { iterate_ast(o.arg, l); } }; @@ -7992,7 +7988,7 @@ namespace sqlite_orm { using node_type = join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -8002,7 +7998,7 @@ namespace sqlite_orm { using node_type = left_outer_join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -8012,7 +8008,7 @@ namespace sqlite_orm { using node_type = inner_join_t; template - void operator()(const node_type &j, const L &l) const { + void operator()(const node_type& j, const L& l) const { iterate_ast(j.constraint, l); } }; @@ -8022,15 +8018,15 @@ namespace sqlite_orm { using node_type = simple_case_t; template - void operator()(const node_type &c, const L &l) const { - c.case_expression.apply([&l](auto &c_) { + void operator()(const node_type& c, const L& l) const { + c.case_expression.apply([&l](auto& c_) { iterate_ast(c_, l); }); - iterate_tuple(c.args, [&l](auto &pair) { + iterate_tuple(c.args, [&l](auto& pair) { iterate_ast(pair.first, l); iterate_ast(pair.second, l); }); - c.else_expression.apply([&l](auto &el) { + c.else_expression.apply([&l](auto& el) { iterate_ast(el, l); }); } @@ -8041,7 +8037,7 @@ namespace sqlite_orm { using node_type = as_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.expression, l); } }; @@ -8051,7 +8047,7 @@ namespace sqlite_orm { using node_type = limit_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.lim, l); } }; @@ -8061,9 +8057,9 @@ namespace sqlite_orm { using node_type = limit_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.lim, l); - a.off.apply([&l](auto &value) { + a.off.apply([&l](auto& value) { iterate_ast(value, l); }); } @@ -8074,8 +8070,8 @@ namespace sqlite_orm { using node_type = limit_t; template - void operator()(const node_type &a, const L &l) const { - a.off.apply([&l](auto &value) { + void operator()(const node_type& a, const L& l) const { + a.off.apply([&l](auto& value) { iterate_ast(value, l); }); iterate_ast(a.lim, l); @@ -8087,7 +8083,7 @@ namespace sqlite_orm { using node_type = distinct_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.t, l); } }; @@ -8097,7 +8093,7 @@ namespace sqlite_orm { using node_type = all_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.t, l); } }; @@ -8107,7 +8103,7 @@ namespace sqlite_orm { using node_type = bitwise_not_t; template - void operator()(const node_type &a, const L &l) const { + void operator()(const node_type& a, const L& l) const { iterate_ast(a.argument, l); } }; @@ -8117,7 +8113,7 @@ namespace sqlite_orm { using node_type = values_t; template - void operator()(const node_type &node, const L &l) const { + void operator()(const node_type& node, const L& l) const { iterate_ast(node.tuple, l); } }; @@ -8127,7 +8123,7 @@ namespace sqlite_orm { using node_type = dynamic_values_t; template - void operator()(const node_type &node, const L &l) const { + void operator()(const node_type& node, const L& l) const { iterate_ast(node.vector, l); } }; @@ -8137,7 +8133,7 @@ namespace sqlite_orm { using node_type = collate_t; template - void operator()(const node_type &node, const L &l) const { + void operator()(const node_type& node, const L& l) const { iterate_ast(node.expr, l); } }; @@ -8168,11 +8164,11 @@ namespace sqlite_orm { using storage_type = S; using self = view_t; - storage_type &storage; + storage_type& storage; connection_ref connection; get_all_t, Args...> args; - view_t(storage_type &stor, decltype(connection) conn, Args &&... args_) : + view_t(storage_type& stor, decltype(connection) conn, Args&&... args_) : storage(stor), connection(std::move(conn)), args{std::make_tuple(std::forward(args_)...)} {} size_t size() { @@ -8184,7 +8180,7 @@ namespace sqlite_orm { } iterator_t begin() { - sqlite3_stmt *stmt = nullptr; + sqlite3_stmt* stmt = nullptr; auto db = this->connection.get(); using context_t = serializator_context; context_t context{this->storage.impl}; @@ -8194,7 +8190,7 @@ namespace sqlite_orm { auto ret = sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr); if(ret == SQLITE_OK) { auto index = 1; - iterate_ast(this->args.conditions, [&index, stmt, db](auto &node) { + iterate_ast(this->args.conditions, [&index, stmt, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -8313,7 +8309,7 @@ namespace sqlite_orm { get_connection_t get_connection; template - T get_pragma(const std::string &name) { + T get_pragma(const std::string& name) { auto connection = this->get_connection(); auto query = "PRAGMA " + name; T result; @@ -8321,8 +8317,8 @@ namespace sqlite_orm { auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(T *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(T*)data; if(argc) { res = row_extractor().extract(argv[0]); } @@ -8343,7 +8339,7 @@ namespace sqlite_orm { * but it turns out that bindings in pragma statements are not supported. */ template - void set_pragma(const std::string &name, const T &value, sqlite3 *db = nullptr) { + void set_pragma(const std::string& name, const T& value, sqlite3* db = nullptr) { auto con = this->get_connection(); if(!db) { db = con.get(); @@ -8353,7 +8349,7 @@ namespace sqlite_orm { internal::perform_void_exec(db, ss.str()); } - void set_pragma(const std::string &name, const sqlite_orm::journal_mode &value, sqlite3 *db = nullptr) { + void set_pragma(const std::string& name, const sqlite_orm::journal_mode& value, sqlite3* db = nullptr) { auto con = this->get_connection(); if(!db) { db = con.get(); @@ -8607,9 +8603,9 @@ namespace sqlite_orm { */ struct backup_t { backup_t(connection_ref to_, - const std::string &zDestName, + const std::string& zDestName, connection_ref from_, - const std::string &zSourceName, + const std::string& zSourceName, std::unique_ptr holder_) : handle(sqlite3_backup_init(to_.get(), zDestName.c_str(), from_.get(), zSourceName.c_str())), to(to_), from(from_), holder(move(holder_)) { @@ -8618,7 +8614,7 @@ namespace sqlite_orm { } } - backup_t(backup_t &&other) : + backup_t(backup_t&& other) : handle(other.handle), to(other.to), from(other.from), holder(move(other.holder)) { other.handle = nullptr; } @@ -8652,7 +8648,7 @@ namespace sqlite_orm { } protected: - sqlite3_backup *handle = nullptr; + sqlite3_backup* handle = nullptr; connection_ref to; connection_ref from; std::unique_ptr holder; @@ -8665,9 +8661,9 @@ namespace sqlite_orm { namespace internal { struct storage_base { - using collating_function = std::function; + using collating_function = std::function; - std::function on_open; + std::function on_open; pragma_t pragma; limit_accesor limit; @@ -8678,7 +8674,7 @@ namespace sqlite_orm { return {this->get_connection(), move(commitFunc), move(rollbackFunc)}; } - void drop_index(const std::string &indexName) { + void drop_index(const std::string& indexName) { std::stringstream ss; ss << "DROP INDEX '" << indexName + "'"; perform_void_exec(get_connection().get(), ss.str()); @@ -8691,7 +8687,7 @@ namespace sqlite_orm { /** * Drops table with given name. */ - void drop_table(const std::string &tableName) { + void drop_table(const std::string& tableName) { auto con = this->get_connection(); this->drop_table_internal(tableName, con.get()); } @@ -8699,7 +8695,7 @@ namespace sqlite_orm { /** * Rename table named `from` to `to`. */ - void rename_table(const std::string &from, const std::string &to) { + void rename_table(const std::string& from, const std::string& to) { std::stringstream ss; ss << "ALTER TABLE '" << from << "' RENAME TO '" << to << "'"; perform_void_exec(get_connection().get(), ss.str()); @@ -8738,7 +8734,7 @@ namespace sqlite_orm { return sqlite3_libversion(); } - bool transaction(const std::function &f) { + bool transaction(const std::function& f) { this->begin_transaction(); auto shouldCommit = f(); if(shouldCommit) { @@ -8781,8 +8777,8 @@ namespace sqlite_orm { int res = sqlite3_exec( db, sql.c_str(), - [](void *data, int argc, char **argv, char * * /*columnName*/) -> int { - auto &tableNames_ = *(data_t *)data; + [](void* data, int argc, char** argv, char* * /*columnName*/) -> int { + auto& tableNames_ = *(data_t*)data; for(int i = 0; i < argc; i++) { if(argv[i]) { tableNames_.push_back(argv[i]); @@ -8808,8 +8804,8 @@ namespace sqlite_orm { } } - void create_collation(const std::string &name, collating_function f) { - collating_function *functionPointer = nullptr; + void create_collation(const std::string& name, collating_function f) { + collating_function* functionPointer = nullptr; if(f) { functionPointer = &(collatingFunctions[name] = std::move(f)); } else { @@ -8857,47 +8853,47 @@ namespace sqlite_orm { } } - void backup_to(const std::string &filename) { + void backup_to(const std::string& filename) { auto backup = this->make_backup_to(filename); backup.step(-1); } - void backup_to(storage_base &other) { + void backup_to(storage_base& other) { auto backup = this->make_backup_to(other); backup.step(-1); } - void backup_from(const std::string &filename) { + void backup_from(const std::string& filename) { auto backup = this->make_backup_from(filename); backup.step(-1); } - void backup_from(storage_base &other) { + void backup_from(storage_base& other) { auto backup = this->make_backup_from(other); backup.step(-1); } - backup_t make_backup_to(const std::string &filename) { + backup_t make_backup_to(const std::string& filename) { auto holder = std::make_unique(filename); connection_ref conRef{*holder}; return {conRef, "main", this->get_connection(), "main", move(holder)}; } - backup_t make_backup_to(storage_base &other) { + backup_t make_backup_to(storage_base& other) { return {other.get_connection(), "main", this->get_connection(), "main", {}}; } - backup_t make_backup_from(const std::string &filename) { + backup_t make_backup_from(const std::string& filename) { auto holder = std::make_unique(filename); connection_ref conRef{*holder}; return {this->get_connection(), "main", conRef, "main", move(holder)}; } - backup_t make_backup_from(storage_base &other) { + backup_t make_backup_from(storage_base& other) { return {this->get_connection(), "main", other.get_connection(), "main", {}}; } - const std::string &filename() const { + const std::string& filename() const { return this->connection->filename; } @@ -8923,7 +8919,7 @@ namespace sqlite_orm { } protected: - storage_base(const std::string &filename_, int foreignKeysCount) : + storage_base(const std::string& filename_, int foreignKeysCount) : pragma(std::bind(&storage_base::get_connection, this)), limit(std::bind(&storage_base::get_connection, this)), inMemory(filename_.empty() || filename_ == ":memory:"), @@ -8934,7 +8930,7 @@ namespace sqlite_orm { } } - storage_base(const storage_base &other) : + storage_base(const storage_base& other) : on_open(other.on_open), pragma(std::bind(&storage_base::get_connection, this)), limit(std::bind(&storage_base::get_connection, this)), inMemory(other.inMemory), connection(std::make_unique(other.connection->filename)), @@ -8971,20 +8967,20 @@ namespace sqlite_orm { #if SQLITE_VERSION_NUMBER >= 3006019 - void foreign_keys(sqlite3 *db, bool value) { + void foreign_keys(sqlite3* db, bool value) { std::stringstream ss; ss << "PRAGMA foreign_keys = " << value; perform_void_exec(db, ss.str()); } - bool foreign_keys(sqlite3 *db) { + bool foreign_keys(sqlite3* db) { std::string query = "PRAGMA foreign_keys"; auto result = false; auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(bool *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(bool*)data; if(argc) { res = row_extractor().extract(argv[0]); } @@ -9000,7 +8996,7 @@ namespace sqlite_orm { } #endif - void on_open_internal(sqlite3 *db) { + void on_open_internal(sqlite3* db) { #if SQLITE_VERSION_NUMBER >= 3006019 if(this->cachedForeignKeysCount) { @@ -9015,7 +9011,7 @@ namespace sqlite_orm { this->pragma.set_pragma("journal_mode", static_cast(this->pragma._journal_mode), db); } - for(auto &p: this->collatingFunctions) { + for(auto& p: this->collatingFunctions) { if(sqlite3_create_collation(db, p.first.c_str(), SQLITE_UTF8, &p.second, collate_callback) != SQLITE_OK) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -9023,7 +9019,7 @@ namespace sqlite_orm { } } - for(auto &p: this->limit.limits) { + for(auto& p: this->limit.limits) { sqlite3_limit(db, p.first, p.second); } @@ -9036,7 +9032,7 @@ namespace sqlite_orm { } } - std::string current_timestamp(sqlite3 *db) { + std::string current_timestamp(sqlite3* db) { std::string result; std::stringstream ss; ss << "SELECT CURRENT_TIMESTAMP"; @@ -9044,8 +9040,8 @@ namespace sqlite_orm { auto rc = sqlite3_exec( db, query.c_str(), - [](void *data, int argc, char **argv, char **) -> int { - auto &res = *(std::string *)data; + [](void* data, int argc, char** argv, char**) -> int { + auto& res = *(std::string*)data; if(argc) { if(argv[0]) { res = row_extractor().extract(argv[0]); @@ -9062,19 +9058,19 @@ namespace sqlite_orm { return result; } - void drop_table_internal(const std::string &tableName, sqlite3 *db) { + void drop_table_internal(const std::string& tableName, sqlite3* db) { std::stringstream ss; ss << "DROP TABLE '" << tableName + "'"; perform_void_exec(db, ss.str()); } - static int collate_callback(void *arg, int leftLen, const void *lhs, int rightLen, const void *rhs) { - auto &f = *(collating_function *)arg; + static int collate_callback(void* arg, int leftLen, const void* lhs, int rightLen, const void* rhs) { + auto& f = *(collating_function*)arg; return f(leftLen, lhs, rightLen, rhs); } - static int busy_handler_callback(void *selfPointer, int triesCount) { - auto &storage = *static_cast(selfPointer); + static int busy_handler_callback(void* selfPointer, int triesCount) { + auto& storage = *static_cast(selfPointer); if(storage._busy_handler) { return storage._busy_handler(triesCount); } else { @@ -9084,9 +9080,9 @@ namespace sqlite_orm { // returns foreign keys count in storage definition template - static int foreign_keys_count(T &storageImpl) { + static int foreign_keys_count(T& storageImpl) { auto res = 0; - storageImpl.for_each([&res](auto &impl) { + storageImpl.for_each([&res](auto& impl) { res += impl.foreign_keys_count(); }); return res; @@ -9155,7 +9151,7 @@ namespace sqlite_orm { struct get_ref_t { template - auto &operator()(O &t) const { + auto& operator()(O& t) const { return t; } }; @@ -9164,13 +9160,13 @@ namespace sqlite_orm { struct get_ref_t> { template - auto &operator()(O &t) const { + auto& operator()(O& t) const { return t.get(); } }; template - auto &get_ref(T &t) { + auto& get_ref(T& t) { using arg_type = typename std::decay::type; get_ref_t g; return g(t); @@ -9183,7 +9179,7 @@ namespace sqlite_orm { struct get_object_t : get_object_t {}; template - auto &get_object(T &t) { + auto& get_object(T& t) { using expression_type = typename std::decay::type; get_object_t obj; return obj(t); @@ -9194,7 +9190,7 @@ namespace sqlite_orm { using expression_type = replace_t; template - auto &operator()(O &e) const { + auto& operator()(O& e) const { return get_ref(e.obj); } }; @@ -9204,7 +9200,7 @@ namespace sqlite_orm { using expression_type = insert_t; template - auto &operator()(O &e) const { + auto& operator()(O& e) const { return get_ref(e.obj); } }; @@ -9214,7 +9210,7 @@ namespace sqlite_orm { using expression_type = update_t; template - auto &operator()(O &e) const { + auto& operator()(O& e) const { return get_ref(e.obj); } }; @@ -9266,7 +9262,7 @@ namespace sqlite_orm { mutable table_name_set table_names; template - table_name_set operator()(const T &) const { + table_name_set operator()(const T&) const { return {}; } @@ -9278,19 +9274,19 @@ namespace sqlite_orm { } template - void operator()(const column_pointer &) const { + void operator()(const column_pointer&) const { if(this->find_table_name) { table_names.insert({this->find_table_name(typeid(T)), ""}); } } template - void operator()(const alias_column_t &a) const { + void operator()(const alias_column_t& a) const { (*this)(a.column, alias_extractor::get()); } template - void operator()(const count_asterisk_t &) const { + void operator()(const count_asterisk_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); if(!tableName.empty()) { @@ -9300,7 +9296,7 @@ namespace sqlite_orm { } template - void operator()(const asterisk_t &) const { + void operator()(const asterisk_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -9308,7 +9304,7 @@ namespace sqlite_orm { } template - void operator()(const object_t &) const { + void operator()(const object_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -9316,7 +9312,7 @@ namespace sqlite_orm { } template - void operator()(const table_rowid_t &) const { + void operator()(const table_rowid_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -9324,7 +9320,7 @@ namespace sqlite_orm { } template - void operator()(const table_oid_t &) const { + void operator()(const table_oid_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -9332,7 +9328,7 @@ namespace sqlite_orm { } template - void operator()(const table__rowid_t &) const { + void operator()(const table__rowid_t&) const { if(this->find_table_name) { auto tableName = this->find_table_name(typeid(T)); table_names.insert(std::make_pair(move(tableName), "")); @@ -9359,14 +9355,14 @@ namespace sqlite_orm { namespace internal { template - std::string serialize(const T &t, const C &context); + std::string serialize(const T& t, const C& context); template struct column_names_getter { using expression_type = T; template - std::vector operator()(const expression_type &t, const C &context) { + std::vector operator()(const expression_type& t, const C& context) { auto newContext = context; newContext.skip_table_name = false; auto columnName = serialize(t, newContext); @@ -9379,7 +9375,7 @@ namespace sqlite_orm { }; template - std::vector get_column_names(const T &t, const C &context) { + std::vector get_column_names(const T& t, const C& context) { column_names_getter serializator; return serializator(t, context); } @@ -9389,7 +9385,7 @@ namespace sqlite_orm { using expression_type = std::reference_wrapper; template - std::vector operator()(const expression_type &expression, const C &context) { + std::vector operator()(const expression_type& expression, const C& context) { return get_column_names(expression.get(), context); } }; @@ -9399,7 +9395,7 @@ namespace sqlite_orm { using expression_type = asterisk_t; template - std::vector operator()(const expression_type &, const C &) { + std::vector operator()(const expression_type&, const C&) { std::vector res; res.push_back("*"); return res; @@ -9411,7 +9407,7 @@ namespace sqlite_orm { using expression_type = object_t; template - std::vector operator()(const expression_type &, const C &) { + std::vector operator()(const expression_type&, const C&) { std::vector res; res.push_back("*"); return res; @@ -9423,12 +9419,12 @@ namespace sqlite_orm { using expression_type = columns_t; template - std::vector operator()(const expression_type &cols, const C &context) { + std::vector operator()(const expression_type& cols, const C& context) { std::vector columnNames; columnNames.reserve(static_cast(cols.count)); auto newContext = context; newContext.skip_table_name = false; - iterate_tuple(cols.columns, [&columnNames, &newContext](auto &m) { + iterate_tuple(cols.columns, [&columnNames, &newContext](auto& m) { auto columnName = serialize(m, newContext); if(columnName.length()) { columnNames.push_back(columnName); @@ -9457,7 +9453,7 @@ namespace sqlite_orm { struct order_by_serializator; template - std::string serialize_order_by(const T &t, const C &context) { + std::string serialize_order_by(const T& t, const C& context) { order_by_serializator serializator; return serializator(t, context); } @@ -9467,7 +9463,7 @@ namespace sqlite_orm { using statement_type = order_by_t; template - std::string operator()(const statement_type &orderBy, const C &context) const { + std::string operator()(const statement_type& orderBy, const C& context) const { std::stringstream ss; auto newContext = context; newContext.skip_table_name = false; @@ -9493,9 +9489,9 @@ namespace sqlite_orm { using statement_type = dynamic_order_by_t; template - std::string operator()(const statement_type &orderBy, const C &) const { + std::string operator()(const statement_type& orderBy, const C&) const { std::vector expressions; - for(auto &entry: orderBy) { + for(auto& entry: orderBy) { std::string entryString; { std::stringstream ss; @@ -9545,7 +9541,7 @@ namespace sqlite_orm { struct statement_serializator; template - std::string serialize(const T &t, const C &context) { + std::string serialize(const T& t, const C& context) { statement_serializator serializator; return serializator(t, context); } @@ -9555,7 +9551,7 @@ namespace sqlite_orm { using statement_type = T; template - std::string operator()(const statement_type &statement, const C &context) { + std::string operator()(const statement_type& statement, const C& context) { if(context.replace_bindable_with_question) { return "?"; } else { @@ -9569,7 +9565,7 @@ namespace sqlite_orm { using statement_type = std::reference_wrapper; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { return serialize(s.get(), context); } }; @@ -9579,7 +9575,7 @@ namespace sqlite_orm { using statement_type = std::nullptr_t; template - std::string operator()(const statement_type &, const C &) { + std::string operator()(const statement_type&, const C&) { return "?"; } }; @@ -9589,7 +9585,7 @@ namespace sqlite_orm { using statement_type = alias_holder; template - std::string operator()(const statement_type &, const C &) { + std::string operator()(const statement_type&, const C&) { return T::get(); } }; @@ -9599,13 +9595,13 @@ namespace sqlite_orm { using statement_type = core_function_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << "("; std::vector args; using args_type = typename std::decay::type::args_type; args.reserve(std::tuple_size::value); - iterate_tuple(c.args, [&args, &context](auto &v) { + iterate_tuple(c.args, [&args, &context](auto& v) { args.push_back(serialize(v, context)); }); for(size_t i = 0; i < args.size(); ++i) { @@ -9624,7 +9620,7 @@ namespace sqlite_orm { using statement_type = as_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto tableAliasString = alias_extractor::get(); return serialize(c.expression, context) + " AS " + tableAliasString; } @@ -9635,7 +9631,7 @@ namespace sqlite_orm { using statement_type = alias_column_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << T::get() << "'."; @@ -9652,7 +9648,7 @@ namespace sqlite_orm { using statement_type = std::string; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { if(context.replace_bindable_with_question) { return "?"; } else { @@ -9662,11 +9658,11 @@ namespace sqlite_orm { }; template<> - struct statement_serializator { - using statement_type = const char *; + struct statement_serializator { + using statement_type = const char*; template - std::string operator()(const char *c, const C &context) const { + std::string operator()(const char* c, const C& context) const { if(context.replace_bindable_with_question) { return "?"; } else { @@ -9680,7 +9676,7 @@ namespace sqlite_orm { using statement_type = F O::*; template - std::string operator()(const statement_type &m, const C &context) const { + std::string operator()(const statement_type& m, const C& context) const { std::stringstream ss; if(!context.skip_table_name) { ss << "\"" << context.impl.find_table_name(typeid(O)) << "\"."; @@ -9695,7 +9691,7 @@ namespace sqlite_orm { using statement_type = rowid_t; template - std::string operator()(const statement_type &s, const C &) { + std::string operator()(const statement_type& s, const C&) { return static_cast(s); } }; @@ -9705,7 +9701,7 @@ namespace sqlite_orm { using statement_type = oid_t; template - std::string operator()(const statement_type &s, const C &) { + std::string operator()(const statement_type& s, const C&) { return static_cast(s); } }; @@ -9715,7 +9711,7 @@ namespace sqlite_orm { using statement_type = _rowid_t; template - std::string operator()(const statement_type &s, const C &) { + std::string operator()(const statement_type& s, const C&) { return static_cast(s); } }; @@ -9725,7 +9721,7 @@ namespace sqlite_orm { using statement_type = table_rowid_t; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(O)) << "'."; @@ -9740,7 +9736,7 @@ namespace sqlite_orm { using statement_type = table_oid_t; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(O)) << "'."; @@ -9755,7 +9751,7 @@ namespace sqlite_orm { using statement_type = table__rowid_t; template - std::string operator()(const statement_type &s, const C &context) { + std::string operator()(const statement_type& s, const C& context) { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(O)) << "'."; @@ -9770,7 +9766,7 @@ namespace sqlite_orm { using statement_type = binary_operator; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto lhs = serialize(c.lhs, context); auto rhs = serialize(c.rhs, context); std::stringstream ss; @@ -9784,7 +9780,7 @@ namespace sqlite_orm { using statement_type = count_asterisk_t; template - std::string operator()(const statement_type &, const C &context) const { + std::string operator()(const statement_type&, const C& context) const { return serialize(count_asterisk_without_type{}, context); } }; @@ -9794,7 +9790,7 @@ namespace sqlite_orm { using statement_type = count_asterisk_without_type; template - std::string operator()(const statement_type &c, const C &) const { + std::string operator()(const statement_type& c, const C&) const { std::stringstream ss; ss << static_cast(c) << "(*)"; return ss.str(); @@ -9806,7 +9802,7 @@ namespace sqlite_orm { using statement_type = distinct_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto expr = serialize(c.t, context); ss << static_cast(c) << "(" << expr << ")"; @@ -9819,7 +9815,7 @@ namespace sqlite_orm { using statement_type = all_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto expr = serialize(c.t, context); ss << static_cast(c) << "(" << expr << ")"; @@ -9832,7 +9828,7 @@ namespace sqlite_orm { using statement_type = column_pointer; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; if(!context.skip_table_name) { ss << "'" << context.impl.find_table_name(typeid(T)) << "'."; @@ -9847,7 +9843,7 @@ namespace sqlite_orm { using statement_type = cast_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " ("; ss << serialize(c.expression, context) << " AS " << type_printer().print() << ")"; @@ -9861,7 +9857,7 @@ namespace sqlite_orm { using statement_type = T; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.left, context) << " "; ss << static_cast(c) << " "; @@ -9875,17 +9871,17 @@ namespace sqlite_orm { using statement_type = simple_case_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << "CASE "; - c.case_expression.apply([&ss, context](auto &c_) { + c.case_expression.apply([&ss, context](auto& c_) { ss << serialize(c_, context) << " "; }); - iterate_tuple(c.args, [&ss, context](auto &pair) { + iterate_tuple(c.args, [&ss, context](auto& pair) { ss << "WHEN " << serialize(pair.first, context) << " "; ss << "THEN " << serialize(pair.second, context) << " "; }); - c.else_expression.apply([&ss, context](auto &el) { + c.else_expression.apply([&ss, context](auto& el) { ss << "ELSE " << serialize(el, context) << " "; }); ss << "END"; @@ -9898,7 +9894,7 @@ namespace sqlite_orm { using statement_type = is_null_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.t, context) << " " << static_cast(c); return ss.str(); @@ -9910,7 +9906,7 @@ namespace sqlite_orm { using statement_type = is_not_null_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.t, context) << " " << static_cast(c); return ss.str(); @@ -9922,7 +9918,7 @@ namespace sqlite_orm { using statement_type = bitwise_not_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; auto cString = serialize(c.argument, context); @@ -9936,7 +9932,7 @@ namespace sqlite_orm { using statement_type = negated_condition_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; auto cString = serialize(c.c, context); @@ -9951,7 +9947,7 @@ namespace sqlite_orm { using statement_type = T; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto leftString = serialize(c.l, context); auto rightString = serialize(c.r, context); std::stringstream ss; @@ -9971,7 +9967,7 @@ namespace sqlite_orm { using statement_type = named_collate; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto newContext = context; newContext.use_parentheses = false; auto res = serialize(c.expr, newContext); @@ -9984,7 +9980,7 @@ namespace sqlite_orm { using statement_type = collate_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto newContext = context; newContext.use_parentheses = false; auto res = serialize(c.expr, newContext); @@ -9997,7 +9993,7 @@ namespace sqlite_orm { using statement_type = in_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto leftString = serialize(c.l, context); ss << leftString << " " << static_cast(c) << " "; @@ -10013,12 +10009,12 @@ namespace sqlite_orm { using statement_type = in_t>; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto leftString = serialize(c.l, context); ss << leftString << " " << static_cast(c) << " ( "; for(size_t index = 0; index < c.arg.size(); ++index) { - auto &value = c.arg[index]; + auto& value = c.arg[index]; ss << " " << serialize(value, context); if(index < c.arg.size() - 1) { ss << ", "; @@ -10034,12 +10030,12 @@ namespace sqlite_orm { using statement_type = like_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.arg, context) << " "; ss << static_cast(c) << " "; ss << serialize(c.pattern, context); - c.arg3.apply([&ss, &context](auto &value) { + c.arg3.apply([&ss, &context](auto& value) { ss << " ESCAPE " << serialize(value, context); }); return ss.str(); @@ -10051,7 +10047,7 @@ namespace sqlite_orm { using statement_type = glob_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << serialize(c.arg, context) << " "; ss << static_cast(c) << " "; @@ -10065,7 +10061,7 @@ namespace sqlite_orm { using statement_type = between_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; auto expr = serialize(c.expr, context); ss << expr << " " << static_cast(c) << " "; @@ -10081,7 +10077,7 @@ namespace sqlite_orm { using statement_type = exists_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; ss << serialize(c.t, context); @@ -10094,7 +10090,7 @@ namespace sqlite_orm { using statement_type = constraints::autoincrement_t; template - std::string operator()(const statement_type &c, const C &) const { + std::string operator()(const statement_type& c, const C&) const { return static_cast(c); } }; @@ -10104,14 +10100,14 @@ namespace sqlite_orm { using statement_type = constraints::primary_key_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto res = static_cast(c); using columns_tuple = typename statement_type::columns_tuple; auto columnsCount = std::tuple_size::value; if(columnsCount) { res += "("; decltype(columnsCount) columnIndex = 0; - iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto &column) { + iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto& column) { res += context.column_name(column); if(columnIndex < columnsCount - 1) { res += ", "; @@ -10129,14 +10125,14 @@ namespace sqlite_orm { using statement_type = constraints::unique_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { auto res = static_cast(c); using columns_tuple = typename statement_type::columns_tuple; auto columnsCount = std::tuple_size::value; if(columnsCount) { res += "("; decltype(columnsCount) columnIndex = 0; - iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto &column) { + iterate_tuple(c.columns, [&context, &res, &columnIndex, columnsCount](auto& column) { res += context.column_name(column); if(columnIndex < columnsCount - 1) { res += ", "; @@ -10154,7 +10150,7 @@ namespace sqlite_orm { using statement_type = constraints::collate_t; template - std::string operator()(const statement_type &c, const C &) const { + std::string operator()(const statement_type& c, const C&) const { return static_cast(c); } }; @@ -10164,7 +10160,7 @@ namespace sqlite_orm { using statement_type = constraints::default_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { return static_cast(c) + " (" + serialize(c.value, context) + ")"; } }; @@ -10174,13 +10170,13 @@ namespace sqlite_orm { using statement_type = constraints::foreign_key_t, std::tuple>; template - std::string operator()(const statement_type &fk, const C &context) const { + std::string operator()(const statement_type& fk, const C& context) const { std::stringstream ss; std::vector columnNames; using columns_type_t = typename std::decay::type::columns_type; constexpr const size_t columnsCount = std::tuple_size::value; columnNames.reserve(columnsCount); - iterate_tuple(fk.columns, [&columnNames, &context](auto &v) { + iterate_tuple(fk.columns, [&columnNames, &context](auto& v) { columnNames.push_back(context.impl.column_name(v)); }); ss << "FOREIGN KEY("; @@ -10201,7 +10197,7 @@ namespace sqlite_orm { auto refTableName = context.impl.find_table_name(typeid(first_reference_mapped_type)); ss << '\'' << refTableName << '\''; } - iterate_tuple(fk.references, [&referencesNames, &context](auto &v) { + iterate_tuple(fk.references, [&referencesNames, &context](auto& v) { referencesNames.push_back(context.impl.column_name(v)); }); ss << "("; @@ -10227,7 +10223,7 @@ namespace sqlite_orm { using statement_type = constraints::check_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { return static_cast(c) + " " + serialize(c.expression, context); } }; @@ -10237,7 +10233,7 @@ namespace sqlite_orm { using statement_type = column_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << "'" << c.name << "' "; using column_type = typename std::decay::type; @@ -10253,7 +10249,7 @@ namespace sqlite_orm { int tupleIndex = 0; iterate_tuple( c.constraints, - [&constraintsStrings, &primaryKeyIndex, &autoincrementIndex, &tupleIndex, &context](auto &v) { + [&constraintsStrings, &primaryKeyIndex, &autoincrementIndex, &tupleIndex, &context](auto& v) { using constraint_type = typename std::decay::type; constraintsStrings.push_back(serialize(v, context)); if(is_primary_key::value) { @@ -10267,7 +10263,7 @@ namespace sqlite_orm { iter_swap(constraintsStrings.begin() + primaryKeyIndex, constraintsStrings.begin() + autoincrementIndex); } - for(auto &str: constraintsStrings) { + for(auto& str: constraintsStrings) { ss << str << ' '; } } @@ -10283,11 +10279,11 @@ namespace sqlite_orm { using statement_type = remove_all_t; template - std::string operator()(const statement_type &rem, const C &context) const { - auto &tImpl = context.impl.template get_impl(); + std::string operator()(const statement_type& rem, const C& context) const { + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "DELETE FROM '" << tImpl.table.name << "' "; - iterate_tuple(rem.conditions, [&context, &ss](auto &v) { + iterate_tuple(rem.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); return ss.str(); @@ -10299,10 +10295,10 @@ namespace sqlite_orm { using statement_type = replace_t; template - std::string operator()(const statement_type &rep, const C &context) const { + std::string operator()(const statement_type& rep, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "REPLACE INTO '" << tImpl.table.name << "' ("; auto columnNames = tImpl.table.column_names(); @@ -10334,12 +10330,12 @@ namespace sqlite_orm { using statement_type = insert_explicit; template - std::string operator()(const statement_type &ins, const C &context) const { + std::string operator()(const statement_type& ins, const C& context) const { constexpr const size_t colsCount = std::tuple_size>::value; static_assert(colsCount > 0, "Use insert or replace with 1 argument instead"); using expression_type = typename std::decay::type; using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "INSERT INTO '" << tImpl.table.name << "' "; std::vector columnNames; @@ -10347,7 +10343,7 @@ namespace sqlite_orm { { auto columnsContext = context; columnsContext.skip_table_name = true; - iterate_tuple(ins.columns.columns, [&columnNames, &columnsContext](auto &m) { + iterate_tuple(ins.columns.columns, [&columnNames, &columnsContext](auto& m) { auto columnName = serialize(m, columnsContext); if(!columnName.empty()) { columnNames.push_back(columnName); @@ -10385,15 +10381,15 @@ namespace sqlite_orm { using statement_type = update_t; template - std::string operator()(const statement_type &upd, const C &context) const { + std::string operator()(const statement_type& upd, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "UPDATE '" << tImpl.table.name << "' SET "; std::vector setColumnNames; - tImpl.table.for_each_column([&setColumnNames](auto &c) { + tImpl.table.for_each_column([&setColumnNames](auto& c) { if(!c.template has>()) { setColumnNames.emplace_back(c.name); } @@ -10425,7 +10421,7 @@ namespace sqlite_orm { using statement_type = update_all_t, Wargs...>; template - std::string operator()(const statement_type &upd, const C &context) const { + std::string operator()(const statement_type& upd, const C& context) const { std::stringstream ss; ss << "UPDATE "; table_name_collector collector{[&context](std::type_index ti) { @@ -10439,7 +10435,7 @@ namespace sqlite_orm { std::vector setPairs; auto leftContext = context; leftContext.skip_table_name = true; - iterate_tuple(upd.set.assigns, [&context, &leftContext, &setPairs](auto &asgn) { + iterate_tuple(upd.set.assigns, [&context, &leftContext, &setPairs](auto& asgn) { std::stringstream sss; sss << serialize(asgn.lhs, leftContext); sss << " " << static_cast(asgn) << " "; @@ -10453,7 +10449,7 @@ namespace sqlite_orm { ss << ", "; } } - iterate_tuple(upd.conditions, [&context, &ss](auto &v) { + iterate_tuple(upd.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); return ss.str(); @@ -10471,15 +10467,15 @@ namespace sqlite_orm { using statement_type = insert_t; template - std::string operator()(const statement_type &, const C &context) const { + std::string operator()(const statement_type&, const C& context) const { using object_type = typename expression_object_type::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "INSERT INTO '" << tImpl.table.name << "' "; std::vector columnNames; auto compositeKeyColumnNames = tImpl.table.composite_key_columns_names(); - tImpl.table.for_each_column([&tImpl, &columnNames, &compositeKeyColumnNames](auto &c) { + tImpl.table.for_each_column([&tImpl, &columnNames, &compositeKeyColumnNames](auto& c) { if(tImpl.table._without_rowid || !c.template has>()) { auto it = find(compositeKeyColumnNames.begin(), compositeKeyColumnNames.end(), c.name); if(it == compositeKeyColumnNames.end()) { @@ -10524,8 +10520,8 @@ namespace sqlite_orm { using statement_type = remove_t; template - std::string operator()(const statement_type &, const C &context) const { - auto &tImpl = context.impl.template get_impl(); + std::string operator()(const statement_type&, const C& context) const { + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "DELETE FROM '" << tImpl.table.name << "' "; ss << "WHERE "; @@ -10546,10 +10542,10 @@ namespace sqlite_orm { using statement_type = replace_range_t; template - std::string operator()(const statement_type &rep, const C &context) const { + std::string operator()(const statement_type& rep, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_type::object_type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "REPLACE INTO '" << tImpl.table.name << "' ("; auto columnNames = tImpl.table.column_names(); @@ -10593,15 +10589,15 @@ namespace sqlite_orm { using statement_type = insert_range_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { using expression_type = typename std::decay::type; using object_type = typename expression_type::object_type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "INSERT INTO '" << tImpl.table.name << "' ("; std::vector columnNames; - tImpl.table.for_each_column([&columnNames](auto &c) { + tImpl.table.for_each_column([&columnNames](auto& c) { if(!c.template has>()) { columnNames.emplace_back(c.name); } @@ -10644,7 +10640,7 @@ namespace sqlite_orm { }; template - std::string serialize_get_all_impl(const T &get, const C &context) { + std::string serialize_get_all_impl(const T& get, const C& context) { using primary_type = typename T::type; table_name_collector collector; @@ -10653,7 +10649,7 @@ namespace sqlite_orm { iterate_ast(get.conditions, collector); std::stringstream ss; ss << "SELECT "; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); auto columnNames = tImpl.table.column_names(); for(size_t i = 0; i < columnNames.size(); ++i) { ss << "\"" << tImpl.table.name << "\"." @@ -10668,7 +10664,7 @@ namespace sqlite_orm { std::vector> tableNames(collector.table_names.begin(), collector.table_names.end()); for(size_t i = 0; i < tableNames.size(); ++i) { - auto &tableNamePair = tableNames[i]; + auto& tableNamePair = tableNames[i]; ss << "'" << tableNamePair.first << "' "; if(!tableNamePair.second.empty()) { ss << tableNamePair.second << " "; @@ -10678,7 +10674,7 @@ namespace sqlite_orm { } ss << " "; } - iterate_tuple(get.conditions, [&context, &ss](auto &v) { + iterate_tuple(get.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); return ss.str(); @@ -10690,7 +10686,7 @@ namespace sqlite_orm { using statement_type = get_all_optional_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_all_impl(get, context); } }; @@ -10701,7 +10697,7 @@ namespace sqlite_orm { using statement_type = get_all_pointer_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_all_impl(get, context); } }; @@ -10711,15 +10707,15 @@ namespace sqlite_orm { using statement_type = get_all_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_all_impl(get, context); } }; template - std::string serialize_get_impl(const T &, const C &context) { + std::string serialize_get_impl(const T&, const C& context) { using primary_type = typename T::type; - auto &tImpl = context.impl.template get_impl(); + auto& tImpl = context.impl.template get_impl(); std::stringstream ss; ss << "SELECT "; auto columnNames = tImpl.table.column_names(); @@ -10752,7 +10748,7 @@ namespace sqlite_orm { using statement_type = get_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_impl(get, context); } }; @@ -10762,7 +10758,7 @@ namespace sqlite_orm { using statement_type = get_pointer_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_impl(get, context); } }; @@ -10773,7 +10769,7 @@ namespace sqlite_orm { using statement_type = get_optional_t; template - std::string operator()(const statement_type &get, const C &context) const { + std::string operator()(const statement_type& get, const C& context) const { return serialize_get_impl(get, context); } }; @@ -10783,7 +10779,7 @@ namespace sqlite_orm { using statement_type = select_t; template - std::string operator()(const statement_type &sel, const C &context) const { + std::string operator()(const statement_type& sel, const C& context) const { std::stringstream ss; if(!is_base_of_template::value) { if(!sel.highest_level) { @@ -10807,7 +10803,7 @@ namespace sqlite_orm { }}; iterate_ast(sel.col, collector); iterate_ast(sel.conditions, collector); - internal::join_iterator()([&collector, &context](const auto &c) { + internal::join_iterator()([&collector, &context](const auto& c) { using original_join_type = typename std::decay::type::join_type::type; using cross_join_type = typename internal::mapped_type_proxy::type; auto crossJoinedTableName = context.impl.find_table_name(typeid(cross_join_type)); @@ -10821,7 +10817,7 @@ namespace sqlite_orm { std::vector> tableNames(collector.table_names.begin(), collector.table_names.end()); for(size_t i = 0; i < tableNames.size(); ++i) { - auto &tableNamePair = tableNames[i]; + auto& tableNamePair = tableNames[i]; ss << "'" << tableNamePair.first << "' "; if(!tableNamePair.second.empty()) { ss << tableNamePair.second << " "; @@ -10832,7 +10828,7 @@ namespace sqlite_orm { ss << " "; } } - iterate_tuple(sel.conditions, [&context, &ss](auto &v) { + iterate_tuple(sel.conditions, [&context, &ss](auto& v) { ss << serialize(v, context); }); if(!is_base_of_template::value) { @@ -10849,7 +10845,7 @@ namespace sqlite_orm { using statement_type = indexed_column_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; ss << serialize(statement.column_or_expression, context); if(!statement._collation_name.empty()) { @@ -10876,7 +10872,7 @@ namespace sqlite_orm { using statement_type = index_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; ss << "CREATE "; if(statement.unique) { @@ -10888,7 +10884,7 @@ namespace sqlite_orm { ss << "INDEX IF NOT EXISTS '" << statement.name << "' ON '" << context.impl.find_table_name(typeid(indexed_type)) << "' ("; std::vector columnNames; - iterate_tuple(statement.columns, [&columnNames, &context](auto &v) { + iterate_tuple(statement.columns, [&columnNames, &context](auto& v) { columnNames.push_back(context.column_name(v.column_or_expression)); }); for(size_t i = 0; i < columnNames.size(); ++i) { @@ -10907,7 +10903,7 @@ namespace sqlite_orm { using statement_type = where_t; template - std::string operator()(const statement_type &w, const C &context) const { + std::string operator()(const statement_type& w, const C& context) const { std::stringstream ss; ss << static_cast(w) << " "; auto whereString = serialize(w.c, context); @@ -10921,7 +10917,7 @@ namespace sqlite_orm { using statement_type = order_by_t; template - std::string operator()(const statement_type &orderBy, const C &context) const { + std::string operator()(const statement_type& orderBy, const C& context) const { std::stringstream ss; ss << static_cast(orderBy) << " "; auto orderByString = serialize_order_by(orderBy, context); @@ -10935,7 +10931,7 @@ namespace sqlite_orm { using statement_type = dynamic_order_by_t; template - std::string operator()(const statement_type &orderBy, const CC &context) const { + std::string operator()(const statement_type& orderBy, const CC& context) const { return serialize_order_by(orderBy, context); } }; @@ -10945,10 +10941,10 @@ namespace sqlite_orm { using statement_type = multi_order_by_t; template - std::string operator()(const statement_type &orderBy, const C &context) const { + std::string operator()(const statement_type& orderBy, const C& context) const { std::stringstream ss; std::vector expressions; - iterate_tuple(orderBy.args, [&expressions, &context](auto &v) { + iterate_tuple(orderBy.args, [&expressions, &context](auto& v) { auto expression = serialize_order_by(v, context); expressions.push_back(move(expression)); }); @@ -10969,7 +10965,7 @@ namespace sqlite_orm { using statement_type = cross_join_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; ss << " '" << context.impl.find_table_name(typeid(O)) << "'"; @@ -10982,7 +10978,7 @@ namespace sqlite_orm { using statement_type = inner_join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -11000,7 +10996,7 @@ namespace sqlite_orm { using statement_type = on_t; template - std::string operator()(const statement_type &t, const C &context) const { + std::string operator()(const statement_type& t, const C& context) const { std::stringstream ss; auto newContext = context; newContext.skip_table_name = false; @@ -11014,7 +11010,7 @@ namespace sqlite_orm { using statement_type = join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -11032,7 +11028,7 @@ namespace sqlite_orm { using statement_type = left_join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -11050,7 +11046,7 @@ namespace sqlite_orm { using statement_type = left_outer_join_t; template - std::string operator()(const statement_type &l, const C &context) const { + std::string operator()(const statement_type& l, const C& context) const { std::stringstream ss; ss << static_cast(l) << " "; auto aliasString = alias_extractor::get(); @@ -11068,7 +11064,7 @@ namespace sqlite_orm { using statement_type = natural_join_t; template - std::string operator()(const statement_type &c, const C &context) const { + std::string operator()(const statement_type& c, const C& context) const { std::stringstream ss; ss << static_cast(c) << " "; ss << " '" << context.impl.find_table_name(typeid(O)) << "'"; @@ -11081,12 +11077,12 @@ namespace sqlite_orm { using statement_type = group_by_t; template - std::string operator()(const statement_type &groupBy, const C &context) const { + std::string operator()(const statement_type& groupBy, const C& context) const { std::stringstream ss; std::vector expressions; auto newContext = context; newContext.skip_table_name = false; - iterate_tuple(groupBy.args, [&expressions, &newContext](auto &v) { + iterate_tuple(groupBy.args, [&expressions, &newContext](auto& v) { auto expression = serialize(v, newContext); expressions.push_back(expression); }); @@ -11107,7 +11103,7 @@ namespace sqlite_orm { using statement_type = having_t; template - std::string operator()(const statement_type &hav, const C &context) const { + std::string operator()(const statement_type& hav, const C& context) const { std::stringstream ss; auto newContext = context; newContext.skip_table_name = false; @@ -11126,21 +11122,21 @@ namespace sqlite_orm { using statement_type = limit_t; template - std::string operator()(const statement_type &limt, const C &context) const { + std::string operator()(const statement_type& limt, const C& context) const { auto newContext = context; newContext.skip_table_name = false; std::stringstream ss; ss << static_cast(limt) << " "; if(HO) { if(OI) { - limt.off.apply([&newContext, &ss](auto &value) { + limt.off.apply([&newContext, &ss](auto& value) { ss << serialize(value, newContext); }); ss << ", "; ss << serialize(limt.lim, newContext); } else { ss << serialize(limt.lim, newContext) << " OFFSET "; - limt.off.apply([&newContext, &ss](auto &value) { + limt.off.apply([&newContext, &ss](auto& value) { ss << serialize(value, newContext); }); } @@ -11156,7 +11152,7 @@ namespace sqlite_orm { using statement_type = using_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { auto newContext = context; newContext.skip_table_name = true; return static_cast(statement) + " (" + serialize(statement.column, newContext) + " )"; @@ -11168,12 +11164,12 @@ namespace sqlite_orm { using statement_type = std::tuple; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; ss << '('; auto index = 0; using TupleSize = std::tuple_size; - iterate_tuple(statement, [&context, &index, &ss](auto &value) { + iterate_tuple(statement, [&context, &index, &ss](auto& value) { ss << serialize(value, context); if(index < TupleSize::value - 1) { ss << ", "; @@ -11190,7 +11186,7 @@ namespace sqlite_orm { using statement_type = values_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; if(context.use_parentheses) { ss << '('; @@ -11198,10 +11194,10 @@ namespace sqlite_orm { ss << "VALUES "; { auto index = 0; - auto &tuple = statement.tuple; + auto& tuple = statement.tuple; using tuple_type = typename std::decay::type; using TupleSize = std::tuple_size; - iterate_tuple(tuple, [&context, &index, &ss](auto &value) { + iterate_tuple(tuple, [&context, &index, &ss](auto& value) { ss << serialize(value, context); if(index < TupleSize::value - 1) { ss << ", "; @@ -11221,7 +11217,7 @@ namespace sqlite_orm { using statement_type = dynamic_values_t; template - std::string operator()(const statement_type &statement, const C &context) const { + std::string operator()(const statement_type& statement, const C& context) const { std::stringstream ss; if(context.use_parentheses) { ss << '('; @@ -11230,7 +11226,7 @@ namespace sqlite_orm { { auto vectorSize = statement.vector.size(); for(decltype(vectorSize) index = 0; index < vectorSize; ++index) { - auto &value = statement.vector[index]; + auto& value = statement.vector[index]; ss << serialize(value, context); if(index < vectorSize - 1) { ss << ", "; @@ -11268,10 +11264,10 @@ namespace sqlite_orm { * @param filename database filename. * @param impl_ storage_impl head */ - storage_t(const std::string &filename, impl_type impl_) : + storage_t(const std::string& filename, impl_type impl_) : storage_base{filename, foreign_keys_count(impl_)}, impl(std::move(impl_)) {} - storage_t(const storage_t &other) : storage_base(other), impl(other.impl) {} + storage_t(const storage_t& other) : storage_base(other), impl(other.impl) {} protected: impl_type impl; @@ -11289,14 +11285,14 @@ namespace sqlite_orm { friend struct serializator_context_builder; template - void create_table(sqlite3 *db, const std::string &tableName, const I &tableImpl) { + void create_table(sqlite3* db, const std::string& tableName, const I& tableImpl) { std::stringstream ss; ss << "CREATE TABLE '" << tableName << "' ( "; auto columnsCount = tableImpl.table.columns_count; auto index = 0; using context_t = serializator_context; context_t context{this->impl}; - iterate_tuple(tableImpl.table.columns, [columnsCount, &index, &ss, &context](auto &c) { + iterate_tuple(tableImpl.table.columns, [columnsCount, &index, &ss, &context](auto& c) { ss << serialize(c, context); if(index < columnsCount - 1) { ss << ", "; @@ -11311,7 +11307,7 @@ namespace sqlite_orm { } template - void backup_table(sqlite3 *db, const I &tableImpl, const std::vector &columnsToIgnore) { + void backup_table(sqlite3* db, const I& tableImpl, const std::vector& columnsToIgnore) { // here we copy source table to another with a name with '_backup' suffix, but in case table with such // a name already exists we append suffix 1, then 2, etc until we find a free name.. @@ -11346,18 +11342,18 @@ namespace sqlite_orm { } template - auto &get_impl() const { + auto& get_impl() const { return this->impl.template get_impl(); } template - auto &get_impl() { + auto& get_impl() { return this->impl.template get_impl(); } public: template - view_t iterate(Args &&... args) { + view_t iterate(Args&&... args) { this->assert_mapped_type(); auto con = this->get_connection(); @@ -11372,7 +11368,7 @@ namespace sqlite_orm { * @example: storage.remove_all(where(in(&User::id, {5, 6, 7}))); - DELETE FROM users WHERE id IN (5, 6, 7) */ template - void remove_all(Args &&... args) { + void remove_all(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::remove_all(std::forward(args)...)); this->execute(statement); @@ -11397,7 +11393,7 @@ namespace sqlite_orm { * @param o object to be updated. */ template - void update(const O &o) { + void update(const O& o) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::update(std::ref(o))); this->execute(statement); @@ -11411,7 +11407,7 @@ namespace sqlite_orm { protected: template - std::string group_concat_internal(F O::*m, std::unique_ptr y, Args &&... args) { + std::string group_concat_internal(F O::*m, std::unique_ptr y, Args&&... args) { this->assert_mapped_type(); std::vector rows; if(y) { @@ -11436,7 +11432,7 @@ namespace sqlite_orm { * @example: storage.get_all(where(like(&User::name, "N%")), order_by(&User::id)); - SELECT * FROM users WHERE name LIKE 'N%' ORDER BY id */ template - auto get_all(Args &&... args) { + auto get_all(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all(std::forward(args)...)); return this->execute(statement); @@ -11451,7 +11447,7 @@ namespace sqlite_orm { * @example: storage.get_all>(where(like(&User::name, "N%")), order_by(&User::id)); - SELECT * FROM users WHERE name LIKE 'N%' ORDER BY id */ template - auto get_all(Args &&... args) { + auto get_all(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all(std::forward(args)...)); return this->execute(statement); @@ -11466,7 +11462,7 @@ namespace sqlite_orm { * @example: storage.get_all_pointer(where(length(&User::name) > 6)); - SELECT * FROM users WHERE LENGTH(name) > 6 */ template - auto get_all_pointer(Args &&... args) { + auto get_all_pointer(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all_pointer(std::forward(args)...)); return this->execute(statement); @@ -11481,7 +11477,7 @@ namespace sqlite_orm { * @example: storage.get_all_pointer>(where(length(&User::name) > 6)); - SELECT * FROM users WHERE LENGTH(name) > 6 */ template - auto get_all_pointer(Args &&... args) { + auto get_all_pointer(Args&&... args) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::get_all_pointer(std::forward(args)...)); return this->execute(statement); @@ -11549,7 +11545,7 @@ namespace sqlite_orm { * @return Number of O object in table. */ template::type> - int count(Args &&... args) { + int count(Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::count(), std::forward(args)...); if(!rows.empty()) { @@ -11564,7 +11560,7 @@ namespace sqlite_orm { * @param m member pointer to class mapped to the storage. */ template - int count(F O::*m, Args &&... args) { + int count(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::count(m), std::forward(args)...); if(!rows.empty()) { @@ -11580,7 +11576,7 @@ namespace sqlite_orm { * @return average value from db. */ template - double avg(F O::*m, Args &&... args) { + double avg(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::avg(m), std::forward(args)...); if(!rows.empty()) { @@ -11605,7 +11601,7 @@ namespace sqlite_orm { class... Args, class Tuple = std::tuple, typename sfinae = typename std::enable_if::value >= 1>::type> - std::string group_concat(F O::*m, Args &&... args) { + std::string group_concat(F O::*m, Args&&... args) { return this->group_concat_internal(m, {}, std::forward(args)...); } @@ -11615,14 +11611,14 @@ namespace sqlite_orm { * @return group_concat query result. */ template - std::string group_concat(F O::*m, std::string y, Args &&... args) { + std::string group_concat(F O::*m, std::string y, Args&&... args) { return this->group_concat_internal(m, std::make_unique(move(y)), std::forward(args)...); } template - std::string group_concat(F O::*m, const char *y, Args &&... args) { + std::string group_concat(F O::*m, const char* y, Args&&... args) { std::unique_ptr str; if(y) { str = std::make_unique(y); @@ -11638,7 +11634,7 @@ namespace sqlite_orm { * @return std::unique_ptr with max value or null if sqlite engine returned null. */ template::type> - std::unique_ptr max(F O::*m, Args &&... args) { + std::unique_ptr max(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::max(m), std::forward(args)...); if(!rows.empty()) { @@ -11654,7 +11650,7 @@ namespace sqlite_orm { * @return std::unique_ptr with min value or null if sqlite engine returned null. */ template::type> - std::unique_ptr min(F O::*m, Args &&... args) { + std::unique_ptr min(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::min(m), std::forward(args)...); if(!rows.empty()) { @@ -11670,7 +11666,7 @@ namespace sqlite_orm { * @return std::unique_ptr with sum value or null if sqlite engine returned null. */ template::type> - std::unique_ptr sum(F O::*m, Args &&... args) { + std::unique_ptr sum(F O::*m, Args&&... args) { this->assert_mapped_type(); std::vector> rows = this->select(sqlite_orm::sum(m), std::forward(args)...); @@ -11692,7 +11688,7 @@ namespace sqlite_orm { * https://www.sqlite.org/lang_aggfunc.html) */ template - double total(F O::*m, Args &&... args) { + double total(F O::*m, Args&&... args) { this->assert_mapped_type(); auto rows = this->select(sqlite_orm::total(m), std::forward(args)...); if(!rows.empty()) { @@ -11718,7 +11714,7 @@ namespace sqlite_orm { template typename std::enable_if::value, std::string>::type - dump(const T &preparedStatement) const { + dump(const T& preparedStatement) const { using context_t = serializator_context; context_t context{this->impl}; return serialize(preparedStatement.t, context); @@ -11730,13 +11726,13 @@ namespace sqlite_orm { */ template typename std::enable_if::value, std::string>::type - dump(const O &o) { - auto &tImpl = this->get_impl(); + dump(const O& o) { + auto& tImpl = this->get_impl(); std::stringstream ss; ss << "{ "; using pair = std::pair; std::vector pairs; - tImpl.table.for_each_column([&pairs, &o](auto &c) { + tImpl.table.for_each_column([&pairs, &o](auto& c) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; pair p{c.name, std::string()}; @@ -11750,7 +11746,7 @@ namespace sqlite_orm { pairs.push_back(move(p)); }); for(size_t i = 0; i < pairs.size(); ++i) { - auto &p = pairs[i]; + auto& p = pairs[i]; ss << p.first << " : '" << p.second << "'"; if(i < pairs.size() - 1) { ss << ", "; @@ -11768,7 +11764,7 @@ namespace sqlite_orm { * id and creates own one. */ template - void replace(const O &o) { + void replace(const O& o) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::replace(std::ref(o))); this->execute(statement); @@ -11787,7 +11783,7 @@ namespace sqlite_orm { } template - int insert(const O &o, columns_t cols) { + int insert(const O& o, columns_t cols) { constexpr const size_t colsCount = std::tuple_size>::value; static_assert(colsCount > 0, "Use insert or replace with 1 argument instead"); this->assert_mapped_type(); @@ -11801,7 +11797,7 @@ namespace sqlite_orm { * @return id of just created object. */ template - int insert(const O &o) { + int insert(const O& o) { this->assert_mapped_type(); auto statement = this->prepare(sqlite_orm::insert(std::ref(o))); return int(this->execute(statement)); @@ -11826,7 +11822,7 @@ namespace sqlite_orm { template void rename_table(std::string name) { this->assert_mapped_type(); - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); tImpl.table.name = move(name); } @@ -11837,15 +11833,15 @@ namespace sqlite_orm { * any SQLite queries */ template - const std::string &tablename() const { + const std::string& tablename() const { this->assert_mapped_type(); - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); return tImpl.table.name; } protected: template - sync_schema_result sync_table(const storage_impl, Tss...> &tableImpl, sqlite3 *db, bool) { + sync_schema_result sync_table(const storage_impl, Tss...>& tableImpl, sqlite3* db, bool) { auto res = sync_schema_result::already_in_sync; using context_t = serializator_context; context_t context{this->impl}; @@ -11856,7 +11852,7 @@ namespace sqlite_orm { template sync_schema_result - sync_table(const storage_impl, Tss...> &tImpl, sqlite3 *db, bool preserve) { + sync_table(const storage_impl, Tss...>& tImpl, sqlite3* db, bool preserve) { auto res = sync_schema_result::already_in_sync; auto schema_stat = tImpl.schema_status(db, preserve); @@ -11876,7 +11872,7 @@ namespace sqlite_orm { auto dbTableInfo = tImpl.get_table_info(tImpl.table.name, db); // this vector will contain pointers to columns that gotta be added.. - std::vector columnsToAdd; + std::vector columnsToAdd; tImpl.get_remove_add_columns(columnsToAdd, storageTableInfo, dbTableInfo); @@ -11913,7 +11909,7 @@ namespace sqlite_orm { template prepared_statement_t prepare_impl(S statement) { auto con = this->get_connection(); - sqlite3_stmt *stmt; + sqlite3_stmt* stmt; auto db = con.get(); using context_t = serializator_context; context_t context{this->impl}; @@ -11960,7 +11956,7 @@ namespace sqlite_orm { auto con = this->get_connection(); std::map result; auto db = con.get(); - this->impl.for_each([&result, db, preserve, this](auto &tableImpl) { + this->impl.for_each([&result, db, preserve, this](auto& tableImpl) { auto res = this->sync_table(tableImpl, db, preserve); result.insert({tableImpl.table.name, res}); }); @@ -11987,7 +11983,7 @@ namespace sqlite_orm { * Note: table can be not mapped to a storage * @return true if table with a given name exists in db, false otherwise. */ - bool table_exists(const std::string &tableName) { + bool table_exists(const std::string& tableName) { auto con = this->get_connection(); return this->impl.table_exists(tableName, con.get()); } @@ -12085,7 +12081,7 @@ namespace sqlite_orm { } template - int64 execute(const prepared_statement_t> &statement) { + int64 execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; @@ -12093,13 +12089,13 @@ namespace sqlite_orm { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; - auto &tImpl = this->get_impl(); - auto &o = statement.t.obj; + auto& tImpl = this->get_impl(); + auto& o = statement.t.obj; sqlite3_reset(stmt); - iterate_tuple(statement.t.columns.columns, [&o, &index, &stmt, &tImpl, db](auto &m) { + iterate_tuple(statement.t.columns.columns, [&o, &index, &stmt, &tImpl, db](auto& m) { using column_type = typename std::decay::type; using field_type = typename column_result_t::type; - const field_type *value = tImpl.table.template get_object_field_pointer(o, m); + const field_type* value = tImpl.table.template get_object_field_pointer(o, m); if(SQLITE_OK != statement_binder().bind(stmt, index++, *value)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), sqlite3_errmsg(db)); @@ -12110,19 +12106,19 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_type::object_type; - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); auto index = 1; auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; sqlite3_reset(stmt); for(auto it = statement.t.range.first; it != statement.t.range.second; ++it) { - auto &o = *it; - tImpl.table.for_each_column([&o, &index, &stmt, db](auto &c) { + auto& o = *it; + tImpl.table.for_each_column([&o, &index, &stmt, db](auto& c) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; if(c.member_pointer) { @@ -12146,7 +12142,7 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_type::object_type; @@ -12154,11 +12150,11 @@ namespace sqlite_orm { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); sqlite3_reset(stmt); for(auto it = statement.t.range.first; it != statement.t.range.second; ++it) { - auto &o = *it; - tImpl.table.for_each_column([&o, &index, &stmt, db](auto &c) { + auto& o = *it; + tImpl.table.for_each_column([&o, &index, &stmt, db](auto& c) { if(!c.template has>()) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; @@ -12185,7 +12181,7 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; @@ -12193,10 +12189,10 @@ namespace sqlite_orm { auto db = con.get(); auto stmt = statement.stmt; auto index = 1; - auto &o = get_object(statement.t); - auto &tImpl = this->get_impl(); + auto& o = get_object(statement.t); + auto& tImpl = this->get_impl(); sqlite3_reset(stmt); - tImpl.table.for_each_column([&o, &index, &stmt, db](auto &c) { + tImpl.table.for_each_column([&o, &index, &stmt, db](auto& c) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; if(c.member_pointer) { @@ -12217,7 +12213,7 @@ namespace sqlite_orm { } template - int64 execute(const prepared_statement_t> &statement) { + int64 execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; @@ -12225,11 +12221,11 @@ namespace sqlite_orm { auto db = con.get(); auto stmt = statement.stmt; auto index = 1; - auto &tImpl = this->get_impl(); - auto &o = get_object(statement.t); + auto& tImpl = this->get_impl(); + auto& o = get_object(statement.t); auto compositeKeyColumnNames = tImpl.table.composite_key_columns_names(); sqlite3_reset(stmt); - tImpl.table.for_each_column([&o, &index, &stmt, &tImpl, &compositeKeyColumnNames, db](auto &c) { + tImpl.table.for_each_column([&o, &index, &stmt, &tImpl, &compositeKeyColumnNames, db](auto& c) { if(tImpl.table._without_rowid || !c.template has>()) { auto it = std::find(compositeKeyColumnNames.begin(), compositeKeyColumnNames.end(), c.name); if(it == compositeKeyColumnNames.end()) { @@ -12259,13 +12255,13 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -12276,18 +12272,18 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using object_type = typename expression_object_type::type; auto con = this->get_connection(); auto db = con.get(); - auto &tImpl = this->get_impl(); + auto& tImpl = this->get_impl(); auto stmt = statement.stmt; auto index = 1; - auto &o = get_object(statement.t); + auto& o = get_object(statement.t); sqlite3_reset(stmt); - tImpl.table.for_each_column([&o, stmt, &index, db](auto &c) { + tImpl.table.for_each_column([&o, stmt, &index, db](auto& c) { if(!c.template has>()) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; @@ -12309,7 +12305,7 @@ namespace sqlite_orm { } } }); - tImpl.table.for_each_column([&o, stmt, &index, db](auto &c) { + tImpl.table.for_each_column([&o, stmt, &index, db](auto& c) { if(c.template has>()) { using column_type = typename std::decay::type; using field_type = typename column_type::field_type; @@ -12334,14 +12330,14 @@ namespace sqlite_orm { } template - std::unique_ptr execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + std::unique_ptr execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -12368,14 +12364,14 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template - std::optional execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + std::optional execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -12402,14 +12398,14 @@ namespace sqlite_orm { #endif // SQLITE_ORM_OPTIONAL_SUPPORTED template - T execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + T execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.ids, [stmt, &index, db](auto &v) { + iterate_ast(statement.t.ids, [stmt, &index, db](auto& v) { using field_type = typename std::decay::type; if(SQLITE_OK != statement_binder().bind(stmt, index++, v)) { throw std::system_error(std::error_code(sqlite3_errcode(db), get_sqlite_error_category()), @@ -12435,13 +12431,13 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t> &statement) { + void execute(const prepared_statement_t>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t.conditions, [stmt, &index, db](auto &node) { + iterate_ast(statement.t.conditions, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12453,14 +12449,14 @@ namespace sqlite_orm { } template - void execute(const prepared_statement_t, Wargs...>> &statement) { + void execute(const prepared_statement_t, Wargs...>>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_tuple(statement.t.set.assigns, [&index, stmt, db](auto &setArg) { - iterate_ast(setArg, [&index, stmt, db](auto &node) { + iterate_tuple(statement.t.set.assigns, [&index, stmt, db](auto& setArg) { + iterate_ast(setArg, [&index, stmt, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12469,7 +12465,7 @@ namespace sqlite_orm { } }); }); - iterate_ast(statement.t.conditions, [stmt, &index, db](auto &node) { + iterate_ast(statement.t.conditions, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12481,13 +12477,13 @@ namespace sqlite_orm { } template::type> - std::vector execute(const prepared_statement_t> &statement) { + std::vector execute(const prepared_statement_t>& statement) { auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12521,14 +12517,14 @@ namespace sqlite_orm { } template - R execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + R execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12559,14 +12555,14 @@ namespace sqlite_orm { } template - R execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + R execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12598,14 +12594,14 @@ namespace sqlite_orm { #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template - R execute(const prepared_statement_t> &statement) { - auto &tImpl = this->get_impl(); + R execute(const prepared_statement_t>& statement) { + auto& tImpl = this->get_impl(); auto con = this->get_connection(); auto db = con.get(); auto stmt = statement.stmt; auto index = 1; sqlite3_reset(stmt); - iterate_ast(statement.t, [stmt, &index, db](auto &node) { + iterate_ast(statement.t, [stmt, &index, db](auto& node) { using node_type = typename std::decay::type; conditional_binder> binder{stmt, index}; if(SQLITE_OK != binder(node)) { @@ -12645,7 +12641,7 @@ namespace sqlite_orm { } template - internal::storage_t make_storage(const std::string &filename, Ts... tables) { + internal::storage_t make_storage(const std::string& filename, Ts... tables) { return {filename, internal::storage_impl(tables...)}; } @@ -12970,131 +12966,131 @@ __pragma(pop_macro("min")) namespace sqlite_orm { template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return std::get(statement.t.range); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } #endif // SQLITE_ORM_OPTIONAL_SUPPORTED template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { return internal::get_ref(std::get(statement.t.ids)); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for update statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for update statement"); return internal::get_ref(statement.t.obj); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for replace statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for replace statement"); return internal::get_ref(statement.t.obj); } template - auto &get(internal::prepared_statement_t> &statement) { + auto& get(internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t> &statement) { + const auto& get(const internal::prepared_statement_t>& statement) { static_assert(N == 0, "get<> works only with 0 argument for insert statement"); return internal::get_ref(statement.t.obj); } template - const auto &get(const internal::prepared_statement_t &statement) { + const auto& get(const internal::prepared_statement_t& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using node_tuple = typename internal::node_tuple::type; using bind_tuple = typename internal::bindable_filter::type; using result_tupe = typename std::tuple_element::type; - const result_tupe *result = nullptr; + const result_tupe* result = nullptr; auto index = -1; - internal::iterate_ast(statement.t, [&result, &index](auto &node) { + internal::iterate_ast(statement.t, [&result, &index](auto& node) { using node_type = typename std::decay::type; if(internal::is_bindable::value) { ++index; } if(index == N) { - internal::static_if{}>([](auto &r, auto &n) { + internal::static_if{}>([](auto& r, auto& n) { r = const_cast::type>(&n); })(result, node); } @@ -13103,21 +13099,21 @@ namespace sqlite_orm { } template - auto &get(internal::prepared_statement_t &statement) { + auto& get(internal::prepared_statement_t& statement) { using statement_type = typename std::decay::type; using expression_type = typename statement_type::expression_type; using node_tuple = typename internal::node_tuple::type; using bind_tuple = typename internal::bindable_filter::type; using result_tupe = typename std::tuple_element::type; - result_tupe *result = nullptr; + result_tupe* result = nullptr; auto index = -1; - internal::iterate_ast(statement.t, [&result, &index](auto &node) { + internal::iterate_ast(statement.t, [&result, &index](auto& node) { using node_type = typename std::decay::type; if(internal::is_bindable::value) { ++index; } if(index == N) { - internal::static_if{}>([](auto &r, auto &n) { + internal::static_if{}>([](auto& r, auto& n) { r = const_cast::type>(&n); })(result, node); } diff --git a/tests/backup_tests.cpp b/tests/backup_tests.cpp index e20c68b38..07f9bfd5f 100644 --- a/tests/backup_tests.cpp +++ b/tests/backup_tests.cpp @@ -10,7 +10,7 @@ namespace BackupTests { std::string name; }; - bool operator==(const User &lhs, const User &rhs) { + bool operator==(const User& lhs, const User& rhs) { return lhs.id == rhs.id && lhs.name == rhs.name; } @@ -20,7 +20,7 @@ namespace BackupTests { std::string abilities; }; - inline auto initStorageMarvel(const std::string &path) { + inline auto initStorageMarvel(const std::string& path) { using namespace sqlite_orm; auto storage = make_storage(path, make_table("marvel", @@ -35,7 +35,7 @@ TEST_CASE("backup") { using namespace BackupTests; using Catch::Matchers::UnorderedEquals; const std::string usersTableName = "users"; - auto makeStorage = [&usersTableName](const std::string &filename) { + auto makeStorage = [&usersTableName](const std::string& filename) { return make_storage( filename, make_table(usersTableName, make_column("id", &User::id, primary_key()), make_column("name", &User::name))); diff --git a/tests/constraints/default.cpp b/tests/constraints/default.cpp index 07617c34b..814cbcc8b 100644 --- a/tests/constraints/default.cpp +++ b/tests/constraints/default.cpp @@ -33,7 +33,7 @@ TEST_CASE("Default value") { auto emailDefault = emailColumn.default_value(); REQUIRE(emailDefault); - auto &emailDefaultString = *emailDefault; + auto& emailDefaultString = *emailDefault; REQUIRE(emailDefaultString == "'example@email.com'"); } diff --git a/tests/constraints/unique.cpp b/tests/constraints/unique.cpp index f207d70c0..cba98d686 100644 --- a/tests/constraints/unique.cpp +++ b/tests/constraints/unique.cpp @@ -41,7 +41,7 @@ TEST_CASE("Unique") { try { storage.insert(Contact{0, "Johnny", "Doe", "john.doe@gmail.com"}); REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { //.. } catch(...) { REQUIRE(false); @@ -52,7 +52,7 @@ TEST_CASE("Unique") { try { storage.insert(Shape{0, "red", "green"}); REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { //.. } catch(...) { REQUIRE(false); diff --git a/tests/core_functions_tests.cpp b/tests/core_functions_tests.cpp index 0ea38cae0..f708db24c 100644 --- a/tests/core_functions_tests.cpp +++ b/tests/core_functions_tests.cpp @@ -53,7 +53,7 @@ TEST_CASE("zeroblob") { { auto rows = storage.select(zeroblob(10)); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(row.size() == 10); std::vector expectedValue(10); std::fill(expectedValue.begin(), expectedValue.end(), 0); @@ -64,7 +64,7 @@ TEST_CASE("zeroblob") { auto rows = storage.select(zeroblob(&Test::value)); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(row.size() == 100); std::vector expectedValue(100); std::fill(expectedValue.begin(), expectedValue.end(), 0); @@ -250,7 +250,7 @@ TEST_CASE("instr") { }; struct sw : alias_tag { - static const std::string &get() { + static const std::string& get() { static const std::string res = "sw"; return res; } @@ -315,7 +315,7 @@ namespace replace_func_local { std::string phone; }; - bool operator==(const Contact &lhs, const Contact &rhs) { + bool operator==(const Contact& lhs, const Contact& rhs) { return lhs.id == rhs.id && lhs.firstName == rhs.firstName && lhs.lastName == rhs.lastName && lhs.phone == rhs.phone; } diff --git a/tests/datetime_function_tests.cpp b/tests/datetime_function_tests.cpp index f360c3204..4cc113e15 100644 --- a/tests/datetime_function_tests.cpp +++ b/tests/datetime_function_tests.cpp @@ -24,7 +24,7 @@ TEST_CASE("julianday") { auto storage = make_storage({}, make_table("test", make_column("text", &Test::text))); storage.sync_schema(); - auto singleTestCase = [&storage](const std::string &arg, double expected) { + auto singleTestCase = [&storage](const std::string& arg, double expected) { { auto rows = storage.select(julianday(arg)); REQUIRE(rows.size() == 1); diff --git a/tests/dynamic_order_by.cpp b/tests/dynamic_order_by.cpp index 0091ceab3..1a98594e8 100644 --- a/tests/dynamic_order_by.cpp +++ b/tests/dynamic_order_by.cpp @@ -116,7 +116,7 @@ TEST_CASE("Dynamic order by") { auto rows = storage.get_all(orderBy); REQUIRE(rows.size() == 4); for(auto i = 0; i < int(rows.size()); ++i) { - auto &row = rows[i]; + auto& row = rows[i]; REQUIRE(row.id == expectedIds[i]); } orderBy.clear(); diff --git a/tests/get_all_custom_containers.cpp b/tests/get_all_custom_containers.cpp index 592be9028..56104c7e5 100644 --- a/tests/get_all_custom_containers.cpp +++ b/tests/get_all_custom_containers.cpp @@ -13,11 +13,11 @@ struct User { struct Comparator { - bool operator()(const User &lhs, const User &rhs) const { + bool operator()(const User& lhs, const User& rhs) const { return lhs.id == rhs.id && lhs.name == rhs.name; } - bool operator()(const std::unique_ptr &lhs, const User &rhs) const { + bool operator()(const std::unique_ptr& lhs, const User& rhs) const { if(lhs) { return this->operator()(*lhs, rhs); } else { @@ -25,7 +25,7 @@ struct Comparator { } } #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED - bool operator()(const std::optional &lhs, const User &rhs) const { + bool operator()(const std::optional& lhs, const User& rhs) const { if(lhs.has_value()) { return this->operator()(*lhs, rhs); } else { @@ -36,16 +36,16 @@ struct Comparator { }; struct Tester { - const std::vector &expected; + const std::vector& expected; template - void testContainer(const T &users) const { + void testContainer(const T& users) const { REQUIRE(std::equal(users.begin(), users.end(), this->expected.begin(), this->expected.end(), Comparator{})); static_assert(std::is_same::value, ""); } template - void testPreparedStatement(S &storage, const T &statement) const { + void testPreparedStatement(S& storage, const T& statement) const { this->testContainer(storage.execute(statement)); } }; diff --git a/tests/operators/arithmetic_operators.cpp b/tests/operators/arithmetic_operators.cpp index 85318eacb..07e7c42d1 100644 --- a/tests/operators/arithmetic_operators.cpp +++ b/tests/operators/arithmetic_operators.cpp @@ -23,22 +23,22 @@ TEST_CASE("Arithmetic operators") { "Upside down", }; auto number = 10; - for(auto &name: names) { + for(auto& name: names) { storage.insert(Object{name, int(name.length()), number}); } { // + auto rows = storage.select(c(&Object::nameLen) + 1000); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; - auto &name = names[i]; + auto& row = rows[i]; + auto& name = names[i]; REQUIRE(int(row) == name.length() + 1000); } } { // + auto rows = storage.select(columns(c(&Object::nameLen) + 1000)); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; - auto &name = names[i]; + auto& row = rows[i]; + auto& name = names[i]; REQUIRE(int(std::get<0>(row)) == name.length() + 1000); } } @@ -46,8 +46,8 @@ TEST_CASE("Arithmetic operators") { std::string suffix = "ototo"; auto rows = storage.select(c(&Object::name) || suffix); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; - auto &name = names[i]; + auto& row = rows[i]; + auto& name = names[i]; REQUIRE(row == name + suffix); } } @@ -55,8 +55,8 @@ TEST_CASE("Arithmetic operators") { std::string suffix = "ototo"; auto rows = storage.select(columns(conc(&Object::name, suffix))); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; - auto &name = names[i]; + auto& row = rows[i]; + auto& name = names[i]; REQUIRE(std::get<0>(row) == name + suffix); } } @@ -92,8 +92,8 @@ TEST_CASE("Arithmetic operators") { c(&Object::nameLen) / 2)); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; - auto &name = names[i]; + auto& row = rows[i]; + auto& name = names[i]; REQUIRE(std::get<0>(row) == name + suffix); REQUIRE(std::get<1>(row) == std::get<0>(row)); REQUIRE(std::get<2>(row) == std::get<1>(row)); @@ -105,7 +105,7 @@ TEST_CASE("Arithmetic operators") { REQUIRE(std::get<6>(row) == std::get<5>(row)); REQUIRE(std::get<7>(row) == std::get<6>(row)); { - auto &rowValue = std::get<8>(row); + auto& rowValue = std::get<8>(row); REQUIRE(rowValue == int(name.length()) + 1000); } @@ -138,8 +138,8 @@ TEST_CASE("Arithmetic operators") { c(&Object::nameLen) % c(&Object::number), c(&Object::nameLen) % 5)); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; - auto &name = names[i]; + auto& row = rows[i]; + auto& name = names[i]; REQUIRE(std::get<0>(row) == static_cast(name.length()) % number); REQUIRE(std::get<1>(row) == std::get<0>(row)); REQUIRE(std::get<2>(row) == std::get<1>(row)); diff --git a/tests/operators/cast.cpp b/tests/operators/cast.cpp index 94bd158ec..a214de379 100644 --- a/tests/operators/cast.cpp +++ b/tests/operators/cast.cpp @@ -22,14 +22,14 @@ TEST_CASE("Cast") { { auto rows = storage.select(columns(cast(&Student::scoreFloat), cast(&Student::scoreString))); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(std::get<0>(row) == 10); REQUIRE(std::get<1>(row) == 14); } { auto rows = storage.select(cast(5)); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(row == "5"); } } diff --git a/tests/operators/glob.cpp b/tests/operators/glob.cpp index 7b461b892..a10bace09 100644 --- a/tests/operators/glob.cpp +++ b/tests/operators/glob.cpp @@ -40,9 +40,9 @@ TEST_CASE("Glob") { storage.replace_range(employees.begin(), employees.end()); } - auto expectIds = [](const std::vector &employees, const std::vector ids) { + auto expectIds = [](const std::vector& employees, const std::vector ids) { for(auto expectedId: ids) { - REQUIRE(find_if(employees.begin(), employees.end(), [expectedId](auto &employee) { + REQUIRE(find_if(employees.begin(), employees.end(), [expectedId](auto& employee) { return employee.id == expectedId; }) != employees.end()); } diff --git a/tests/pragma_tests.cpp b/tests/pragma_tests.cpp index acec737ad..cf8ad92ff 100644 --- a/tests/pragma_tests.cpp +++ b/tests/pragma_tests.cpp @@ -9,7 +9,7 @@ TEST_CASE("Journal mode") { ::remove(filename); auto storage = make_storage(filename); auto storageCopy = storage; - decltype(storage) *stor = nullptr; + decltype(storage)* stor = nullptr; SECTION("Storage as is") { stor = &storage; }; @@ -63,7 +63,7 @@ TEST_CASE("Synchronous") { try { storage.pragma.synchronous(newValue); throw std::runtime_error("Must not fire"); - } catch(const std::system_error &) { + } catch(const std::system_error&) { // Safety level may not be changed inside a transaction REQUIRE(storage.pragma.synchronous() == value); } diff --git a/tests/prepared_statement_tests/get.cpp b/tests/prepared_statement_tests/get.cpp index 96a91313d..e2b7e7566 100644 --- a/tests/prepared_statement_tests/get.cpp +++ b/tests/prepared_statement_tests/get.cpp @@ -75,7 +75,7 @@ TEST_CASE("Prepared get") { auto user = storage.execute(statement); std::ignore = user; REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { REQUIRE(true); } } @@ -102,7 +102,7 @@ TEST_CASE("Prepared get") { try { auto user = storage.execute(statement); REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { //.. } } @@ -110,8 +110,8 @@ TEST_CASE("Prepared get") { { storage.replace(Visit{1, /*userId*/ 2, 1000}); auto statement = storage.prepare(get(2, 1)); - std::ignore = get<0>(static_cast(statement)); - std::ignore = get<1>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); + std::ignore = get<1>(static_cast(statement)); REQUIRE(get<0>(statement) == 2); REQUIRE(get<1>(statement) == 1); { diff --git a/tests/prepared_statement_tests/get_optional.cpp b/tests/prepared_statement_tests/get_optional.cpp index 8d6b750ec..78c4d3a16 100644 --- a/tests/prepared_statement_tests/get_optional.cpp +++ b/tests/prepared_statement_tests/get_optional.cpp @@ -41,7 +41,7 @@ TEST_CASE("Prepared get optional") { { auto statement = storage.prepare(get_optional(1)); REQUIRE(get<0>(statement) == 1); - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); testSerializing(statement); SECTION("nothing") { //.. @@ -100,8 +100,8 @@ TEST_CASE("Prepared get optional") { { storage.replace(Visit{1, /*userId*/ 2, 1000}); auto statement = storage.prepare(get_optional(2, 1)); - std::ignore = get<0>(static_cast(statement)); - std::ignore = get<1>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); + std::ignore = get<1>(static_cast(statement)); REQUIRE(get<0>(statement) == 2); REQUIRE(get<1>(statement) == 1); { diff --git a/tests/prepared_statement_tests/get_pointer.cpp b/tests/prepared_statement_tests/get_pointer.cpp index ecc946ba9..b71c31386 100644 --- a/tests/prepared_statement_tests/get_pointer.cpp +++ b/tests/prepared_statement_tests/get_pointer.cpp @@ -40,7 +40,7 @@ TEST_CASE("Prepared get pointer") { { auto statement = storage.prepare(get_pointer(1)); REQUIRE(get<0>(statement) == 1); - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); testSerializing(statement); SECTION("nothing") { //.. @@ -99,8 +99,8 @@ TEST_CASE("Prepared get pointer") { { storage.replace(Visit{1, /*userId*/ 2, 1000}); auto statement = storage.prepare(get_pointer(2, 1)); - std::ignore = get<0>(static_cast(statement)); - std::ignore = get<1>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); + std::ignore = get<1>(static_cast(statement)); REQUIRE(get<0>(statement) == 2); REQUIRE(get<1>(statement) == 1); { diff --git a/tests/prepared_statement_tests/insert.cpp b/tests/prepared_statement_tests/insert.cpp index 6834d4193..1ceb72cc0 100644 --- a/tests/prepared_statement_tests/insert.cpp +++ b/tests/prepared_statement_tests/insert.cpp @@ -57,7 +57,7 @@ TEST_CASE("Prepared insert") { } REQUIRE(insertedId == 4); user.name = "Sia"; - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); REQUIRE(get<0>(statement) == user); REQUIRE(&get<0>(statement) == &user); insertedId = storage.execute(statement); diff --git a/tests/prepared_statement_tests/insert_explicit.cpp b/tests/prepared_statement_tests/insert_explicit.cpp index 062b949ab..b1f01ddcb 100644 --- a/tests/prepared_statement_tests/insert_explicit.cpp +++ b/tests/prepared_statement_tests/insert_explicit.cpp @@ -41,7 +41,7 @@ TEST_CASE("Prepared insert explicit") { User user{5, "Eminem"}; SECTION("by ref") { auto statement = storage.prepare(insert(std::ref(user), columns(&User::id, &User::name))); - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); { auto insertedId = storage.execute(statement); REQUIRE(insertedId == user.id); @@ -69,7 +69,7 @@ TEST_CASE("Prepared insert explicit") { try { storage.execute(statement); REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { REQUIRE(storage.count(where(is_equal(&User::name, "Nate Dogg"))) == 0); } catch(...) { REQUIRE(false); diff --git a/tests/prepared_statement_tests/insert_range.cpp b/tests/prepared_statement_tests/insert_range.cpp index 6600e25d7..f154b13dc 100644 --- a/tests/prepared_statement_tests/insert_range.cpp +++ b/tests/prepared_statement_tests/insert_range.cpp @@ -47,7 +47,7 @@ TEST_CASE("Prepared insert range") { try { auto statement = storage.prepare(insert_range(users.begin(), users.end())); REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { //.. } } @@ -76,15 +76,15 @@ TEST_CASE("Prepared insert range") { decltype(users) otherUsers; otherUsers.push_back(User{6, "DJ Alban"}); otherUsers.push_back(User{7, "Flo Rida"}); - for(auto &user: otherUsers) { + for(auto& user: otherUsers) { expected.push_back(user); } get<0>(statement) = otherUsers.begin(); get<1>(statement) = otherUsers.end(); storage.execute(statement); - std::ignore = get<0>(static_cast(statement)); - std::ignore = get<1>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); + std::ignore = get<1>(static_cast(statement)); } auto rows = storage.get_all(); REQUIRE_THAT(rows, UnorderedEquals(expected)); diff --git a/tests/prepared_statement_tests/prepared_common.h b/tests/prepared_statement_tests/prepared_common.h index cbcfd0e00..576b9eecd 100644 --- a/tests/prepared_statement_tests/prepared_common.h +++ b/tests/prepared_statement_tests/prepared_common.h @@ -23,15 +23,15 @@ namespace PreparedStatementTests { std::string description; }; - inline bool operator==(const User &lhs, const User &rhs) { + inline bool operator==(const User& lhs, const User& rhs) { return lhs.id == rhs.id && lhs.name == rhs.name; } - inline bool operator!=(const User &lhs, const User &rhs) { + inline bool operator!=(const User& lhs, const User& rhs) { return !(lhs == rhs); } - inline void testSerializing(const sqlite_orm::internal::prepared_statement_base &statement) { + inline void testSerializing(const sqlite_orm::internal::prepared_statement_base& statement) { auto sql = statement.sql(); std::ignore = sql; #if SQLITE_VERSION_NUMBER >= 3014000 @@ -44,7 +44,7 @@ namespace PreparedStatementTests { #endif } - inline std::ostream &operator<<(std::ostream &os, const User &user) { + inline std::ostream& operator<<(std::ostream& os, const User& user) { return os << "{" << user.id << ", " << user.name << "}"; } } diff --git a/tests/prepared_statement_tests/remove.cpp b/tests/prepared_statement_tests/remove.cpp index 4341d5cde..438e97e3c 100644 --- a/tests/prepared_statement_tests/remove.cpp +++ b/tests/prepared_statement_tests/remove.cpp @@ -40,7 +40,7 @@ TEST_CASE("Prepared remove") { SECTION("by val") { { auto statement = storage.prepare(remove(1)); - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); REQUIRE(get<0>(statement) == 1); testSerializing(statement); storage.execute(statement); diff --git a/tests/prepared_statement_tests/replace.cpp b/tests/prepared_statement_tests/replace.cpp index b08291950..12fdfd193 100644 --- a/tests/prepared_statement_tests/replace.cpp +++ b/tests/prepared_statement_tests/replace.cpp @@ -47,7 +47,7 @@ TEST_CASE("Prepared replace") { auto statement = storage.prepare(replace(std::ref(user))); storage.execute(statement); - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); REQUIRE(user == get<0>(statement)); REQUIRE(&user == &get<0>(statement)); } diff --git a/tests/prepared_statement_tests/replace_range.cpp b/tests/prepared_statement_tests/replace_range.cpp index fc4bc08cf..6dbf27ef7 100644 --- a/tests/prepared_statement_tests/replace_range.cpp +++ b/tests/prepared_statement_tests/replace_range.cpp @@ -46,7 +46,7 @@ TEST_CASE("Prepared replace range") { try { auto statement = storage.prepare(replace_range(users.begin(), users.end())); REQUIRE(false); - } catch(const std::system_error &e) { + } catch(const std::system_error& e) { //.. } } diff --git a/tests/prepared_statement_tests/select.cpp b/tests/prepared_statement_tests/select.cpp index 97b98e1bf..4a248e843 100644 --- a/tests/prepared_statement_tests/select.cpp +++ b/tests/prepared_statement_tests/select.cpp @@ -82,7 +82,7 @@ REQUIRE(get<1>(statement) == 25); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == "ototo"); REQUIRE(get<1>(row) == 25); } @@ -92,7 +92,7 @@ str = storage.dump(statement); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == "Rock"); REQUIRE(get<1>(row) == -15); } @@ -109,7 +109,7 @@ str = storage.dump(statement); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == "ototo"); REQUIRE(get<1>(row) == 25); } @@ -122,7 +122,7 @@ str = storage.dump(statement); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == "Rock"); REQUIRE(get<1>(row) == -15); } @@ -138,7 +138,7 @@ REQUIRE(get<1>(statement) == 10); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == 5.0); REQUIRE(get<2>(row) == 3); } @@ -148,7 +148,7 @@ str = storage.dump(statement); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == 4.0); REQUIRE(get<2>(row) == 1); } @@ -166,7 +166,7 @@ str = storage.dump(statement); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == 5.0); REQUIRE(get<2>(row) == 3); } @@ -177,7 +177,7 @@ str = storage.dump(statement); { auto rows = storage.execute(statement); REQUIRE(rows.size() == 1); - auto &row = rows.front(); + auto& row = rows.front(); REQUIRE(get<0>(row) == 4.0); REQUIRE(get<2>(row) == 1); } diff --git a/tests/prepared_statement_tests/update.cpp b/tests/prepared_statement_tests/update.cpp index e9753a734..aa35409b3 100644 --- a/tests/prepared_statement_tests/update.cpp +++ b/tests/prepared_statement_tests/update.cpp @@ -41,7 +41,7 @@ TEST_CASE("Prepared update") { SECTION("by ref") { auto statement = storage.prepare(update(std::ref(user))); REQUIRE(get<0>(statement) == user); - std::ignore = get<0>(static_cast(statement)); + std::ignore = get<0>(static_cast(statement)); REQUIRE(&get<0>(statement) == &user); testSerializing(statement); SECTION("nothing") { diff --git a/tests/prepared_statement_tests/update_all.cpp b/tests/prepared_statement_tests/update_all.cpp index 00efd6c32..43829ef26 100644 --- a/tests/prepared_statement_tests/update_all.cpp +++ b/tests/prepared_statement_tests/update_all.cpp @@ -46,7 +46,7 @@ TEST_CASE("Prepared update all") { static_assert(std::tuple_size::value == 1, ""); { using Arg0 = std::tuple_element<0, SetBind>::type; - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); } REQUIRE(strcmp(get<0>(statement), "_") == 0); testSerializing(statement); diff --git a/tests/row_id.cpp b/tests/row_id.cpp index e5c49ce8c..7c3892371 100644 --- a/tests/row_id.cpp +++ b/tests/row_id.cpp @@ -29,7 +29,7 @@ TEST_CASE("Row id") { &SimpleTable::letter, &SimpleTable::desc)); for(size_t i = 0; i < rows.size(); ++i) { - auto &row = rows[i]; + auto& row = rows[i]; REQUIRE(std::get<0>(row) == std::get<1>(row)); REQUIRE(std::get<1>(row) == std::get<2>(row)); REQUIRE(std::get<2>(row) == static_cast(i + 1)); diff --git a/tests/select_asterisk.cpp b/tests/select_asterisk.cpp index aa973d466..a076c7737 100644 --- a/tests/select_asterisk.cpp +++ b/tests/select_asterisk.cpp @@ -13,7 +13,7 @@ TEST_CASE("select asterisk") { std::string address; // optional double salary; // optional - bool operator==(const Employee &other) const { + bool operator==(const Employee& other) const { return this->id == other.id && this->name == other.name && this->age == other.age && this->address == other.address && this->salary == other.salary; } diff --git a/tests/statement_serializator_tests/base_types.cpp b/tests/statement_serializator_tests/base_types.cpp index dbf9ff1db..5024802d0 100644 --- a/tests/statement_serializator_tests/base_types.cpp +++ b/tests/statement_serializator_tests/base_types.cpp @@ -18,7 +18,7 @@ TEST_CASE("statement_serializator base types") { } } SECTION("const char *") { - const char *str = "baby"; + const char* str = "baby"; SECTION("no question") { auto value = serialize(str, context); REQUIRE(value == "\'baby\'"); diff --git a/tests/statement_serializator_tests/column_names.cpp b/tests/statement_serializator_tests/column_names.cpp index 40fc3a7be..72e517e76 100644 --- a/tests/statement_serializator_tests/column_names.cpp +++ b/tests/statement_serializator_tests/column_names.cpp @@ -43,7 +43,7 @@ TEST_CASE("statement_serializator column names") { this->id = value; } - const std::string &getName() const { + const std::string& getName() const { return this->name; } diff --git a/tests/static_tests.cpp b/tests/static_tests.cpp index 6ae6bd1a9..8b0a78111 100644 --- a/tests/static_tests.cpp +++ b/tests/static_tests.cpp @@ -14,7 +14,7 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect object_type"); static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Incorrect getter_type"); static_assert(std::is_same::value, "Incorrect setter_type"); } @@ -24,7 +24,7 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect object_type"); static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Incorrect getter_type"); static_assert(std::is_same::value, "Incorrect setter_type"); } @@ -34,7 +34,7 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect object_type"); static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Incorrect getter_type"); static_assert(std::is_same::value, "Incorrect setter_type"); } @@ -44,8 +44,8 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect object_type"); static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); - static_assert(std::is_same::value, "Incorrect getter_type"); - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Incorrect getter_type"); + static_assert(std::is_same::value, "Incorrect setter_type"); } { @@ -54,8 +54,8 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect object_type"); static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); - static_assert(std::is_same::value, "Incorrect getter_type"); - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Incorrect getter_type"); + static_assert(std::is_same::value, "Incorrect setter_type"); } { @@ -65,7 +65,7 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); static_assert(std::is_same::value, "Incorrect getter_type"); - static_assert(std::is_same::value, "Incorrect setter_type"); + static_assert(std::is_same::value, "Incorrect setter_type"); } { using column_type = decltype(make_column("id", &User::setIdByRef, &User::getIdByValConst)); @@ -74,7 +74,7 @@ TEST_CASE("Column") { static_assert(std::is_same::value, "Incorrect field_type"); static_assert(std::is_same::value, "Incorrect member pointer type"); static_assert(std::is_same::value, "Incorrect getter_type"); - static_assert(std::is_same::value, "Incorrect setter_type"); + static_assert(std::is_same::value, "Incorrect setter_type"); } { using column_type = decltype(column(&Token::id)); @@ -106,23 +106,23 @@ TEST_CASE("Aggregate function return types") { return this->name; } - void setNameByConstRef(const std::string &name_) { + void setNameByConstRef(const std::string& name_) { this->name = name_; } - const int &getConstIdByRefConst() const { + const int& getConstIdByRefConst() const { return this->id; } - void setIdByRef(int &id_) { + void setIdByRef(int& id_) { this->id = id_; } - const std::string &getConstNameByRefConst() const { + const std::string& getConstNameByRefConst() const { return this->name; } - void setNameByRef(std::string &name_) { + void setNameByRef(std::string& name_) { this->name = std::move(name_); } }; diff --git a/tests/static_tests/is_bindable.cpp b/tests/static_tests/is_bindable.cpp index fe9169f81..b1c5c74ca 100644 --- a/tests/static_tests/is_bindable.cpp +++ b/tests/static_tests/is_bindable.cpp @@ -58,10 +58,10 @@ TEST_CASE("is_bindable") { bool falseCalled = false; auto dummy = 5; // for gcc compilation internal::static_if{}>( - [&trueCalled](int &) { + [&trueCalled](int&) { trueCalled = true; }, - [&falseCalled](int &) { + [&falseCalled](int&) { falseCalled = true; })(dummy); REQUIRE(!trueCalled); diff --git a/tests/static_tests/member_traits_tests.cpp b/tests/static_tests/member_traits_tests.cpp index 4a5a335c5..8477dd4dd 100644 --- a/tests/static_tests/member_traits_tests.cpp +++ b/tests/static_tests/member_traits_tests.cpp @@ -16,11 +16,11 @@ TEST_CASE("member_traits_tests") { struct User { int id; - const int &getIdByRefConst() const { + const int& getIdByRefConst() const { return this->id; } - const int &getIdByRef() { + const int& getIdByRef() { return this->id; } @@ -32,11 +32,11 @@ TEST_CASE("member_traits_tests") { this->id = id; } - void setIdByConstRef(const int &id) { + void setIdByConstRef(const int& id) { this->id = id; } - void setIdByRef(int &id) { + void setIdByRef(int& id) { this->id = id; } }; diff --git a/tests/static_tests/node_tuple.cpp b/tests/static_tests/node_tuple.cpp index e3fcb1069..46b2be6be 100644 --- a/tests/static_tests/node_tuple.cpp +++ b/tests/static_tests/node_tuple.cpp @@ -118,9 +118,9 @@ TEST_CASE("Node tuple") { auto c = is_equal("ototo", &User::name); using C = decltype(c); using Tuple = node_tuple::type; - using Expected = std::tuple; + using Expected = std::tuple; static_assert(is_same::value, "is_equal_t"); - static_assert(is_same::type, std::tuple>::value, ""); + static_assert(is_same::type, std::tuple>::value, ""); } { // 5 != 6.0f auto c = is_not_equal(5, 6.0f); @@ -201,7 +201,7 @@ TEST_CASE("Node tuple") { using Tuple = node_tuple::type; using Expected = std::tuple; @@ -226,7 +226,7 @@ TEST_CASE("Node tuple") { auto un = intersect(select(&User::name), select(&User::name, where(is_equal(&User::name, "Anny")))); using Union = decltype(un); using Tuple = node_tuple::type; - using Expected = std::tuple; + using Expected = std::tuple; static_assert(is_same::value, "intersect"); } } @@ -327,27 +327,27 @@ using NodeTuple = node_tuple; using ArgTuple = NodeTuple::arg_tuple; static_assert(is_same>::value, "arg_tuple"); using PatternTuple = NodeTuple::pattern_tuple; -static_assert(is_same>::value, "pattern_tuple"); +static_assert(is_same>::value, "pattern_tuple"); using EscapeTuple = NodeTuple::escape_tuple; static_assert(is_same>::value, "escape_tuple"); using Tuple = NodeTuple::type; static_assert(std::tuple_size::value == 2, "like(&User::name, \"S%\") size"); using Tuple0 = std::tuple_element<0, Tuple>::type; static_assert(is_same::value, "like(&User::name, \"S%\") type 0"); -static_assert(is_same>::value, "like(&User::name, \"S%\")"); +static_assert(is_same>::value, "like(&User::name, \"S%\")"); } { // like(&User::name, std::string("pattern"), "%") auto lk = like(&User::name, std::string("pattern"), "%"); using Like = decltype(lk); using NodeTuple = node_tuple::type; - using Expected = std::tuple; + using Expected = std::tuple; static_assert(is_same::value, "like(&User::name, std::string(\"pattern\"), \"%\")"); } { // like(&User::name, std::string("pattern")).escape("%") auto lk = like(&User::name, std::string("pattern")).escape("%"); using Like = decltype(lk); using NodeTuple = node_tuple::type; - using Expected = std::tuple; + using Expected = std::tuple; static_assert(is_same::value, "like(&User::name, std::string(\"pattern\")).escape(\"%\")"); } } @@ -355,7 +355,7 @@ static_assert(is_same>::v auto gl = glob(&User::name, "H*"); using Glob = decltype(gl); using Tuple = node_tuple::type; - static_assert(is_same>::value, "glob(&User::name, \"H*\")"); + static_assert(is_same>::value, "glob(&User::name, \"H*\")"); } { // between_t auto bet = between(&User::id, 10, 20); @@ -367,7 +367,7 @@ static_assert(is_same>::v auto sel = select(&User::name, where(is_equal(&User::name, "Mercury").collate("ototo"))); using Select = decltype(sel); using Tuple = node_tuple