43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "parser.h"
|
|
#include "table.h"
|
|
|
|
#include <string>
|
|
|
|
class Executor {
|
|
private:
|
|
|
|
public:
|
|
Executor();
|
|
|
|
bool execute(Node& node);
|
|
|
|
private:
|
|
bool execute_create_table(CreateTableNode& node);
|
|
bool execute_insert_into_table(InsertIntoTableNode& node);
|
|
bool execute_select(SelectFromTableNode& node);
|
|
bool execute_delete(DeleteFromTableNode& node);
|
|
bool execute_update(UpdateTableNode& node);
|
|
|
|
Table* find_table(const std::string name);
|
|
private:
|
|
std::vector<Table> m_tables;
|
|
|
|
bool evalWhere(Node *where, Table *table,
|
|
std::vector<Row, std::allocator<Row>>::iterator &row) const;
|
|
|
|
std::unique_ptr<Node>
|
|
evalNode(Table *table, std::vector<Row, std::allocator<Row>>::iterator &row,
|
|
Node *node) const;
|
|
|
|
bool evalRelationalOperator(const RelationalOperatorNode &filter, Table *table,
|
|
std::vector<Row, std::allocator<Row>>::iterator &row) const;
|
|
|
|
bool evalLogicalOperator(LogicalOperatorNode &node, Table *pTable,
|
|
std::vector<Row, std::allocator<Row>>::iterator &iter) const;
|
|
|
|
std::unique_ptr<Node> evalArithmetic(ArithmeticalOperatorNode &node, Table *table,
|
|
std::vector<Row, std::allocator<Row>>::iterator &row) const;
|
|
};
|