blob: 3c009e673496798f5641835176f3b09215cd597a [file] [log] [blame]
Václav Kubernát624a8872018-03-02 17:28:47 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
Václav Kubernátd6662962018-03-22 17:41:33 +01003 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
Václav Kubernát624a8872018-03-02 17:28:47 +01004 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
Václav Kubernátd6662962018-03-22 17:41:33 +01007*/
Václav Kubernát624a8872018-03-02 17:28:47 +01008
9#pragma once
Václav Kubernát509ce652019-05-29 19:46:44 +020010#include "ast_commands.hpp"
11#include "ast_path.hpp"
12#include "schema.hpp"
Václav Kubernátb61336d2018-05-28 17:35:03 +020013
Václav Kubernát624a8872018-03-02 17:28:47 +010014
Václav Kubernátb96eef72018-05-04 19:10:22 +020015class InvalidCommandException : public std::invalid_argument {
16public:
17 using std::invalid_argument::invalid_argument;
18 ~InvalidCommandException() override;
19};
20
Václav Kubernát624a8872018-03-02 17:28:47 +010021class TooManyArgumentsException : public std::invalid_argument {
22public:
23 using std::invalid_argument::invalid_argument;
24 ~TooManyArgumentsException() override;
25};
26
Václav Kubernát48fc3832018-05-28 14:21:22 +020027class Parser {
Václav Kubernát624a8872018-03-02 17:28:47 +010028public:
Václav Kubernáta10d8b62018-06-13 17:42:46 +020029 Parser(const std::shared_ptr<const Schema> schema);
Václav Kubernátb61336d2018-05-28 17:35:03 +020030 command_ parseCommand(const std::string& line, std::ostream& errorStream);
Václav Kubernát2eaceb82018-10-08 19:56:30 +020031 void changeNode(const dataPath_& name);
Václav Kubernát2a9e1792018-05-28 12:53:48 +020032 std::string currentNode() const;
Václav Kubernát9456b5c2019-10-02 21:14:52 +020033 std::set<std::string> availableNodes(const boost::optional<boost::variant<boost::variant<dataPath_, schemaPath_>, module_>>& path, const Recursion& option) const;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010034 std::set<std::string> completeCommand(const std::string& line, std::ostream& errorStream) const;
Václav Kubernát624a8872018-03-02 17:28:47 +010035
36private:
Václav Kubernáta10d8b62018-06-13 17:42:46 +020037 const std::shared_ptr<const Schema> m_schema;
Václav Kubernát2eaceb82018-10-08 19:56:30 +020038 dataPath_ m_curDir;
Václav Kubernát624a8872018-03-02 17:28:47 +010039};