Add Schema::nodeType method

Change-Id: Id17e00ebef4820abae3b66d2e262be4b16c7a672
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index dddebf5..3470865 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -412,3 +412,32 @@
 {
     return m_context->get_module(name.c_str(), nullptr, 0);
 }
+
+namespace {
+yang::NodeTypes impl_nodeType(const libyang::S_Schema_Node& node)
+{
+    if (!node) {
+        throw InvalidNodeException();
+    }
+    switch (node->nodetype()) {
+    case LYS_CONTAINER:
+        return libyang::Schema_Node_Container{node}.presence() ? yang::NodeTypes::PresenceContainer : yang::NodeTypes::Container;
+    case LYS_LEAF:
+        return yang::NodeTypes::Leaf;
+    case LYS_LIST:
+        return yang::NodeTypes::List;
+    default:
+        throw std::runtime_error{"YangSchema::nodeType: unsupported type"};
+    }
+}
+}
+
+yang::NodeTypes YangSchema::nodeType(const schemaPath_& location, const ModuleNodePair& node) const
+{
+    return impl_nodeType(getSchemaNode(location, node));
+}
+
+yang::NodeTypes YangSchema::nodeType(const std::string& path) const
+{
+    return impl_nodeType(getSchemaNode(path));
+}