This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
forked from fnc12/sqlite_orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed and and or operators for expression
- Loading branch information
Showing
11 changed files
with
323 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "operators.h" | ||
|
||
namespace sqlite_orm { | ||
|
||
namespace internal { | ||
|
||
template<class L, class R> | ||
struct and_condition_t; | ||
|
||
template<class L, class R> | ||
struct or_condition_t; | ||
|
||
/** | ||
* Is not an operator but a result of c(...) function. Has operator= overloaded which returns assign_t | ||
*/ | ||
template<class T> | ||
struct expression_t : condition_t { | ||
T value; | ||
|
||
expression_t(T value_) : value(std::move(value_)) {} | ||
|
||
template<class R> | ||
assign_t<T, R> operator=(R r) const { | ||
return {this->value, std::move(r)}; | ||
} | ||
|
||
assign_t<T, std::nullptr_t> operator=(std::nullptr_t) const { | ||
return {this->value, nullptr}; | ||
} | ||
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED | ||
assign_t<T, std::nullopt_t> operator=(std::nullopt_t) const { | ||
return {this->value, std::nullopt}; | ||
} | ||
#endif | ||
template<class... Args> | ||
in_t<T, Args...> in(Args... args) const { | ||
return {this->value, std::make_tuple(std::forward<Args>(args)...), false}; | ||
} | ||
|
||
template<class... Args> | ||
in_t<T, Args...> not_in(Args... args) const { | ||
return {this->value, std::make_tuple(std::forward<Args>(args)...), true}; | ||
} | ||
|
||
template<class R> | ||
and_condition_t<T, R> and_(R right) const { | ||
return {this->value, std::move(right)}; | ||
} | ||
|
||
template<class R> | ||
or_condition_t<T, R> or_(R right) const { | ||
return {this->value, std::move(right)}; | ||
} | ||
}; | ||
|
||
template<class T> | ||
T get_from_expression(T value) { | ||
return std::move(value); | ||
} | ||
|
||
template<class T> | ||
T get_from_expression(expression_t<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<class T> | ||
internal::expression_t<T> c(T value) { | ||
return {std::move(value)}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
namespace sqlite_orm { | ||
namespace internal { | ||
struct negatable_t {}; | ||
|
||
/** | ||
* Inherit from this class if target class can be chained with other conditions with '&&' and '||' operators | ||
*/ | ||
struct condition_t {}; | ||
} | ||
} |
Oops, something went wrong.