xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
QueryEngine.h
Go to the documentation of this file.
1#ifndef ENGINE_QUERY_ENGINE_H
2#define ENGINE_QUERY_ENGINE_H
3
4#include "Query/IParser.h"
5#include "Query/Statement.h"
8
9#include <string>
10#include <vector>
11#include <memory>
12
13namespace Xale::Engine
14{
16 {
17 public:
18 QueryEngine() = default;
19
26 Xale::Query::IParser* parser,
28
34 bool run(std::string sqlQuery);
35
40 std::unique_ptr<Xale::DataStructure::ResultSet> getResults();
41
46 std::string getResultsToString();
47
48 private:
49 Xale::Query::IParser* _parser;
51 std::unique_ptr<Xale::DataStructure::ResultSet> _results;
52 Xale::Query::StatementType _lastStatementType;
53 std::vector<std::string> _multiResponses;
54
60 std::vector<std::string> splitQueries(const std::string& input) const;
61
66 std::string formatCurrentResult();
67
72 std::string formatSelectResult();
73
78 std::string formatInsertResult();
79
84 std::string formatUpdateResult();
85
90 std::string formatDeleteResult();
91
96 std::string formatCreateResult();
97
102 std::string formatDropResult();
103 };
104}
105
106#endif // ENGINE_QUERY_ENGINE_H
std::unique_ptr< Xale::DataStructure::ResultSet > getResults()
Get the last runned query results.
Definition QueryEngine.cpp:66
bool run(std::string sqlQuery)
Run one or more semicolon-separated SQL queries.
Definition QueryEngine.cpp:48
std::string getResultsToString()
Get all query results as a formatted string (multi-query aware).
Definition QueryEngine.cpp:74
Interface for executing SQL statements and returning results.
Definition IExecutor.h:15
Interface for SQL parsers.
Definition IParser.h:16
Definition QueryEngine.h:14
StatementType
Types of SQL statements.
Definition Statement.h:15