blob: 77357e7b78575e9c7714bbbcdef966ec1ec37ee6 [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*/
8
Václav Kubernát48fc3832018-05-28 14:21:22 +02009#include "schema.hpp"
Václav Kubernát195eeea2018-05-18 13:52:36 +020010struct ParserContext {
Václav Kubernát72749c62020-01-03 16:47:34 +010011 ParserContext(const Schema& schema, const dataPath_& curDir);
12 schemaPath_ currentSchemaPath();
13 dataPath_ currentDataPath();
14 void clearPath();
15 void pushPathFragment(const dataNode_& node);
16 void pushPathFragment(const schemaNode_& node);
17 void resetPath();
18
Václav Kubernát48fc3832018-05-28 14:21:22 +020019 const Schema& m_schema;
Václav Kubernát72749c62020-01-03 16:47:34 +010020 const dataPath_ m_curPathOrig;
Václav Kubernát744f57f2018-06-29 22:46:26 +020021 boost::optional<std::string> m_curModule;
Václav Kubernát195eeea2018-05-18 13:52:36 +020022 std::string m_errorMsg;
23 std::string m_tmpListName;
Václav Kubernát744f57f2018-06-29 22:46:26 +020024 bool m_topLevelModulePresent = false;
Václav Kubernát195eeea2018-05-18 13:52:36 +020025 std::set<std::string> m_tmpListKeys;
Václav Kubernát7707cae2020-01-16 12:04:53 +010026
27 struct {
28 schemaPath_ m_location;
29 ModuleNodePair m_node;
30 } m_tmpListKeyLeafPath;
Václav Kubernát195eeea2018-05-18 13:52:36 +020031 bool m_errorHandled = false;
Václav Kubernátac035d62019-02-18 10:59:08 +010032 bool m_completing = false;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010033 std::set<std::string> m_suggestions;
34 // Iterator pointing to where suggestions were created
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010035 boost::optional<std::string::const_iterator> m_completionIterator;
Václav Kubernát4c325482019-04-11 17:51:55 +020036 // If the parser determines that suggestions are unambiguous (after
37 // filtering by prefix), this suffix gets added to the completion (for
38 // example a left bracket after a list)
39 std::string m_completionSuffix;
Václav Kubernát72749c62020-01-03 16:47:34 +010040
41private:
42 boost::variant<dataPath_, schemaPath_> m_curPath;
Václav Kubernát195eeea2018-05-18 13:52:36 +020043};