Skip to content

Commit

Permalink
Renamed quoted_function_builder::from() to quote()
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed Nov 23, 2023
1 parent cc7c4f6 commit 5377c09
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
24 changes: 12 additions & 12 deletions dev/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ namespace sqlite_orm {
/*
* Generator of a user-defined function call in a sql query expression.
*
* Use the string literal operator template `""_scalar.from()` to quote
* Use the string literal operator template `""_scalar.quote()` to quote
* a freestanding function, stateless lambda or function object.
*
* Calling the function captures the parameters in a `function_call` node.
Expand Down Expand Up @@ -419,7 +419,7 @@ namespace sqlite_orm {
*/
template<class F>
requires(std::is_function_v<std::remove_pointer_t<F>>)
[[nodiscard]] consteval auto from(F callable) const {
[[nodiscard]] consteval auto quote(F callable) const {
using Sig = function_signature_type_t<F>;
return quoted_scalar_function<F, Sig, N>{this->nme, std::move(callable)};
}
Expand All @@ -428,7 +428,7 @@ namespace sqlite_orm {
* From an overloaded freestanding function.
*/
template<orm_function_sig F>
[[nodiscard]] consteval auto from(F* callable) const {
[[nodiscard]] consteval auto quote(F* callable) const {
return quoted_scalar_function<F*, F, N>{this->nme, std::move(callable)};
}

Expand All @@ -437,7 +437,7 @@ namespace sqlite_orm {
*/
template<class F>
requires(orm_classic_function_object<F> && (stateless<F> || std::copy_constructible<F>))
[[nodiscard]] consteval auto from(F callable) const {
[[nodiscard]] consteval auto quote(F callable) const {
using Sig = function_signature_type_t<decltype(&F::operator())>;
// detect whether overloaded call operator can be picked using `Sig`
using call_operator_type = decltype(static_cast<Sig F::*>(&F::operator()));
Expand All @@ -449,7 +449,7 @@ namespace sqlite_orm {
*/
template<orm_function_sig Sig, class F>
requires((stateless<F> || std::copy_constructible<F>))
[[nodiscard]] consteval auto from(F callable) const {
[[nodiscard]] consteval auto quote(F callable) const {
// detect whether overloaded call operator can be picked using `Sig`
using call_operator_type = decltype(static_cast<Sig F::*>(&F::operator()));
return quoted_scalar_function<F, Sig, N>{this->nme, std::move(callable)};
Expand All @@ -460,7 +460,7 @@ namespace sqlite_orm {
*/
template<orm_classic_function_object F, class... Args>
requires(stateless<F> || std::copy_constructible<F>)
[[nodiscard]] consteval auto from(Args&&... constructorArgs) const {
[[nodiscard]] consteval auto quote(Args&&... constructorArgs) const {
using Sig = function_signature_type_t<decltype(&F::operator())>;
return quoted_scalar_function<F, Sig, N>{this->nme, std::forward<Args>(constructorArgs)...};
}
Expand All @@ -470,7 +470,7 @@ namespace sqlite_orm {
*/
template<orm_function_sig Sig, class F, class... Args>
requires((stateless<F> || std::copy_constructible<F>))
[[nodiscard]] consteval auto from(Args&&... constructorArgs) const {
[[nodiscard]] consteval auto quote(Args&&... constructorArgs) const {
// detect whether overloaded call operator can be picked using `Sig`
using call_operator_type = decltype(static_cast<Sig F::*>(&F::operator()));
return quoted_scalar_function<F, Sig, N>{this->nme, std::forward<Args>(constructorArgs)...};
Expand Down Expand Up @@ -505,17 +505,17 @@ namespace sqlite_orm {
*
* Examples:
* // freestanding function from a library
* constexpr auto clamp_int_f = "clamp_int"_scalar.from(std::clamp<int>);
* constexpr auto clamp_int_f = "clamp_int"_scalar.quote(std::clamp<int>);
* // stateless lambda
* constexpr auto is_fatal_error_f = "IS_FATAL_ERROR"_scalar.from([](unsigned long errcode) {
* constexpr auto is_fatal_error_f = "IS_FATAL_ERROR"_scalar.quote([](unsigned long errcode) {
* return errcode != 0;
* });
* // function object instance
* constexpr auto equal_to_int_f = "equal_to"_scalar.from(std::equal_to<int>{});
* constexpr auto equal_to_int_f = "equal_to"_scalar.quote(std::equal_to<int>{});
* // function object
* constexpr auto equal_to_int_2_f = "equal_to"_scalar.from<std::equal_to<int>>();
* constexpr auto equal_to_int_2_f = "equal_to"_scalar.quote<std::equal_to<int>>();
* // pick function object's template call operator
* constexpr auto equal_to_int_3_f = "equal_to"_scalar.from<bool(const int&, const int&) const>(std::equal_to<void>{});
* constexpr auto equal_to_int_3_f = "equal_to"_scalar.quote<bool(const int&, const int&) const>(std::equal_to<void>{});
*
* storage.create_scalar_function<clamp_int_f>();
* storage.create_scalar_function<is_fatal_error_f>();
Expand Down
24 changes: 12 additions & 12 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11336,7 +11336,7 @@ namespace sqlite_orm {
/*
* Generator of a user-defined function call in a sql query expression.
*
* Use the string literal operator template `""_scalar.from()` to quote
* Use the string literal operator template `""_scalar.quote()` to quote
* a freestanding function, stateless lambda or function object.
*
* Calling the function captures the parameters in a `function_call` node.
Expand Down Expand Up @@ -11405,7 +11405,7 @@ namespace sqlite_orm {
*/
template<class F>
requires(std::is_function_v<std::remove_pointer_t<F>>)
[[nodiscard]] consteval auto from(F callable) const {
[[nodiscard]] consteval auto quote(F callable) const {
using Sig = function_signature_type_t<F>;
return quoted_scalar_function<F, Sig, N>{this->nme, std::move(callable)};
}
Expand All @@ -11414,7 +11414,7 @@ namespace sqlite_orm {
* From an overloaded freestanding function.
*/
template<orm_function_sig F>
[[nodiscard]] consteval auto from(F* callable) const {
[[nodiscard]] consteval auto quote(F* callable) const {
return quoted_scalar_function<F*, F, N>{this->nme, std::move(callable)};
}

Expand All @@ -11423,7 +11423,7 @@ namespace sqlite_orm {
*/
template<class F>
requires(orm_classic_function_object<F> && (stateless<F> || std::copy_constructible<F>))
[[nodiscard]] consteval auto from(F callable) const {
[[nodiscard]] consteval auto quote(F callable) const {
using Sig = function_signature_type_t<decltype(&F::operator())>;
// detect whether overloaded call operator can be picked using `Sig`
using call_operator_type = decltype(static_cast<Sig F::*>(&F::operator()));
Expand All @@ -11435,7 +11435,7 @@ namespace sqlite_orm {
*/
template<orm_function_sig Sig, class F>
requires((stateless<F> || std::copy_constructible<F>))
[[nodiscard]] consteval auto from(F callable) const {
[[nodiscard]] consteval auto quote(F callable) const {
// detect whether overloaded call operator can be picked using `Sig`
using call_operator_type = decltype(static_cast<Sig F::*>(&F::operator()));
return quoted_scalar_function<F, Sig, N>{this->nme, std::move(callable)};
Expand All @@ -11446,7 +11446,7 @@ namespace sqlite_orm {
*/
template<orm_classic_function_object F, class... Args>
requires(stateless<F> || std::copy_constructible<F>)
[[nodiscard]] consteval auto from(Args&&... constructorArgs) const {
[[nodiscard]] consteval auto quote(Args&&... constructorArgs) const {
using Sig = function_signature_type_t<decltype(&F::operator())>;
return quoted_scalar_function<F, Sig, N>{this->nme, std::forward<Args>(constructorArgs)...};
}
Expand All @@ -11456,7 +11456,7 @@ namespace sqlite_orm {
*/
template<orm_function_sig Sig, class F, class... Args>
requires((stateless<F> || std::copy_constructible<F>))
[[nodiscard]] consteval auto from(Args&&... constructorArgs) const {
[[nodiscard]] consteval auto quote(Args&&... constructorArgs) const {
// detect whether overloaded call operator can be picked using `Sig`
using call_operator_type = decltype(static_cast<Sig F::*>(&F::operator()));
return quoted_scalar_function<F, Sig, N>{this->nme, std::forward<Args>(constructorArgs)...};
Expand Down Expand Up @@ -11491,17 +11491,17 @@ namespace sqlite_orm {
*
* Examples:
* // freestanding function from a library
* constexpr auto clamp_int_f = "clamp_int"_scalar.from(std::clamp<int>);
* constexpr auto clamp_int_f = "clamp_int"_scalar.quote(std::clamp<int>);
* // stateless lambda
* constexpr auto is_fatal_error_f = "IS_FATAL_ERROR"_scalar.from([](unsigned long errcode) {
* constexpr auto is_fatal_error_f = "IS_FATAL_ERROR"_scalar.quote([](unsigned long errcode) {
* return errcode != 0;
* });
* // function object instance
* constexpr auto equal_to_int_f = "equal_to"_scalar.from(std::equal_to<int>{});
* constexpr auto equal_to_int_f = "equal_to"_scalar.quote(std::equal_to<int>{});
* // function object
* constexpr auto equal_to_int_2_f = "equal_to"_scalar.from<std::equal_to<int>>();
* constexpr auto equal_to_int_2_f = "equal_to"_scalar.quote<std::equal_to<int>>();
* // pick function object's template call operator
* constexpr auto equal_to_int_3_f = "equal_to"_scalar.from<bool(const int&, const int&) const>(std::equal_to<void>{});
* constexpr auto equal_to_int_3_f = "equal_to"_scalar.quote<bool(const int&, const int&) const>(std::equal_to<void>{});
*
* storage.create_scalar_function<clamp_int_f>();
* storage.create_scalar_function<is_fatal_error_f>();
Expand Down
20 changes: 10 additions & 10 deletions tests/user_defined_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ TEST_CASE("generalized scalar udf") {
storage.sync_schema();

SECTION("freestanding function") {
constexpr auto err_fatal_error_f = "ERR_FATAL_ERROR"_scalar.from(ERR_FATAL_ERROR);
constexpr auto err_fatal_error_f = "ERR_FATAL_ERROR"_scalar.quote(ERR_FATAL_ERROR);
storage.create_scalar_function<err_fatal_error_f>();
{
auto rows = storage.select(err_fatal_error_f(1));
Expand All @@ -438,7 +438,7 @@ TEST_CASE("generalized scalar udf") {
}

SECTION("stateless lambda") {
constexpr auto is_fatal_error_f = "is_fatal_error"_scalar.from([](unsigned long errcode) {
constexpr auto is_fatal_error_f = "is_fatal_error"_scalar.quote([](unsigned long errcode) {
return errcode != 0;
});
storage.create_scalar_function<is_fatal_error_f>();
Expand All @@ -451,7 +451,7 @@ TEST_CASE("generalized scalar udf") {
}

SECTION("function object instance") {
constexpr auto equal_to_int_f = "equal_to"_scalar.from(std::equal_to<int>{});
constexpr auto equal_to_int_f = "equal_to"_scalar.quote(std::equal_to<int>{});
storage.create_scalar_function<equal_to_int_f>();
{
auto rows = storage.select(equal_to_int_f(1, 1));
Expand All @@ -462,7 +462,7 @@ TEST_CASE("generalized scalar udf") {
}

SECTION("explicit function object type") {
constexpr auto equal_to_int_f = "equal_to"_scalar.from<std::equal_to<int>>();
constexpr auto equal_to_int_f = "equal_to"_scalar.quote<std::equal_to<int>>();
storage.create_scalar_function<equal_to_int_f>();
{
auto rows = storage.select(equal_to_int_f(1, 1));
Expand All @@ -474,7 +474,7 @@ TEST_CASE("generalized scalar udf") {

SECTION("'transparent' function object instance") {
constexpr auto equal_to_int_f =
"equal_to"_scalar.from<bool(const int&, const int&) const>(std::equal_to<void>{});
"equal_to"_scalar.quote<bool(const int&, const int&) const>(std::equal_to<void>{});
storage.create_scalar_function<equal_to_int_f>();
{
auto rows = storage.select(equal_to_int_f(1, 1));
Expand All @@ -486,7 +486,7 @@ TEST_CASE("generalized scalar udf") {

SECTION("explicit 'transparent' function object type") {
constexpr auto equal_to_int_f =
"equal_to"_scalar.from<bool(const int&, const int&) const, std::equal_to<void>>();
"equal_to"_scalar.quote<bool(const int&, const int&) const, std::equal_to<void>>();
storage.create_scalar_function<equal_to_int_f>();
{
auto rows = storage.select(equal_to_int_f(1, 1));
Expand All @@ -497,7 +497,7 @@ TEST_CASE("generalized scalar udf") {
}

SECTION("specialized template function") {
constexpr auto clamp_int_f = "clamp_int"_scalar.from(std::clamp<int>);
constexpr auto clamp_int_f = "clamp_int"_scalar.quote(std::clamp<int>);
storage.create_scalar_function<clamp_int_f>();
{
auto rows = storage.select(clamp_int_f(0, 1, 1));
Expand All @@ -509,7 +509,7 @@ TEST_CASE("generalized scalar udf") {

SECTION("overloaded template function") {
constexpr auto clamp_int_f =
"clamp_int"_scalar.from<const int&(const int&, const int&, const int&)>(std::clamp);
"clamp_int"_scalar.quote<const int&(const int&, const int&, const int&)>(std::clamp);
storage.create_scalar_function<clamp_int_f>();
{
auto rows = storage.select(clamp_int_f(0, 1, 1));
Expand All @@ -520,7 +520,7 @@ TEST_CASE("generalized scalar udf") {
}

SECTION("non-copyable function object") {
constexpr auto idfunc_f = "idfunc"_scalar.from<noncopyable_scalar>();
constexpr auto idfunc_f = "idfunc"_scalar.quote<noncopyable_scalar>();
storage.create_scalar_function<idfunc_f>();
{
auto rows = storage.select(idfunc_f(1));
Expand All @@ -531,7 +531,7 @@ TEST_CASE("generalized scalar udf") {
}

SECTION("stateful function object") {
constexpr auto offset0_f = "offset0"_scalar.from(offset0);
constexpr auto offset0_f = "offset0"_scalar.quote(offset0);
storage.create_scalar_function<offset0_f>();
{
auto rows = storage.select(columns(offset0_f(1), offset0_f(1)));
Expand Down

0 comments on commit 5377c09

Please sign in to comment.