blob: 2a5ba220e4e53139abe84b92ec5cc23e9f5f3e72 [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át195eeea2018-05-18 13:52:36 +020026 std::string m_errorMsg;
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át3a99f002020-03-31 02:27:41 +020032
Václav Kubernát2db124c2020-05-28 21:58:36 +020033 // When parsing list suffixes, this path is used to store the path of the list whose keys are being parsed.
34 dataPath_ m_tmpListPath;
Václav Kubernátc15fe822020-06-04 11:28:39 +020035 ListInstance m_tmpListKeys;
Václav Kubernát2db124c2020-05-28 21:58:36 +020036
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};