plugins types FEATURE missing callbacks for decimal64
diff --git a/src/plugins_types.h b/src/plugins_types.h
index 8563a3c..3b916b3 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -697,6 +697,17 @@
uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node,
struct lyd_value *storage, struct lys_glob_unres *unres, struct ly_err_item **err);
+/**
+ * @brief Implementation of ::lyplg_type_compare_clb for the built-in decimal64 type.
+ */
+LY_ERR lyplg_type_compare_decimal64(const struct lyd_value *val1, const struct lyd_value *val2);
+
+/**
+ * @brief Implementation of ::lyplg_type_print_clb for the built-in decimal64 type.
+ */
+const void *lyplg_type_print_decimal64(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
+ void *prefix_data, ly_bool *dynamic, size_t *value_len);
+
/** @} pluginsTypesDecimal64 */
/**
diff --git a/src/plugins_types/decimal64.c b/src/plugins_types/decimal64.c
index 2b7ab17..3b4a314 100644
--- a/src/plugins_types/decimal64.c
+++ b/src/plugins_types/decimal64.c
@@ -160,6 +160,42 @@
return ret;
}
+API LY_ERR
+lyplg_type_compare_decimal64(const struct lyd_value *val1, const struct lyd_value *val2)
+{
+ if (val1->realtype != val2->realtype) {
+ return LY_ENOT;
+ }
+
+ /* if type is the same, the fraction digits are, too */
+ if (val1->dec64 != val2->dec64) {
+ return LY_ENOT;
+ }
+ return LY_SUCCESS;
+}
+
+API const void *
+lyplg_type_print_decimal64(const struct ly_ctx *UNUSED(ctx), const struct lyd_value *value, LY_VALUE_FORMAT format,
+ void *UNUSED(prefix_data), ly_bool *dynamic, size_t *value_len)
+{
+ if (format == LY_VALUE_LYB) {
+ *dynamic = 0;
+ if (value_len) {
+ *value_len = sizeof value->dec64;
+ }
+ return &value->dec64;
+ }
+
+ /* use the cached canonical value */
+ if (dynamic) {
+ *dynamic = 0;
+ }
+ if (value_len) {
+ *value_len = strlen(value->_canonical);
+ }
+ return value->_canonical;
+}
+
/**
* @brief Plugin information for decimal64 type implementation.
*
@@ -176,8 +212,8 @@
.plugin.id = "libyang 2 - decimal64, version 1",
.plugin.store = lyplg_type_store_decimal64,
.plugin.validate = NULL,
- .plugin.compare = lyplg_type_compare_simple,
- .plugin.print = lyplg_type_print_simple,
+ .plugin.compare = lyplg_type_compare_decimal64,
+ .plugin.print = lyplg_type_print_decimal64,
.plugin.hash = lyplg_type_hash_simple,
.plugin.duplicate = lyplg_type_dup_simple,
.plugin.free = lyplg_type_free_simple