#pragma once #include #include // std::move, std::forward #include "functional/cxx_optional.h" #include "functional/cxx_universal.h" #include "operators.h" namespace sqlite_orm { namespace internal { template struct and_condition_t; template struct or_condition_t; /** * Is not an operator but a result of c(...) function. Has operator= overloaded which returns assign_t */ template struct expression_t : condition_t { T value; expression_t(T value_) : value(std::move(value_)) {} template assign_t operator=(R r) const { return {this->value, std::move(r)}; } assign_t operator=(nullptr_t) const { return {this->value, nullptr}; } #ifdef SQLITE_ORM_OPTIONAL_SUPPORTED assign_t operator=(std::nullopt_t) const { return {this->value, std::nullopt}; } #endif template in_t in(Args... args) const { return {this->value, std::make_tuple(std::forward(args)...), false}; } template in_t not_in(Args... args) const { return {this->value, std::make_tuple(std::forward(args)...), true}; } template and_condition_t and_(R right) const { return {this->value, std::move(right)}; } template or_condition_t or_(R right) const { return {this->value, std::move(right)}; } }; template T get_from_expression(T value) { return std::move(value); } template T get_from_expression(expression_t expression) { return std::move(expression.value); } } /** * Public interface for syntax sugar for columns. Example: `where(c(&User::id) == 5)` or * `storage.update(set(c(&User::name) = "Dua Lipa")); */ template internal::expression_t c(T value) { return {std::move(value)}; } }