Codecs

UA Binary and XML encoders/decoders.

ua::UaBinaryDataValueCodec

class

Encodes and decodes DataValue instances to and from the OPC UA Binary wire format.

All state is fixed at construction, so a single instance is safe to share across threads and use concurrently. Construct via create; in server contexts an instance is normally obtained from Server::ua_binary_data_value_codec(), which wires it to the server's namespace table and structure registry.

Movable but not copyable; ownership is held through a unique_ptr returned by create.

Static functions

std::unique_ptr< UaBinaryDataValueCodec > create(StructureResolver structureResolver, CodecNamespaceContext namespaceConfig, EncodingLimits encodingLimits)

Creates a codec bound to the given structure resolver, namespace context, and limits.

  • structureResolver (StructureResolver) - Resolves structured DataTypes encountered while (de)coding; moved into the codec.
  • namespaceConfig (CodecNamespaceContext) - Namespace-table context applied to NodeIds and qualified names; moved into the codec.
  • encodingLimits (EncodingLimits) - Bounds applied asymmetrically. The size caps (mMaxStringLength / mMaxByteStringLength / mMaxArrayLength) are enforced on decode only, where they guard against malformed or hostile input; the encoder never consults them. Both directions receive the nesting/work budget (stack_depth()), which bounds how deeply a structure may nest.

Returns: The owned codec instance.

Functions

~UaBinaryDataValueCodec()

Move-constructs a codec, leaving the source in a valid but unspecified state.

UaBinaryDataValueCodec & operator=(UaBinaryDataValueCodec &&) noexcept

Move-assigns a codec, leaving the source in a valid but unspecified state.

Returns: Reference to this codec.

ByteString encode(const DataValue &value) const

Encodes a DataValue into its OPC UA Binary representation.

  • value (const DataValue &) - Value to serialise.

Returns: The encoded bytes.

DataValueResult decode(std::span< const byte > data) const

Decodes a DataValue from its OPC UA Binary representation.

Returns: The decoded DataValue, or an ErrorDetail describing why the input could not be decoded. Never throws.

Was this page helpful?