65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
#ifndef CONDITION_CONDITION_OPERATORS_HPP
|
|
#define CONDITION_CONDITION_OPERATORS_HPP
|
|
|
|
#include "matador/condition/binary_condition_node.hpp"
|
|
#include "matador/condition/collection_condition_node.hpp"
|
|
#include "matador/condition/column.hpp"
|
|
|
|
namespace matador::condition {
|
|
|
|
template<class Type>
|
|
condition_node_ptr operator==(const column &col, Type val) {
|
|
return std::make_unique<binary_condition_node>(col, binary_operator::EQUALS, val);
|
|
}
|
|
|
|
template<class Type>
|
|
condition_node_ptr operator!=(const column &col, Type val) {
|
|
return std::make_unique<binary_condition_node>(col, binary_operator::NOT_EQUALS, val);
|
|
}
|
|
|
|
template<class Type>
|
|
condition_node_ptr operator>(const column &col, Type val) {
|
|
return std::make_unique<binary_condition_node>(col, binary_operator::GREATER_THAN, val);
|
|
}
|
|
|
|
template<class Type>
|
|
condition_node_ptr operator>=(const column &col, Type val) {
|
|
return std::make_unique<binary_condition_node>(col, binary_operator::GREATER_THAN_OR_EQUAL, val);
|
|
}
|
|
|
|
template<class Type>
|
|
condition_node_ptr operator<(const column &col, Type val) {
|
|
return std::make_unique<binary_condition_node>(col, binary_operator::LESS_THAN, val);
|
|
}
|
|
|
|
template<class Type>
|
|
condition_node_ptr operator<=(const column &col, Type val) {
|
|
return std::make_unique<binary_condition_node>(col, binary_operator::LESS_THAN_OR_EQUAL, val);
|
|
}
|
|
|
|
condition_node_ptr operator&&(condition_node_ptr left, condition_node_ptr right);
|
|
|
|
condition_node_ptr operator||(condition_node_ptr left, condition_node_ptr right);
|
|
|
|
condition_node_ptr operator!(condition_node_ptr cond);
|
|
|
|
template < class Type >
|
|
condition_node_ptr in(const column &col, std::initializer_list<Type> args) {
|
|
std::vector<value> values;
|
|
for ( auto &&arg : args ) {
|
|
values.emplace_back(std::move(arg));
|
|
}
|
|
return std::make_unique<collection_condition_node>(col, collection_operator::IN, std::move(values));
|
|
}
|
|
|
|
template < class V >
|
|
condition_node_ptr out(const column &col, std::initializer_list<V> args) {
|
|
std::vector<value> values;
|
|
for ( auto &&arg : args ) {
|
|
values.emplace_back(std::move(arg));
|
|
}
|
|
return std::make_unique<collection_condition_node>(col, collection_operator::OUT, values);
|
|
}
|
|
|
|
}
|
|
#endif //CONDITION_CONDITION_OPERATORS_HPP
|