#ifndef QUERY_TREE_H #define QUERY_TREE_H #include #include #include #include #include "data/query/QueryOperator.h" class QueryTree { public: static std::deque tokenizeQuery(const std::string& query); static std::string getTokenName(const std::string& token); static std::string getTokenTypeName(const std::string& token); QueryTree(); QueryTree(const std::string& query); ~QueryTree(); std::shared_ptr getRoot() const; bool isValid() const; void build(const std::string& query); void print(std::ostream& ostream) const; private: std::shared_ptr buildTree(std::deque& tokens, std::shared_ptr frontNode); std::shared_ptr buildGroup(std::deque& tokens, QueryOperator::OperatorType closeType); std::shared_ptr getNextNode(std::deque& tokens); std::shared_ptr createCommand(const std::string& name); std::shared_ptr createToken(const std::string& name); std::shared_ptr m_root; std::string m_query; bool m_valid; }; std::ostream& operator<<(std::ostream& ostream, const QueryTree& tree); #endif // QUERY_TREE_H