Add Schema::leaftype(const std::string&)

Will be used in the CLI.

Change-Id: I31ddc63e92bfad4c37b5b2b65ae72c33e939af2f
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index d915eef..06749ba 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -257,20 +257,29 @@
     }
 }
 
-yang::LeafDataTypes YangSchema::leafType(const schemaPath_& location, const ModuleNodePair& node) const
+namespace {
+yang::LeafDataTypes impl_leafType(const libyang::S_Schema_Node& node)
 {
     using namespace std::string_literals;
-    if (!isLeaf(location, node))
-        throw InvalidSchemaQueryException(fullNodeName(location, node) + " is not a leaf");
-
-    libyang::Schema_Node_Leaf leaf(getSchemaNode(location, node));
+    libyang::Schema_Node_Leaf leaf(node);
     auto baseType{leaf.type()->base()};
     try {
         return lyTypeToLeafDataTypes(baseType);
     } catch (std::logic_error& ex) {
-        throw UnsupportedYangTypeException("the type of "s + fullNodeName(location, node) + " is not supported: " + ex.what());
+        throw UnsupportedYangTypeException("the type of "s + node->name() + " is not supported: " + ex.what());
     }
 }
+}
+
+yang::LeafDataTypes YangSchema::leafType(const schemaPath_& location, const ModuleNodePair& node) const
+{
+    return impl_leafType(getSchemaNode(location, node));
+}
+
+yang::LeafDataTypes YangSchema::leafType(const std::string& path) const
+{
+    return impl_leafType(getSchemaNode(path));
+}
 
 yang::LeafDataTypes YangSchema::leafrefBase(const schemaPath_& location, const ModuleNodePair& node) const
 {