Add special type for representing special values
Before this, pseudo-values like lists and containers were represented by
a string leaf value. Now, I can tell these values apart. This can be
helpful for filtering (for example, when printing the values). It will
also be used for implementing key value completion.
Change-Id: I48f6fa2facaf3e8e52aa3b3b4d92130e63acdb6f
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index b01b484..221f482 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -39,11 +39,11 @@
case SR_DECIMAL64_T:
return value->data()->get_decimal64();
case SR_CONTAINER_T:
- return "(container)"s;
+ return special_{SpecialValue::Container};
case SR_CONTAINER_PRESENCE_T:
- return "(presence container)"s;
+ return special_{SpecialValue::PresenceContainer};
case SR_LIST_T:
- return "(list)"s;
+ return special_{SpecialValue::List};
default: // TODO: implement all types
return value->val_to_string();
}
@@ -66,6 +66,11 @@
return std::make_shared<sysrepo::Val>(res.c_str(), SR_IDENTITYREF_T);
}
+ sysrepo::S_Val operator()(const special_& value) const
+ {
+ throw std::runtime_error("Tried constructing S_Val from a " + specialValueToString(value));
+ }
+
sysrepo::S_Val operator()(const std::string& value) const
{
return std::make_shared<sysrepo::Val>(value.c_str());