Rework yang::LeafDataType
Before this patch, Schema::leafType was used like this: you called the
method, and it would give you an enum value from which you could tell
the type. In case the type was, for example, yang::LeafDataTypes::Enum,
you would call enumValues to get the valid values from the enum.
However, this approach came up as a problem when implementing the union
yang type. Example: if the union consisted of two different enums, there
was no way to differentiate those two enums (so enumValues wouldn't know
which one to return). The new approach encodes everything inside the
return value of Schema::leafType, so no futher method calls are needed.
This also means, that methods like Schema::leafEnumIsValid and others
are unneeded, since you get all the info from Schema::leafType.
Also, I got rid of all the on_success handlers, and moved the code to
inside to impl_LeafData. This means that enum/identityref validity is
checked inside there. If I wanted to keep the on_success handlers I
would have create another member in ParserContext (which would contain
the values), but it doesn't give any advantage, except that it
automatically rolls back the iterator on fail (I have to do that myself
now, but I don't think it's a huge deal).
createSetSuggestions::on_success was also moved to impl_LeafData.
Change-Id: Ie9a30174094b73f2c25af8cfc88d0aa5e9e882b3
diff --git a/tests/keyvalue_completion.cpp b/tests/keyvalue_completion.cpp
index c6a2350..61e90cd 100644
--- a/tests/keyvalue_completion.cpp
+++ b/tests/keyvalue_completion.cpp
@@ -30,10 +30,10 @@
schema->addContainer("/", "example:a");
schema->addContainer("/", "example:b");
schema->addList("/", "example:list", {"number"});
- schema->addLeaf("/example:list", "example:number", yang::LeafDataTypes::Int32);
+ schema->addLeaf("/example:list", "example:number", yang::Int32{});
schema->addList("/", "example:twoKeyList", {"number", "name"});
- schema->addLeaf("/example:twoKeyList", "example:number", yang::LeafDataTypes::Int32);
- schema->addLeaf("/example:twoKeyList", "example:name", yang::LeafDataTypes::String);
+ schema->addLeaf("/example:twoKeyList", "example:number", yang::Int32{});
+ schema->addLeaf("/example:twoKeyList", "example:name", yang::String{});
auto mockDatastore = std::make_shared<MockDatastoreAccess>();
// DataQuery gets the schema from DatastoreAccess once