50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#ifndef RSQL_PARSER_BINARY_CONDITION_NODE_HPP
|
|
#define RSQL_PARSER_BINARY_CONDITION_NODE_HPP
|
|
|
|
#include "node.hpp"
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace matador::rsql {
|
|
enum class binary_operator {
|
|
Equals,
|
|
NotEquals,
|
|
GreaterThan,
|
|
GreaterThanOrEqual,
|
|
LessThan,
|
|
LessThanOrEqual,
|
|
};
|
|
|
|
static const std::map<std::string, binary_operator> binary_operators = {
|
|
{ "==", binary_operator::Equals },
|
|
{ "!=", binary_operator::NotEquals },
|
|
{ ">", binary_operator::GreaterThan },
|
|
{ "=gt*", binary_operator::GreaterThan },
|
|
{ ">=", binary_operator::GreaterThanOrEqual },
|
|
{ "=ge=", binary_operator::GreaterThanOrEqual },
|
|
{ "<", binary_operator::LessThan },
|
|
{ "=lt=", binary_operator::LessThan },
|
|
{ "<=", binary_operator::LessThanOrEqual },
|
|
{ "=le=", binary_operator::LessThanOrEqual }
|
|
};
|
|
|
|
class node_visitor;
|
|
class binary_condition_node final : public node {
|
|
public:
|
|
binary_condition_node(std::string field, binary_operator op, std::string value);
|
|
|
|
void accept(node_visitor& visitor) const override;
|
|
|
|
[[nodiscard]] const std::string& field() const;
|
|
[[nodiscard]] binary_operator operand() const;
|
|
[[nodiscard]] const std::string& value() const;
|
|
|
|
private:
|
|
std::string field_;
|
|
binary_operator op_;
|
|
std::string value_;
|
|
};
|
|
|
|
};
|
|
#endif //RSQL_PARSER_BINARY_CONDITION_NODE_HPP
|