9#include <initializer_list>
61 std::string_view
name() const noexcept {
66 constexpr bool isGood() const noexcept {
76 constexpr bool isBad() const noexcept {
91template <
typename T, TypeIndex typeIndex,
typename CharT>
94 static_assert(std::is_same_v<T, UA_String>);
112 template <
typename InputIt>
114 :
StringWrapper(first, last, typename std::iterator_traits<InputIt>::iterator_category{}) {}
120 return this->
native().length;
140 assert(index <
size());
141 return data()[index];
145 assert(index <
size());
146 return data()[index];
222 if (
data() ==
nullptr) {
228 template <
typename InputIt,
typename Tag>
230 init(std::distance(first, last));
231 std::copy(first, last,
data());
234 template <
typename InputIt>
237 std::vector<uint8_t> buffer(first, last);
239 std::copy(buffer.begin(), buffer.end(),
data());
253 using StringWrapper::StringWrapper;
259 operator std::string_view() const noexcept {
263 [[deprecated(
"use conversion function with static_cast instead")]]
264 std::string_view
get() const noexcept {
274 return !(lhs == rhs);
278 return (
static_cast<std::string_view
>(lhs) == rhs);
282 return (
static_cast<std::string_view
>(lhs) != rhs);
286 return (lhs ==
static_cast<std::string_view
>(rhs));
290 return (lhs !=
static_cast<std::string_view
>(rhs));
301 dst =
static_cast<std::string_view
>(src);
315 dst = std::string(src);
339 dst =
String({
static_cast<const char*
>(src), N});
357 using UaDuration = std::chrono::duration<int64_t, std::ratio<1, 10'000'000>>;
361 template <
typename Clock,
typename Duration>
362 DateTime(std::chrono::time_point<Clock, Duration> timePoint)
371 template <
typename Clock,
typename Duration>
375 std::chrono::duration_cast<UaDuration>(timePoint.time_since_epoch()).count()
381 return DateTime(UA_DateTime_fromUnixTime(unixTime));
390 template <
typename Clock = DefaultClock,
typename Duration = UaDuration>
392 const std::chrono::time_point<Clock, Duration> unixEpoch{};
397 return unixEpoch + std::chrono::duration_cast<Duration>(sinceEpoch);
405 return UA_DateTime_toUnixTime(
get());
414 int64_t
get() const noexcept {
420 std::string
format(std::string_view
format,
bool localtime =
false)
const;
423template <
typename Clock,
typename Duration>
425 using ValueType = std::chrono::time_point<Clock, Duration>;
447 explicit Guid(std::array<uint8_t, 16> data) noexcept
450 static_cast<uint32_t
>(
451 (data[0] << 24U) | (data[1] << 16U) | (data[2] << 8U) | data[3]
453 static_cast<uint16_t
>((data[4] << 8U) | data[5]),
454 static_cast<uint16_t
>((data[6] << 8U) | data[7]),
456 {data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]},
459 Guid(uint32_t data1, uint16_t data2, uint16_t data3, std::array<uint8_t, 8> data4) noexcept
464 {data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7]},
479 return !(lhs == rhs);
492 using StringWrapper::StringWrapper;
508 explicit operator std::string_view() const noexcept {
509 return {
reinterpret_cast<const char*
>(
data()),
size()};
516 [[deprecated(
"use conversion function with static_cast instead")]]
517 std::string_view
get() const noexcept {
518 return {
reinterpret_cast<const char*
>(
data()),
size()};
523 return (
static_cast<std::string_view
>(lhs) == rhs);
527 return (
static_cast<std::string_view
>(lhs) != rhs);
531 return (lhs ==
static_cast<std::string_view
>(rhs));
535 return (lhs !=
static_cast<std::string_view
>(rhs));
546 using StringWrapper::StringWrapper;
552 operator std::string_view() const noexcept {
556 [[deprecated(
"use conversion function with static_cast instead")]]
557 std::string_view
get() const noexcept {
567template <
typename T,
typename =
void>
571struct IsNodeIdEnum<T, std::void_t<decltype(getNamespace(std::declval<T>()))>> : std::true_type {};
632 template <typename T, typename = std::enable_if_t<detail::IsNodeIdEnum<T>::value>>
640 uint32_t
hash() const noexcept {
654 switch (
handle()->identifierType) {
669 template <
typename T>
675 template <NodeIdType E>
697 return UA_NodeId_equal(&lhs, &rhs);
701 return !(lhs == rhs);
713 return (lhs < rhs) || (lhs == rhs);
717 return (lhs > rhs) || (lhs == rhs);
745 uint32_t
hash() const noexcept {
771 return UA_ExpandedNodeId_equal(&lhs, &rhs);
775 return !(lhs == rhs);
787 return (lhs < rhs) || (lhs == rhs);
791 return (lhs > rhs) || (lhs == rhs);
819 return (lhs.namespaceIndex == rhs.namespaceIndex) && (lhs.name == rhs.name);
823 return !(lhs == rhs);
856 return (lhs.locale == rhs.locale) && (lhs.text == rhs.text);
860 return !(lhs == rhs);
879template <VariantPolicy>
893 template <VariantPolicy Policy = VariantPolicy::Copy,
typename T>
902 template <VariantPolicy Policy = VariantPolicy::Copy,
typename T>
911 template <VariantPolicy Policy = VariantPolicy::Copy,
typename ArrayLike>
916 Handler::setArray(var,
Span{std::forward<ArrayLike>(array)});
918 Handler::setArray(var, array.begin(), array.end());
925 template <VariantPolicy Policy = VariantPolicy::Copy,
typename ArrayLike>
930 Handler::setArray(var,
Span{std::forward<ArrayLike>(array)}, dataType);
932 Handler::setArray(var, array.begin(), array.end(), dataType);
939 template <VariantPolicy Policy = VariantPolicy::Copy,
typename InputIt>
948 template <VariantPolicy Policy = VariantPolicy::Copy,
typename InputIt>
950 InputIt first, InputIt last,
const UA_DataType& dataType
978 handle()->type !=
nullptr && dataType !=
nullptr &&
979 handle()->type->typeId == dataType->typeId
994 template <
typename T>
1012 const void*
data() const noexcept {
1018 template <
typename T>
1020 assertIsNative<T>();
1022 checkIsDataType<T>();
1027 template <
typename T>
1029 assertIsNative<T>();
1031 checkIsDataType<T>();
1032 return *
static_cast<const T*
>(
handle()->
data);
1036 template <
typename T>
1042 template <
typename T>
1049 template <
typename T>
1051 assertIsCopyableOrConvertible<T>();
1052 return getScalarCopyImpl<T>();
1067 template <
typename T>
1069 assertIsNative<T>();
1071 checkIsDataType<T>();
1077 template <
typename T>
1079 assertIsNative<T>();
1081 checkIsDataType<T>();
1087 template <
typename T>
1089 assertIsCopyableOrConvertible<T>();
1090 return getArrayCopyImpl<T>();
1094 template <
typename T>
1096 assertIsNative<T>();
1101 template <
typename T>
1107 template <
typename T>
1109 assertIsCopyableOrConvertible<T>();
1113 setScalarCopyConvertImpl(value);
1118 template <
typename T>
1120 setScalarCopyImpl(value, dataType);
1129 template <
typename ArrayLike>
1131 using ValueType =
typename std::remove_reference_t<ArrayLike>::value_type;
1132 assertIsNative<ValueType>();
1141 template <
typename ArrayLike>
1143 static_assert(!isTemporaryArray<decltype(array)>());
1145 std::data(std::forward<ArrayLike>(array)),
1146 std::size(std::forward<ArrayLike>(array)),
1157 template <
typename ArrayLike>
1167 template <
typename ArrayLike>
1175 template <
typename InputIt>
1177 using ValueType =
typename std::iterator_traits<InputIt>::value_type;
1178 assertIsCopyableOrConvertible<ValueType>();
1182 setArrayCopyConvertImpl(first, last);
1189 template <
typename InputIt>
1191 setArrayCopyImpl(first, last, dataType);
1195 template <
typename ArrayLike>
1196 static constexpr bool isTemporaryArray() {
1197 constexpr bool isTemporary = std::is_rvalue_reference_v<ArrayLike>;
1199 return isTemporary && !isView;
1202 template <
typename T>
1203 static constexpr void assertIsNative() {
1206 "Template type must be a native/wrapper type to assign or get scalar/array without copy"
1210 template <
typename T>
1211 static constexpr void assertIsCopyableOrConvertible() {
1214 "Template type must be either a native/wrapper type (copyable) or a convertible type. "
1215 "If the type is a native type: Provide the data type (UA_DataType) manually "
1216 "or register the type with a TypeRegistry template specialization. "
1217 "If the type should be converted: Add a template specialization for TypeConverter."
1221 template <
typename T>
1222 static constexpr void assertNoVariant() {
1224 !std::is_same_v<T, Variant> && !std::is_same_v<T, UA_Variant>,
1225 "Variants cannot directly contain another variant"
1229 void checkIsScalar()
const {
1231 throw BadVariantAccess(
"Variant is not a scalar");
1235 void checkIsArray()
const {
1237 throw BadVariantAccess(
"Variant is not an array");
1241 template <
typename T>
1242 void checkIsDataType()
const {
1245 throw BadVariantAccess(
"Variant does not contain a value convertible to template type");
1249 template <
typename T>
1250 inline T getScalarCopyImpl()
const;
1251 template <
typename T>
1252 inline std::vector<T> getArrayCopyImpl()
const;
1254 template <
typename T>
1255 inline void setScalarImpl(
1258 template <
typename T>
1259 inline void setArrayImpl(
1262 template <
typename T>
1263 inline void setScalarCopyImpl(
const T& value,
const UA_DataType& dataType);
1264 template <
typename T>
1265 inline void setScalarCopyConvertImpl(
const T& value);
1266 template <
typename InputIt>
1267 inline void setArrayCopyImpl(InputIt first, InputIt last,
const UA_DataType& dataType);
1268 template <
typename InputIt>
1269 inline void setArrayCopyConvertImpl(InputIt first, InputIt last);
1272template <
typename T>
1273T Variant::getScalarCopyImpl()
const {
1277 using Native =
typename TypeConverter<T>::NativeType;
1284template <
typename T>
1285std::vector<T> Variant::getArrayCopyImpl()
const {
1286 std::vector<T> result(
handle()->arrayLength);
1289 std::transform(
native.begin(),
native.end(), result.begin(), [](
auto&& value) {
1290 return detail::copy(value, opcua::getDataType<T>());
1293 using Native =
typename TypeConverter<T>::NativeType;
1295 for (
size_t i = 0; i <
native.size(); ++i) {
1296 TypeConverter<T>::fromNative(
native[i], result[i]);
1302template <
typename T>
1303void Variant::setScalarImpl(
1306 assertNoVariant<T>();
1307 assert(
sizeof(T) == dataType.memSize);
1309 handle()->type = &dataType;
1310 handle()->storageType = storageType;
1311 handle()->data = data;
1314template <
typename T>
1315void Variant::setArrayImpl(
1318 assertNoVariant<T>();
1319 assert(
sizeof(T) == dataType.memSize);
1321 handle()->type = &dataType;
1322 handle()->storageType = storageType;
1323 handle()->data = data;
1324 handle()->arrayLength = arrayLength;
1327template <
typename T>
1328void Variant::setScalarCopyImpl(
const T& value,
const UA_DataType& dataType) {
1331 setScalarImpl(
native.release(), dataType, UA_VARIANT_DATA);
1334template <
typename T>
1335void Variant::setScalarCopyConvertImpl(
const T& value) {
1336 using Native =
typename TypeConverter<T>::NativeType;
1339 TypeConverter<T>::toNative(value, *
native);
1340 setScalarImpl(
native.release(), dataType, UA_VARIANT_DATA);
1343template <
typename InputIt>
1344void Variant::setArrayCopyImpl(InputIt first, InputIt last,
const UA_DataType& dataType) {
1345 using ValueType =
typename std::iterator_traits<InputIt>::value_type;
1346 const size_t size = std::distance(first, last);
1348 std::transform(first, last,
native.get(), [&](
const ValueType& value) {
1349 return detail::copy(value, dataType);
1351 setArrayImpl(
native.release(), size, dataType, UA_VARIANT_DATA);
1354template <
typename InputIt>
1355void Variant::setArrayCopyConvertImpl(InputIt first, InputIt last) {
1356 using ValueType =
typename std::iterator_traits<InputIt>::value_type;
1357 using Native =
typename TypeConverter<ValueType>::NativeType;
1359 const size_t size = std::distance(first, last);
1361 for (
size_t i = 0; i < size; ++i) {
1362 TypeConverter<ValueType>::toNative(*first++,
native.get()[i]);
1364 setArrayImpl(
native.release(), size, dataType, UA_VARIANT_DATA);
1371 template <
typename T>
1376 template <
typename T>
1381 template <
typename T>
1386 template <
typename T>
1391 template <
typename InputIt>
1396 template <
typename InputIt>
1404 template <
typename T>
1406 var.setScalar(value);
1409 template <
typename T>
1411 var.setScalar(value, dtype);
1414 template <
typename T>
1416 var.setArray(array);
1419 template <
typename T>
1421 var.setArray(array, dtype);
1430 template <
typename T>
1433 var.setScalar(value);
1435 var.setScalarCopy(value);
1439 template <
typename T>
1441 var.setScalar(value, dtype);
1444 template <
typename T>
1447 var.setArray(array);
1449 var.setArrayCopy(array);
1453 template <
typename T>
1455 var.setArray(array, dtype);
1458 template <
typename T>
1463 template <
typename T>
1488 std::optional<DateTime> sourceTimestamp,
1489 std::optional<DateTime> serverTimestamp,
1490 std::optional<uint16_t> sourcePicoseconds,
1491 std::optional<uint16_t> serverPicoseconds,
1492 std::optional<StatusCode>
status
1498 sourcePicoseconds.value_or(uint16_t{}),
1499 serverPicoseconds.value_or(uint16_t{}),
1502 sourceTimestamp.has_value(),
1503 serverTimestamp.has_value(),
1504 sourcePicoseconds.has_value(),
1505 serverPicoseconds.has_value(),
1671 template <
typename T>
1684 obj->content.decoded.type = &type;
1685 obj->content.decoded.data = data;
1692 template <
typename T>
1709 obj->content.decoded.type = &type;
1763 template <
typename T>
1765 return isDecodedDataType<T>() ?
static_cast<T*
>(
getDecodedData()) :
nullptr;
1771 template <
typename T>
1773 return isDecodedDataType<T>() ?
static_cast<const T*
>(
getDecodedData()) :
nullptr;
1795 template <
typename T>
1796 bool isDecodedDataType() const noexcept {
1877 return (lhs.min == rhs.min) && (lhs.max == rhs.max);
1883 return !(lhs == rhs);
1909 return dimensions_.empty();
1919 std::vector<NumericRangeDimension> dimensions_;
1934struct std::hash<
opcua::ExpandedNodeId> {
Exception for bad status codes from open62541 UA_STATUSCODE_*.
UA_ByteString wrapper class.
std::string_view get() const noexcept
std::string toBase64() const
Convert to Base64 encoded string.
operator std::string_view() const noexcept
Explicit conversion to std::string_view.
ByteString(std::string_view str)
ByteString(Span< const uint8_t > bytes)
static ByteString fromBase64(std::string_view encoded)
Parse ByteString from Base64 encoded string.
ByteString(const char *str)
UA_DataValue wrapper class.
bool hasServerPicoseconds() const noexcept
void setSourceTimestamp(DateTime sourceTimestamp) noexcept
Set source timestamp for the value.
bool hasValue() const noexcept
DateTime getServerTimestamp() const noexcept
Get server timestamp for the value.
DataValue(Variant value) noexcept
const Variant && getValue() const &&noexcept
Get value (rvalue).
uint16_t getServerPicoseconds() const noexcept
Get picoseconds interval added to the server timestamp.
bool hasSourceTimestamp() const noexcept
void setServerPicoseconds(uint16_t serverPicoseconds) noexcept
Set picoseconds interval added to the server timestamp.
const Variant & getValue() const &noexcept
Get value.
bool hasStatus() const noexcept
static DataValue fromScalar(Args &&... args)
Create DataValue from scalar value.
void setValue(Variant &&value) noexcept
Set value (move).
void setServerTimestamp(DateTime serverTimestamp) noexcept
Set server timestamp for the value.
Variant & getValue() &noexcept
Get value.
static DataValue fromArray(Args &&... args)
Create DataValue from array.
StatusCode getStatus() const noexcept
Get status.
void setStatus(StatusCode status) noexcept
Set status.
void setSourcePicoseconds(uint16_t sourcePicoseconds) noexcept
Set picoseconds interval added to the source timestamp.
bool hasSourcePicoseconds() const noexcept
uint16_t getSourcePicoseconds() const noexcept
Get picoseconds interval added to the source timestamp.
bool hasServerTimestamp() const noexcept
void setValue(const Variant &value)
Set value (copy).
Variant && getValue() &&noexcept
Get value (rvalue).
DataValue(Variant value, std::optional< DateTime > sourceTimestamp, std::optional< DateTime > serverTimestamp, std::optional< uint16_t > sourcePicoseconds, std::optional< uint16_t > serverPicoseconds, std::optional< StatusCode > status) noexcept
DateTime getSourceTimestamp() const noexcept
Get source timestamp for the value.
UA_DateTime wrapper class.
int64_t get() const noexcept
Get DateTime value as 100 nanosecond intervals since January 1, 1601 (UTC).
UA_DateTimeStruct toStruct() const noexcept
Convert to UA_DateTimeStruct.
static DateTime fromUnixTime(int64_t unixTime) noexcept
Get DateTime from Unix time.
static DateTime now() noexcept
Get current DateTime.
std::chrono::duration< int64_t, std::ratio< 1, 10 '000 '000 > > UaDuration
static DateTime fromTimePoint(std::chrono::time_point< Clock, Duration > timePoint)
Get DateTime from std::chrono::time_point.
int64_t toUnixTime() const noexcept
Convert to Unix time (number of seconds since January 1, 1970 UTC).
static int64_t localTimeUtcOffset() noexcept
Offset of local time to UTC.
DateTime(std::chrono::time_point< Clock, Duration > timePoint)
std::string format(std::string_view format, bool localtime=false) const
Convert to string with given format (same format codes as strftime).
std::chrono::time_point< Clock, Duration > toTimePoint() const
Convert to std::chrono::time_point.
std::chrono::system_clock DefaultClock
UA_DiagnosticInfo wrapper class.
bool hasInnerStatusCode() const noexcept
bool hasLocalizedText() const noexcept
int32_t getSymbolicId() const noexcept
int32_t getNamespaceUri() const noexcept
bool hasSymbolicId() const noexcept
bool hasLocale() const noexcept
bool hasInnerDiagnosticInfo() const noexcept
int32_t getLocalizedText() const noexcept
int32_t getLocale() const noexcept
const String & getAdditionalInfo() const noexcept
const DiagnosticInfo * getInnerDiagnosticInfo() const noexcept
StatusCode getInnerStatusCode() const noexcept
bool hasNamespaceUri() const noexcept
bool hasAdditionalInfo() const noexcept
UA_ExpandedNodeId wrapper class.
uint32_t hash() const noexcept
ExpandedNodeId(NodeId id) noexcept
const NodeId & getNodeId() const noexcept
ExpandedNodeId(NodeId id, std::string_view namespaceUri, uint32_t serverIndex)
bool isLocal() const noexcept
std::string toString() const
Encode ExpandedNodeId as a string like svr=1;nsu=http://test.org/UA/Data/;ns=2;i=10157.
uint32_t getServerIndex() const noexcept
NodeId & getNodeId() noexcept
std::string_view getNamespaceUri() const
UA_ExtensionObject wrapper class.
bool isDecoded() const noexcept
Check if the ExtensionObject is decoded.
static ExtensionObject fromDecoded(void *data, const UA_DataType &type) noexcept
Create an ExtensionObject from a decoded object (reference).
static ExtensionObject fromDecodedCopy(const void *data, const UA_DataType &type)
Create an ExtensionObject from a decoded object (copy).
bool isEmpty() const noexcept
Check if the ExtensionObject is empty.
const UA_DataType * getDecodedDataType() const noexcept
Get the decoded data type.
T * getDecodedData() noexcept
Get pointer to the decoded data with given template type.
const ByteString * getEncodedBody() const noexcept
Get the encoded body.
static ExtensionObject fromDecodedCopy(const T &data)
Create an ExtensionObject from a decoded object (copy).
static ExtensionObject fromDecoded(T &data) noexcept
Create an ExtensionObject from a decoded object (reference).
const T * getDecodedData() const noexcept
Get const pointer to the decoded data with given template type.
const NodeId * getEncodedTypeId() const noexcept
Get the encoded type id.
ExtensionObjectEncoding getEncoding() const noexcept
Get the encoding.
void * getDecodedData() noexcept
Get pointer to the decoded data.
bool isEncoded() const noexcept
Check if the ExtensionObject is encoded (usually if the data type is unknown).
const void * getDecodedData() const noexcept
Get pointer to the decoded data.
Guid(uint32_t data1, uint16_t data2, uint16_t data3, std::array< uint8_t, 8 > data4) noexcept
Guid(std::array< uint8_t, 16 > data) noexcept
std::string toString() const
static Guid random() noexcept
UA_LocalizedText wrapper class.
std::string_view getLocale() const noexcept
std::string_view getText() const noexcept
LocalizedText(std::string_view locale, std::string_view text)
std::string toString() const
Encode NodeId as a string like ns=1;s=SomeNode.
NodeId(T identifier) noexcept
Create NodeId from enum class with numeric identifiers like opcua::ObjectId.
NodeId(NamespaceIndex namespaceIndex, uint32_t identifier) noexcept
Create NodeId with numeric identifier.
NodeId(NamespaceIndex namespaceIndex, ByteString identifier) noexcept
Create NodeId with ByteString identifier.
std::variant< uint32_t, String, Guid, ByteString > getIdentifier() const
Get identifier variant.
NodeId(NamespaceIndex namespaceIndex, Guid identifier) noexcept
Create NodeId with Guid identifier.
auto getIdentifierAs() const
Get identifier by template type.
bool isNull() const noexcept
NamespaceIndex getNamespaceIndex() const noexcept
NodeIdType getIdentifierType() const noexcept
NodeId(NamespaceIndex namespaceIndex, String identifier) noexcept
Create NodeId with String identifier from String wrapper class.
uint32_t hash() const noexcept
NodeId(NamespaceIndex namespaceIndex, std::string_view identifier)
Create NodeId with String identifier from standard strings.
Numeric range to indicate subsets of (multidimensional) arrays.
bool empty() const noexcept
NumericRange(std::string_view encodedRange)
NumericRange(const char *encodedRange)
NumericRange(Span< const NumericRangeDimension > dimensions)
Span< const NumericRangeDimension > dimensions() const noexcept
NumericRange(const UA_NumericRange &native)
std::string toString() const
UA_QualifiedName wrapper class.
NamespaceIndex getNamespaceIndex() const noexcept
QualifiedName(NamespaceIndex namespaceIndex, std::string_view name)
std::string_view getName() const noexcept
View to a contiguous sequence of objects, similar to std::span in C++20.
constexpr iterator begin() const noexcept
constexpr iterator end() const noexcept
UA_StatusCode wrapper class.
constexpr void throwIfBad() const
Throw a BadStatus exception if the status code is bad.
constexpr bool isUncertain() const noexcept
Check if the status code is uncertain.
constexpr bool isBad() const noexcept
Check if the status code is bad.
std::string_view name() const noexcept
Get human-readable name of the StatusCode.
constexpr bool isGood() const noexcept
Check if the status code is good.
constexpr UA_StatusCode get() const noexcept
Explicitly get underlying UA_StatusCode.
constexpr StatusCode() noexcept=default
Create a StatusCode with the default status code UA_STATUSCODE_GOOD.
std::string_view get() const noexcept
String(std::string_view str)
Template base class to wrap UA_* type objects.
constexpr TypeWrapper()=default
UA_Variant wrapper class.
void setArrayCopy(const ArrayLike &array, const UA_DataType &dataType)
Copy array to variant with custom data type.
bool isType(const UA_DataType *dataType) const noexcept
Check if the variant type is equal to the provided data type.
T getScalarCopy() const
Get copy of scalar value with given template type.
Span< T > getArray()
Get array with given template type (only native or wrapper types).
const T && getScalar() const &&
Get reference to scalar value with given template type (only native or wrapper types).
void setArray(ArrayLike &&array) noexcept
Assign array to variant (no copy).
const void * data() const noexcept
Get pointer to the underlying data.
void setArray(ArrayLike &&array, const UA_DataType &dataType) noexcept
Assign array to variant with custom data type (no copy).
void setArrayCopy(const ArrayLike &array)
Copy array to variant.
T && getScalar() &&
Get reference to scalar value with given template type (only native or wrapper types).
const UA_DataType * getDataType() const noexcept
Get data type.
Span< const uint32_t > getArrayDimensions() const noexcept
Get array dimensions.
size_t getArrayLength() const noexcept
Get array length or 0 if variant is not an array.
void setArrayCopy(InputIt first, InputIt last)
Copy range of elements as array to variant.
static Variant fromScalar(T &&value)
Create Variant from scalar value.
bool isType(const UA_DataType &dataType) const noexcept
Check if the variant type is equal to the provided data type.
std::vector< T > getArrayCopy() const
Get copy of array with given template type and return it as a std::vector.
static Variant fromScalar(T &&value, const UA_DataType &dataType)
Create Variant from scalar value with custom data type.
void setScalarCopy(const T &value)
Copy scalar value to variant.
static Variant fromArray(InputIt first, InputIt last, const UA_DataType &dataType)
Create Variant from range of elements with custom data type (copy required).
void setScalar(T &value) noexcept
Assign scalar value to variant (no copy).
bool isType(const NodeId &id) const noexcept
Check if the variant type is equal to the provided data type node id.
Span< const T > getArray() const
Get array with given template type (only native or wrapper types).
bool isEmpty() const noexcept
Check if the variant is empty.
void setScalar(T &value, const UA_DataType &dataType) noexcept
Assign scalar value to variant with custom data type (no copy).
static Variant fromArray(ArrayLike &&array, const UA_DataType &dataType)
Create Variant from array with custom data type.
void setScalarCopy(const T &value, const UA_DataType &dataType)
Copy scalar value to variant with custom data type.
static Variant fromArray(InputIt first, InputIt last)
Create Variant from range of elements (copy required).
bool isArray() const noexcept
Check if the variant is an array.
void setArrayCopy(InputIt first, InputIt last, const UA_DataType &dataType)
Copy range of elements as array to variant with custom data type.
const T & getScalar() const &
Get reference to scalar value with given template type (only native or wrapper types).
T & getScalar() &
Get reference to scalar value with given template type (only native or wrapper types).
bool isScalar() const noexcept
Check if the variant is a scalar.
bool isType() const noexcept
Check if the variant type is equal to the provided template type.
static Variant fromArray(ArrayLike &&array)
Create Variant from array.
void * data() noexcept
Get pointer to the underlying data.
Template base class to wrap native objects.
constexpr const UA_StatusCode & native() const noexcept
constexpr UA_DateTime * handle() noexcept
UA_XmlElement wrapper class.
std::string_view get() const noexcept
XmlElement(std::string_view str)
std::reverse_iterator< const_iterator > const_reverse_iterator
const_reference operator[](size_t index) const noexcept
StringWrapper(InputIt first, InputIt last, std::input_iterator_tag)
reverse_iterator rbegin() noexcept
const value_type & const_reference
reverse_iterator rend() noexcept
reference back() noexcept
const_reverse_iterator rbegin() const noexcept
size_t length() const noexcept
iterator begin() noexcept
std::reverse_iterator< iterator > reverse_iterator
const_iterator begin() const noexcept
StringWrapper(std::initializer_list< CharT > init)
const_reverse_iterator crbegin() const noexcept
const_reverse_iterator crend() const noexcept
const_reference front() const noexcept
StringWrapper(InputIt first, InputIt last)
bool empty() const noexcept
size_t size() const noexcept
const_iterator cbegin() const noexcept
const value_type * const_pointer
const_pointer const_iterator
reference operator[](size_t index) noexcept
const_iterator cend() const noexcept
const_reference back() const noexcept
const_pointer data() const noexcept
const_reverse_iterator rend() const noexcept
reference front() noexcept
StringWrapper(InputIt first, InputIt last, Tag)
std::ptrdiff_t difference_type
const_iterator end() const noexcept
constexpr Namespace getNamespace(DataTypeId) noexcept
Get namespace of DataTypeId.
constexpr NativeType * asNative(WrapperType *wrapper) noexcept
Cast Wrapper object pointers to native object pointers.
static UA_LogCategory const char va_list args
UA_String allocNativeString(std::string_view src)
Allocate UA_String from std::string_view.
constexpr T copy(const T &src, const UA_DataType &type) noexcept(isPointerFree< T >)
auto allocateUniquePtr(const UA_DataType &type)
std::string_view toStringView(const UA_String &src) noexcept
Convert UA_String to std::string_view Can be marked noexcept: https://stackoverflow....
constexpr bool isGood(UA_StatusCode code) noexcept
constexpr bool isRegisteredType
constexpr void clear(T &native, const UA_DataType &type) noexcept
constexpr bool isUncertain(UA_StatusCode code) noexcept
T * allocate(const UA_DataType &type)
auto allocateArrayUniquePtr(size_t size, const UA_DataType &type)
constexpr bool isConvertibleType
constexpr bool isBad(UA_StatusCode code) noexcept
ExtensionObjectEncoding
Extension object encoding.
bool operator>=(const UA_NodeId &lhs, const UA_NodeId &rhs) noexcept
VariantPolicy
Policies for variant factory methods Variant::fromScalar, Variant::fromArray.
@ ReferenceIfPossible
Favor referencing but fall back to copying if necessary.
@ Copy
Store copy of scalar/array inside the variant.
@ Reference
Store reference to scalar/array inside the variant.
bool operator<=(const UA_NodeId &lhs, const UA_NodeId &rhs) noexcept
std::ostream & operator<<(std::ostream &os, const String &str)
constexpr void throwIfBad(UA_StatusCode code)
Check the status code and throw a BadStatus exception if the status code is bad.
Client * asWrapper(UA_Client *client) noexcept
Convert native UA_Client pointer to its wrapper instance.
Span(Container &) -> Span< typename Container::value_type >
uint16_t NamespaceIndex
Namespace index.
bool operator!=(const Client &lhs, const Client &rhs) noexcept
@ NodeId
Unambiguous identifier of a node.
const UA_DataType & getDataType() noexcept
bool operator<(const UA_NodeId &lhs, const UA_NodeId &rhs) noexcept
bool operator>(const UA_NodeId &lhs, const UA_NodeId &rhs) noexcept
bool operator==(const Client &lhs, const Client &rhs) noexcept
#define UA_STATUSCODE_BADOUTOFMEMORY
UA_Boolean hasSourcePicoseconds
UA_Boolean hasServerTimestamp
UA_UInt16 serverPicoseconds
UA_DateTime serverTimestamp
UA_UInt16 sourcePicoseconds
UA_DateTime sourceTimestamp
UA_Boolean hasSourceTimestamp
UA_Boolean hasServerPicoseconds
UA_Boolean hasNamespaceUri
UA_Boolean hasInnerDiagnosticInfo
UA_Boolean hasLocalizedText
UA_Boolean hasInnerStatusCode
UA_StatusCode innerStatusCode
UA_Boolean hasAdditionalInfo
UA_ExtensionObjectEncoding encoding
struct UA_ExtensionObject::@26::@27 encoded
union UA_ExtensionObject::@26 content
struct UA_ExtensionObject::@26::@28 decoded
enum UA_NodeIdType identifierType
union UA_NodeId::@25 identifier
UA_NumericRangeDimension * dimensions
UA_UInt32 * arrayDimensions
size_t arrayDimensionsSize
static void toNative(const ValueType &src, NativeType &dst)
static void toNative(const char *src, NativeType &dst)
static void fromNative(const NativeType &src, ValueType &dst)
static void toNative(const ValueType &src, NativeType &dst)
std::chrono::time_point< Clock, Duration > ValueType
static void fromNative(const NativeType &src, ValueType &dst)
static void toNative(const ValueType &src, NativeType &dst)
static void toNative(std::string_view src, NativeType &dst)
std::string_view ValueType
static void fromNative(const NativeType &src, std::string_view &dst)
Type conversion from and to native types.
static void setArray(Variant &var, Span< T > array)
static void setArray(Variant &var, Span< T > array, const UA_DataType &dtype)
static void setScalar(Variant &var, const T &value, const UA_DataType &dtype)
static void setArray(Variant &var, InputIt first, InputIt last, const UA_DataType &dtype)
static void setArray(Variant &var, InputIt first, InputIt last)
static void setScalar(Variant &var, const T &value)
static void setScalar(Variant &var, T &value, const UA_DataType &dtype) noexcept
static void setArray(Variant &var, Span< const T > array)
static void setScalar(Variant &var, T &value) noexcept(detail::isRegisteredType< T >)
static void setArray(Variant &var, Span< const T > array, const UA_DataType &dtype)
static void setArray(Variant &var, Span< T > array) noexcept(detail::isRegisteredType< T >)
static void setArray(Variant &var, Span< T > array, const UA_DataType &dtype) noexcept
static void setScalar(Variant &var, T &value) noexcept
static void setArray(Variant &var, Span< T > array, const UA_DataType &dtype) noexcept
static void setArray(Variant &var, Span< T > array) noexcept
static void setScalar(Variant &var, T &value, const UA_DataType &dtype) noexcept
std::size_t operator()(const opcua::ExpandedNodeId &id) const noexcept
std::size_t operator()(const opcua::NodeId &id) const noexcept
UA_StatusCode UA_copy(const void *src, void *dst, const UA_DataType *type)
UA_UInt32 UA_NodeId_hash(const UA_NodeId *n)
UA_EXTENSIONOBJECT_ENCODED_XML
UA_EXTENSIONOBJECT_ENCODED_BYTESTRING
UA_EXTENSIONOBJECT_ENCODED_NOBODY
UA_EXTENSIONOBJECT_DECODED
UA_EXTENSIONOBJECT_DECODED_NODELETE
UA_Boolean UA_String_equal(const UA_String *s1, const UA_String *s2)
#define UA_EMPTY_ARRAY_SENTINEL
UA_Guid UA_Guid_random(void)
UA_UInt32 UA_ExpandedNodeId_hash(const UA_ExpandedNodeId *n)
UA_Order UA_NodeId_order(const UA_NodeId *n1, const UA_NodeId *n2)
#define UA_DATETIME_UNIX_EPOCH
UA_DateTimeStruct UA_DateTime_toStruct(UA_DateTime t)
UA_Boolean UA_NodeId_isNull(const UA_NodeId *p)
UA_EXPORT const char * UA_StatusCode_name(UA_StatusCode code)
UA_Order UA_ExpandedNodeId_order(const UA_ExpandedNodeId *n1, const UA_ExpandedNodeId *n2)
UA_DateTime UA_DateTime_now(void)
UA_Boolean UA_Guid_equal(const UA_Guid *g1, const UA_Guid *g2)
UA_Int64 UA_DateTime_localTimeUtcOffset(void)