Core types
Hand-written built-in OPC UA types: NodeId, Variant, StatusCode, DataValue, QualifiedName, LocalizedText, and friends.
ua::Size
struct
Tag wrapper requesting an Array of a given length, default-initialized.
Disambiguates the size-constructing Array overload from the std::initializer_list<T> constructor under brace initialization: Array<int>{Size{4}} builds four default elements, whereas Array<int>{4} builds a single element with value 4.
Public attributes
size_t value
Number of elements to create.
ua::Array
class
An owning, optionally multi-dimensional sequence of OPC UA values of element type T.
Wraps a contiguous std::vector<T> payload and the Dimensions inherited from ArrayBase. With no dimensions set the array is a flat one-dimensional sequence; when dimensions are present the flattened payload length must equal their product (validated at construction). Element access, iteration, and growth mirror std::vector. Array<bool> is supported via std::vector<bool>'s proxy references.
T Element type - an OPC UA built-in type for which built_in_type is defined.
Member types
T value_type
The element type, so generic code (and Variant::to) can recover T from an Array<T>.
Functions
Array()
Constructs an empty array with no dimensions.
Move-constructs from other, transferring its payload and dimensions.
other(Array &&) - The array to move from; left empty and valid.
Move-assigns from other, transferring its payload and dimensions.
other(Array &&) - The array to move from; left empty and valid.
Returns: A reference to this array.
Copy-constructs a deep copy of other, including its dimensions.
other(const Array &) - The array to deep-copy.
Constructs an array of size default-initialized elements with no dimensions.
size(Size) - Number of elements to create; see Size for why this is wrapped.
Array(const Dimensions &dimensions, const std::vector< T > &payload)
Constructs a dimensioned array from a flattened payload.
dimensions(const Dimensions &) - Length along each dimension, outermost first; empty leaves the array one-dimensional.payload(const std::vector< T > &) - Flattened elements in row-major order.
Copy-assigns a deep copy of other, including its dimensions.
other(const Array &) - The array to deep-copy.
Returns: A reference to this array.
~Array() override=default
Destroys the array, releasing its payload.
Array(std::initializer_list< T > init)
Constructs a one-dimensional array from a braced initializer list.
init(std::initializer_list< T >) - The elements to copy into the payload, in order.
Array & operator=(const std::vector< T > &elements)
Replaces the payload with elements, leaving the dimensions unchanged.
elements(const std::vector< T > &) - The new flattened payload to copy in.
Returns: A reference to this array.
bool operator==(const Array &) const
Returns whether both arrays have equal payloads and equal dimensions.
Returns: true if the payloads and dimensions both compare equal, false otherwise.
std::vector< T >::const_reference operator[](size_t index) const
Returns the element at index without bounds checking.
index(size_t) - Zero-based offset into the flattened payload; must be less than size.
Returns: A reference to the element; for Array<bool> a proxy reference.
std::vector< T >::reference operator[](size_t index)
Returns a mutable reference to the element at index without bounds checking.
index(size_t) - Zero-based offset into the flattened payload; must be less than size.
Returns: A reference to the element; for Array<bool> a proxy reference.
size_t size() const override
Returns the number of elements in the flattened payload.
Returns: The element count of the payload.
const std::vector< T > & payload() const
Returns the underlying flattened payload.
Returns: A const reference to the flattened payload vector.
std::vector< T > & payload()
Returns a mutable reference to the underlying flattened payload.
Returns: A mutable reference to the flattened payload vector.
bool empty() const
Returns whether the payload contains no elements.
Returns: true if the payload is empty, false otherwise.
span< const T > as_span() const
Returns a read-only view over the flattened payload.
Returns: A span valid until the array is resized, reassigned, or destroyed.
span< T > as_span()
Returns a mutable view over the flattened payload.
Returns: A span valid until the array is resized, reassigned, or destroyed.
auto begin() const
Returns a const iterator to the first element of the flattened payload.
Returns: A const iterator to the first element, or end if the payload is empty.
auto begin()
Returns an iterator to the first element of the flattened payload.
Returns: An iterator to the first element, or end if the payload is empty.
auto end() const
Returns a const iterator one past the last element of the flattened payload.
Returns: A const iterator one past the last element.
auto end()
Returns an iterator one past the last element of the flattened payload.
Returns: An iterator one past the last element.
BuiltInTypeId built_in_type_id() const override
Returns the OPC UA built-in type identifier of the element type T.
Returns: The BuiltInTypeId corresponding to element type T.
unique_ptr< Array > clone() const
Returns an owning deep copy of this array as a base-class pointer.
Returns: A unique_ptr owning a deep copy of this array.
void reserve(size_t capacity)
Reserves capacity for at least capacity elements without changing size.
capacity(size_t) - Minimum number of elements the payload should be able to hold.
void resize(size_t size)
Resizes the payload to size elements, default-initializing any new ones.
size(size_t) - Number of elements the payload should contain after the call.
void push_back(const T &value)
Appends a copy of value to the payload.
value(const T &) - The element to copy onto the end of the payload.
void push_back(T &&value)
Appends value to the payload by move.
value(T &&) - The element to move onto the end of the payload.
T & emplace_back(Args &&... args)
Constructs an element in place at the end of the payload.
args(Args &&...) - Arguments forwarded to the element constructor.
Returns: A reference to the newly constructed element.
void clear()
Removes all elements and clears any dimensions.
Deep-copies the payload of other over this array's payload.
other(const Array< U > &) - The source array whose payload is copied in.
Returns: *this.
ua::ArrayBase
class
Element-type-erased base of the Array<T> value type.
Holds the dimension metadata shared by every array element type and exposes the type-agnostic operations (element count, value rank, built-in type) that callers can use without knowing the static element type. The concrete element storage lives in the derived Array<T>; the pure-virtual hooks below form its extension contract.
Functions
~ArrayBase()=default
bool operator==(const ArrayBase &) const =default
Compares two arrays for equality by their dimension metadata.
Returns: true if both arrays have equal dimension metadata; otherwise false.
const optional< ua::Dimensions > & dimensions() const
Returns the array dimensions, or an empty optional if none are set.
Returns: The dimension sizes (outermost first), or nullopt for an array that carries no explicit dimension metadata.
optional< ua::Dimensions > & dimensions()
Returns a mutable reference to the array dimensions.
Returns: A mutable reference to the optional array dimensions (outermost first).
size_t size() const =0
Returns the total number of elements stored in the array.
Returns: The total number of elements stored in the array.
int32_t value_rank() const
Returns the value rank, i.e.
Returns: The count of entries in dimensions, or 1 when no dimension metadata is set (an array is at least one-dimensional).
BuiltInTypeId built_in_type_id() const =0
Returns the built-in type identifier of the array's element type.
Returns: The built-in type identifier of the array's element type.
void add_and_validate_dimensions(Dimensions &&dims)
Sets the array dimensions after validating them against the element count.
dims(Dimensions &&) - The dimension sizes to install (outermost first); consumed on success.
ua::ByteString
class
The OPC UA ByteString built-in type: an owning, contiguous sequence of bytes.
Stores its bytes in a std::vector<uint8_t> and exposes a container-like interface (indexing, iteration, resize/reserve, span conversions) so it can be used wherever raw binary data is carried on the wire - opaque blobs, certificates, nonces, and encoded payloads.
A ByteString distinguishes the null state (no value present, as encoded by a length of -1 on the wire) from the empty state (a value present with zero bytes); see is_null() versus empty(). A default-constructed instance is null.
Member types
uint8_t value_type
Element type of the byte sequence.
std::vector< uint8_t >::iterator iterator
Mutable iterator over the bytes.
std::vector< uint8_t >::const_iterator const_iterator
Read-only iterator over the bytes.
Static functions
BuiltInTypeId built_in_type_id()
Returns the built-in type identifier for ByteString.
Returns: Always BuiltInTypeId::ByteString.
Functions
ByteString()=default
Constructs a null ByteString (no value present).
ByteString(const ByteString &)=default
Copies the bytes of the source.
ByteString(ByteString &&) noexcept=default
Steals the bytes of the source, leaving it null.
ByteString & operator=(const ByteString &)=default
Copy-assigns the bytes of the source.
Returns: *this.
ByteString & operator=(ByteString &&) noexcept=default
Move-assigns the bytes of the source, leaving it null.
Returns: *this.
~ByteString()=default
Destroys the ByteString, releasing its bytes.
ByteString(std::initializer_list< uint8_t > init)
Constructs from a brace-enclosed list of byte values.
init(std::initializer_list< uint8_t >) - Brace-enclosed byte values copied into the new ByteString.
ByteString(size_t count, uint8_t value)
Constructs a ByteString of count bytes, each equal to value.
count(size_t) - Number of bytes.value(uint8_t) - Value each byte is initialised to.
ByteString(std::vector< uint8_t > data)
Constructs by taking ownership of an existing byte vector.
data(std::vector< uint8_t >) - Byte buffer; moved into the new ByteString.
ByteString(span< const uint8_t > data)
Constructs by copying the bytes viewed by data.
data(span< const uint8_t >) - View over the source bytes; not retained after construction.
ByteString(span< const byte > data)
Constructs by copying the bytes viewed by data.
data(span< const byte >) - View over the source bytes; not retained after construction.
ByteString(InputIt first, InputIt last)
Constructs by copying the byte range [first, last).
first(InputIt) - Iterator to the first byte.last(InputIt) - Iterator one past the last byte.
bool operator==(const ByteString &) const =default
Compares two ByteStrings for byte-wise equality.
Returns: true if the two byte sequences are identical; false otherwise.
auto operator<=>(const ByteString &) const =default
Orders two ByteStrings lexicographically by their bytes.
Returns: The lexicographical ordering of the two byte sequences.
bool is_null() const
Returns whether this ByteString is null (no value present).
Returns: true if this ByteString is null (no value present); false otherwise.
bool empty() const
Returns whether the byte sequence contains no bytes.
Returns: true if the sequence holds no bytes; false otherwise.
size_t size() const
Returns the number of bytes held.
Returns: The number of bytes held.
void resize(size_t count)
Resizes the sequence to count bytes, value-initialising any new bytes.
count(size_t) - New byte count.
void resize(size_t count, uint8_t value)
Resizes the sequence to count bytes, filling any new bytes with value.
count(size_t) - New byte count.value(uint8_t) - Value used to fill bytes appended when growing.
void reserve(size_t capacity)
Reserves storage for at least capacity bytes without changing size().
capacity(size_t) - Minimum capacity to allocate.
void clear()
Removes all bytes, leaving size() == 0.
uint8_t & operator[](size_t index)
Returns a reference to the byte at index.
index(size_t) - Zero-based position; must be less than size().
Returns: Mutable reference to the indexed byte.
const uint8_t & operator[](size_t index) const
Returns a const reference to the byte at index.
index(size_t) - Zero-based position; must be less than size().
Returns: Read-only reference to the indexed byte.
uint8_t * data()
Returns a pointer to the first byte of the contiguous storage.
Returns: Pointer to the byte buffer, or nullptr if empty. The pointer is invalidated by any operation that reallocates (resize, reserve, push_back, clear).
const uint8_t * data() const
Returns a const pointer to the first byte of the contiguous storage.
Returns: Pointer to the byte buffer, or nullptr if empty. The pointer is invalidated by any operation that reallocates (resize, reserve, push_back, clear).
std::vector< uint8_t >::iterator begin()
Returns a mutable iterator to the first byte.
Returns: Mutable iterator to the first byte.
std::vector< uint8_t >::const_iterator begin() const
Returns a const iterator to the first byte.
Returns: Read-only iterator to the first byte.
std::vector< uint8_t >::iterator end()
Returns a mutable iterator one past the last byte.
Returns: Mutable iterator one past the last byte.
std::vector< uint8_t >::const_iterator end() const
Returns a const iterator one past the last byte.
Returns: Read-only iterator one past the last byte.
void push_back(uint8_t value)
Appends one byte to the end of the sequence.
value(uint8_t) - Byte to append.
void assign(const uint8_t *first, const uint8_t *last)
Replaces the contents with the byte range [first, last).
first(const uint8_t *) - Pointer to the first source byte.last(const uint8_t *) - Pointer one past the last source byte.
operator span< uint8_t >()
Returns a mutable span over the bytes.
operator span< const uint8_t >() const
Returns a read-only span over the bytes.
operator span< byte >()
Returns a mutable std::byte span over the bytes.
operator span< const byte >() const
Returns a read-only std::byte span over the bytes.
std::vector< uint8_t > & payload()
Returns a reference to the underlying byte vector.
Returns: Mutable reference to the backing storage, owned by this ByteString.
const std::vector< uint8_t > & payload() const
Returns a const reference to the underlying byte vector.
Returns: Read-only reference to the backing storage, owned by this ByteString.
ua::CodecNamespaceContext
struct
Bundle of namespace-resolution and index-translation hooks supplied to codecs.
Groups the URI-to-index resolver used during encoding with the optional in-place translators applied to decoded/encoded values. All hooks are invoked synchronously by the codec on the calling thread; an unset hook is simply not invoked. Each hook owns its captured state for the lifetime of the context.
Static functions
CodecNamespaceContext for_address_space(WeakAddressSpace addressSpace)
Creates a context whose resolver reads indexes from a weak AddressSpace reference.
addressSpace(WeakAddressSpace) - Weak reference consulted for URI-to-index resolution.
Returns: A context whose resolver is bound to addressSpace.
CodecNamespaceContext with_translators(NodeIdTranslator translateNodeId, QualifiedNameTranslator translateQualifiedName, ExpandedNodeIdTranslator translateExpandedNodeId)
Creates a context carrying only in-place index translators and no resolver.
translateNodeId(NodeIdTranslator) - Translator applied to NodeId values.translateQualifiedName(QualifiedNameTranslator) - Translator applied to QualifiedName values.translateExpandedNodeId(ExpandedNodeIdTranslator) - Translator applied to ExpandedNodeId values.
Returns: A context with the given translators and an unset resolver.
Functions
CodecNamespaceContext()=default
Constructs a context with no resolver and no translators.
CodecNamespaceContext(NamespaceIndexResolver getNamespaceIndex, NodeIdTranslator translateNodeId={}, QualifiedNameTranslator translateQualifiedName={}, ExpandedNodeIdTranslator translateExpandedNodeId={})
Constructs a context from a resolver and optional translators.
getNamespaceIndex(NamespaceIndexResolver) - Resolver for URI-to-index lookups.translateNodeId(NodeIdTranslator) - Optional NodeId translator; omit to leave unset.translateQualifiedName(QualifiedNameTranslator) - Optional QualifiedName translator; omit to leave unset.translateExpandedNodeId(ExpandedNodeIdTranslator) - Optional ExpandedNodeId translator; omit to leave unset.
Public attributes
NamespaceIndexResolver mGetNamespaceIndex
Resolves a namespace URI to a runtime index for encoders and generated code.
NodeIdTranslator mTranslateNodeId
Optional in-place translator applied to NodeId values; unset to skip translation.
QualifiedNameTranslator mTranslateQualifiedName
Optional in-place translator applied to QualifiedName values; unset to skip translation.
ExpandedNodeIdTranslator mTranslateExpandedNodeId
Optional in-place translator applied to ExpandedNodeId values; unset to skip translation.
ua::DataValue
class
A value together with its quality status and source/server timestamps.
Models the OPC UA DataValue built-in type: the Variant payload plus the optional metadata that accompanies it on the wire - a quality StatusCode and the source- and server-side timestamps (each with optional picosecond precision). Every metadata field is optional and absent by default; only the value is always present (a default-constructed instance holds a null Variant). This is a plain value type with no thread-affinity: copies are independent and any thread may use a given instance, but concurrent access to the same instance is not synchronized.
Static functions
BuiltInTypeId built_in_type_id()
Returns the built-in type identifier of this type (BuiltInTypeId::DataValue).
Returns: BuiltInTypeId::DataValue.
Functions
Constructs a null data value: a null Variant with no status or timestamps.
~DataValue()
Deep-copies other, independently cloning its Variant payload and metadata.
other(const DataValue &) - The data value to copy from.
Move-constructs from other, transferring its payload; other is left holding a null value.
other(DataValue &&) - The data value to move from; left holding a null value.
Deep-copies other, independently cloning its Variant payload and metadata.
other(const DataValue &) - The data value to copy from.
Returns: *this.
Move-assigns from other, transferring its payload; other is left holding a null value.
other(DataValue &&) - The data value to move from; left holding a null value.
Returns: *this.
Constructs a data value carrying only the given value, with no status or timestamps.
value(Variant) - The payload; moved into the new instance.
DataValue(Variant value, StatusCode status)
Constructs a data value carrying the given value and quality status.
value(Variant) - The payload; moved into the new instance.status(StatusCode) - The quality StatusCode for the value.
Constructs a data value carrying the given value and source timestamp.
value(Variant) - The payload; moved into the new instance.sourceTimestamp(DateTime) - The instant at which the source produced the value.
DataValue(Variant value, StatusCode status, DateTime sourceTimestamp)
Constructs a data value carrying the given value, quality status, and source timestamp.
value(Variant) - The payload; moved into the new instance.status(StatusCode) - The quality StatusCode for the value.sourceTimestamp(DateTime) - The instant at which the source produced the value.
DataValue(StatusCode status)
Constructs a data value carrying only a quality status, with a null Variant.
status(StatusCode) - The quality StatusCode, typically a bad code reporting why no value is present.
bool operator==(const DataValue &obj) const
Compares two data values for equality across the value and all metadata fields.
obj(const DataValue &) - The data value to compare against.
Returns: true if the value and every metadata field are equal; false otherwise.
const Variant & value() const
Returns the contained value.
Returns: The contained Variant payload.
Variant & value()
Returns a mutable reference to the contained value.
Returns: Mutable reference to the contained Variant payload.
const optional< StatusCode > & status() const
Returns the quality status, or an empty optional if none is set.
Returns: The quality StatusCode, or an empty optional if none is set.
optional< StatusCode > & status()
Returns a mutable reference to the optional quality status.
Returns: Mutable reference to the optional quality StatusCode.
const optional< DateTime > & source_timestamp() const
Returns the source timestamp, or an empty optional if none is set.
Returns: The source timestamp, or an empty optional if none is set.
optional< DateTime > & source_timestamp()
Returns a mutable reference to the optional source timestamp.
Returns: Mutable reference to the optional source timestamp.
const optional< uint16_t > & source_pico_seconds() const
Returns the source picosecond refinement, or an empty optional if none is set.
Returns: The source-timestamp refinement in picoseconds (0..sMaxPicoSeconds), or nullopt.
optional< uint16_t > & source_pico_seconds()
Returns a mutable reference to the optional source picosecond refinement.
Returns: Mutable reference to the optional source-timestamp picosecond refinement.
const optional< DateTime > & server_timestamp() const
Returns the server timestamp, or an empty optional if none is set.
Returns: The server timestamp, or an empty optional if none is set.
optional< DateTime > & server_timestamp()
Returns a mutable reference to the optional server timestamp.
Returns: Mutable reference to the optional server timestamp.
const optional< uint16_t > & server_pico_seconds() const
Returns the server picosecond refinement, or an empty optional if none is set.
Returns: The server-timestamp refinement in picoseconds (0..sMaxPicoSeconds), or nullopt.
optional< uint16_t > & server_pico_seconds()
Returns a mutable reference to the optional server picosecond refinement.
Returns: Mutable reference to the optional server-timestamp picosecond refinement.
bool is_null() const
Returns whether the contained value is null.
Returns: true if the Variant payload is null; the status and timestamp metadata do not affect this result.
void clear()
Resets to the null, metadata-free state of a default-constructed instance.
Static attributes
const uint16_t sMaxPicoSeconds
Maximum representable picosecond offset for either picosecond field, in picoseconds.
ua::DateTime
class
An OPC UA DateTime: a UTC instant stored at 100-nanosecond resolution.
Wraps a std::chrono::sys_time measured in datetime::OneHundredNanoSeconds (UTC, no time-zone offset is retained). Values are totally ordered by their underlying instant via the defaulted three-way comparison. The representable range runs from min (1601-01-01T00:00:00Z, the OPC UA epoch) to max (9999-12-31T23:59:59Z).
Static functions
DateTime from_iso_string(string_view iso)
Parses an ISO 8601 UTC string in the format YYYY-MM-DDTHH:MM:SS[.fffffff]Z.
iso(string_view) - Text to parse; the trailing Z (UTC) designator is required.
Returns: The parsed instant.
DateTime now()
Returns the current UTC time, truncated to 100-nanosecond resolution.
Returns: The current UTC time, truncated to 100-nanosecond resolution.
consteval std::chrono::sys_time< datetime::OneHundredNanoSeconds > min()
Returns the smallest representable instant: the OPC UA epoch 1601-01-01T00:00:00Z.
Returns: The OPC UA epoch 1601-01-01T00:00:00Z.
consteval std::chrono::sys_time< datetime::OneHundredNanoSeconds > max()
Returns the largest representable instant: 9999-12-31T23:59:59Z.
Returns: The largest representable instant, 9999-12-31T23:59:59Z.
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for DateTime.
Returns: BuiltInTypeId::DateTime.
Functions
DateTime()
Constructs the null DateTime (min, the OPC UA epoch), for which is_null is true.
DateTime(std::chrono::sys_time< datetime::OneHundredNanoSeconds > timePoint)
Constructs from an absolute UTC instant at 100-nanosecond resolution.
timePoint(std::chrono::sys_time< datetime::OneHundredNanoSeconds >) - UTC instant; any sub-100 ns precision is already excluded by the tick type.
DateTime(std::chrono::year year, std::chrono::month month, std::chrono::day day, std::chrono::hours hours, std::chrono::minutes minutes, double seconds, std::chrono::minutes offset=std::chrono::minutes{0})
Constructs from broken-down calendar fields in a fixed UTC offset.
year(std::chrono::year) - Calendar year.month(std::chrono::month) - Calendar month (1-12).day(std::chrono::day) - Day of month (1-31).hours(std::chrono::hours) - Hour of day (0-23) in the supplied offset.minutes(std::chrono::minutes) - Minute of hour (0-59) in the supplied offset.seconds(double) - Seconds within the minute; the fractional part carries sub-second precision.offset(std::chrono::minutes) - Offset of the supplied fields from UTC; subtracted to normalise to UTC.
DateTime(int year, int month, int day, int hours, int minutes, double seconds, int offset=0)
Constructs from broken-down calendar fields given as plain integers in a fixed UTC offset.
year(int) - Calendar year.month(int) - Calendar month (1-12).day(int) - Day of month (1-31).hours(int) - Hour of day (0-23) in the supplied offset.minutes(int) - Minute of hour (0-59) in the supplied offset.seconds(double) - Seconds within the minute; the fractional part carries sub-second precision.offset(int) - Offset in minutes from UTC; subtracted to normalise to UTC.
Copies the wrapped instant.
dateTime(const DateTime &) - The value to copy from.
Copies the wrapped instant (the value type is trivially copyable; nothing is stolen).
dateTime(DateTime &&) - The value to move from (copied, as the type is trivially copyable).
Copy-assigns the wrapped instant.
dateTime(const DateTime &) - The value to copy from.
Returns: *this.
Copy-assigns the wrapped instant (the value type is trivially copyable; nothing is stolen).
dateTime(DateTime &&) - The value to move from (copied, as the type is trivially copyable).
Returns: *this.
~DateTime()=default
Destroys the DateTime value.
auto operator<=>(const DateTime &obj) const =default
Orders two values by their underlying UTC instant.
obj(const DateTime &) - The value to compare against.
Returns: The ordering of the two underlying UTC instants.
std::chrono::sys_time< datetime::OneHundredNanoSeconds > & value()
Returns a mutable reference to the underlying UTC instant.
Returns: Reference to the wrapped sys_time; valid for the lifetime of this DateTime.
const std::chrono::sys_time< datetime::OneHundredNanoSeconds > & value() const
Returns the underlying UTC instant.
Returns: Reference to the wrapped sys_time; valid for the lifetime of this DateTime.
bool is_null() const
Reports whether this value is the OPC UA null sentinel (min, the epoch instant).
Returns: true if this value equals min (the OPC UA null sentinel); false otherwise.
std::string as_iso_string() const
Formats the instant as an ISO 8601 UTC string YYYY-MM-DDTHH:MM:SS[.fffffff]Z.
Returns: The instant as an ISO 8601 UTC string.
ua::Decimal
class
An arbitrary-precision decimal number, as defined by OPC 10000-6.
A Decimal represents the rational value mantissa * 10^(-scale). The mantissa is a signed, arbitrary-length integer carried in value() as a little-endian two's-complement ByteString; scale() is the base-10 exponent. For example, a mantissa of 12345 with a scale of 2 denotes 123.45. A default-constructed Decimal has scale 0 and an empty mantissa, which denotes the value 0.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for Decimal.
Returns: BuiltInTypeId for this type.
Functions
Decimal()=default
Constructs a Decimal with scale 0 and an empty mantissa (the value 0).
Copies the scale and mantissa of other.
other(const Decimal &) - Decimal whose scale and mantissa are copied.
Moves other's mantissa, leaving it with the empty (value 0) mantissa.
other(Decimal &&) - Decimal whose mantissa is moved from; left with the empty mantissa.
Copy-assigns the scale and mantissa of other.
other(const Decimal &) - Decimal whose scale and mantissa are copied.
Returns: Reference to this Decimal.
Move-assigns other's mantissa, leaving it with the empty (value 0) mantissa.
other(Decimal &&) - Decimal whose mantissa is moved from; left with the empty mantissa.
Returns: Reference to this Decimal.
~Decimal()=default
Destroys the Decimal, releasing its mantissa.
bool operator==(const Decimal &obj) const =default
Compares two Decimals for exact representational equality.
obj(const Decimal &) - Decimal to compare against.
Returns: true when both the scale and the raw mantissa bytes match.
const int16_t & scale() const
Returns the base-10 exponent applied to the mantissa.
Returns: The base-10 exponent applied to the mantissa.
int16_t & scale()
Returns a mutable reference to the base-10 exponent.
Returns: Mutable reference to the base-10 exponent.
const ByteString & value() const
Returns the signed mantissa as a little-endian two's-complement byte string.
Returns: The mantissa as a little-endian two's-complement byte string.
ByteString & value()
Returns a mutable reference to the mantissa byte string.
Returns: Mutable reference to the mantissa byte string.
void clear()
Resets to scale 0 and an empty mantissa (the value 0).
ua::DiagnosticInfo
class
Optional diagnostic detail attached to a service or operation result.
Mirrors the OPC UA built-in DiagnosticInfo type (Part 4 / Part 6). The four index fields (symbolic_id, namespace_uri, locale, localized_text) are zero-based indices into the response's string table, not strings themselves; they are only meaningful alongside the table that produced them. A nested inner_diagnostic_info forms a chain that follows the corresponding chain of inner_status_code values back to the originating service.
Every field is optional: a default-constructed value carries no diagnostic information (is_null returns true) and encodes to the empty wire form.
Static functions
BuiltInTypeId built_in_type_id()
Returns the built-in type identifier for DiagnosticInfo.
Returns: BuiltInTypeId for this type.
Functions
DiagnosticInfo()=default
Constructs a null DiagnosticInfo (no field set; is_null is true).
DiagnosticInfo(const DiagnosticInfo &other)
Deep-copies other, cloning the whole inner_diagnostic_info chain.
other(const DiagnosticInfo &) - DiagnosticInfo to deep-copy.
DiagnosticInfo(DiagnosticInfo &&other) noexcept=default
Move-constructs from other, transferring its inner-diagnostic chain; other is left null.
other(DiagnosticInfo &&) - DiagnosticInfo to move from; left null.
DiagnosticInfo & operator=(const DiagnosticInfo &other)
Deep-copies other, cloning the whole inner_diagnostic_info chain.
other(const DiagnosticInfo &) - DiagnosticInfo to deep-copy.
Returns: Reference to this DiagnosticInfo.
DiagnosticInfo & operator=(DiagnosticInfo &&other) noexcept=default
Move-assigns from other, transferring its inner-diagnostic chain; other is left null.
other(DiagnosticInfo &&) - DiagnosticInfo to move from; left null.
Returns: Reference to this DiagnosticInfo.
~DiagnosticInfo()=default
Destroys the DiagnosticInfo, releasing its inner-diagnostic chain.
bool operator==(const DiagnosticInfo &obj) const
Compares all fields for equality, recursing into inner_diagnostic_info.
obj(const DiagnosticInfo &) - DiagnosticInfo to compare against.
Returns: true when every field is equal, including the nested diagnostic chain.
const optional< int32_t > & symbolic_id() const
Index of the symbolic name in the response string table, if set.
Returns: The symbolic-name index, or an empty optional when unset.
optional< int32_t > & symbolic_id()
Mutable accessor for symbolic_id.
Returns: Mutable reference to the symbolic-name index optional.
const optional< int32_t > & namespace_uri() const
Index of the namespace URI in the response string table, if set.
Returns: The namespace-URI index, or an empty optional when unset.
optional< int32_t > & namespace_uri()
Mutable accessor for namespace_uri.
Returns: Mutable reference to the namespace-URI index optional.
const optional< int32_t > & locale() const
Index of the locale in the response string table, if set.
Returns: The locale index, or an empty optional when unset.
optional< int32_t > & locale()
Mutable accessor for locale.
Returns: Mutable reference to the locale index optional.
const optional< int32_t > & localized_text() const
Index of the localized text in the response string table, if set.
Returns: The localized-text index, or an empty optional when unset.
optional< int32_t > & localized_text()
Mutable accessor for localized_text.
Returns: Mutable reference to the localized-text index optional.
const optional< std::string > & additional_info() const
Vendor-specific additional diagnostic text, if set.
Returns: The additional diagnostic text, or an empty optional when unset.
optional< std::string > & additional_info()
Mutable accessor for additional_info.
Returns: Mutable reference to the additional-info optional.
const optional< StatusCode > & inner_status_code() const
Status code of the inner (nested) operation, if this diagnostic wraps one.
Returns: The inner status code, or an empty optional when there is none.
optional< StatusCode > & inner_status_code()
Mutable accessor for inner_status_code.
Returns: Mutable reference to the inner-status-code optional.
const unique_ptr< DiagnosticInfo > & inner_diagnostic_info() const
Nested diagnostic for the inner operation, forming a diagnostic chain.
Returns: The nested diagnostic, or a null pointer when there is no further nesting.
unique_ptr< DiagnosticInfo > & inner_diagnostic_info()
Mutable accessor for inner_diagnostic_info.
Returns: Mutable reference to the nested-diagnostic owning pointer.
bool is_null() const
Returns true when no field is set, i.e.
Returns: true when the object carries no diagnostic information.
bool is_not_null() const
Returns true when at least one field is set.
Returns: true when at least one field is set.
void clear()
Resets every field, returning the object to the null state.
ua::ExpandedNodeId
class
A NodeId extended with an optional namespace URI and server index.
Identifies a node that may live in another server's address space. Beyond the wrapped NodeId it carries two optional qualifiers: a namespace URI that, when present, supersedes the wrapped NodeId's numeric namespace index (the URI is the authoritative namespace identity; the index is meaningful only relative to a particular server's namespace table); a server index into the local server's ServerArray, where 0 denotes the local server.
A default-constructed instance is null (index-based, local, and wrapping a null NodeId); see is_null(). Equality is member-wise over the wrapped NodeId, namespace URI, and server index, so two values that designate the same node by different means (URI versus index) do not compare equal. NodeId
Static functions
BuiltInTypeId built_in_type_id()
Returns the built-in type identifier for ExpandedNodeId.
Returns: Always BuiltInTypeId::ExpandedNodeId.
Functions
ExpandedNodeId()=default
Constructs a null ExpandedNodeId (null NodeId, empty namespace URI, server index 0).
ExpandedNodeId(NodeId nodeId)
Constructs an index-based, local ExpandedNodeId wrapping nodeId.
nodeId(NodeId) - Node identity to wrap; its namespace index is retained as-is.
ExpandedNodeId(NodeId nodeId, string_view namespaceUri)
Constructs a local ExpandedNodeId identified by namespace URI.
nodeId(NodeId) - Node identity to wrap.namespaceUri(string_view) - Namespace URI; copied into this value.
ExpandedNodeId(NodeId nodeId, uint32_t serverIndex)
Constructs an index-based ExpandedNodeId on the server addressed by serverIndex.
nodeId(NodeId) - Node identity to wrap.serverIndex(uint32_t) - Index into the local server's ServerArray; 0 denotes the local server.
ExpandedNodeId(NodeId nodeId, string_view namespaceUri, uint32_t serverIndex)
Constructs an ExpandedNodeId with both a namespace URI and a server index.
nodeId(NodeId) - Node identity to wrap.namespaceUri(string_view) - Namespace URI; copied into this value.serverIndex(uint32_t) - Index into the local server's ServerArray; 0 denotes the local server.
ExpandedNodeId(const ExpandedNodeId &other)=default
Copies the wrapped NodeId, namespace URI, and server index.
other(const ExpandedNodeId &) - ExpandedNodeId to copy.
ExpandedNodeId(ExpandedNodeId &&other) noexcept=default
Moves other's NodeId and namespace URI, leaving it null.
other(ExpandedNodeId &&) - ExpandedNodeId to move from; left null.
ExpandedNodeId & operator=(const ExpandedNodeId &other)=default
Copy-assigns the wrapped NodeId, namespace URI, and server index.
other(const ExpandedNodeId &) - ExpandedNodeId to copy.
Returns: Reference to this ExpandedNodeId.
ExpandedNodeId & operator=(ExpandedNodeId &&other) noexcept=default
Move-assigns other's NodeId and namespace URI, leaving it null.
other(ExpandedNodeId &&) - ExpandedNodeId to move from; left null.
Returns: Reference to this ExpandedNodeId.
~ExpandedNodeId()=default
Destroys the ExpandedNodeId, releasing its wrapped NodeId and namespace URI.
bool operator==(const ExpandedNodeId &obj) const =default
Compares member-wise over the wrapped NodeId, namespace URI, and server index.
obj(const ExpandedNodeId &) - ExpandedNodeId to compare against.
Returns: true when the wrapped NodeId, namespace URI, and server index all match.
const NodeId & node_id() const
Returns the wrapped node identity.
Returns: Read-only reference to the wrapped NodeId, owned by this ExpandedNodeId.
NodeId & node_id()
Returns a mutable reference to the wrapped node identity.
Returns: Mutable reference to the wrapped NodeId, owned by this ExpandedNodeId.
const String & namespace_uri() const
Returns the namespace URI, or an empty String when this value is index-based.
Returns: Read-only reference to the namespace URI, owned by this ExpandedNodeId.
String & namespace_uri()
Returns a mutable reference to the namespace URI.
Returns: Mutable reference to the namespace URI, owned by this ExpandedNodeId.
uint32_t server_index() const
Returns the server index.
Returns: Index into the local server's ServerArray; 0 denotes the local server.
uint32_t & server_index()
Returns a mutable reference to the server index.
Returns: Mutable reference to the server index; 0 denotes the local server.
bool is_null() const
Reports whether this is the null ExpandedNodeId.
Returns: true when the value is index-based, local, and wraps a null NodeId.
bool is_local() const
Reports whether the value addresses the local server.
Returns: true when the server index is 0.
bool is_index_based() const
Reports whether the namespace is conveyed by index rather than URI.
Returns: true when no namespace URI is set (the wrapped NodeId's namespace index applies).
bool is_remote() const
Reports whether the value addresses a remote server.
Returns: true when the server index is non-zero.
bool is_not_index_based() const
Reports whether the namespace is conveyed by URI rather than index.
Returns: true when a namespace URI is set; the inverse of is_index_based().
void set_from_definition(string_view definition)
Parses an ExpandedNodeId from its textual definition, replacing the current value.
definition(string_view) - Textual ExpandedNodeId definition to parse.
std::string as_definition() const
Renders this value as its textual definition.
Returns: The textual ExpandedNodeId definition; round-trips through set_from_definition().
void clear()
Resets the value to null (clears the namespace URI, sets the server index to 0, and clears the wrapped NodeId).
NodeId to_node_id(const NamespaceIndexResolver &resolveNamespaceIndex) const
Resolves this value to a runtime-index NodeId.
resolveNamespaceIndex(const NamespaceIndexResolver &) - Synchronous URI-to-index resolver, invoked only when this value is not index-based.
Returns: The resolved NodeId.
ua::Guid
class
The OPC UA Guid built-in type: a 128-bit globally unique identifier.
Wraps a 16-byte UUID as defined by OPC 10000-6. The string form is the canonical hyphenated representation (e.g. "72962B91-FA75-4AE6-8D28-B404DC7DAF63"), and the wire form is the fixed 16-byte little-endian-fields encoding produced by as_ua_binary(). A default-constructed Guid is the all-zero (null) value; use generate() or create_and_generate() to obtain a fresh random identifier.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for Guid.
Returns: BuiltInTypeId for this type.
Guid create_and_generate()
Creates a new Guid holding a freshly generated random (version 4) UUID.
Returns: A newly generated Guid.
Functions
Guid()
Constructs the null (all-zero) Guid.
Guid(string_view definition)
Constructs a Guid by parsing its canonical hyphenated string form.
definition(string_view) - The textual UUID, e.g. "72962B91-FA75-4AE6-8D28-B404DC7DAF63".
Copies the 16-byte value. A Guid is a trivially copyable value.
Copies the 16-byte value (trivially copyable; the source is unchanged).
other(Guid &&) - Guid whose 16-byte value is copied.
Copy-assigns the 16-byte value.
other(const Guid &) - Guid whose 16-byte value is copied.
Returns: Reference to this Guid.
Copy-assigns the 16-byte value (trivially copyable; the source is unchanged).
other(Guid &&) - Guid whose 16-byte value is copied.
Returns: Reference to this Guid.
~Guid()=default
Destroys the Guid value.
bool operator==(const Guid &obj) const =default
Compares two Guids for byte-wise equality.
obj(const Guid &) - Guid to compare against.
Returns: true when the two 16-byte values are byte-wise equal.
std::strong_ordering operator<=>(const Guid &other) const
Orders two Guids by their 16-byte value.
other(const Guid &) - Guid to compare against.
Returns: The ordering of this Guid's bytes relative to other.
void swap(Guid &obj) noexcept
Swaps the contents of two Guids.
obj(Guid &) - Guid to swap contents with.
std::string as_string() const
Returns the canonical hyphenated string form of this Guid.
Returns: The textual UUID, e.g. "72962B91-FA75-4AE6-8D28-B404DC7DAF63".
void from_string(string_view definition)
Replaces this Guid by parsing its canonical hyphenated string form.
definition(string_view) - The textual UUID to parse.
std::array< byte, sLength > as_ua_binary() const
Encodes this Guid as its 16-byte OPC UA binary wire form.
Returns: The fixed-length, 16-byte encoding per OPC 10000-6.
void from_ua_binary(span< const byte > encoding)
Replaces this Guid by decoding its OPC UA binary wire form.
encoding(span< const byte >) - The 16-byte encoding to decode; must be exactly sLength bytes long.
bool is_null() const
Returns true if this is the null (all-zero) Guid.
Returns: true when every one of the 16 bytes is zero.
size_t hash() const
Returns a hash of this Guid suitable for use in unordered containers.
Returns: A hash of the 16-byte value.
void clear()
Resets this Guid to the null (all-zero) value.
void generate()
Replaces this Guid with a freshly generated random (version 4) UUID.
Static attributes
const size_t sLength
The fixed length of a Guid in bytes (16).
ua::LocalizedText
class
A human-readable text value tagged with a locale, optionally carrying several translations.
The OPC UA wire form of a LocalizedText is a single {locale, text} pair, but server-side storage may hold several translations of the same text for one node. This type normalises between two internal representations: a scalar case (a single {locale, text} pair) and a shared aggregate (two or more translations held behind a shared_ptr). Copies of a multi-translation value stay O(1), and callers that only deal with the single-translation case never pay for the aggregate apparatus.
Locale resolution - collapsing an aggregate to the scalar appropriate for a given session is driven by resolve. A default-constructed value is scalar-empty (see is_null).
Member types
A single {locale, text} translation pair.
Static functions
LocalizedText from_translations(std::vector< Scalar > translations)
Builds a value from a list of translations, choosing scalar or aggregate storage.
translations(std::vector< Scalar >) - Translation pairs, in insertion order (the first entry becomes the canonical scalar view).
Returns: The normalised value.
bool is_locale_format_valid(string_view locale)
Returns true if locale is a syntactically valid OPC UA locale identifier.
locale(string_view) - Candidate locale string (e.g. "en", "en-US").
Returns: True if locale is a syntactically valid OPC UA locale identifier.
Splits a locale identifier into its {language, region} components.
locale(string_view) - Locale string to parse (e.g. "en-US").
Returns: The {language, region} pair; the region is empty when none is present.
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for LocalizedText.
Returns: The OPC UA built-in type identifier for LocalizedText.
Functions
LocalizedText()=default
Constructs a scalar-empty value (empty locale and empty text).
LocalizedText(const LocalizedText &other)=default
Copies other; an aggregate is shared by pointer, so the copy is O(1).
other(const LocalizedText &) - LocalizedText to copy.
LocalizedText(LocalizedText &&other) noexcept=default
Move-constructs from other, leaving it scalar-empty.
other(LocalizedText &&) - LocalizedText to move from; left scalar-empty.
LocalizedText & operator=(const LocalizedText &other)=default
Copy-assigns other; an aggregate is shared by pointer, so the copy is O(1).
other(const LocalizedText &) - LocalizedText to copy.
Returns: Reference to this LocalizedText.
LocalizedText & operator=(LocalizedText &&other) noexcept=default
Move-assigns from other, leaving it scalar-empty.
other(LocalizedText &&) - LocalizedText to move from; left scalar-empty.
Returns: Reference to this LocalizedText.
~LocalizedText()=default
Destroys the value, releasing any shared aggregate storage.
LocalizedText(LocaleId locale, String text)
Constructs a scalar value from an explicit locale and text.
LocalizedText(String text)
Constructs a scalar value with the given text and an empty locale.
text(String) - Text of the translation; the locale is left empty.
const LocaleId & locale() const
Returns the canonical locale - on an aggregate, the first-inserted entry's locale.
Returns: The canonical locale.
const String & text() const
Returns the canonical text - on an aggregate, the first-inserted entry's text.
Returns: The canonical text.
LocaleId & locale()
Returns a mutable reference to the scalar locale for in-place assignment.
Returns: A mutable reference to the scalar locale.
String & text()
Returns a mutable reference to the scalar text for in-place assignment.
Returns: A mutable reference to the scalar text.
bool is_scalar() const noexcept
Returns true if the value is stored as a single {locale, text} pair.
Returns: True if the value is stored as a single {locale, text} pair.
bool is_aggregate() const noexcept
Returns true if the value holds two or more translations in shared aggregate storage.
Returns: True if the value holds two or more translations in shared aggregate storage.
std::size_t translation_count() const noexcept
Returns the number of translations held (0 for scalar-empty, 1 for scalar, >= 2 for an aggregate).
Returns: The number of translations held.
std::optional< String > text_for_locale(string_view locale) const
Returns the text for an exact locale match, or nullopt if no translation carries it.
locale(string_view) - Locale identifier to match exactly (no fallback or language-only matching).
Returns: The matching text, or nullopt if absent.
std::vector< Scalar > translations() const
Returns a flat snapshot of all translations as Scalar pairs.
Returns: A snapshot vector of all translations as Scalar pairs.
LocalizedText with_translation(LocaleId locale, String text) const
Returns a copy with text set for locale, leaving the receiver untouched.
locale(LocaleId) - Locale to upsert.text(String) - Text to store (empty stores an explicit empty translation, not a deletion).
Returns: A new value with the translation applied.
LocalizedText without_translation(string_view locale) const
Returns a copy with the given locale removed, leaving the receiver untouched.
locale(string_view) - Locale to remove; a no-op if the receiver carries no such translation.
Returns: A new value, normalised to scalar if the removal leaves fewer than two entries.
LocalizedText merged_with(const LocalizedText &update) const
Returns a copy merged with update per spec 5.10.4 client-write semantics.
update(const LocalizedText &) - The incoming client write to apply.
Returns: A new merged value.
LocalizedText resolve() const
Resolves to the canonical scalar with no session context or server default.
Returns: A value for which is_scalar() is true.
LocalizedText resolve(span< const LocaleId > locales) const
Resolves to the best-matching scalar for the given session locales.
locales(span< const LocaleId >) - Session-preferred locales, in priority order.
Returns: A value for which is_scalar() is true.
LocalizedText resolve(span< const LocaleId > locales, const LocaleId &defaultLocale) const
Resolves to the best-matching scalar for the session locales plus a server-wide default.
locales(span< const LocaleId >) - Session-preferred locales, in priority order.defaultLocale(const LocaleId &) - Server-wide default locale, tried after the session locales.
Returns: A value for which is_scalar() is true.
bool is_null() const
Returns true if the value is scalar-empty (empty locale and empty text, no aggregate).
Returns: True if the value is scalar-empty.
void clear()
Resets the value to scalar-empty.
ua::NodeId
class
An OPC UA node identifier (OPC 10000-6 5.2.2.9).
Identifies a node within an OPC UA address space. A NodeId pairs a namespace index with an Identifier whose value is one of four OPC UA identifier types: numeric, string, GUID, or opaque (ByteString). The numerous typed constructors accept the generated NS0 identifier enums (ObjectId, VariableId, etc.) as a convenience for referring to standard nodes.
This is a plain value type: copyable, movable, comparable, and hashable. It holds no external resources and is not tied to any thread or strand.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type id for NodeId.
Returns: The BuiltInTypeId for NodeId.
Functions
NodeId()=default
Constructs a null NodeId in namespace 0 (numeric identifier 0).
NodeId(uint32_t identifier)
Constructs a numeric NodeId in namespace 0.
identifier(uint32_t) - The numeric identifier value.
NodeId(uint16_t namespaceIndex, uint32_t identifier)
Constructs a numeric NodeId in the given namespace.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(uint32_t) - The numeric identifier value.
Constructs a numeric NodeId in namespace 0 from a standard NS0 DataTypeId.
NodeId(uint16_t namespaceIndex, DataTypeId identifier)
Constructs a numeric NodeId in the given namespace from a DataTypeId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(DataTypeId) - The standard NS0 DataTypeId whose numeric value becomes the identifier.
Constructs a numeric NodeId in namespace 0 from a standard NS0 ObjectTypeId.
NodeId(uint16_t namespaceIndex, ObjectTypeId identifier)
Constructs a numeric NodeId in the given namespace from an ObjectTypeId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(ObjectTypeId) - The standard NS0 ObjectTypeId whose numeric value becomes the identifier.
Constructs a numeric NodeId in namespace 0 from a standard NS0 ObjectId.
Constructs a numeric NodeId in the given namespace from an ObjectId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(ObjectId) - The standard NS0 ObjectId whose numeric value becomes the identifier.
Constructs a numeric NodeId in namespace 0 from a standard NS0 VariableTypeId.
NodeId(uint16_t namespaceIndex, VariableTypeId identifier)
Constructs a numeric NodeId in the given namespace from a VariableTypeId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(VariableTypeId) - The standard NS0 VariableTypeId whose numeric value becomes the identifier.
Constructs a numeric NodeId in namespace 0 from a standard NS0 VariableId.
NodeId(uint16_t namespaceIndex, VariableId identifier)
Constructs a numeric NodeId in the given namespace from a VariableId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(VariableId) - The standard NS0 VariableId whose numeric value becomes the identifier.
Constructs a numeric NodeId in namespace 0 from a standard NS0 ReferenceTypeId.
NodeId(uint16_t namespaceIndex, ReferenceTypeId identifier)
Constructs a numeric NodeId in the given namespace from a ReferenceTypeId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(ReferenceTypeId) - The standard NS0 ReferenceTypeId whose numeric value becomes the identifier.
Constructs a numeric NodeId in namespace 0 from a standard NS0 MethodId.
Constructs a numeric NodeId in the given namespace from a MethodId.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(MethodId) - The standard NS0 MethodId whose numeric value becomes the identifier.
NodeId(string_view identifier)
Constructs a string NodeId in namespace 0 holding a copy of identifier.
identifier(string_view) - The string identifier value to copy.
NodeId(uint16_t namespaceIndex, string_view identifier)
Constructs a string NodeId in the given namespace holding a copy of identifier.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(string_view) - The string identifier value to copy.
Constructs a GUID NodeId in namespace 0 holding a copy of identifier.
identifier(const Guid &) - The GUID identifier value to copy.
Constructs a GUID NodeId in the given namespace holding a copy of identifier.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(const Guid &) - The GUID identifier value to copy.
NodeId(const ByteString &identifier)
Constructs an opaque NodeId in namespace 0 holding a copy of identifier.
identifier(const ByteString &) - The opaque (ByteString) identifier value to copy.
NodeId(uint16_t namespaceIndex, const ByteString &identifier)
Constructs an opaque NodeId in the given namespace holding a copy of identifier.
namespaceIndex(uint16_t) - The namespace index in which the node resides.identifier(const ByteString &) - The opaque (ByteString) identifier value to copy.
Copy-constructs a NodeId, preserving its namespace and identifier.
obj(const NodeId &) - The NodeId to copy.
Move-constructs a NodeId; the source is left in a valid but unspecified state.
obj(NodeId &&) - The NodeId to move from.
NodeId(const ExpandedNodeId &obj)
Constructs a NodeId from a local, index-based ExpandedNodeId.
obj(const ExpandedNodeId &) - Source ExpandedNodeId; copied into this NodeId.
NodeId(ExpandedNodeId &&obj)
Constructs a NodeId by moving from a local, index-based ExpandedNodeId.
obj(ExpandedNodeId &&) - Source ExpandedNodeId; its identifier is moved into this NodeId.
Copy-assigns a NodeId, replacing the namespace and identifier.
other(const NodeId &) - The NodeId to copy-assign from.
Returns: A reference to this NodeId.
Move-assigns a NodeId; the source is left in a valid but unspecified state.
other(NodeId &&) - The NodeId to move-assign from.
Returns: A reference to this NodeId.
~NodeId()=default
Destroys the NodeId, releasing its identifier value.
bool operator==(const NodeId &obj) const
Compares two NodeIds for equality.
obj(const NodeId &) - The NodeId to compare against.
Returns: true if the NodeIds are equal, false otherwise.
std::strong_ordering operator<=>(const NodeId &other) const
Orders two NodeIds, first by namespace index then by Identifier.
other(const NodeId &) - The NodeId to compare against.
Returns: The ordering of this NodeId relative to other.
IdType id_type() const
Returns the IdType of the identifier (numeric, string, GUID, or opaque).
Returns: The IdType of the identifier.
bool is_null() const
Returns whether this is the null NodeId.
Returns: true if this is the null NodeId, false otherwise.
bool is_structurally_valid() const noexcept
Returns whether the identifier satisfies the structural NodeId rules.
Returns: true if the identifier is structurally valid, false otherwise.
bool is_numeric() const
Returns whether the identifier holds a numeric value.
Returns: true if the identifier holds a numeric value, false otherwise.
bool is_string() const
Returns whether the identifier holds a string value.
Returns: true if the identifier holds a string value, false otherwise.
bool is_guid() const
Returns whether the identifier holds a GUID value.
Returns: true if the identifier holds a GUID value, false otherwise.
bool is_opaque() const
Returns whether the identifier holds an opaque (ByteString) value.
Returns: true if the identifier holds an opaque (ByteString) value, false otherwise.
uint16_t namespace_index() const
Returns the namespace index.
Returns: The namespace index.
uint16_t & namespace_index()
Returns a mutable reference to the namespace index for in-place modification.
Returns: A mutable reference to the namespace index.
const Identifier & identifier() const
Returns a reference to the Identifier.
Returns: A reference to the Identifier.
Identifier & identifier()
Returns a mutable reference to the Identifier for in-place modification.
Returns: A mutable reference to the Identifier.
void set_from_definition(string_view definition, bool namespaceIndexAllowed=true)
Parses a textual NodeId definition into this NodeId, replacing its contents.
definition(string_view) - Textual NodeId definition to parse.namespaceIndexAllowed(bool) - Whether a leading ns= prefix is permitted; when false, a definition carrying one is rejected.
std::string as_definition() const
Returns the OPC UA textual representation of this NodeId.
Returns: The textual NodeId definition.
void clear()
Resets this NodeId to the null NodeId in namespace 0.
size_t hash() const
Returns a hash combining the namespace index and identifier.
Returns: The hash of the namespace index and identifier.
ua::DimensionRange
struct
An inclusive index range for a single dimension of a NumericRange.
Both bounds are zero-based array indices. The range covers every index from low to high inclusive; a single-index selection is encoded as high equal to low.
Public attributes
uint32_t low
Lowest selected index in this dimension (inclusive).
uint32_t high
Highest selected index in this dimension (inclusive); equals low for a single index.
ua::ParsedNumericRange
struct
A NumericRange parsed into one inclusive DimensionRange per dimension.
The dimensions are ordered outermost-first, matching the comma-separated order of the source NumericRange string. An empty dimensions vector denotes the whole value (the result of parsing an empty range string).
Functions
bool empty() const
Whether the parsed range selects the whole value (no dimensions).
Returns: true if there are no dimensions, meaning the whole value is selected.
size_t dimension_count() const
The number of dimensions in the parsed range.
Returns: The number of dimensions in the parsed range.
size_t element_count(size_t dim) const
The number of selected elements in dimension dim.
dim(size_t) - Zero-based dimension index.
Returns: The inclusive element count high - low + 1, or 0 if dim is out of range.
Public attributes
std::vector< DimensionRange > dimensions
One inclusive range per dimension, outermost first.
ua::QualifiedName
class
A name qualified by a namespace, as defined by OPC 10000-6.
A QualifiedName pairs a name() with the namespace_index() of the namespace table entry that scopes it, so the same text can be reused in different namespaces without collision. It is most commonly used for BrowseNames. A default-constructed QualifiedName has namespace index 0 and a null name(), which is the null value reported by is_null().
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for QualifiedName.
Returns: BuiltInTypeId for this type.
Functions
QualifiedName()=default
Constructs a null QualifiedName with namespace index 0 and a null name.
QualifiedName(const QualifiedName &other)=default
Copy-constructs, deep-copying the name text.
other(const QualifiedName &) - The QualifiedName to copy.
QualifiedName(QualifiedName &&other) noexcept=default
Move-constructs; the source is left in a valid but unspecified state.
other(QualifiedName &&) - The QualifiedName to move from; left in a valid but unspecified state.
QualifiedName & operator=(const QualifiedName &other)=default
Copy-assigns, deep-copying the name text.
other(const QualifiedName &) - The QualifiedName to copy.
Returns: Reference to this QualifiedName.
QualifiedName & operator=(QualifiedName &&other) noexcept=default
Move-assigns; the source is left in a valid but unspecified state.
other(QualifiedName &&) - The QualifiedName to move from; left in a valid but unspecified state.
Returns: Reference to this QualifiedName.
~QualifiedName()=default
Destroys the QualifiedName, releasing its name text.
QualifiedName(string_view name)
Constructs a QualifiedName in namespace 0 with the given name text.
name(string_view) - Name text; copied into the QualifiedName.
QualifiedName(uint16_t namespaceIndex, string_view name)
Constructs a QualifiedName in the given namespace with the given name text.
namespaceIndex(uint16_t) - Index into the server namespace table that scopes the name.name(string_view) - Name text; copied into the QualifiedName.
bool operator==(const QualifiedName &obj) const =default
Compares two QualifiedNames for equality of namespace index and name.
obj(const QualifiedName &) - The QualifiedName to compare against.
Returns: true if both the namespace index and the name are equal.
std::strong_ordering operator<=>(const QualifiedName &other) const
Orders by namespace_index() first, then by name().
other(const QualifiedName &) - The QualifiedName to compare against.
Returns: The ordering of this QualifiedName relative to other.
uint16_t namespace_index() const
Returns the index of the namespace that scopes the name.
Returns: The namespace index that scopes the name.
uint16_t & namespace_index()
Returns a mutable reference to the namespace index.
Returns: A mutable reference to the namespace index.
const String & name() const
Returns the name text.
Returns: The name text.
String & name()
Returns a mutable reference to the name text.
Returns: A mutable reference to the name text.
bool is_null() const
Returns whether this is the null value (a null name()).
Returns: true if the name is null.
void clear()
Resets to the null value (namespace index 0 and a null name).
size_t hash() const
Returns a hash of the namespace index and name, suitable for hashed containers.
Returns: A hash of the namespace index and name.
ua::RefStructure
class
A value-semantic holder for a polymorphic Structure, copied by cloning.
Wraps a unique_ptr<T> so that a heap-allocated, polymorphic OPC UA structure can be stored and passed with value semantics. Copying a RefStructure performs a deep copy via Structure::clone (the held object is duplicated, not shared); moving transfers ownership and leaves the source empty. This lets structured DataTypes participate in Variant and other value types without slicing.
T The held structure type; defaults to Structure. Must derive from Structure (the clone result is dynamic_cast to T*). Not thread-safe: a single instance must not be accessed concurrently from multiple threads without external synchronisation.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type id of the held structure type.
Returns: The BuiltInTypeId reported by T. Independent of whether a structure is currently held.
Functions
RefStructure()=default
Constructs an empty holder owning no structure.
RefStructure(RefStructure &&other) noexcept=default
Move-constructs, transferring ownership and leaving other empty.
other(RefStructure &&) - The holder to move from; left empty.
RefStructure & operator=(RefStructure &&other) noexcept=default
Move-assigns, transferring ownership and leaving other empty.
other(RefStructure &&) - The holder to move from; left empty.
Returns: Reference to this holder.
~RefStructure()=default
Destroys the holder, releasing any held structure.
RefStructure(const RefStructure &other)
Copy-constructs by deep-cloning the structure held by other.
other(const RefStructure &) - The holder whose structure is deep-cloned.
RefStructure(const unique_ptr< Structure > &other)
Constructs by deep-cloning the structure referenced by other.
other(const unique_ptr< Structure > &) - Source pointer to clone; if null, the holder is left empty. The pointee is not adopted - a clone is taken and other is unchanged.
RefStructure & operator=(const RefStructure &other)
Copy-assigns by deep-cloning the structure held by other.
other(const RefStructure &) - The holder whose structure is deep-cloned.
Returns: Reference to this holder.
RefStructure & operator=(const unique_ptr< Structure > &other)
Assigns by deep-cloning the structure referenced by other.
other(const unique_ptr< Structure > &) - Source pointer to clone; if null, the holder becomes empty. The pointee is not adopted - a clone is taken and other is unchanged.
Returns: Reference to this holder.
RefStructure & operator=(unique_ptr< Structure > &&other)
Assigns by adopting ownership of other, leaving it empty.
other(unique_ptr< Structure > &&) - Source pointer to adopt; ownership is transferred and other is left empty.
Returns: Reference to this holder.
bool operator==(const RefStructure &obj) const
Returns whether both holders are empty or hold equal structures.
obj(const RefStructure &) - The holder to compare against.
Returns: true if both holders are empty or hold equal structures.
bool operator!=(const RefStructure &obj) const
Returns the logical negation of operator==.
obj(const RefStructure &) - The holder to compare against.
Returns: true if the holders are not equal.
unique_ptr< T > & operator->()
Accesses the held structure through the underlying owning pointer.
Returns: Reference to the held unique_ptr<T>; null if the holder is empty.
const unique_ptr< T > & operator->() const
Accesses the held structure through the underlying owning pointer.
Returns: Reference to the held unique_ptr<T>; null if the holder is empty.
T & operator*()
Dereferences to the held structure.
Returns: Reference to the held T.
const T & operator*() const
Dereferences to the held structure.
Returns: Reference to the held T.
operator bool() const
Returns whether a structure is held.
Returns: true if a structure is held, false if the holder is empty.
T * get()
Returns a non-owning pointer to the held structure.
Returns: Pointer to the held T, or nullptr if the holder is empty. Ownership is retained by this holder; the pointer is valid only for its lifetime.
const T * get() const
Returns a non-owning pointer to the held structure.
Returns: Pointer to the held T, or nullptr if the holder is empty. Ownership is retained by this holder; the pointer is valid only for its lifetime.
unique_ptr< T > & inner_unique_ptr()
Returns the underlying owning pointer for direct manipulation.
Returns: Reference to the held unique_ptr<T>. Mutating it (e.g. reset) bypasses the cloning semantics of the copy/assign overloads.
const unique_ptr< T > & inner_unique_ptr() const
Returns the underlying owning pointer for inspection.
Returns: Reference to the held unique_ptr<T>; null if the holder is empty.
ua::RefWrapper
class
A move-only owning handle that gives value-like access to a heap-allocated T.
Wraps a unique_ptr<T> and forwards dereference, member access, and boolean testing to it, so a RefWrapper<T> can be used like the pointed-to object while retaining sole ownership of the allocation. Copying is deleted; the wrapper is moved, never duplicated. A default-constructed or moved-from wrapper is empty (holds no object); test with operator bool before dereferencing.
T Type of the owned object.
Functions
RefWrapper()=default
Constructs an empty wrapper that owns no object.
RefWrapper(RefWrapper &&other) noexcept=default
Move-constructs, transferring ownership and leaving other empty.
other(RefWrapper &&) - The wrapper to move from; left empty.
RefWrapper & operator=(RefWrapper &&other) noexcept=default
Move-assigns, transferring ownership and leaving other empty.
other(RefWrapper &&) - The wrapper to move from; left empty.
Returns: Reference to this wrapper.
~RefWrapper()=default
Destroys the wrapper, releasing any owned object.
RefWrapper(unique_ptr< T > &&other) noexcept
Constructs by adopting an existing owning pointer.
other(unique_ptr< T > &&) - Pointer to adopt; ownership is transferred and other is left empty. May be null, yielding an empty wrapper.
RefWrapper & operator=(unique_ptr< T > &&other) noexcept
Replaces the owned object by adopting an existing owning pointer.
other(unique_ptr< T > &&) - Pointer to adopt; ownership is transferred and other is left empty. May be null, yielding an empty wrapper.
Returns: Reference to this wrapper.
unique_ptr< T > & operator->()
Provides member access to the owned object.
Returns: Reference to the underlying owning pointer; the chained -> resolves to the owned T.
const unique_ptr< T > & operator->() const
Provides const member access to the owned object.
Returns: Const reference to the underlying owning pointer; the chained -> resolves to the owned T.
T & operator*()
Dereferences to the owned object.
Returns: Reference to the owned T.
const T & operator*() const
Dereferences to the owned object (const).
Returns: Const reference to the owned T.
operator bool() const
Tests whether the wrapper currently owns an object.
Returns: true if an object is owned, false if empty.
T * get()
Returns a non-owning pointer to the owned object.
Returns: Pointer to the owned T, or nullptr if empty. Ownership is retained by the wrapper; the caller must not delete the pointer or use it beyond the wrapper's lifetime.
const T * get() const
Returns a non-owning const pointer to the owned object.
Returns: Const pointer to the owned T, or nullptr if empty. Ownership is retained by the wrapper; the caller must not delete the pointer or use it beyond the wrapper's lifetime.
unique_ptr< T > & inner_unique_ptr()
Returns the underlying owning pointer for direct manipulation.
Returns: Reference to the wrapped unique_ptr<T>. Ownership remains with the wrapper unless the caller moves the pointer out.
const unique_ptr< T > & inner_unique_ptr() const
Returns the underlying owning pointer for inspection (const).
Returns: Const reference to the wrapped unique_ptr<T>.
ua::StatusCode
class
An OPC UA StatusCode: a 32-bit status value optionally paired with structured ErrorDetail context.
The 32-bit value follows OPC 10000-6 5.1.2: the top two bits encode severity (Good / Uncertain / Bad), the upper 16 bits the status code proper, and the lower bits a set of info bits (StructureChanged, SemanticsChanged, and the DataValue InfoBits such as Overflow). The optional ErrorDetail is an out-of-band diagnostic payload that travels with the code in-process; it is not part of the wire encoding and does not participate in identity.
The attached detail is held by shared_ptr<const ErrorDetail> and is shared, not copied, between StatusCode instances.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for StatusCode.
Returns: The BuiltInTypeId tag for this built-in type.
Functions
constexpr StatusCode() noexcept=default
Constructs a Good (zero-valued) StatusCode with no detail.
StatusCode(StatusCodeValue value) noexcept
Constructs a StatusCode from a raw 32-bit wire value, with no detail.
value(StatusCodeValue) - The full 32-bit status value, including any info bits.
StatusCode(Status value) noexcept
Constructs a StatusCode from a named Status enumerator, with no detail.
value(Status) - The named status; its underlying value becomes the code.
StatusCode(Status value, std::shared_ptr< const ErrorDetail > detail) noexcept
Constructs a StatusCode pairing a named status with structured detail.
value(Status) - The named status.detail(std::shared_ptr< const ErrorDetail >) - Diagnostic context to attach; may be null, in which case this is equivalent to StatusCode{value}. Ownership is shared.
StatusCode(StatusCodeValue value, std::shared_ptr< const ErrorDetail > detail) noexcept
Constructs a StatusCode pairing a raw 32-bit value with structured detail.
value(StatusCodeValue) - The full 32-bit status value, including any info bits.detail(std::shared_ptr< const ErrorDetail >) - Diagnostic context to attach; may be null, in which case this is equivalent to StatusCode{value}. Ownership is shared.
~StatusCode()
Destroys the StatusCode, releasing its share of any attached detail.
StatusCode(const StatusCode &other)
Copy-constructs, sharing the source's detail (no deep copy of detail).
other(const StatusCode &) - The StatusCode to copy.
StatusCode(StatusCode &&other) noexcept
Move-constructs, transferring the source's detail and leaving it detached.
other(StatusCode &&) - The StatusCode to move from; left detached.
StatusCode & operator=(const StatusCode &other)
Copy-assigns, sharing the source's detail (no deep copy of detail).
other(const StatusCode &) - The StatusCode to copy.
Returns: Reference to this StatusCode.
StatusCode & operator=(StatusCode &&other) noexcept
Move-assigns, transferring the source's detail and leaving it detached.
other(StatusCode &&) - The StatusCode to move from; left detached.
Returns: Reference to this StatusCode.
StatusCode & operator=(Status other)
Assigns a named Status, replacing the code and clearing any detail.
other(Status) - The named status to assign.
Returns: Reference to this StatusCode.
bool operator==(const StatusCode &obj) const noexcept
Compares two StatusCodes for equality of their full 32-bit value.
obj(const StatusCode &) - The StatusCode to compare against.
Returns: True if both 32-bit values are identical.
bool equivalent(const StatusCode &obj) const
Tests whether two StatusCodes share the same underlying Status.
obj(const StatusCode &) - The StatusCode to compare against.
Returns: True if both reduce to the same Status.
Status as_status() const
Returns the named Status, with the info bits masked off.
Returns: The status code proper (upper 16 bits) as a Status enumerator.
uint32_t as_uint32() const
Returns the full 32-bit value, including all info bits.
Returns: The raw wire-format status value.
StatusCodeValue value() const noexcept
Returns the full 32-bit value as a typed StatusCodeValue.
Returns: The raw wire-format status value.
const std::shared_ptr< const ErrorDetail > & shared_detail() const noexcept
Returns the attached ErrorDetail by shared ownership, if any.
Returns: The shared detail pointer; null on Good and on detail-less Bad. The returned reference is valid for the lifetime of this StatusCode.
const ErrorDetail * detail() const noexcept
Returns a non-owning pointer to the attached ErrorDetail, if any.
Returns: Pointer to the detail, or null if none is attached. The pointee is owned by this StatusCode (and any that share the detail); do not retain it beyond their lifetime.
StatusCode without_detail() const noexcept
Returns a copy of this StatusCode with the ErrorDetail stripped.
Returns: A StatusCode with the same 32-bit value and no detail.
bool is_good() const
Reports whether the severity is Good (neither Bad nor Uncertain).
Returns: True if the code carries Good severity.
bool is_bad() const
Reports whether the severity is Bad (top severity bit set).
Returns: True if the code carries Bad severity.
bool is_uncertain() const
Reports whether the severity is Uncertain (and not Bad).
Returns: True if the code carries Uncertain severity.
bool is_not_good() const
Reports whether the severity is anything other than Good.
Returns: True if the code is Bad or Uncertain.
bool is_not_bad() const
Reports whether the severity is anything other than Bad.
Returns: True if the code is Good or Uncertain.
bool is_not_uncertain() const
Reports whether the severity is anything other than Uncertain.
Returns: True if the code is Good or Bad.
bool structure_changed() const
Reports whether the StructureChanged info bit is set.
Returns: True if the structure of the associated value has changed.
void structure_changed(bool value)
Sets or clears the StructureChanged info bit.
value(bool) - True to set the bit, false to clear it.
bool semantics_changed() const
Reports whether the SemanticsChanged info bit is set.
Returns: True if the semantics of the associated value have changed.
void semantics_changed(bool value)
Sets or clears the SemanticsChanged info bit.
value(bool) - True to set the bit, false to clear it.
bool info_type_data_value() const
Reports whether the InfoType field selects DataValue.
Returns: True if InfoType == DataValue.
void info_type_data_value(bool value)
Sets or clears the DataValue InfoType selection.
value(bool) - True to select InfoType == DataValue (which also clears the high InfoType bit); false clears the low InfoType bit only.
bool overflow() const
Reports whether the Overflow info bit is set.
Returns: True if the Overflow DataValue InfoBit is set.
void overflow(bool value)
Sets or clears the Overflow DataValue InfoBit.
value(bool) - True to set the Overflow bit, false to clear it.
bool extra_data() const
Reports whether the ExtraData historian info bit is set.
Returns: True if the ExtraData DataValue InfoBit is set.
void extra_data(bool value)
Sets or clears the ExtraData historian info bit.
value(bool) - True to set the ExtraData bit, false to clear it.
ua::String
class
The OPC UA String built-in type: a sequence of UTF-8 encoded characters.
Owns its character data in a backing std::string, so copies are deep and independent. Constructs implicitly from const char*, string_view, and std::string, and converts implicitly back to either of those view/string forms, so a String is usable wherever standard text is expected. As defined by OPC 10000-6, the null String and the empty String share the same value in this representation; is_null() and empty() are therefore equivalent. Constructing from a null const char* yields the empty value.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for String.
Returns: BuiltInTypeId for this type.
Functions
String()=default
Constructs the empty (null) String.
Copy-constructs, deep-copying the character data.
Move-constructs; the source is left in a valid but unspecified state.
other(String &&) - The String to move from; left in a valid but unspecified state.
Copy-assigns, deep-copying the character data.
other(const String &) - The String to copy.
Returns: Reference to this String.
Move-assigns; the source is left in a valid but unspecified state.
other(String &&) - The String to move from; left in a valid but unspecified state.
Returns: Reference to this String.
~String()=default
Destroys the String, releasing its character data.
String(const char *value)
Constructs a String from a null-terminated C string.
value(const char *) - The text to copy; a null pointer yields the empty String.
String(string_view value)
Constructs a String by copying the characters viewed by value.
value(string_view) - The text to copy.
String(const std::string &value)
Constructs a String by copying value.
value(const std::string &) - The text to copy.
String & operator=(const std::string &other)
Replaces this String's contents with a copy of other.
other(const std::string &) - The text to copy.
Returns: Reference to this String.
String & operator=(string_view other)
Replaces this String's contents with a copy of the characters viewed by other.
other(string_view) - The text to copy.
Returns: Reference to this String.
String & operator=(const char *other)
Replaces this String's contents with a copy of the null-terminated C string other.
other(const char *) - The text to copy; a null pointer yields the empty String.
Returns: Reference to this String.
bool operator==(const String &) const =default
Compares two Strings for byte-wise equality of their characters.
Returns: true if both Strings hold the same sequence of character bytes.
auto operator<=>(const String &) const =default
Orders two Strings lexicographically by their character bytes.
Returns: The ordering of this String relative to the other.
operator string_view() const
Returns a non-owning view over this String's characters.
Returns: A view over this String's UTF-8 character bytes.
operator std::string() const
Returns a copy of this String's characters as a std::string.
Returns: A std::string copy of this String's characters.
bool empty() const
Returns true if this String holds no characters.
Returns: true if this String holds no characters.
bool is_null() const
Returns true if this is the null String.
Returns: true if this is the null String.
size_t size() const
Returns the number of UTF-8 code units (bytes) in this String.
Returns: The number of UTF-8 code units (bytes) in this String.
void clear()
Resets this String to the empty (null) value.
ua::Structure
class
Abstract base for every OPC UA structured DataType carried as an ExtensionObject.
Models the spec-defined structured-type hierarchy: generated DataTypes (and Union) derive from this base and implement its pure-virtual seams, while concrete instances are passed polymorphically through Variant and the codecs. The base supplies value equality and the identity/serialization/cloning contract; derived types add their typed fields. Holds value semantics - clients copy or clone instances rather than sharing them.
Static functions
BuiltInTypeId built_in_type_id()
Returns the built-in type tag for structured values, BuiltInTypeId::ExtensionObject.
Returns: BuiltInTypeId::ExtensionObject.
Functions
~Structure()=default
Virtual destructor enabling polymorphic ownership through unique_ptr<Structure>.
bool operator==(const Structure &obj) const =default
Compares two structures for member-wise value equality.
obj(const Structure &) - Structure to compare against.
Returns: true if both structures share a dynamic type and all fields compare equal; false otherwise.
bool is_of_type(const CodecNamespaceContext &ns, const NodeId &typeId) const
Tests whether this structure is of, or derives from, the given DataType.
ns(const CodecNamespaceContext &) - Namespace context used to resolve typeId against this type's identity.typeId(const NodeId &) - DataType node identifier to test against.
Returns: true if this structure is an instance of typeId or one of its subtypes.
NodeId type_id(const CodecNamespaceContext &ns) const =0
Returns the DataType node identifier of this structure, resolved in the given namespace.
ns(const CodecNamespaceContext &) - Namespace context that maps the type's namespace URI to a runtime index.
Returns: The NodeId of this concrete DataType.
ExpandedNodeId type_id() const =0
Returns the DataType identifier of this structure as a namespace-URI-qualified value.
Returns: The ExpandedNodeId of this concrete DataType.
String type_name() const =0
Returns the OPC UA type name of this concrete DataType.
Returns: This DataType's OPC UA type name.
void encode_id(StackDepth limit, const CodecNamespaceContext &ns, Encoder &encoder) const =0
Encodes this structure's DataType identifier (its encoding NodeId) onto the stream.
limit(StackDepth) - Work budget guarding against pathologically nested encodings; shared across the encode walk and consumed as nodes and edges are processed.ns(const CodecNamespaceContext &) - Namespace context resolving the encoding NodeId's namespace URI to an index.encoder(Encoder &) - Sink the identifier bytes are written to.
void encode(StackDepth limit, Encoder &encoder) const
Encodes this structure's field payload onto the stream.
limit(StackDepth) - Work budget guarding against pathologically nested encodings; shared across the encode walk and consumed as nested structures are visited.encoder(Encoder &) - Sink the field bytes are written to.
void decode(StackDepth limit, Decoder &decoder)
Decodes this structure's field payload from the stream into this instance.
limit(StackDepth) - Work budget guarding against pathologically nested decodings; shared across the decode walk and consumed as nested structures are visited.decoder(Decoder &) - Source the field bytes are read from.
unique_ptr< Structure > clone() const =0
Returns an owning, independent deep copy of this structure.
Returns: A unique_ptr owning a copy of the concrete type.
void resolve(span< const LocaleId > locales)
Collapses localized-text fields under a set of session locales, recursing into nested fields.
locales(span< const LocaleId >) - Ordered, most-preferred-first list of session locales used to pick each text.
std::string to_string(int indent=0) const =0
Returns a human-readable, indented rendering of this structure for diagnostics and logging.
indent(int) - Number of indentation levels to prefix; used when nesting one structure in another. Defaults to top level (0).
Returns: The rendered text.
ua::Union
class
Abstract base for OPC UA union structured DataTypes.
A union is a Structure that holds at most one of its defined fields at a time, selected by a 1-based switch value; switch 0 is the null union (no field set). Generated union DataTypes derive from this class and implement the field accessors alongside the Structure encoding/cloning contract.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type id for Union.
Returns: The built-in type id identifying Union values.
Functions
~Union()=default
Defaulted virtual destructor; destruction runs through the polymorphic Structure base.
uint32_t switch_field() const =0
Returns the 1-based index of the active field, or 0 if no field is set.
Returns: The selected field's 1-based index in [1, field_count()], or 0 for the null union (no field set).
uint32_t field_count() const =0
Returns the number of fields defined by this union type.
Returns: The count of fields the union type declares.
void clear()=0
Resets the union to the null state.
ua::UnknownStructure
class
A Structure of an unresolved type whose raw encoded body is preserved verbatim.
Produced when the decoder cannot resolve an ExtensionObject's encoding id to a concrete type. Rather than discard the value, the raw encoded body is kept unchanged (tagged with the codec it came from) so it can be re-emitted losslessly on the wire, or reified into a concrete type later once the type model becomes known.
Identity contract: an unknown structure holds ONLY the wire TypeId - i.e. the encoding id (the DefaultBinary/DefaultXml encoding node), which is codec-specific. The DataType id is genuinely unknowable without the type model, so type_id is unsupported and is_of_type always returns false. Only encode_id (writes the encoding id) and encode (writes the preserved body) participate in round-trip.
Not thread-safe: a single instance must not be accessed concurrently from multiple threads without external synchronisation.
Member types
BodyEncoding (enum)
Codec that produced the preserved body.
Functions
UnknownStructure(const NodeId &encodingId)
Constructs the empty-body form, holding only the encoding id.
encodingId(const NodeId &) - The unresolved wire TypeId (encoding id). Copied.
UnknownStructure(NodeId encodingId, BodyEncoding bodyEncoding, ByteString body)
Constructs the body-preserving form, retaining the raw encoded body.
encodingId(NodeId) - The unresolved wire TypeId (encoding id). Moved in.bodyEncoding(BodyEncoding) - Codec the body content is encoded in.body(ByteString) - Raw encoded body content in bodyEncoding form. Moved in.
bool is_of_type(const CodecNamespaceContext &ns, const NodeId &typeId) const override
Reports whether this structure matches a DataType id; always false.
ns(const CodecNamespaceContext &) - Namespace context; ignored, since no DataType id is known to resolve against.typeId(const NodeId &) - DataType node identifier to test against; ignored.
Returns: false unconditionally.
NodeId type_id(const CodecNamespaceContext &ns) const override
Unsupported: the DataType id of an unknown structure cannot be determined.
ns(const CodecNamespaceContext &) - Namespace context; ignored, as no DataType id is available to resolve.
Returns: Never returns normally; always throws UaException with Status::BadNotSupported.
ExpandedNodeId type_id() const override
Unsupported: the DataType id of an unknown structure cannot be determined.
Returns: Never returns normally; always throws UaException with Status::BadNotSupported.
String type_name() const override
Returns a human-readable name for the structure type.
Returns: The placeholder type name "Unknown".
void encode_id(StackDepth limit, const CodecNamespaceContext &ns, Encoder &encoder) const override
Encodes the encoding id (wire TypeId) to encoder.
limit(StackDepth) - Remaining stack depth budget guarding against unbounded nesting.ns(const CodecNamespaceContext &) - Namespace context mapping namespace indices for the target codec.encoder(Encoder &) - Sink that receives the encoded encoding id.
void encode(StackDepth limit, Encoder &encoder) const override
Encodes the preserved raw body to encoder verbatim.
limit(StackDepth) - Remaining stack depth budget guarding against unbounded nesting.encoder(Encoder &) - Sink that receives the preserved body.
void decode(StackDepth limit, Decoder &decoder) override
Decodes a structure body from decoder into this instance.
limit(StackDepth) - Remaining stack depth budget guarding against unbounded nesting.decoder(Decoder &) - Source of the encoded body.
unique_ptr< Structure > clone() const override
Returns an owning deep copy of this structure.
Returns: A new Structure holding the same encoding id, encoding, and preserved body.
std::string to_string(int indent=0) const override
Returns a human-readable, indented rendering of the structure.
indent(int) - Number of indentation levels to prefix nested lines with.
Returns: The rendered text.
const NodeId & encoding_id() const
Returns the unresolved encoding id (wire TypeId).
Returns: Reference to the held encoding id; valid for this instance's lifetime.
BodyEncoding body_encoding() const
Returns which codec the preserved body is encoded in.
Returns: The body's BodyEncoding (Binary or Xml).
const ByteString & encoded_data() const
Returns the preserved raw encoded body.
Returns: Reference to the held body; empty for the empty-body form. Valid for this instance's lifetime.
ua::uri_array_details::UriHash
struct
Transparent hash for the URI map, hashing String and string_view keys identically.
The is_transparent member lets unordered_map::find(string_view) look up an entry without first heap-allocating a String copy. The URI map is hit on every encode of every type, so eliminating that per-call allocation is the dominant performance win.
Member types
void is_transparent
Enables heterogeneous lookup by string_view.
Functions
size_t operator()(string_view s) const noexcept
Hashes a URI viewed as a string_view.
s(string_view) - URI to hash.
Returns: The hash of s.
size_t operator()(const String &s) const noexcept
Hashes a URI held as a String, consistently with the string_view overload.
s(const String &) - URI to hash.
Returns: The hash of s, equal to the string_view overload's result for the same text.
ua::uri_array_details::UriEq
struct
Transparent equality for the URI map, comparing String and string_view keys by value.
The is_transparent member pairs with UriHash to enable heterogeneous lookup, so a string_view query compares against stored String keys without an intervening copy.
Member types
void is_transparent
Enables heterogeneous lookup by string_view.
Functions
bool operator()(string_view a, string_view b) const noexcept
Compares two string_view URIs for byte-wise equality.
a(string_view) - First URI to compare.b(string_view) - Second URI to compare.
Returns: true if a and b are byte-wise equal.
bool operator()(const String &a, string_view b) const noexcept
Compares a stored String URI against a string_view query.
a(const String &) - Stored String URI.b(string_view) - string_view query URI.
Returns: true if a and b are byte-wise equal.
bool operator()(string_view a, const String &b) const noexcept
Compares a string_view query against a stored String URI.
a(string_view) - string_view query URI.b(const String &) - Stored String URI.
Returns: true if a and b are byte-wise equal.
Compares two stored String URIs for byte-wise equality.
a(const String &) - First stored String URI.b(const String &) - Second stored String URI.
Returns: true if a and b are byte-wise equal.
ua::UriArray
class
A thread-safe, append-only registry that assigns dense indices to URI-keyed elements.
Models an OPC UA URI table (such as a NamespaceArray or ServerArray): each element is identified by a URI and assigned a stable, zero-based index in insertion order. Indices are never reused and elements are never removed, so an index stays valid for the lifetime of the registry. Lookups by URI use a transparent hash map to avoid copying the key on every query.
Every public method serializes against an internal std::shared_mutex: read accessors take a shared lock and add_element takes an exclusive lock, so instances are safe to share across threads. The URI of each ElementType is obtained through the uri_array_details::get_uri customization point, which defaults to calling element.uri().
ElementType Stored element type; must expose a URI via the get_uri customization point. IndexType Unsigned integer type used for indices; its maximum bounds the capacity.
Functions
UriArray()=default
Constructs an empty registry with no entries.
IndexType get_index(string_view uri) const
Returns the index registered for uri.
uri(string_view) - Namespace/server URI to resolve; compared by value, not retained.
Returns: The zero-based index assigned to uri.
String get_uri(IndexType index) const
Returns the URI registered at index.
index(IndexType) - Zero-based index into the registry.
Returns: The URI stored at index.
ElementType get_element(IndexType index) const
Returns a copy of the element registered at index.
index(IndexType) - Zero-based index into the registry.
Returns: A copy of the element stored at index.
ElementType get_element(string_view uri) const
Returns a copy of the element registered for uri.
uri(string_view) - Namespace/server URI to resolve; compared by value, not retained.
Returns: A copy of the element registered for uri.
Returns a snapshot of all registered URIs in index order.
Returns: The registered URIs ordered by ascending index.
IndexType add_element(ElementType element)
Appends element and returns the index assigned to it.
element(ElementType) - Element to register; its URI is read through the get_uri customization point.
Returns: The zero-based index newly assigned to element.
PreparedAppend prepare_append(ElementType element) const
Builds the complete replacement state for appending element without changing this registry.
element(ElementType) - The element to append once the state is committed.
Returns: The fully allocated replacement state, ready to install.
bool commit_prepared_append(PreparedAppend prepared) noexcept
Installs a state returned by prepare_append using no-throw container swaps.
prepared(PreparedAppend) - A state returned by prepare_append.
Returns: true when the state was installed, false when another writer changed the registry after it was prepared.
ua::ValueRank
class
The OPC UA ValueRank of a Variable or VariableType value.
ValueRank is the Int32 attribute defined by OPC 10000-3 5.6.2 that states the dimensionality a value may take: a negative well-known constant (see sScalarOrOneDimension, sAny, sScalar, sOneOrMore) or a positive count giving the exact number of array dimensions. A default-constructed ValueRank is sAny (the value may be a scalar or an array of any rank). The wrapped value is never below sScalarOrOneDimension.
Functions
Constructs a ValueRank equal to sAny.
ValueRank(int32_t value)
Constructs a ValueRank from a raw OPC UA rank value.
value(int32_t) - The rank: a well-known negative constant (sScalarOrOneDimension ... sScalar) or a positive array-dimension count.
bool is_any() const
Returns whether the rank is sAny.
Returns: true if the rank is sAny.
bool is_scalar() const
Returns whether the rank is sScalar (the value is always a scalar).
Returns: true if the rank is sScalar.
bool is_scalar_or_one_dimension() const
Returns whether the rank is sScalarOrOneDimension.
Returns: true if the rank is sScalarOrOneDimension.
bool is_array() const
Returns whether the rank denotes an array with a fixed dimension count.
Returns: true for any positive rank (one or more fixed dimensions), false for the negative well-known constants and sOneOrMore.
bool is_one_dimensional() const
Returns whether the rank is exactly one fixed dimension (rank 1).
Returns: true if the rank is exactly one fixed dimension.
bool is_one_or_more_dimensional() const
Returns whether the rank is sOneOrMore (an array of unspecified rank).
Returns: true if the rank is sOneOrMore.
optional< int32_t > no_of_dimensions() const
Returns the fixed number of array dimensions, if the rank specifies one.
Returns: The positive dimension count when is_array() holds; an empty optional for the negative well-known constants and sOneOrMore.
int32_t as_int32() const
Returns the raw OPC UA rank value, including negative well-known constants.
Returns: The wrapped Int32 rank value.
void set_to_any()
Sets the rank to sAny.
void set_to_scalar()
Sets the rank to sScalar.
void set_to_one_dimensional()
Sets the rank to a single fixed dimension (rank 1).
void set_to_one_or_more_dimensional()
Sets the rank to sOneOrMore (an array of unspecified dimensionality).
void set_no_of_dimensions(size_t noOfDims)
Sets the rank to a fixed number of array dimensions.
noOfDims(size_t) - The number of array dimensions; 0 is equivalent to sOneOrMore, any positive count fixes the rank.
Static attributes
constexpr int32_t sScalarOrOneDimension
The value is a scalar or a one-dimensional array (well-known rank -3).
constexpr int32_t sAny
The value may be a scalar or an array of any dimensionality (well-known rank -2).
constexpr int32_t sScalar
The value is always a scalar (well-known rank -1).
constexpr int32_t sOneOrMore
The value is an array with one or more dimensions (well-known rank 0).
ua::Variant
class
A type-erased container for any built-in OPC UA value, scalar or array.
A Variant either is empty or holds exactly one built-in scalar (see IsBuiltInScalarType) or one built-in array (see IsBuiltInArrayType), including Structure-derived values and nested Array<Variant>. The held value is owned by the Variant; copying copies the contained value (deep copy), and moving transfers it. This is a plain value type with no internal synchronisation: it is not thread-safe for concurrent mutation, but distinct instances may be used from different threads.
Query the contained type with the is_* predicates or get_built_in_type, then read it with the throwing as accessor or the non-throwing try_as accessor.
IsBuiltInType, DataValue, Array
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type id for the Variant type itself.
Returns: BuiltInTypeId::Variant.
Functions
Variant()
Constructs an empty Variant holding no value.
Copy-constructs from other, deep-copying the contained value.
other(const Variant &) - Variant to copy from.
Move-constructs from other, transferring the contained value.
other(Variant &&) - Variant to move from.
Copy-assigns from other, deep-copying the contained value.
other(const Variant &) - Variant to copy from.
Returns: Reference to this Variant.
Move-assigns from other, transferring the contained value.
other(Variant &&) - Variant to move from.
Returns: Reference to this Variant.
~Variant()=default
Destroys the Variant, releasing any contained value.
Variant(const T &value)
Constructs a Variant holding a copy of a built-in scalar value.
value(const T &) - Value to copy into the Variant.
Variant(const T &value)
Constructs a Variant holding a copy of a built-in array value.
value(const T &) - Array to copy into the Variant.
Variant(T &&value) noexcept
Constructs a Variant by moving a built-in scalar value into it.
value(T &&) - Value to move into the Variant.
Variant(T &&value) noexcept
Constructs a Variant by moving a built-in array value into it.
value(T &&) - Array to move into the Variant.
Variant(unique_ptr< T > &&value) noexcept
Constructs a Variant that takes ownership of a heap-allocated Structure-derived value.
value(unique_ptr< T > &&) - Owning pointer whose pointee is adopted by the Variant; must be non-null.
Variant(T value)
Constructs a Variant from a Structure-derived value, heap-allocating a copy internally.
value(T) - Value moved into the internally allocated storage.
Variant & operator=(const T &value)
Replaces the contained value with a copy of a built-in scalar.
value(const T &) - Value to copy into the Variant.
Returns: Reference to this Variant.
Variant & operator=(const T &value)
Replaces the contained value with a copy of a built-in array.
value(const T &) - Array to copy into the Variant.
Returns: Reference to this Variant.
Variant & operator=(T &&value) noexcept
Replaces the contained value by moving in a built-in scalar.
value(T &&) - Value to move into the Variant.
Returns: Reference to this Variant.
Variant & operator=(unique_ptr< T > &&value) noexcept
Replaces the contained value, taking ownership of a heap-allocated Structure-derived value.
value(unique_ptr< T > &&) - Owning pointer whose pointee is adopted by the Variant; must be non-null.
Returns: Reference to this Variant.
Variant & operator=(T value)
Replaces the contained value with a Structure-derived value, copying it to the heap.
value(T) - Value moved into the internally allocated storage.
Returns: Reference to this Variant.
Variant & operator=(T &&value) noexcept
Replaces the contained value by moving in a built-in array.
value(T &&) - Array to move into the Variant.
Returns: Reference to this Variant.
bool operator==(const Variant &other) const
Compares two Variants for equality.
other(const Variant &) - Variant to compare against.
Returns: true if both Variants are empty, or hold the same built-in type with equal values; false otherwise.
bool empty() const
Returns whether the Variant holds no value.
Returns: true if the Variant holds no value; false otherwise.
bool is_array() const
Returns whether the Variant holds a built-in array value.
Returns: true if the Variant holds a built-in array value; false otherwise.
bool is_scalar() const
Returns whether the Variant holds a built-in scalar value.
Returns: true if the Variant holds a built-in scalar value; false otherwise.
bool is_boolean() const
Returns whether the Variant holds a bool scalar.
Returns: true if the Variant holds a bool scalar; false otherwise.
bool is_int8() const
Returns whether the Variant holds an int8_t scalar.
Returns: true if the Variant holds an int8_t scalar; false otherwise.
bool is_uint8() const
Returns whether the Variant holds a uint8_t scalar.
Returns: true if the Variant holds a uint8_t scalar; false otherwise.
bool is_int16() const
Returns whether the Variant holds an int16_t scalar.
Returns: true if the Variant holds an int16_t scalar; false otherwise.
bool is_uint16() const
Returns whether the Variant holds a uint16_t scalar.
Returns: true if the Variant holds a uint16_t scalar; false otherwise.
bool is_int32() const
Returns whether the Variant holds an int32_t scalar.
Returns: true if the Variant holds an int32_t scalar; false otherwise.
bool is_uint32() const
Returns whether the Variant holds a uint32_t scalar.
Returns: true if the Variant holds a uint32_t scalar; false otherwise.
bool is_int64() const
Returns whether the Variant holds an int64_t scalar.
Returns: true if the Variant holds an int64_t scalar; false otherwise.
bool is_uint64() const
Returns whether the Variant holds a uint64_t scalar.
Returns: true if the Variant holds a uint64_t scalar; false otherwise.
bool is_float() const
Returns whether the Variant holds a float scalar.
Returns: true if the Variant holds a float scalar; false otherwise.
bool is_double() const
Returns whether the Variant holds a double scalar.
Returns: true if the Variant holds a double scalar; false otherwise.
bool is_date_time() const
Returns whether the Variant holds a DateTime scalar.
Returns: true if the Variant holds a DateTime scalar; false otherwise.
bool is_guid() const
Returns whether the Variant holds a Guid scalar.
Returns: true if the Variant holds a Guid scalar; false otherwise.
bool is_xml_element() const
Returns whether the Variant holds an XmlElement scalar.
Returns: true if the Variant holds an XmlElement scalar; false otherwise.
bool is_string() const
Returns whether the Variant holds a String scalar.
Returns: true if the Variant holds a String scalar; false otherwise.
bool is_byte_string() const
Returns whether the Variant holds a ByteString scalar.
Returns: true if the Variant holds a ByteString scalar; false otherwise.
bool is_node_id() const
Returns whether the Variant holds a NodeId scalar.
Returns: true if the Variant holds a NodeId scalar; false otherwise.
bool is_expanded_node_id() const
Returns whether the Variant holds an ExpandedNodeId scalar.
Returns: true if the Variant holds an ExpandedNodeId scalar; false otherwise.
bool is_status_code() const
Returns whether the Variant holds a StatusCode scalar.
Returns: true if the Variant holds a StatusCode scalar; false otherwise.
bool is_qualified_name() const
Returns whether the Variant holds a QualifiedName scalar.
Returns: true if the Variant holds a QualifiedName scalar; false otherwise.
bool is_localized_text() const
Returns whether the Variant holds a LocalizedText scalar.
Returns: true if the Variant holds a LocalizedText scalar; false otherwise.
bool is_structure() const
Returns whether the Variant holds a Structure scalar.
Returns: true if the Variant holds a Structure scalar; false otherwise.
bool is_data_value() const
Returns whether the Variant holds a DataValue scalar.
Returns: true if the Variant holds a DataValue scalar; false otherwise.
bool is_decimal() const
Returns whether the Variant holds a Decimal scalar.
Returns: true if the Variant holds a Decimal scalar; false otherwise.
bool is_array_of_boolean() const
Returns whether the Variant holds an array of bool.
Returns: true if the Variant holds an array of bool; false otherwise.
bool is_array_of_int8() const
Returns whether the Variant holds an array of int8_t.
Returns: true if the Variant holds an array of int8_t; false otherwise.
bool is_array_of_uint8() const
Returns whether the Variant holds an array of uint8_t.
Returns: true if the Variant holds an array of uint8_t; false otherwise.
bool is_array_of_int16() const
Returns whether the Variant holds an array of int16_t.
Returns: true if the Variant holds an array of int16_t; false otherwise.
bool is_array_of_uint16() const
Returns whether the Variant holds an array of uint16_t.
Returns: true if the Variant holds an array of uint16_t; false otherwise.
bool is_array_of_int32() const
Returns whether the Variant holds an array of int32_t.
Returns: true if the Variant holds an array of int32_t; false otherwise.
bool is_array_of_uint32() const
Returns whether the Variant holds an array of uint32_t.
Returns: true if the Variant holds an array of uint32_t; false otherwise.
bool is_array_of_int64() const
Returns whether the Variant holds an array of int64_t.
Returns: true if the Variant holds an array of int64_t; false otherwise.
bool is_array_of_uint64() const
Returns whether the Variant holds an array of uint64_t.
Returns: true if the Variant holds an array of uint64_t; false otherwise.
bool is_array_of_float() const
Returns whether the Variant holds an array of float.
Returns: true if the Variant holds an array of float; false otherwise.
bool is_array_of_double() const
Returns whether the Variant holds an array of double.
Returns: true if the Variant holds an array of double; false otherwise.
bool is_array_of_date_time() const
Returns whether the Variant holds an array of DateTime.
Returns: true if the Variant holds an array of DateTime; false otherwise.
bool is_array_of_guid() const
Returns whether the Variant holds an array of Guid.
Returns: true if the Variant holds an array of Guid; false otherwise.
bool is_array_of_xml_element() const
Returns whether the Variant holds an array of XmlElement.
Returns: true if the Variant holds an array of XmlElement; false otherwise.
bool is_array_of_string() const
Returns whether the Variant holds an array of String.
Returns: true if the Variant holds an array of String; false otherwise.
bool is_array_of_byte_string() const
Returns whether the Variant holds an array of ByteString.
Returns: true if the Variant holds an array of ByteString; false otherwise.
bool is_array_of_node_id() const
Returns whether the Variant holds an array of NodeId.
Returns: true if the Variant holds an array of NodeId; false otherwise.
bool is_array_of_expanded_node_id() const
Returns whether the Variant holds an array of ExpandedNodeId.
Returns: true if the Variant holds an array of ExpandedNodeId; false otherwise.
bool is_array_of_status_code() const
Returns whether the Variant holds an array of StatusCode.
Returns: true if the Variant holds an array of StatusCode; false otherwise.
bool is_array_of_qualified_name() const
Returns whether the Variant holds an array of QualifiedName.
Returns: true if the Variant holds an array of QualifiedName; false otherwise.
bool is_array_of_localized_text() const
Returns whether the Variant holds an array of LocalizedText.
Returns: true if the Variant holds an array of LocalizedText; false otherwise.
bool is_array_of_structure() const
Returns whether the Variant holds an array of Structure.
Returns: true if the Variant holds an array of Structure; false otherwise.
bool is_array_of_data_value() const
Returns whether the Variant holds an array of DataValue.
Returns: true if the Variant holds an array of DataValue; false otherwise.
bool is_array_of_decimal() const
Returns whether the Variant holds an array of Decimal.
Returns: true if the Variant holds an array of Decimal; false otherwise.
bool is_array_of_variant() const
Returns whether the Variant holds an array of Variant.
Returns: true if the Variant holds an array of Variant; false otherwise.
const ArrayBase & get_array_base() const
Returns the contained array through its type-erased base.
Returns: Reference to the contained array as an ArrayBase.
ArrayBase & get_array_base()
Returns the contained array through its mutable type-erased base.
Returns: Reference to the contained array as an ArrayBase.
BuiltInTypeId get_built_in_type() const
Returns the OPC UA built-in type id of the contained value.
Returns: The BuiltInTypeId of the contained value.
auto as() const -> const T &
Returns a const reference to the contained value as type T.
Returns: Reference to the contained value; valid only while the Variant holds it.
auto as() -> T &
Returns a mutable reference to the contained value as type T.
Returns: Reference to the contained value; valid only while the Variant holds it.
const T * try_as() const
Returns a pointer to the contained value if it is a built-in scalar of type T.
Returns: Pointer to the contained value, or nullptr if the Variant does not hold a T.
const T * try_as() const
Returns a pointer to the contained Structure if it is dynamically of type T.
Returns: Pointer to the contained value, or nullptr if the Variant does not hold a structure or the structure is not a T.
const T * try_as() const
Returns a pointer to the contained array if it is a built-in array of type T.
Returns: Pointer to the contained array, or nullptr if the Variant does not hold a T.
Result< T > to() const noexcept
Coerces the contained value to a native C++ T, scalar or array, non-throwing.
Returns: Result<T> holding a copy of the value, or a bad Result (Bad_TypeMismatch on a type mismatch, Bad_NotSupported for an unsupported T).
Result< std::vector< T > > to_vector() const noexcept
Coerces the contained built-in array to a std::vector<T> of its element type, non-throwing.
Returns: Result<std::vector<T>> holding a copy of the elements, or a bad Result.
void encode(StackDepth limit, Encoder &encoder) const
Encodes the Variant to the wire using the supplied encoder.
limit(StackDepth) - Remaining nesting budget; decremented as nested structures and arrays are encoded to bound recursion.encoder(Encoder &) - Encoder to write the encoded value to.
void clear()
Resets the Variant to the empty state, releasing any contained value.
ua::XmlElement
class
The OPC UA XmlElement built-in type: an XML fragment held as serialized text.
Owns its serialized markup in a backing std::string, so copies are deep and independent. The text is the raw XML as it appears on the wire; this type does not parse or validate the markup. Constructs implicitly from string_view and std::string, and converts implicitly back to a string_view, so an XmlElement is usable wherever standard text is expected.
Static functions
BuiltInTypeId built_in_type_id()
Returns the OPC UA built-in type identifier for XmlElement.
Returns: BuiltInTypeId for this type.
Functions
XmlElement()=default
Constructs the empty XmlElement.
XmlElement(const XmlElement &)=default
Copy-constructs, deep-copying the serialized text.
XmlElement(XmlElement &&other) noexcept=default
Move-constructs; the source is left in a valid but unspecified state.
other(XmlElement &&) - The XmlElement to move from.
XmlElement & operator=(const XmlElement &other)=default
Copy-assigns, deep-copying the serialized text.
other(const XmlElement &) - The XmlElement to copy from.
Returns: Reference to this XmlElement.
XmlElement & operator=(XmlElement &&other) noexcept=default
Move-assigns; the source is left in a valid but unspecified state.
other(XmlElement &&) - The XmlElement to move from.
Returns: Reference to this XmlElement.
~XmlElement()=default
Destroys the XmlElement, releasing its serialized text.
XmlElement & operator=(std::string other)
Replaces this XmlElement's contents by taking ownership of other.
other(std::string) - The XML text to move from.
Returns: Reference to this XmlElement.
XmlElement & operator=(string_view other)
Replaces this XmlElement's contents with a copy of the text viewed by other.
other(string_view) - The XML text to copy.
Returns: Reference to this XmlElement.
bool operator==(const XmlElement &) const =default
Compares two XmlElements for byte-wise equality of their serialized text.
Returns: true if both XmlElements hold byte-wise identical serialized text; false otherwise.
operator string_view() const
Returns a non-owning view over this XmlElement's serialized text.
bool empty() const
Returns true if this XmlElement holds no text.
Returns: true if this XmlElement holds no text; false otherwise.
void clear()
Resets this XmlElement to the empty value.
const std::string & value() const
Returns a read-only reference to this XmlElement's serialized text.
Returns: Const reference to the serialized XML text.
std::string & value()
Returns a mutable reference to this XmlElement's serialized text.
Returns: Mutable reference to the serialized XML text.
ua::DynamicEnumTypeDescriptor
class
Immutable, shared metadata describing a dynamic enumeration or UInteger-based option-set type.
Exactly one descriptor exists per registered dynamic enum/option-set type. All views and DynamicOptionSet instances of that type share the single descriptor through a shared_ptr<const DynamicEnumTypeDescriptor>, so the object is effectively const after construction and safe to read concurrently from any thread.
For enumerations, each EnumField::value() is the integer enum value. For option sets, each EnumField::value() is the 0-based bit number.
Non-copyable and non-movable: the internal name/value lookup maps hold string_views into the owned EnumDefinition strings, which a move (or small-string optimisation) could invalidate. Always heap-allocate via make_shared.
Functions
DynamicEnumTypeDescriptor(String typeName, ExpandedNodeId typeId, bool isOptionSet, EnumDefinition definition)
Constructs a descriptor from an enum definition and its type identity.
typeName(String) - Human-readable type name (e.g. "MyPermissionFlags").typeId(ExpandedNodeId) - DataType NodeId, including its namespace URI.isOptionSet(bool) - true if this describes an option set (bitmask), false for a plain enum.definition(EnumDefinition) - Enum definition supplying the fields; ownership is transferred.
~DynamicEnumTypeDescriptor()=default
Defaulted destructor; completes the rule of five without affecting copyability.
const String & type_name() const
Returns the human-readable type name.
Returns: The human-readable type name.
const ExpandedNodeId & type_id() const
Returns the DataType NodeId, including its namespace URI.
Returns: The DataType NodeId, including its namespace URI.
bool is_option_set() const
Returns true if this describes an option set (bitmask), false for a plain enumeration.
Returns: true if this describes an option set (bitmask); false for a plain enumeration.
std::optional< string_view > name_for_value(int64_t value) const
Returns the field name for a given enum value.
value(int64_t) - Integer enum value, or 0-based bit number for an option set.
Returns: The field name, or nullopt if no field has that value. The view references storage owned by this descriptor and stays valid for its lifetime.
std::optional< int64_t > value_for_name(string_view name) const
Returns the enum value for a given field name.
name(string_view) - Field name to look up.
Returns: The integer value (or 0-based bit number for an option set), or nullopt if no field has that name.
const EnumDefinition & definition() const
Returns the underlying enum definition supplying the fields.
Returns: The underlying EnumDefinition supplying the fields.
ua::DynamicOptionSet
class
A Structure-based OptionSet whose bit definitions are known only at runtime.
Inherits from the generated OptionSet, which supplies the Value and ValidBits ByteString fields plus encode/decode support. This type layers named bit access on top via a shared DynamicEnumTypeDescriptor whose every EnumField::value() is the bit number (0-based) of the corresponding flag.
Use this for option sets that need more than 64 bits or that track valid bits. For UInteger-based option sets (64 bits or fewer), use DynamicOptionSetView instead.
Functions
DynamicOptionSet(shared_ptr< const DynamicEnumTypeDescriptor > descriptor)
Constructs an empty option set bound to the given type descriptor.
descriptor(shared_ptr< const DynamicEnumTypeDescriptor >) - Shared, immutable metadata for this option-set type; must describe an option set (is_option_set() == true) and outlives this instance via shared ownership. Must not be null.
DynamicOptionSet(const DynamicOptionSet &other)=default
Copy-constructs, deep-copying the bit data; the descriptor binding is shared, not duplicated.
other(const DynamicOptionSet &) - Option set to copy from.
DynamicOptionSet(DynamicOptionSet &&other) noexcept=default
Move-constructs; the source is left in a valid but unspecified state.
other(DynamicOptionSet &&) - Option set to move from.
DynamicOptionSet & operator=(const DynamicOptionSet &other)=default
Copy-assigns, deep-copying the bit data; the descriptor binding is shared, not duplicated.
other(const DynamicOptionSet &) - Option set to copy from.
Returns: Reference to this option set.
DynamicOptionSet & operator=(DynamicOptionSet &&other) noexcept=default
Move-assigns; the source is left in a valid but unspecified state.
other(DynamicOptionSet &&) - Option set to move from.
Returns: Reference to this option set.
~DynamicOptionSet() override=default
Defaulted destructor; completes the rule of five and keeps the type copyable/movable.
bool operator==(const DynamicOptionSet &other) const
Compares two option sets for value equality.
other(const DynamicOptionSet &) - Option set to compare against.
Returns: true if both share the same type descriptor and their Value and ValidBits ByteStrings compare equal; false otherwise.
bool is_of_type(const CodecNamespaceContext &ns, const NodeId &typeId) const override
Tests whether this option set is of, or derives from, the given DataType.
ns(const CodecNamespaceContext &) - Namespace context used to resolve typeId against this type's identity.typeId(const NodeId &) - DataType node identifier to test against.
Returns: true if typeId matches this type or one of its supertypes.
NodeId type_id(const CodecNamespaceContext &ns) const override
Returns the DataType node identifier carried by the descriptor, resolved in ns.
ns(const CodecNamespaceContext &) - Namespace context that maps the type's namespace URI to a runtime index.
Returns: The NodeId of this option set's DataType.
ExpandedNodeId type_id() const override
Returns the DataType identifier carried by the descriptor as a namespace-URI-qualified value.
Returns: The ExpandedNodeId of this option set's DataType.
String type_name() const override
Returns the type name carried by the descriptor.
Returns: The type name carried by the descriptor.
void encode_id(StackDepth limit, const CodecNamespaceContext &ns, Encoder &encoder) const override
Encodes this option set's encoding NodeId onto the stream.
limit(StackDepth) - Work budget guarding against pathologically nested encodings.ns(const CodecNamespaceContext &) - Namespace context resolving the encoding NodeId's namespace URI to an index.encoder(Encoder &) - Sink the identifier bytes are written to.
unique_ptr< Structure > clone() const override
Returns an owning, independent deep copy of this option set, including its descriptor binding.
Returns: A unique_ptr owning a copy of this concrete type.
std::string to_string(int indent=0) const override
Returns a human-readable, indented rendering of this option set for diagnostics and logging.
indent(int) - Number of indentation levels to prefix; defaults to top level (0).
Returns: The rendered text.
bool is_set(string_view bitName) const
Tests whether the named bit is set in the Value ByteString.
bitName(string_view) - Flag name as defined by the type descriptor.
Returns: true if the named bit is set.
void set_bit(string_view bitName, bool bitValue=true)
Sets or clears the named bit in the Value ByteString.
bitName(string_view) - Flag name as defined by the type descriptor.bitValue(bool) - true to set the bit, false to clear it. Defaults to true.
bool is_valid(string_view bitName) const
Tests whether the named bit is marked as valid in the ValidBits ByteString.
bitName(string_view) - Flag name as defined by the type descriptor.
Returns: true if the named bit is marked valid.
void set_valid(string_view bitName, bool valid=true)
Sets or clears the named bit in the ValidBits ByteString.
bitName(string_view) - Flag name as defined by the type descriptor.valid(bool) - true to mark the bit valid, false to mark it invalid. Defaults to true.
const DynamicEnumTypeDescriptor & descriptor() const
Returns the type descriptor bound to this option set.
Returns: The DynamicEnumTypeDescriptor bound to this option set.
ua::DynamicStructure
class
A Structure whose shape is defined at runtime by a DynamicStructureTypeDescriptor.
Represents an instance of a structured DataType that is not known at compile time - for example a custom server type discovered from a NodeSet or read over the wire - so its fields are carried in a Variant vector rather than as typed members. Handles plain structures, structures with optional fields, and structures whose fields may carry subtypes. The overloaded StructureField::isOptional flag controls presence only for StructureType::StructureWithOptionalFields; for StructureWithSubtypedValues it permits a subtype and never suppresses the field.
The instance shares an immutable descriptor with every other instance of the same type via shared_ptr<const DynamicStructureTypeDescriptor>; the descriptor outlives and is unmodified by the instance. All fields are eagerly default-constructed from their declared DataType at construction. For optional fields the slot is populated but its encoding-mask bit is unset, so the field is absent on the wire until marked present via set_field_present. Holds value semantics - copy or clone instances rather than sharing them.
Functions
DynamicStructure(shared_ptr< const DynamicStructureTypeDescriptor > descriptor)
Constructs an instance of the type described by descriptor with all fields default-valued.
descriptor(shared_ptr< const DynamicStructureTypeDescriptor >) - Shared, immutable type metadata; retained for the lifetime of the instance. Must not be null.
DynamicStructure(const DynamicStructure &other)
Copy-constructs an independent instance sharing the same descriptor.
other(const DynamicStructure &) - Structure to copy from.
DynamicStructure(DynamicStructure &&other) noexcept=default
Move-constructs from other, leaving it in a valid but unspecified state.
other(DynamicStructure &&) - Structure to move from.
DynamicStructure & operator=(const DynamicStructure &other)
Copy-assigns from other, replacing this instance's fields and descriptor.
other(const DynamicStructure &) - Structure to copy from.
Returns: Reference to this structure.
DynamicStructure & operator=(DynamicStructure &&other) noexcept=default
Move-assigns from other, leaving it in a valid but unspecified state.
other(DynamicStructure &&) - Structure to move from.
Returns: Reference to this structure.
~DynamicStructure() override=default
Defaulted destructor; completes the rule of five and keeps the type copyable/movable.
bool operator==(const DynamicStructure &other) const
Compares two dynamic structures for value equality.
other(const DynamicStructure &) - Structure to compare against.
Returns: true if both refer to the same DataType and all corresponding fields, including the presence of optional fields, compare equal; false otherwise.
bool is_of_type(const CodecNamespaceContext &ns, const NodeId &typeId) const override
Tests whether this structure is of, or derives from, the given DataType.
ns(const CodecNamespaceContext &) - Namespace context used to resolve typeId against this type's identity.typeId(const NodeId &) - DataType node identifier to test against.
Returns: true if this structure is an instance of typeId or one of its subtypes.
NodeId type_id(const CodecNamespaceContext &ns) const override
Returns this structure's DataType node identifier, resolved in the given namespace.
ns(const CodecNamespaceContext &) - Namespace context that maps the descriptor's namespace URI to a runtime index.
Returns: The NodeId of this DataType.
ExpandedNodeId type_id() const override
Returns this structure's DataType identifier as a namespace-URI-qualified value.
Returns: The ExpandedNodeId of this DataType.
String type_name() const override
Returns this type's human-readable name, as recorded in the descriptor.
Returns: This type's human-readable name, as recorded in the descriptor.
void encode_id(StackDepth limit, const CodecNamespaceContext &ns, Encoder &encoder) const override
Encodes this structure's encoding NodeId (its ExtensionObject identity prefix) onto the stream.
limit(StackDepth) - Work budget guarding against pathologically nested encodings; consumed as the encode walk proceeds.ns(const CodecNamespaceContext &) - Namespace context resolving the encoding NodeId's namespace URI to an index.encoder(Encoder &) - Sink the identifier bytes are written to.
void encode(StackDepth limit, Encoder &encoder) const override
Encodes the field payload onto the stream in descriptor field order.
limit(StackDepth) - Work budget guarding against pathologically nested encodings; consumed as nested structures are visited.encoder(Encoder &) - Sink the field bytes are written to.
void decode(StackDepth limit, Decoder &decoder) override
Decodes the field payload from the stream, overwriting this instance's fields.
limit(StackDepth) - Work budget guarding against pathologically nested decodings; consumed as nested structures are visited.decoder(Decoder &) - Source the field bytes are read from.
unique_ptr< Structure > clone() const override
Returns an owning, independent deep copy of this structure.
Returns: A unique_ptr owning the copy.
std::string to_string(int indent=0) const override
Returns a human-readable, indented rendering of this structure for diagnostics and logging.
indent(int) - Number of indentation levels to prefix; used when nesting one structure in another. Defaults to top level (0).
Returns: The rendered text.
Variant & operator[](string_view name)
Returns a mutable reference to the field named name.
name(string_view) - Field name, as declared in the type definition.
Returns: Reference to the field's value, valid until the structure is modified or destroyed.
const Variant & operator[](string_view name) const
Returns a read-only reference to the field named name.
name(string_view) - Field name, as declared in the type definition.
Returns: Reference to the field's value, valid until the structure is modified or destroyed.
Variant & field(size_t index)
Returns a mutable reference to the field at index in definition order.
index(size_t) - Zero-based field index, less than field_count.
Returns: Reference to the field's value, valid until the structure is modified or destroyed.
const Variant & field(size_t index) const
Returns a read-only reference to the field at index in definition order.
index(size_t) - Zero-based field index, less than field_count.
Returns: Reference to the field's value, valid until the structure is modified or destroyed.
bool has_field(string_view name) const
Reports whether the field named name is currently present.
name(string_view) - Field name, as declared in the type definition.
Returns: true if the field exists and is present (will be encoded); false otherwise.
void set_field_present(string_view name, bool present)
Sets whether the optional field named name is present (encoded on the wire).
name(string_view) - Field name, as declared in the type definition.present(bool) - true to include the field on the wire, false to omit it.
const DynamicStructureTypeDescriptor & descriptor() const
Returns the shared, immutable descriptor defining this structure's type and field layout.
Returns: The shared, immutable DynamicStructureTypeDescriptor defining this structure's type and field layout.
size_t field_count() const
Returns the number of fields declared by the type, including optional ones.
Returns: The number of fields declared by the type, including optional ones.
ua::DynamicStructureTypeDescriptor
class
Immutable, shared metadata describing a dynamically registered structure or union type.
Exactly one descriptor exists per registered dynamic type. All DynamicStructure and DynamicUnion instances of that type share a single descriptor through a shared_ptr<const DynamicStructureTypeDescriptor>, so the object must be heap-allocated (typically via make_shared) and is never copied or moved.
The descriptor stores ExpandedNodeId values keyed by namespace URI rather than index, making it portable across sessions; URI-to-index translation happens at encode/decode time via CodecNamespaceContext.
The object is immutable after construction except for the two resolution hooks (set_field_built_in_type and resolve_nested) that the owning DynamicTypeRegistry uses to finalise the type graph.
Not copyable or movable: the field-name index holds string_views into the stored StructureDefinition, which a move could invalidate.
Static functions
BuiltInTypeId data_type_to_built_in_type(const NodeId &dataType)
Maps a DataType NodeId to the BuiltInTypeId it encodes as.
dataType(const NodeId &) - DataType NodeId to classify.
Returns: The corresponding built-in type.
Functions
DynamicStructureTypeDescriptor(String typeName, ExpandedNodeId typeId, ExpandedNodeId encodingId, StructureDefinition definition, NamespaceUriLookup nsLookup)
Constructs a descriptor from a StructureDefinition, resolving field DataTypes to URIs.
typeName(String) - Human-readable type name (for example "MyCustomType").typeId(ExpandedNodeId) - DataType NodeId carrying its namespace URI.encodingId(ExpandedNodeId) - Binary encoding NodeId carrying its namespace URI.definition(StructureDefinition) - Field set and structure kind for the type.nsLookup(NamespaceUriLookup) - Resolves each field's namespace index to a URI.
DynamicStructureTypeDescriptor(String typeName, ExpandedNodeId typeId, ExpandedNodeId encodingId, StructureDefinition definition)
Constructs a descriptor for NS0-only types, where no namespace translation is required.
typeName(String) - Human-readable type name (for example "MyCustomType").typeId(ExpandedNodeId) - DataType NodeId carrying its namespace URI.encodingId(ExpandedNodeId) - Binary encoding NodeId carrying its namespace URI.definition(StructureDefinition) - Field set and structure kind for the type.
~DynamicStructureTypeDescriptor()=default
Defaulted destructor (members are self-owning; copy/move already deleted above).
const String & type_name() const
Returns the human-readable type name.
Returns: The human-readable type name.
const ExpandedNodeId & type_id() const
Returns the DataType NodeId, with its namespace expressed as a URI.
Returns: The DataType NodeId, with its namespace expressed as a URI.
const ExpandedNodeId & encoding_id() const
Returns the binary encoding NodeId, with its namespace expressed as a URI.
Returns: The binary encoding NodeId, with its namespace expressed as a URI.
StructureType structure_type() const
Returns whether the type is a plain structure, a union, or an optional-field structure.
Returns: The StructureType: plain structure, union, or optional-field structure.
size_t field_count() const
Returns the number of fields in the type.
Returns: The number of fields in the type.
const StructureField & field(size_t index) const
Returns the field metadata at index.
index(size_t) - Zero-based field position; must be less than field_count.
Returns: The StructureField metadata at index.
std::optional< size_t > field_index(string_view name) const
Returns the index of the field named name, or std::nullopt if no such field exists.
name(string_view) - Field name to look up.
Returns: The zero-based index of the field named name, or std::nullopt if no such field exists.
BuiltInTypeId field_built_in_type(size_t index) const
Returns the built-in type the field at index encodes as.
index(size_t) - Zero-based field position; must be less than field_count.
Returns: The BuiltInTypeId the field at index encodes as.
void set_field_built_in_type(size_t index, BuiltInTypeId builtInType)
Overrides the precomputed built-in type for the field at index.
index(size_t) - Zero-based field position; must be less than field_count.builtInType(BuiltInTypeId) - Corrected built-in type for the field.
const ExpandedNodeId & field_data_type_expanded(size_t index) const
Returns the field's DataType as a URI-based, namespace-index-independent ExpandedNodeId.
index(size_t) - Zero-based field position; must be less than field_count.
Returns: The field's DataType as a URI-based, namespace-index-independent ExpandedNodeId.
shared_ptr< const DynamicStructureTypeDescriptor > nested_descriptor(size_t fieldIndex) const
Returns the descriptor resolved for the nested structure at fieldIndex, or nullptr if the field is not a structure or has not yet been resolved.
fieldIndex(size_t) - Zero-based field position; must be less than field_count.
Returns: The resolved descriptor for the nested structure at fieldIndex, or nullptr if the field is not a structure or has not yet been resolved.
void resolve_nested(size_t fieldIndex, shared_ptr< const DynamicStructureTypeDescriptor > descriptor)
Resolves the nested descriptor for the structure field at fieldIndex.
fieldIndex(size_t) - Zero-based field position; must be less than field_count.descriptor(shared_ptr< const DynamicStructureTypeDescriptor >) - Shared descriptor for the field's structure type.
bool fully_resolved() const
Returns whether every nested structure field has had its descriptor resolved.
Returns: true if every nested structure field has had its descriptor resolved; false otherwise.
const StructureDefinition & definition() const
Returns the underlying StructureDefinition.
Returns: The underlying StructureDefinition.
ua::DynamicTypeRegistry
class
Central registry that owns dynamic type descriptors keyed by DataType NodeId.
Holds the descriptors for structures, unions, enums, and option sets discovered at runtime (for example from a server's type dictionary) and exposes them for decoding and resolution. Types must be registered in dependency order - enums first, then structures from leaves inward - because the registry eagerly resolves every field dependency at registration time.
Use register_all_with to wire the registered types into a decoder pipeline, or make_resolver to obtain a self-contained StructureResolver snapshot.
All public methods are thread-safe. Registration (write) and lookup/resolve (read) may be called concurrently: registration takes an exclusive lock and lookups take a shared lock. This supports gateway-style servers that discover new upstream types at runtime while existing connections are actively decoding.
Member types
Callback that registers one type with an external factory keyed by encoding NodeId.
Functions
DynamicTypeRegistry()=default
Constructs an empty registry with no registered types.
VoidResult register_type(StructureDefinition definition, ExpandedNodeId typeId, ExpandedNodeId encodingId, String typeName, NamespaceUriLookup nsLookup={})
Registers a structure or union type.
definition(StructureDefinition) - Field layout of the structure or union.typeId(ExpandedNodeId) - DataType NodeId the descriptor is keyed by.encodingId(ExpandedNodeId) - Default binary encoding NodeId, used to index the type for resolution.typeName(String) - Human-readable type name retained on the descriptor.nsLookup(NamespaceUriLookup) - Maps a namespace index to its URI; called once per field at registration time to qualify field DataType NodeIds. Empty by default.
Returns: A successful result, or an ErrorDetail if a field dependency is not yet registered. Never throws.
VoidResult register_type(EnumDefinition definition, ExpandedNodeId typeId, String typeName, bool isOptionSet=false)
Registers an enum or option-set type.
definition(EnumDefinition) - Enumerated values of the type.typeId(ExpandedNodeId) - DataType NodeId the descriptor is keyed by.typeName(String) - Human-readable type name retained on the descriptor.isOptionSet(bool) - true for a UInteger-based option set, false for a plain enum. Retained on the descriptor (see DynamicEnumTypeDescriptor::is_option_set) and used to encode referencing fields as UInt32 (option set) or Int32 (enum).
Returns: A successful result, or an ErrorDetail on failure. Never throws.
const DynamicStructureTypeDescriptor * find_structure(const ExpandedNodeId &typeId) const
Looks up a registered structure or union descriptor by DataType NodeId.
typeId(const ExpandedNodeId &) - DataType NodeId to look up.
Returns: Borrowed pointer to the descriptor, owned by the registry, or nullptr if no type is registered under typeId. The pointer is valid until the type is replaced.
const DynamicEnumTypeDescriptor * find_enum(const ExpandedNodeId &typeId) const
Looks up a registered enum or option-set descriptor by DataType NodeId.
typeId(const ExpandedNodeId &) - DataType NodeId to look up.
Returns: Borrowed pointer to the descriptor, owned by the registry, or nullptr if no type is registered under typeId. The pointer is valid until the type is replaced.
void register_all_with(TypeRegistrar registrar) const
Registers all structure and union types with an external factory via registrar.
registrar(TypeRegistrar) - Receives each type's encoding NodeId and instance factory.
void register_all_with(TypeRegistrar registrar, NamespaceIndexLookup nsLookup) const
Registers all structure and union types with an external factory, mapping encoding NodeId namespace URIs to local namespace indices.
registrar(TypeRegistrar) - Receives each type's encoding NodeId and instance factory.nsLookup(NamespaceIndexLookup) - Maps each encoding NodeId's namespace URI to a local namespace index.
StructureResolver make_resolver() const
Creates a StructureResolver that resolves encoding NodeIds against this registry.
Returns: A resolver over the registry's current contents.
StructureResolver make_resolver(NamespaceIndexLookup nsLookup) const
Creates a StructureResolver that translates encoding NodeIds from local namespace indices to namespace URIs before looking them up in the registry.
nsLookup(NamespaceIndexLookup) - Maps a namespace URI to a local namespace index for the snapshot's lookups.
Returns: A resolver over the registry's current contents.
ua::DynamicUnion
class
A Union whose shape is defined at runtime by a DynamicStructureTypeDescriptor.
Used for union DataTypes discovered at runtime (for example imported from a server's type dictionary) that have no generated C++ class. The descriptor names the fields and their data types; this instance carries the field values and the active switch selection. Every field slot is eagerly default-constructed, so selecting a field overwrites a pre-existing value rather than constructing one. The switch field is 1-based and identifies the active field; 0 is the null union (no field selected).
Holds value semantics like every Structure - instances are copied or cloned rather than shared. The descriptor is shared immutably (shared_ptr<const ...>) across all instances of the same type and must outlive the union; copying a union copies the field values and shares the same descriptor.
Functions
DynamicUnion(shared_ptr< const DynamicStructureTypeDescriptor > descriptor)
Constructs a null union of the type described by descriptor.
descriptor(shared_ptr< const DynamicStructureTypeDescriptor >) - Shared, immutable type description; its StructureType must be StructureType::Union or StructureType::UnionWithSubtypedValues. Must be non-null and must outlive this union.
DynamicUnion(const DynamicUnion &other)
Copy-constructs a union, copying the field values and sharing other's descriptor.
other(const DynamicUnion &) - Union whose field values are copied and whose descriptor is shared.
DynamicUnion(DynamicUnion &&other) noexcept=default
Move-constructs from other, leaving it in a valid but unspecified state.
other(DynamicUnion &&) - Union whose field values and descriptor are moved from.
DynamicUnion & operator=(const DynamicUnion &other)
Copy-assigns a union, replacing the field values and adopting other's descriptor.
other(const DynamicUnion &) - Union whose field values are copied and whose descriptor is adopted.
Returns: Reference to this union.
DynamicUnion & operator=(DynamicUnion &&other) noexcept=default
Move-assigns from other, leaving it in a valid but unspecified state.
other(DynamicUnion &&) - Union whose field values and descriptor are moved from.
Returns: Reference to this union.
~DynamicUnion() override=default
Defaulted destructor; completes the rule of five and keeps the type copyable/movable.
bool operator==(const DynamicUnion &other) const
Compares two dynamic unions for value equality.
other(const DynamicUnion &) - Union to compare against.
Returns: true if the two unions are value-equal, false otherwise.
uint32_t switch_field() const override
Returns the 1-based index of the active field, or 0 if the union is null.
Returns: The 1-based index of the active field, or 0 when the union is null.
uint32_t field_count() const override
Returns the number of fields defined by this union's descriptor.
Returns: The number of fields defined by the descriptor.
void clear() override
Resets the union to the null state, clearing the active field selection.
bool is_of_type(const CodecNamespaceContext &ns, const NodeId &typeId) const override
Tests whether this union is of, or derives from, the given DataType.
ns(const CodecNamespaceContext &) - Namespace context used to resolve typeId against this type's identity.typeId(const NodeId &) - DataType node identifier to test against.
Returns: true if this union is an instance of typeId or one of its subtypes.
NodeId type_id(const CodecNamespaceContext &ns) const override
Returns the DataType node identifier of this union, resolved in ns.
ns(const CodecNamespaceContext &) - Namespace context used to resolve this union's DataType identity.
Returns: The DataType NodeId of this union, resolved in ns.
ExpandedNodeId type_id() const override
Returns the DataType identifier of this union as a namespace-URI-qualified value.
Returns: The DataType identifier as a namespace-URI-qualified ExpandedNodeId.
String type_name() const override
Returns the OPC UA type name of this union's DataType.
Returns: The OPC UA type name of this union's DataType.
void encode_id(StackDepth limit, const CodecNamespaceContext &ns, Encoder &encoder) const override
Encodes this union's encoding NodeId onto encoder.
limit(StackDepth) - Work budget guarding against pathologically nested encodings.ns(const CodecNamespaceContext &) - Namespace context resolving the encoding NodeId's namespace URI to an index.encoder(Encoder &) - Sink the identifier bytes are written to.
void encode(StackDepth limit, Encoder &encoder) const override
Encodes the switch field followed by the active field's value onto encoder.
limit(StackDepth) - Work budget guarding against pathologically nested encodings.encoder(Encoder &) - Sink the field bytes are written to.
void decode(StackDepth limit, Decoder &decoder) override
Decodes the switch field and active field value from decoder into this instance.
limit(StackDepth) - Work budget guarding against pathologically nested decodings.decoder(Decoder &) - Source the field bytes are read from.
unique_ptr< Structure > clone() const override
Returns an owning, independent deep copy of this union.
Returns: A unique_ptr owning a copy with the same descriptor and field values.
std::string to_string(int indent=0) const override
Returns a human-readable, indented rendering of this union for diagnostics and logging.
indent(int) - Number of indentation levels to prefix; used when nesting one structure in another. Defaults to top level (0).
Returns: The rendered text.
const Variant & value() const
Returns the value of the active field.
Returns: Reference to the active field's value, valid until the union is modified or destroyed.
void select(string_view name, Variant fieldValue)
Selects the field named name and sets its value, updating the switch field accordingly.
name(string_view) - Field name as declared by the descriptor.fieldValue(Variant) - Value to store in the selected field; moved in.
void select(size_t index, Variant fieldValue)
Selects the field at zero-based index and sets its value, setting the switch field to index + 1.
index(size_t) - Zero-based field index in definition order, in [0, field_count()).fieldValue(Variant) - Value to store in the selected field; moved in.
string_view active_field_name() const
Returns the name of the active field, or an empty view if the union is null.
Returns: The active field's name, backed by the descriptor and valid for its lifetime; empty when switch_field() == 0.
const DynamicStructureTypeDescriptor & descriptor() const
Returns the type descriptor defining this union's fields and identity.
Returns: Reference to the shared, immutable descriptor; valid for this union's lifetime.
ua::DynamicEnumView
class
Lightweight read-only view that interprets an integer as a named enumeration value.
Not a data type and not involved in encoding; this is a presentation helper that pairs a raw integer value with a DynamicEnumTypeDescriptor to provide name lookup and formatting. The view does not own the descriptor: it holds a reference to it, so the descriptor must outlive the view.
Functions
DynamicEnumView(int64_t value, const DynamicEnumTypeDescriptor &descriptor)
Constructs a view pairing a raw integer value with its enum type descriptor.
value(int64_t) - Raw integer enum value to interpret.descriptor(const DynamicEnumTypeDescriptor &) - Enum type descriptor used for name lookup; must outlive this view.
int64_t value() const
Returns the raw integer value.
Returns: The raw integer value being interpreted.
string_view value_name() const
Returns the name for this value.
Returns: The enumerator name, or an empty string_view if the value is not present in the descriptor's definition.
std::string to_string() const
Formats the value as a human-readable string.
Returns: "TypeName::ValueName" for a known value, or "TypeName(42)" when the value is not present in the descriptor's definition.
const DynamicEnumTypeDescriptor & descriptor() const
Returns the associated enum type descriptor.
Returns: Reference to the descriptor used for name lookup; valid for this view's lifetime.
ua::DynamicOptionSetView
class
Lightweight mutable view that interprets an integer as a named bitmask.
Each bit has a name defined by the DynamicEnumTypeDescriptor's EnumDefinition, where EnumField::value() is the bit number (0-based). This is a presentation and mutation helper, not a data type, and it is not involved in encoding. Mutations are applied to an internal copy of the raw value; call underlying to retrieve the modified bitmask. The view does not own the descriptor: it holds a reference to it, so the descriptor must outlive the view.
Functions
DynamicOptionSetView(uint64_t value, const DynamicEnumTypeDescriptor &descriptor)
Constructs a view pairing a raw bitmask value with its option set type descriptor.
value(uint64_t) - Raw bitmask value to interpret.descriptor(const DynamicEnumTypeDescriptor &) - Type descriptor used for bit-name lookup; must outlive this view.
bool is_set(string_view bitName) const
Tests whether the named bit is set.
bitName(string_view) - Name of the bit to test.
Returns: true if the named bit is set, false otherwise.
void set_bit(string_view bitName, bool value=true)
Sets or clears the named bit.
bitName(string_view) - Name of the bit to modify.value(bool) - true to set the bit, false to clear it.
uint64_t underlying() const
Returns the current bitmask value, reflecting any mutations applied through this view.
Returns: The current bitmask value, including any bits changed through this view.
std::string to_string() const
Formats the set bits as a human-readable string.
Returns: "TypeName{Bit1, Bit3, Bit5}", listing the currently set bits by name.
const DynamicEnumTypeDescriptor & descriptor() const
Returns the associated enum type descriptor.
Returns: Reference to the descriptor used for bit-name lookup; valid for this view's lifetime.
ua::dynamic_types::TypeRegistrationFailure
struct
A single DataType that failed to register, with the cause explaining why.
Collected per type into LoaderRegistrationStats::failures while the rest of the load proceeds; an individual failure does not abort the whole load.
Public attributes
ua::NodeId typeId
NodeId of the DataType that failed to register.
ua::String typeName
Browse name of the DataType, if it was resolved before the failure.
std::shared_ptr< const ua::ErrorDetail > detail
Cause chain for the failure; never null.
ua::dynamic_types::LoaderRegistrationStats
struct
Outcome counters and per-type failures from a single load invocation.
A non-empty failures list does not imply the surrounding operation failed: types that could not be registered are recorded here while the remainder of the load completes, so a successful Result can still carry failures.
Functions
bool has_failures() const
Reports whether any type failed to register.
Returns: true if at least one type failed to register, false otherwise.
size_t failure_count() const
Returns the number of types that failed to register.
Returns: The number of entries in failures.
Public attributes
size_t structureCount
Number of structure DataTypes successfully registered.
size_t enumCount
Number of enumeration DataTypes successfully registered.
size_t skippedAbstract
Number of abstract DataTypes skipped (never registered).
size_t dependencyCount
Number of field-dependency DataTypes pulled in and registered.
std::vector< TypeRegistrationFailure > failures
Per-type registration failures, in encounter order.
ua::dynamic_types::DiscoveredType
class
A DataType surfaced by the loader's hierarchy walk, offered to a TypeFilter.
The loader constructs one of these for every DataType it discovers and passes it to the filter so the predicate can decide - by browse name, abstractness, supertype, or kind, not just NodeId - whether the type should be registered. It is a non-owning view: the referenced strings and NodeIds are owned by the loader and are valid only for the duration of the filter call. Do not retain a DiscoveredType (or references obtained from it) beyond that call.
Selecting a type pulls in its field dependencies regardless of the filter's verdict on those dependencies (see TypeFilter).
Functions
DiscoveredType(const ua::NodeId &nodeId, const ua::String &browseName, bool isAbstract, const ua::NodeId &superType, DiscoveredTypeKind kind) noexcept
nodeId(const ua::NodeId &) - Target node identifier.browseName(const ua::String &) - The browse name.isAbstract(bool) - The is abstract.superType(const ua::NodeId &) - The super type.kind(DiscoveredTypeKind) - The kind. Constructs a view over the given DataType attributes. The referenced objects must outlive the view. Callers other than the loader construct these only in tests.
const ua::NodeId & node_id() const noexcept
Returns: A reference to this object. DataType NodeId.
const ua::String & browse_name() const noexcept
Returns: A reference to this object. Browse name of the DataType (its unqualified name).
bool is_abstract() const noexcept
Returns: True when the requested condition is satisfied. Whether the DataType is abstract. Abstract types are never registered even if selected.
const ua::NodeId & super_type() const noexcept
Returns: A reference to this object. NodeId of the immediate supertype, or a null NodeId if none was resolved.
DiscoveredTypeKind kind() const noexcept
Returns: The requested value. Structure / Enumeration / Other classification from the DataTypeDefinition.
ua::dynamic_types::TypeModelAccess
class
General-purpose async interface for reading attributes and browsing references on an OPC UA information model.
Mirrors the OPC UA Read and Browse services with a single batched, callback-canonical async operation each. Two implementations are provided: AddressSpaceModelAccess reads from a local AddressSpace (server-side) and SessionModelAccess issues service calls over a Session (client-side). Both accept batches so callers can minimise round trips.
Implementations may cache mutable state (for example operation limits read from the server on first use), so a single instance is not safe to call concurrently from multiple threads unless the implementation documents otherwise. The caller must keep the TypeModelAccess alive until every outstanding callback has fired.
Member types
Callback for read_async; on success the Result holds one DataValue per requested ReadValueId in request order, on failure it carries an ErrorDetail.
std::function< void(ua::Result< std::vector< ua::BrowseResult > >)> BrowseCallback
Callback for browse_async; on success the Result holds one BrowseResult per requested BrowseDescription in request order, on failure it carries an ErrorDetail.
Functions
~TypeModelAccess()=default
void read_async(std::vector< ua::ReadValueId > nodesToRead, ReadCallback complete)=0
Reads one or more attribute values.
nodesToRead(std::vector< ua::ReadValueId >) - Attributes to read; the result preserves this order.complete(ReadCallback) - Receives the outcome. On success the Result holds one DataValue per entry in nodesToRead, in the same order; on failure it carries an ErrorDetail. This overload never throws.
void browse_async(std::vector< ua::BrowseDescription > nodesToBrowse, BrowseCallback complete)=0
Browses references from one or more nodes.
nodesToBrowse(std::vector< ua::BrowseDescription >) - Nodes to browse; the result preserves this order.complete(BrowseCallback) - Receives the outcome. On success the Result holds one BrowseResult per entry in nodesToBrowse, in the same order; on failure it carries an ErrorDetail. This overload never throws.
ua::StructureFactory
class
A thread-safe registry that creates Structure instances from encoding NodeIds.
Decoders register a factory callable against each encoding NodeId, then create freshly decoded Structure instances by that id. All methods are safe to call concurrently from any thread; access is serialized internally by a shared mutex (concurrent reads, exclusive writes). The type is neither copyable nor movable.
Member types
std::function< unique_ptr< Structure >()> CreateMethod
Callable that constructs a fresh, owned Structure instance.
Functions
StructureFactory()=default
~StructureFactory()=default
void register_type(const NodeId &encodingId, CreateMethod method) noexcept
Registers a factory callable for an encoding NodeId.
encodingId(const NodeId &) - Encoding NodeId the factory is keyed by.method(CreateMethod) - Callable invoked to construct an instance for encodingId.
Creates a new Structure instance for an encoding NodeId.
encodingId(const NodeId &) - Encoding NodeId to look up.
Returns: A newly constructed instance, or nullptr if encodingId is not registered.
StructureResolver resolver() const
Returns a StructureResolver that delegates to this factory's create_instance().
Returns: A StructureResolver bound to this factory.
Enumerations
ua::BuiltInTypeId
enum
Numeric identifier of an OPC UA built-in type.
Null- No value present (an empty Variant).Boolean- Two-state logical value.SByte- Signed 8-bit integer.Byte- Unsigned 8-bit integer.Int16- Signed 16-bit integer.UInt16- Unsigned 16-bit integer.Int32- Signed 32-bit integer.UInt32- Unsigned 32-bit integer.Int64- Signed 64-bit integer.UInt64- Unsigned 64-bit integer.Float- IEEE 754 single-precision floating point.Double- IEEE 754 double-precision floating point.String- Unicode string (UTF-8 on the wire).DateTime- UTC instant as 100 ns ticks since 1601-01-01.Guid- 16-byte globally unique identifier.ByteString- Opaque sequence of bytes.XmlElement- Serialised XML element.NodeId- Identifier of a node in the address space.ExpandedNodeId- NodeId extended with namespace URI and server index.StatusCode- 32-bit operation result/status code.QualifiedName- Namespace-qualified name.LocalizedText- Text paired with a locale identifier.ExtensionObject- Encoded structured value (a Structure).DataValue- Value plus status code and timestamps.Variant- A union of any built-in type (possibly an array).DiagnosticInfo- Nested diagnostic information for a service result.
ua::dynamic_types::DiscoveredTypeKind
enum
Broad classification of a discovered DataType, as read from its DataTypeDefinition.
Structure- Has a StructureDefinition (concrete or abstract structure/union).Enumeration- Has an EnumDefinition (plain enumeration or option set).Other- Neither - e.g. a subtype of a built-in scalar with no DataTypeDefinition.
Type aliases
ua::StructureResolver
type alias
using StructureResolver = std::function< std::unique_ptr< Structure >(const class NodeId &)>;
Creates a Structure instance from an encoding NodeId.

