Skip to content

Commit

Permalink
refactor(util): Use better defaults for UA_SimpleAttributeOperand_parse
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Feb 21, 2024
1 parent 1581b06 commit 1f98c5a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/open62541/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ UA_RelativePath_print(const UA_RelativePath *rp, UA_String *out);
* values reported for each event instance.
*
* The TypeDefinitionId is a NodeId and restricts the starting point for the
* lookup to instances of the TypeDefinitionNode or one of its subtypes. The
* NodeId defaults to the wildcard ns=0;i=0. The NodeId is extended-and-escaped.
* lookup to instances of the TypeDefinitionNode or one of its subtypes. If not
* defined, the NodeId defaults to the BaseEventType. The NodeId is
* extended-and-escaped.
*
* The BrowsePath is a list of BrowseNames (QualifiedName expression with
* extended-and-escaping of the name) to be followed from the TypeDefinitionNode
Expand All @@ -310,8 +311,10 @@ UA_RelativePath_print(const UA_RelativePath *rp, UA_String *out);
* to only follow into Variable- and ObjectNodes. If the BrowsePath is empty,
* the value is taken from the instance of the TypeDefinition itself.
*
* The attribute is the textual name of the possible node attributes.
* For the index range, see the section on :ref:`numericrange`.::
* The attribute is the textual name of the selected node attribute.
* If undefined, the attribute defaults to the Value attribute.
* For the index range, see the section on :ref:`numericrange`.
* The BNF definition of the SimpleAttributeOperand is as follows::
*
* SimpleAttributeOperand :=
* TypeDefinitionId? SimpleBrowsePath ("#" Attribute)? ("[" IndexRange "]")?
Expand Down
6 changes: 6 additions & 0 deletions src/util/ua_types_lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,9 @@ UA_SimpleAttributeOperand_parse(UA_SimpleAttributeOperand *sao,
res = UA_NodeId_parse(&sao->typeDefinitionId, typeString);
if(res != UA_STATUSCODE_GOOD)
goto cleanup;
} else {
/* BaseEventType is the default */
sao->typeDefinitionId = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEEVENTTYPE);
}

/* Parse the BrowsePath */
Expand Down Expand Up @@ -994,6 +997,9 @@ UA_SimpleAttributeOperand_parse(UA_SimpleAttributeOperand *sao,
res = UA_STATUSCODE_BADDECODINGERROR;
goto cleanup;
}
} else {
/* The value attribute is the default */
sao->attributeId = UA_ATTRIBUTEID_VALUE;
}

/* Check whether the IndexRange can be parsed.
Expand Down
6 changes: 6 additions & 0 deletions src/util/ua_types_lex.re
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ UA_SimpleAttributeOperand_parse(UA_SimpleAttributeOperand *sao,
res = UA_NodeId_parse(&sao->typeDefinitionId, typeString);
if(res != UA_STATUSCODE_GOOD)
goto cleanup;
} else {
/* BaseEventType is the default */
sao->typeDefinitionId = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEEVENTTYPE);
}

/* Parse the BrowsePath */
Expand Down Expand Up @@ -491,6 +494,9 @@ UA_SimpleAttributeOperand_parse(UA_SimpleAttributeOperand *sao,
res = UA_STATUSCODE_BADDECODINGERROR;
goto cleanup;
}
} else {
/* The value attribute is the default */
sao->attributeId = UA_ATTRIBUTEID_VALUE;
}

/* Check whether the IndexRange can be parsed.
Expand Down

0 comments on commit 1f98c5a

Please sign in to comment.