blob: f83793424d4607445918f32d4d0586084a8f2dd4 [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át195eeea2018-05-18 13:52:36 +020013struct ParserContext {
Václav Kubernát43908fb2020-01-02 19:05:51 +010014 ParserContext(const Schema& schema, const std::shared_ptr<const DataQuery> dataQuery, const dataPath_& curDir);
Václav Kubernát72749c62020-01-03 16:47:34 +010015 schemaPath_ currentSchemaPath();
16 dataPath_ currentDataPath();
17 void clearPath();
18 void pushPathFragment(const dataNode_& node);
19 void pushPathFragment(const schemaNode_& node);
20 void resetPath();
21
Václav Kubernát48fc3832018-05-28 14:21:22 +020022 const Schema& m_schema;
Václav Kubernát72749c62020-01-03 16:47:34 +010023 const dataPath_ m_curPathOrig;
Václav Kubernát43908fb2020-01-02 19:05:51 +010024 const std::shared_ptr<const DataQuery> m_dataquery;
Václav Kubernát744f57f2018-06-29 22:46:26 +020025 boost::optional<std::string> m_curModule;
Václav Kubernát195eeea2018-05-18 13:52:36 +020026 std::string m_errorMsg;
27 std::string m_tmpListName;
Václav Kubernát744f57f2018-06-29 22:46:26 +020028 bool m_topLevelModulePresent = false;
Václav Kubernát7707cae2020-01-16 12:04:53 +010029
30 struct {
31 schemaPath_ m_location;
32 ModuleNodePair m_node;
33 } m_tmpListKeyLeafPath;
Václav Kubernát3a99f002020-03-31 02:27:41 +020034
Václav Kubernát43908fb2020-01-02 19:05:51 +010035 std::map<std::string, leaf_data_> m_tmpListKeys;
Václav Kubernát195eeea2018-05-18 13:52:36 +020036 bool m_errorHandled = false;
Václav Kubernátac035d62019-02-18 10:59:08 +010037 bool m_completing = false;
Václav Kubernátcb3af402020-02-12 16:49:17 +010038
39 std::set<Completion> m_suggestions;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010040 // Iterator pointing to where suggestions were created
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010041 boost::optional<std::string::const_iterator> m_completionIterator;
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};