blob: 87706a5b49c84353fb8cec81e0d592e68109ab1a [file] [log] [blame]
Václav Kubernát195eeea2018-05-18 13:52:36 +02001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
Václav Kubernát7a2f3962020-02-14 16:50:26 +01008#pragma once
Václav Kubernát195eeea2018-05-18 13:52:36 +02009
Václav Kubernátcb3af402020-02-12 16:49:17 +010010#include "completion.hpp"
Václav Kubernát43908fb2020-01-02 19:05:51 +010011#include "data_query.hpp"
Václav Kubernát48fc3832018-05-28 14:21:22 +020012#include "schema.hpp"
Václav Kubernát4a58ce62020-05-14 17:58:10 +020013
Václav Kubernát195eeea2018-05-18 13:52:36 +020014struct ParserContext {
Václav Kubernát43908fb2020-01-02 19:05:51 +010015 ParserContext(const Schema& schema, const std::shared_ptr<const DataQuery> dataQuery, const dataPath_& curDir);
Václav Kubernát72749c62020-01-03 16:47:34 +010016 schemaPath_ currentSchemaPath();
17 dataPath_ currentDataPath();
18 void clearPath();
19 void pushPathFragment(const dataNode_& node);
20 void pushPathFragment(const schemaNode_& node);
21 void resetPath();
22
Václav Kubernát48fc3832018-05-28 14:21:22 +020023 const Schema& m_schema;
Václav Kubernát72749c62020-01-03 16:47:34 +010024 const dataPath_ m_curPathOrig;
Václav Kubernát43908fb2020-01-02 19:05:51 +010025 const std::shared_ptr<const DataQuery> m_dataquery;
Václav Kubernát744f57f2018-06-29 22:46:26 +020026 boost::optional<std::string> m_curModule;
Václav Kubernát195eeea2018-05-18 13:52:36 +020027 std::string m_errorMsg;
28 std::string m_tmpListName;
Václav Kubernát744f57f2018-06-29 22:46:26 +020029 bool m_topLevelModulePresent = false;
Václav Kubernát7707cae2020-01-16 12:04:53 +010030
31 struct {
32 schemaPath_ m_location;
33 ModuleNodePair m_node;
34 } m_tmpListKeyLeafPath;
Václav Kubernát3a99f002020-03-31 02:27:41 +020035
Václav Kubernát43908fb2020-01-02 19:05:51 +010036 std::map<std::string, leaf_data_> m_tmpListKeys;
Václav Kubernát195eeea2018-05-18 13:52:36 +020037 bool m_errorHandled = false;
Václav Kubernátac035d62019-02-18 10:59:08 +010038 bool m_completing = false;
Václav Kubernátcb3af402020-02-12 16:49:17 +010039
40 std::set<Completion> m_suggestions;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010041 // Iterator pointing to where suggestions were created
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010042 boost::optional<std::string::const_iterator> m_completionIterator;
Václav Kubernát72749c62020-01-03 16:47:34 +010043
44private:
45 boost::variant<dataPath_, schemaPath_> m_curPath;
Václav Kubernát195eeea2018-05-18 13:52:36 +020046};