add presence containers

Change-Id: Ic8e33d68e496deae9dfe4c3e5ebcecbd45ee31b2
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 0c7f1c3..1feeeab 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -110,7 +110,6 @@
         } else {
             _pass(context) = false;
         }
-
     }
 };
 
@@ -156,3 +155,61 @@
         return x3::error_handler_result::fail;
     }
 };
+
+struct presenceContainerPathHandler {
+    template <typename T, typename Iterator, typename Context>
+    void on_success(Iterator const&, Iterator const&, T& ast, Context const& context)
+    {
+        auto& parserContext = x3::get<parser_context_tag>(context);
+        const auto& schema = parserContext.m_schema;
+        try {
+            container_ cont = boost::get<container_>(ast.m_path.m_nodes.back());
+            path_ location{decltype(path_::m_nodes)(parserContext.m_curPath.m_nodes.begin(),
+                                                    parserContext.m_curPath.m_nodes.end() - 1)};
+
+            if (!schema.isPresenceContainer(location, cont.m_name)) {
+                _pass(context) = false;
+                return;
+            }
+        } catch (boost::bad_get&) {
+            _pass(context) = false;
+            return;
+        }
+    }
+
+    template <typename Iterator, typename Exception, typename Context>
+    x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const& x, Context const& context)
+    {
+        auto& parserContext = x3::get<parser_context_tag>(context);
+        auto& error_handler = x3::get<x3::error_handler_tag>(context).get();
+        std::string message = "This isn't a path to a presence container.";
+        if (parserContext.m_errorHandled) // someone already handled our error
+            return x3::error_handler_result::fail;
+
+        parserContext.m_errorHandled = true;
+        error_handler(x.where(), message);
+        return x3::error_handler_result::fail;
+    }
+};
+
+struct create_class : public presenceContainerPathHandler {
+};
+
+struct delete_class : public presenceContainerPathHandler {
+};
+
+struct command_class {
+    template <typename Iterator, typename Exception, typename Context>
+    x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const& x, Context const& context)
+    {
+        auto& parserContext = x3::get<parser_context_tag>(context);
+        auto& error_handler = x3::get<x3::error_handler_tag>(context).get();
+        std::string message = "Couldn't parse command.";
+        if (parserContext.m_errorHandled) // someone already handled our error
+            return x3::error_handler_result::fail;
+
+        parserContext.m_errorHandled = true;
+        error_handler(x.where(), message);
+        return x3::error_handler_result::fail;
+    }
+};