High Performance OPC UA Server SDK  1.7.1.383

A union of all built-in data types including an OpcUa_ExtensionObject. More...

Modules

 ua_variant_getter
 Getter and detach functions for the ua_variant structure.
 
 ua_variant_setter
 Setter and attach functions for the ua_variant structure.
 
 ua_variant_utility
 Utility functions for the ua_variant structure.
 

Data Structures

struct  ua_variant_base_properties
 
struct  ua_variant_array
 
struct  ua_variant_matrix
 
struct  ua_variant
 Structure for an UA Variant, see also ua_variant. More...
 

Enumerations

enum  ua_variant_type {
  UA_VT_NULL = 0, UA_VT_BOOLEAN = 1, UA_VT_SBYTE = 2, UA_VT_BYTE = 3,
  UA_VT_INT16 = 4, UA_VT_UINT16 = 5, UA_VT_INT32 = 6, UA_VT_UINT32 = 7,
  UA_VT_INT64 = 8, UA_VT_UINT64 = 9, UA_VT_FLOAT = 10, UA_VT_DOUBLE = 11,
  UA_VT_STRING = 12, UA_VT_DATETIME = 13, UA_VT_GUID = 14, UA_VT_BYTESTRING = 15,
  UA_VT_XMLELEMENT = 16, UA_VT_NODEID = 17, UA_VT_EXPANDEDNODEID = 18, UA_VT_STATUSCODE = 19,
  UA_VT_QUALIFIEDNAME = 20, UA_VT_LOCALIZEDTEXT = 21, UA_VT_EXTENSIONOBJECT = 22, UA_VT_DATAVALUE = 23,
  UA_VT_VARIANT = 24, UA_VT_DIAGNOSTICINFO = 25, UA_VT_ENCODED_BINARY = 26, UA_VT_IS_MATRIX = 0xc0,
  UA_VT_IS_ARRAY = 0x80, UA_VT_ARRAYMASK = 0xc0, UA_VT_TYPEMASK = 0x3f
}
 Type identifier for a variant.
 

Functions

BASE_EXPORT void ua_variant_init (struct ua_variant *v)
 Initialize an ua_variant as null variant.
 
BASE_EXPORT void ua_variant_clear (struct ua_variant *v)
 clear an ua_variant. More...
 
BASE_EXPORT int ua_variant_compare (const struct ua_variant *a, const struct ua_variant *b) UA_PURE_FUNCTION
 Compare the variants a and b. More...
 
BASE_EXPORT int ua_variant_copy (struct ua_variant *dst, const struct ua_variant *src)
 Create a copy of variant src. More...
 
static bool ua_variant_is_null (const struct ua_variant *v)
 Test if the ua_variant v is a null variant.
 
static enum ua_variant_type ua_variant_get_type (const struct ua_variant *v)
 Returns the built-in datatype of the given variant. More...
 
static bool ua_variant_is_array (const struct ua_variant *v)
 Returns true if the given variant is an array. More...
 
static bool ua_variant_is_matrix (const struct ua_variant *v)
 Returns true if the given variant is a matrix. More...
 
static bool ua_variant_is_scalar (const struct ua_variant *v)
 Returns true if the given variant is a scalar value. More...
 
BASE_EXPORT const struct ua_variant_base_propertiesua_variant_get_type_properties (uint8_t type)
 

Detailed Description

A union of all built-in data types including an OpcUa_ExtensionObject.

There are further functons available:

Variants can also contain arrays of any of these built-in types. Variants are used to store any value or parameter with a data type of BaseDataType or one of its subtypes.

Variants can be empty. An empty Variant is described as having a null value and should be treated like a null column in a SQL database. A null value in a Variant may not be the same as a null value for data types that support nulls such as Strings. Some development platforms may not be able to preserve the distinction between a null for a DataType and a null for a Variant. Therefore applications shall not rely on this distinction.

Variants can contain arrays of Variants but they cannot directly contain another Variant.

DataValue and DiagnosticInfo types only have meaning when returned in a response message with an associated StatusCode. As a result, Variants cannot contain instances of DataValue or DiagnosticInfo. This requirement means that if an attribute supports the writing of a null value, it shall also support writing of an empty Variant and vice versa.

Variables with a DataType of BaseDataType are mapped to a Variant, however, the ValueRank and ArrayDimensions attributes place restrictions on what is allowed in the Variant. For example, if the ValueRank is Scalar, the Variant may only contain scalar values.

ExtensionObjects and Variants allow unlimited nesting which could result in stack overflow errors even if the message size is less than the maximum allowed. Decoders shall support at least 100 nesting levels. Decoders shall report an error if the number of nesting levels exceeds what it supports.

Function Documentation

◆ ua_variant_clear()

BASE_EXPORT void ua_variant_clear ( struct ua_variant v)

clear an ua_variant.

Frees all resources allocated by the varaiant v.

Parameters
vthe variant to be cleared. Will be a null-variant afterwards.

◆ ua_variant_compare()

BASE_EXPORT int ua_variant_compare ( const struct ua_variant a,
const struct ua_variant b 
)

Compare the variants a and b.

It returns an integer less than, equal to, or greater than zero if a is less than, matches, or is greater than b. Unfortunately errors cannot be distinguished from a valid result and return -1, which has the same meaning as a is less than b.

This can be used for sorting values.

  1. first the datatype is compared. If the datatypes are not equal the types are compared, which means a is smaller than b if a->type < b->type.
  2. if the types are equal the values get compared, which means simple numeric comparison for numeric values, and string compare for strings. For more complex types the according <type>_compare function is called.

◆ ua_variant_copy()

BASE_EXPORT int ua_variant_copy ( struct ua_variant dst,
const struct ua_variant src 
)

Create a copy of variant src.

Parameters
dstpointer to preallocated variant, is not required to be initialized. If dst is already a variant that holds further memory, it will not be freed.
srcthe variant to copy.
Returns
0 on success or errorcode on failure. If copy fails all resources allocated during copy are released and no clear must be called on dst.

◆ ua_variant_get_type()

static enum ua_variant_type ua_variant_get_type ( const struct ua_variant v)
inlinestatic

Returns the built-in datatype of the given variant.

This unmasks any array or matrix flags so that the return value contains the pure datatype information.

◆ ua_variant_is_array()

static bool ua_variant_is_array ( const struct ua_variant v)
inlinestatic

Returns true if the given variant is an array.

This is also true for matrix values.

◆ ua_variant_is_matrix()

static bool ua_variant_is_matrix ( const struct ua_variant v)
inlinestatic

Returns true if the given variant is a matrix.

A matrix is any form for multi-dimensional array, which has more than one dimension.

◆ ua_variant_is_scalar()

static bool ua_variant_is_scalar ( const struct ua_variant v)
inlinestatic

Returns true if the given variant is a scalar value.