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,
|
|
NOT_EQUALS,
|
|
GREATER_THAN,
|
|
GREATER_THAN_OR_EQUAL,
|
|
LESS_THAN,
|
|
LESS_THAN_OR_EQUAL,
|
|
};
|
|
|
|
static const std::map<std::string, binary_operator> binary_operators = {
|
|
{ "==", binary_operator::EQUALS },
|
|
{ "!=", binary_operator::NOT_EQUALS },
|
|
{ ">", binary_operator::GREATER_THAN },
|
|
{ "=gt*", binary_operator::GREATER_THAN },
|
|
{ ">=", binary_operator::GREATER_THAN_OR_EQUAL },
|
|
{ "=ge=", binary_operator::GREATER_THAN_OR_EQUAL },
|
|
{ "<", binary_operator::LESS_THAN },
|
|
{ "=lt=", binary_operator::LESS_THAN },
|
|
{ "<=", binary_operator::LESS_THAN_OR_EQUAL },
|
|
{ "=le=", binary_operator::LESS_THAN_OR_EQUAL }
|
|
};
|
|
|
|
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;
|
|
|
|
const std::string& field() const;
|
|
binary_operator operand() const;
|
|
const std::string& value() const;
|
|
|
|
private:
|
|
std::string field_;
|
|
binary_operator op_;
|
|
std::string value_;
|
|
};
|
|
|
|
};
|
|
#endif //RSQL_PARSER_BINARY_CONDITION_NODE_HPP
|