Browse Source

Add UA_ExpandedNodeId_equal and UA_QualifiedName_equal

Thomas Bender 6 years ago
parent
commit
50115bb143
2 changed files with 31 additions and 0 deletions
  1. 7 0
      include/ua_types.h
  2. 24 0
      src/ua_types.c

+ 7 - 0
include/ua_types.h

@@ -377,6 +377,9 @@ typedef struct {
     UA_UInt32 serverIndex;
 } UA_ExpandedNodeId;
 
+UA_Boolean UA_EXPORT UA_ExpandedNodeId_equal(const UA_ExpandedNodeId *n1,
+                                             const UA_ExpandedNodeId *n2);
+
 UA_EXPORT extern const UA_ExpandedNodeId UA_EXPANDEDNODEID_NULL;
 
 /** The following functions are shorthand for creating ExpandedNodeIds. */
@@ -444,6 +447,10 @@ UA_QUALIFIEDNAME_ALLOC(UA_UInt16 nsIndex, const char *chars) {
     qn.name = UA_STRING_ALLOC(chars); return qn;
 }
 
+UA_Boolean UA_EXPORT
+UA_QualifiedName_equal(const UA_QualifiedName *qn1,
+                       const UA_QualifiedName *qn2);
+
 /**
  * LocalizedText
  * ^^^^^^^^^^^^^

+ 24 - 0
src/ua_types.c

@@ -103,6 +103,19 @@ String_deleteMembers(UA_String *s, const UA_DataType *_) {
     UA_free((void*)((uintptr_t)s->data & ~(uintptr_t)UA_EMPTY_ARRAY_SENTINEL));
 }
 
+UA_Boolean
+UA_QualifiedName_equal(const UA_QualifiedName *qn1,
+                       const UA_QualifiedName *qn2) {
+    if(qn1 == NULL || qn2 == NULL)
+        return false;
+    if(qn1->namespaceIndex != qn2->namespaceIndex)
+        return false;
+    if(qn1->name.length != qn2->name.length)
+        return false;
+    return (memcmp((char const*)qn1->name.data,
+                   (char const*)qn2->name.data, qn1->name.length) == 0);
+}
+
 /* DateTime */
 UA_DateTimeStruct
 UA_DateTime_toStruct(UA_DateTime t) {
@@ -290,6 +303,17 @@ UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2) {
     return false;
 }
 
+UA_Boolean
+UA_ExpandedNodeId_equal(const UA_ExpandedNodeId *n1, const UA_ExpandedNodeId *n2) {
+    if(n1 == NULL || n2 == NULL)
+        return false;
+    if(n1->serverIndex != n2->serverIndex)
+        return false;
+    if(!UA_String_equal(&n1->namespaceUri, &n2->namespaceUri))
+        return false;
+    return UA_NodeId_equal(&n1->nodeId, &n2->nodeId);
+}
+
 /* FNV non-cryptographic hash function. See
  * https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function */
 #define FNV_PRIME_32 16777619