blob: 98022dbe7ee5bd39951d1900649bad8164a2129c [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át43908fb2020-01-02 19:05:51 +01009#include "data_query.hpp"
Václav Kubernát48fc3832018-05-28 14:21:22 +020010#include "schema.hpp"
Václav Kubernát195eeea2018-05-18 13:52:36 +020011struct ParserContext {
Václav Kubernát43908fb2020-01-02 19:05:51 +010012 ParserContext(const Schema& schema, const std::shared_ptr<const DataQuery> dataQuery, const dataPath_& curDir);
Václav Kubernát72749c62020-01-03 16:47:34 +010013 schemaPath_ currentSchemaPath();
14 dataPath_ currentDataPath();
15 void clearPath();
16 void pushPathFragment(const dataNode_& node);
17 void pushPathFragment(const schemaNode_& node);
18 void resetPath();
19
Václav Kubernát48fc3832018-05-28 14:21:22 +020020 const Schema& m_schema;
Václav Kubernát72749c62020-01-03 16:47:34 +010021 const dataPath_ m_curPathOrig;
Václav Kubernát43908fb2020-01-02 19:05:51 +010022 const std::shared_ptr<const DataQuery> m_dataquery;
Václav Kubernát744f57f2018-06-29 22:46:26 +020023 boost::optional<std::string> m_curModule;
Václav Kubernát195eeea2018-05-18 13:52:36 +020024 std::string m_errorMsg;
25 std::string m_tmpListName;
Václav Kubernát744f57f2018-06-29 22:46:26 +020026 bool m_topLevelModulePresent = false;
Václav Kubernát7707cae2020-01-16 12:04:53 +010027
28 struct {
29 schemaPath_ m_location;
30 ModuleNodePair m_node;
31 } m_tmpListKeyLeafPath;
Václav Kubernát43908fb2020-01-02 19:05:51 +010032 std::map<std::string, leaf_data_> m_tmpListKeys;
Václav Kubernát195eeea2018-05-18 13:52:36 +020033 bool m_errorHandled = false;
Václav Kubernátac035d62019-02-18 10:59:08 +010034 bool m_completing = false;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010035 std::set<std::string> m_suggestions;
36 // Iterator pointing to where suggestions were created
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010037 boost::optional<std::string::const_iterator> m_completionIterator;
Václav Kubernát4c325482019-04-11 17:51:55 +020038 // If the parser determines that suggestions are unambiguous (after
39 // filtering by prefix), this suffix gets added to the completion (for
40 // example a left bracket after a list)
41 std::string m_completionSuffix;
Václav Kubernát72749c62020-01-03 16:47:34 +010042
43private:
44 boost::variant<dataPath_, schemaPath_> m_curPath;
Václav Kubernát195eeea2018-05-18 13:52:36 +020045};