blob: b9798fc5866ea3bba188abe283ca85a0593887a8 [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át43908fb2020-01-02 19:05:51 +010010#include "data_query.hpp"
Václav Kubernát48fc3832018-05-28 14:21:22 +020011#include "schema.hpp"
Václav Kubernát195eeea2018-05-18 13:52:36 +020012struct ParserContext {
Václav Kubernát43908fb2020-01-02 19:05:51 +010013 ParserContext(const Schema& schema, const std::shared_ptr<const DataQuery> dataQuery, const dataPath_& curDir);
Václav Kubernát72749c62020-01-03 16:47:34 +010014 schemaPath_ currentSchemaPath();
15 dataPath_ currentDataPath();
16 void clearPath();
17 void pushPathFragment(const dataNode_& node);
18 void pushPathFragment(const schemaNode_& node);
19 void resetPath();
20
Václav Kubernát48fc3832018-05-28 14:21:22 +020021 const Schema& m_schema;
Václav Kubernát72749c62020-01-03 16:47:34 +010022 const dataPath_ m_curPathOrig;
Václav Kubernát43908fb2020-01-02 19:05:51 +010023 const std::shared_ptr<const DataQuery> m_dataquery;
Václav Kubernát744f57f2018-06-29 22:46:26 +020024 boost::optional<std::string> m_curModule;
Václav Kubernát195eeea2018-05-18 13:52:36 +020025 std::string m_errorMsg;
26 std::string m_tmpListName;
Václav Kubernát744f57f2018-06-29 22:46:26 +020027 bool m_topLevelModulePresent = false;
Václav Kubernát7707cae2020-01-16 12:04:53 +010028
29 struct {
30 schemaPath_ m_location;
31 ModuleNodePair m_node;
32 } m_tmpListKeyLeafPath;
Václav Kubernát43908fb2020-01-02 19:05:51 +010033 std::map<std::string, leaf_data_> m_tmpListKeys;
Václav Kubernát195eeea2018-05-18 13:52:36 +020034 bool m_errorHandled = false;
Václav Kubernátac035d62019-02-18 10:59:08 +010035 bool m_completing = false;
Václav Kubernát4108e0d2018-10-29 13:32:22 +010036 std::set<std::string> m_suggestions;
37 // Iterator pointing to where suggestions were created
Václav Kubernát1ed4aa32020-01-23 13:13:28 +010038 boost::optional<std::string::const_iterator> m_completionIterator;
Václav Kubernát4c325482019-04-11 17:51:55 +020039 // If the parser determines that suggestions are unambiguous (after
40 // filtering by prefix), this suffix gets added to the completion (for
41 // example a left bracket after a list)
42 std::string m_completionSuffix;
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};