+static UA_StatusCode get_property(Pset &pset, const char* keyname, UA_Variant* valuePtr)
+{
+ UA_StatusCode status = UA_STATUSCODE_BAD;
+ if (pset.exists(keyname))
+ {
+ status = UA_STATUSCODE_GOOD;
+ const auto item = pset.get_item(keyname);
+ switch (item->hdr.type)
+ {
+ case PSET_TYPE_INT:
+ UA_Variant_setScalar(valuePtr, const_cast<int32_t*>(&item->val.lVal), &UA_TYPES[UA_TYPES_INT32]);
+ break;
+ case PSET_TYPE_FLOAT:
+ UA_Variant_setScalar(valuePtr, const_cast<float*>(&item->val.fltVal), &UA_TYPES[UA_TYPES_FLOAT]);
+ break;
+ case PSET_TYPE_DOUBLE:
+ UA_Variant_setScalar(valuePtr, const_cast<double*>(&item->val.dblVal), &UA_TYPES[UA_TYPES_DOUBLE]);
+ break;
+ case PSET_TYPE_STRING:
+ {
+ UA_String str = { 0 };
+ str.length = item->length;
+ str.data = (UA_Byte*)UA_malloc(item->length);
+ memcpy(str.data, item->val.strVal, item->length);
+ UA_Variant_setScalarCopy(valuePtr, &str, &UA_TYPES[UA_TYPES_STRING]);
+ break;
+ }
+ default:
+ status = UA_STATUSCODE_BAD;
+ }
+ }
+ return status;
+}
+