Change m_schema in Parser to a shared pointer
Shared pointers are reference counted, so this will prevent segmentation
faults in some cases.
Change-Id: Ie180cf6a639c8e73e70f395d19a6082b4fce73d4
diff --git a/src/parser.cpp b/src/parser.cpp
index e2d0330..0c62358 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -13,7 +13,7 @@
InvalidCommandException::~InvalidCommandException() = default;
-Parser::Parser(const Schema& schema)
+Parser::Parser(const std::shared_ptr<const Schema> schema)
: m_schema(schema)
{
}
@@ -21,7 +21,7 @@
command_ Parser::parseCommand(const std::string& line, std::ostream& errorStream)
{
command_ parsedCommand;
- ParserContext ctx(m_schema, m_curDir);
+ ParserContext ctx(*m_schema, m_curDir);
auto it = line.begin();
boost::spirit::x3::error_handler<std::string::const_iterator> errorHandler(it, line.end(), errorStream);