Skip to content

Commit

Permalink
Add UA_ExpandedNodeId_equal and UA_QualifiedName_equal
Browse files Browse the repository at this point in the history
  • Loading branch information
janitza-thbe authored and Pro committed Feb 19, 2018
1 parent e8fb312 commit f26a182
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/ua_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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
* ^^^^^^^^^^^^^
Expand Down
24 changes: 24 additions & 0 deletions src/ua_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f26a182

Please sign in to comment.