Simplify variant in ls_
Change-Id: I2bccf7b171f0bae619e935edba5a157a2398d877
diff --git a/src/ast_commands.hpp b/src/ast_commands.hpp
index f039ea5..5ce1cbd 100644
--- a/src/ast_commands.hpp
+++ b/src/ast_commands.hpp
@@ -50,7 +50,7 @@
/> ls /module:node)";
bool operator==(const ls_& b) const;
std::vector<LsOption> m_options;
- boost::optional<boost::variant<boost::variant<dataPath_, schemaPath_>, module_>> m_path;
+ boost::optional<boost::variant<dataPath_, schemaPath_, module_>> m_path;
};
struct cd_ : x3::position_tagged {
diff --git a/src/grammars.hpp b/src/grammars.hpp
index dfb8c10..ae7a980 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -47,7 +47,7 @@
} const ls_options;
auto const ls_def =
- ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> ((dataPathListEnd | dataPath | schemaPath) | (module >> "*")));
+ ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> (dataPathListEnd | dataPath | schemaPath | (module >> "*")));
auto const cd_def =
cd_::name >> space_separator > dataPath;
diff --git a/src/parser.cpp b/src/parser.cpp
index 57511d3..794cc25 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -110,10 +110,15 @@
{
return path;
}
+
+ [[noreturn]] schemaPath_ operator()([[maybe_unused]] const module_& path) const
+ {
+ throw std::logic_error("getSchemaPathVisitor: Tried getting a schema path from a module");
+ }
};
-std::set<std::string> Parser::availableNodes(const boost::optional<boost::variant<boost::variant<dataPath_, schemaPath_>, module_>>& path, const Recursion& option) const
+std::set<std::string> Parser::availableNodes(const boost::optional<boost::variant<dataPath_, schemaPath_, module_>>& path, const Recursion& option) const
{
auto pathArg = dataPathToSchemaPath(m_curDir);
if (path) {
@@ -121,7 +126,7 @@
return m_schema->moduleNodes(boost::get<module_>(*path), option);
}
- auto schemaPath = boost::apply_visitor(getSchemaPathVisitor(), boost::get<boost::variant<dataPath_, schemaPath_>>(*path));
+ auto schemaPath = boost::apply_visitor(getSchemaPathVisitor(), *path);
if (schemaPath.m_scope == Scope::Absolute) {
pathArg = schemaPath;
} else {
diff --git a/src/parser.hpp b/src/parser.hpp
index 7a94919..82e7daf 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -37,7 +37,7 @@
command_ parseCommand(const std::string& line, std::ostream& errorStream);
void changeNode(const dataPath_& name);
std::string currentNode() const;
- std::set<std::string> availableNodes(const boost::optional<boost::variant<boost::variant<dataPath_, schemaPath_>, module_>>& path, const Recursion& option) const;
+ std::set<std::string> availableNodes(const boost::optional<boost::variant<dataPath_, schemaPath_, module_>>& path, const Recursion& option) const;
Completions completeCommand(const std::string& line, std::ostream& errorStream) const;
private: