Implement int8, uint8, int16, uint16, int64, uint64 types
This sw did not support uint8 type, which is needed by the upcoming
driver CalibrationBox within cla-sysrepo, so we implemented uint8 and
other types in TODO sections.
Creating leaf_data_XXX_classes for all types would result in a lot of
redundant code so the base class was turned into a template and the type
is passed through the template argument.
Change-Id: I866a3933fe21ea7844299556e5aaf39b3e40e92f
Co-Authored-By: Jan Kundrát <jan.kundrat@cesnet.cz>
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index dd80889..69af5ac 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -395,11 +395,12 @@
}
};
+template<yang::LeafDataTypes TYPE>
struct leaf_data_base_class {
yang::LeafDataTypes m_type;
- leaf_data_base_class(yang::LeafDataTypes type)
- : m_type(type)
+ leaf_data_base_class()
+ : m_type(TYPE)
{
}
@@ -421,11 +422,10 @@
}
};
-struct leaf_data_enum_class : leaf_data_base_class {
- leaf_data_enum_class()
- : leaf_data_base_class(yang::LeafDataTypes::Enum)
- {
- }
+struct leaf_data_binary_data_class;
+
+struct leaf_data_enum_class : leaf_data_base_class<yang::LeafDataTypes::Enum> {
+ using leaf_data_base_class::leaf_data_base_class;
template <typename T, typename Iterator, typename Context>
void on_success(Iterator const& start, Iterator const& end, T& ast, Context const& context)
@@ -449,57 +449,10 @@
}
};
-struct leaf_data_decimal_class : leaf_data_base_class {
- leaf_data_decimal_class()
- : leaf_data_base_class(yang::LeafDataTypes::Decimal)
- {
- }
-};
-
-struct leaf_data_bool_class : leaf_data_base_class {
- leaf_data_bool_class()
- : leaf_data_base_class(yang::LeafDataTypes::Bool)
- {
- }
-};
-
-struct leaf_data_int_class : leaf_data_base_class {
- leaf_data_int_class()
- : leaf_data_base_class(yang::LeafDataTypes::Int)
- {
- }
-};
-
-struct leaf_data_uint_class : leaf_data_base_class {
- leaf_data_uint_class()
- : leaf_data_base_class(yang::LeafDataTypes::Uint)
- {
- }
-};
-
-struct leaf_data_string_class : leaf_data_base_class {
- leaf_data_string_class()
- : leaf_data_base_class(yang::LeafDataTypes::String)
- {
- }
-};
-
-struct leaf_data_binary_data_class;
-
-struct leaf_data_binary_class : leaf_data_base_class {
- leaf_data_binary_class()
- : leaf_data_base_class(yang::LeafDataTypes::Binary)
- {
- }
-};
-
struct leaf_data_identityRef_data_class;
-struct leaf_data_identityRef_class : leaf_data_base_class {
- leaf_data_identityRef_class()
- : leaf_data_base_class(yang::LeafDataTypes::IdentityRef)
- {
- }
+struct leaf_data_identityRef_class : leaf_data_base_class<yang::LeafDataTypes::IdentityRef> {
+ using leaf_data_base_class::leaf_data_base_class;
template <typename T, typename Iterator, typename Context>
void on_success(Iterator const& start, Iterator const& end, T& ast, Context const& context)