67 lines
1.1 KiB
C++
67 lines
1.1 KiB
C++
#ifndef QUERY_BASIC_CONDITION_HPP
|
|
#define QUERY_BASIC_CONDITION_HPP
|
|
|
|
#include "matador/sql/column.hpp"
|
|
|
|
#include <unordered_map>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace matador::sql {
|
|
class dialect;
|
|
struct query_context;
|
|
}
|
|
|
|
namespace matador::query {
|
|
|
|
class basic_condition
|
|
{
|
|
public:
|
|
basic_condition() = default;
|
|
virtual ~basic_condition() = default;
|
|
|
|
enum class operand_type : uint8_t
|
|
{
|
|
EQUAL = 0,
|
|
NOT_EQUAL,
|
|
LESS,
|
|
LESS_EQUAL,
|
|
GREATER,
|
|
GREATER_EQUAL,
|
|
OR,
|
|
AND,
|
|
NOT,
|
|
IN_LIST,
|
|
LIKE
|
|
};
|
|
|
|
virtual std::string evaluate(const sql::dialect &dialect, sql::query_context &query) const = 0;
|
|
|
|
static std::unordered_map<operand_type, std::string> operands;
|
|
};
|
|
|
|
class basic_column_condition : public basic_condition
|
|
{
|
|
public:
|
|
sql::column field_;
|
|
std::string operand;
|
|
|
|
basic_column_condition(sql::column fld, operand_type op);
|
|
};
|
|
|
|
class basic_in_condition : public basic_condition
|
|
{
|
|
public:
|
|
sql::column field_;
|
|
|
|
explicit basic_in_condition(sql::column fld);
|
|
|
|
[[nodiscard]] virtual size_t size() const = 0;
|
|
};
|
|
|
|
/// @endcond
|
|
|
|
}
|
|
|
|
#endif //QUERY_BASIC_CONDITION_HPP
|