Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
Václav Kubernát | d666296 | 2018-03-22 17:41:33 +0100 | [diff] [blame] | 7 | */ |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 8 | |
| 9 | #pragma once |
Václav Kubernát | 509ce65 | 2019-05-29 19:46:44 +0200 | [diff] [blame] | 10 | #include "ast_commands.hpp" |
| 11 | #include "ast_path.hpp" |
Václav Kubernát | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 12 | #include "data_query.hpp" |
Václav Kubernát | 509ce65 | 2019-05-29 19:46:44 +0200 | [diff] [blame] | 13 | #include "schema.hpp" |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 14 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 15 | |
Václav Kubernát | b96eef7 | 2018-05-04 19:10:22 +0200 | [diff] [blame] | 16 | class InvalidCommandException : public std::invalid_argument { |
| 17 | public: |
| 18 | using std::invalid_argument::invalid_argument; |
| 19 | ~InvalidCommandException() override; |
| 20 | }; |
| 21 | |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 22 | class TooManyArgumentsException : public std::invalid_argument { |
| 23 | public: |
| 24 | using std::invalid_argument::invalid_argument; |
| 25 | ~TooManyArgumentsException() override; |
| 26 | }; |
| 27 | |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 28 | struct Completions { |
| 29 | bool operator==(const Completions& b) const; |
| 30 | std::set<std::string> m_completions; |
| 31 | int m_contextLength; |
| 32 | }; |
| 33 | |
Václav Kubernát | 48fc383 | 2018-05-28 14:21:22 +0200 | [diff] [blame] | 34 | class Parser { |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 35 | public: |
Václav Kubernát | 28cf336 | 2020-06-29 17:52:51 +0200 | [diff] [blame] | 36 | Parser(const std::shared_ptr<const Schema> schema, WritableOps writableOps = WritableOps::No, const std::shared_ptr<const DataQuery> dataQuery = nullptr); |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 37 | command_ parseCommand(const std::string& line, std::ostream& errorStream); |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 38 | void changeNode(const dataPath_& name); |
Václav Kubernát | 59e4ee4 | 2020-07-08 17:32:45 +0200 | [diff] [blame] | 39 | [[nodiscard]] std::string currentNode() const; |
Václav Kubernát | 1ed4aa3 | 2020-01-23 13:13:28 +0100 | [diff] [blame] | 40 | Completions completeCommand(const std::string& line, std::ostream& errorStream) const; |
Václav Kubernát | 8208687 | 2020-04-29 01:09:50 +0200 | [diff] [blame] | 41 | dataPath_ currentPath(); |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 42 | |
| 43 | private: |
Václav Kubernát | a10d8b6 | 2018-06-13 17:42:46 +0200 | [diff] [blame] | 44 | const std::shared_ptr<const Schema> m_schema; |
Václav Kubernát | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 45 | const std::shared_ptr<const DataQuery> m_dataquery; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 46 | dataPath_ m_curDir; |
Václav Kubernát | 28cf336 | 2020-06-29 17:52:51 +0200 | [diff] [blame] | 47 | const WritableOps m_writableOps; |
Václav Kubernát | 624a887 | 2018-03-02 17:28:47 +0100 | [diff] [blame] | 48 | }; |