ua_types.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. /*
  2. * Copyright (C) 2013-2015 the contributors as stated in the AUTHORS file
  3. *
  4. * This file is part of open62541. open62541 is free software: you can
  5. * redistribute it and/or modify it under the terms of the GNU Lesser General
  6. * Public License, version 3 (as published by the Free Software Foundation) with
  7. * a static linking exception as stated in the LICENSE file provided with
  8. * open62541.
  9. *
  10. * open62541 is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. #ifndef UA_TYPES_H_
  16. #define UA_TYPES_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #ifndef UA_FFI_BINDINGS
  21. #include <stdbool.h>
  22. #include <inttypes.h>
  23. #endif
  24. #include "ua_config.h"
  25. #include "ua_statuscodes.h"
  26. /* Indicates that an array has the length 0 (NULL indicates an non-defined array of length -1)*/
  27. #define UA_EMPTY_ARRAY_SENTINEL ((void*)0x01)
  28. /****************************/
  29. /* Builtin Type Definitions */
  30. /****************************/
  31. #define UA_BUILTIN_TYPES_COUNT 25
  32. /** A two-state logical value (true or false). */
  33. typedef bool UA_Boolean;
  34. #define UA_TRUE true
  35. #define UA_FALSE false
  36. /** An integer value between -128 and 127. */
  37. typedef int8_t UA_SByte;
  38. #define UA_SBYTE_MAX 127
  39. #define UA_SBYTE_MIN -128
  40. /** An integer value between 0 and 256. */
  41. typedef uint8_t UA_Byte;
  42. #define UA_BYTE_MAX 256
  43. #define UA_BYTE_MIN 0
  44. /** An integer value between -32 768 and 32 767. */
  45. typedef int16_t UA_Int16;
  46. #define UA_INT16_MAX 32767
  47. #define UA_INT16_MIN -32768
  48. /** An integer value between 0 and 65 535. */
  49. typedef uint16_t UA_UInt16;
  50. #define UA_UINT16_MAX 65535
  51. #define UA_UINT16_MIN 0
  52. /** An integer value between -2 147 483 648 and 2 147 483 647. */
  53. typedef int32_t UA_Int32;
  54. #define UA_INT32_MAX 2147483647
  55. #define UA_INT32_MIN -2147483648
  56. /** An integer value between 0 and 429 4967 295. */
  57. typedef uint32_t UA_UInt32;
  58. #define UA_UINT32_MAX 4294967295
  59. #define UA_UINT32_MIN 0
  60. /** An integer value between -10 223 372 036 854 775 808 and 9 223 372 036 854 775 807 */
  61. typedef int64_t UA_Int64;
  62. #define UA_INT64_MAX (int64_t)9223372036854775807
  63. #define UA_INT64_MIN (int64_t)-9223372036854775808
  64. /** An integer value between 0 and 18 446 744 073 709 551 615. */
  65. typedef uint64_t UA_UInt64;
  66. #define UA_UINT64_MAX (int64_t)18446744073709551615
  67. #define UA_UINT64_MIN (int64_t)0
  68. /** An IEEE single precision (32 bit) floating point value. */
  69. typedef float UA_Float;
  70. /** An IEEE double precision (64 bit) floating point value. */
  71. typedef double UA_Double;
  72. /** A sequence of Unicode characters. */
  73. typedef struct {
  74. size_t length; ///< The length of the string
  75. UA_Byte *data; ///< The string's content (not null-terminated)
  76. } UA_String;
  77. /** An instance in time. A DateTime value is encoded as a 64-bit signed integer which represents the
  78. number of 100 nanosecond intervals since January 1, 1601 (UTC). */
  79. typedef UA_Int64 UA_DateTime;
  80. /** A 16 byte value that can be used as a globally unique identifier. */
  81. typedef struct {
  82. UA_UInt32 data1;
  83. UA_UInt16 data2;
  84. UA_UInt16 data3;
  85. UA_Byte data4[8];
  86. } UA_Guid;
  87. /** A sequence of octets. */
  88. typedef UA_String UA_ByteString;
  89. /** An XML element. */
  90. typedef UA_String UA_XmlElement;
  91. enum UA_NodeIdType {
  92. UA_NODEIDTYPE_NUMERIC = 0, ///< On the wire, this can be 0,1,2 for numeric nodeids of different sizes
  93. UA_NODEIDTYPE_STRING = 3,
  94. UA_NODEIDTYPE_GUID = 4,
  95. UA_NODEIDTYPE_BYTESTRING = 5
  96. };
  97. /** An identifier for a node in the address space of an OPC UA Server. The shortened numeric types
  98. are introduced during encoding. */
  99. typedef struct {
  100. UA_UInt16 namespaceIndex;
  101. enum UA_NodeIdType identifierType;
  102. union {
  103. UA_UInt32 numeric;
  104. UA_String string;
  105. UA_Guid guid;
  106. UA_ByteString byteString;
  107. } identifier;
  108. } UA_NodeId;
  109. /** A NodeId that allows the namespace URI to be specified instead of an index. */
  110. typedef struct {
  111. UA_NodeId nodeId;
  112. UA_String namespaceUri;
  113. UA_UInt32 serverIndex;
  114. } UA_ExpandedNodeId;
  115. /** A name qualified by a namespace. */
  116. typedef struct {
  117. UA_UInt16 namespaceIndex; ///< The namespace index
  118. UA_String name; ///< The actual name
  119. } UA_QualifiedName;
  120. /** Human readable text with an optional locale identifier. */
  121. typedef struct {
  122. UA_String locale; ///< The locale (e.g. "en-US")
  123. UA_String text; ///< The actual text
  124. } UA_LocalizedText;
  125. /* Forward Declaration of UA_DataType */
  126. struct UA_DataType;
  127. typedef struct UA_DataType UA_DataType;
  128. /** A structure that contains an application specific data type that may not be recognized by the receiver. */
  129. typedef struct {
  130. enum {
  131. UA_EXTENSIONOBJECT_ENCODED_NOBODY = 0,
  132. UA_EXTENSIONOBJECT_ENCODED_BYTESTRING = 1,
  133. UA_EXTENSIONOBJECT_ENCODED_XML = 2,
  134. UA_EXTENSIONOBJECT_DECODED = 3, ///< There is a pointer to the decoded data
  135. UA_EXTENSIONOBJECT_DECODED_NODELETE = 4 ///< Don't delete the decoded data at the lifecycle end
  136. } encoding;
  137. union {
  138. struct {
  139. UA_NodeId typeId; ///< The nodeid of the datatype
  140. UA_ByteString body; ///< The bytestring of the encoded data
  141. } encoded;
  142. struct {
  143. const UA_DataType *type;
  144. void *data;
  145. } decoded;
  146. } content;
  147. } UA_ExtensionObject;
  148. /* NumericRanges are used select a subset in a (multidimensional) variant array.
  149. * NumericRange has no official type structure in the standard. On the wire, it
  150. * only exists as an encoded string, such as "1:2,0:3,5". The colon separates
  151. * min/max index and the comma separates dimensions. A single value indicates a
  152. * range with a single element (min==max). */
  153. typedef struct {
  154. size_t dimensionsSize;
  155. struct UA_NumericRangeDimension {
  156. UA_UInt32 min;
  157. UA_UInt32 max;
  158. } *dimensions;
  159. } UA_NumericRange;
  160. /** Variants store (arrays of) any data type. Either they provide a pointer to the data in
  161. * memory, or functions from which the data can be accessed. Variants are replaced together with
  162. * the data they store (exception: use a data source).
  163. *
  164. * Variant semantics:
  165. * - arrayLength == 0 && data == NULL: no existing data
  166. * - arrayLength == 0 && data == 0x01: array of length 0
  167. * - arrayLength == 0 && data > 0x01: scalar value
  168. * - arrayLength > 0: array of the given length
  169. */
  170. typedef struct {
  171. const UA_DataType *type; ///< The nodeid of the datatype
  172. enum {
  173. UA_VARIANT_DATA, ///< The data is "owned" by this variant (copied and deleted together)
  174. UA_VARIANT_DATA_NODELETE, /**< The data is "borrowed" by the variant and shall not be
  175. deleted at the end of this variant's lifecycle. It is not
  176. possible to overwrite borrowed data due to concurrent access.
  177. Use a custom datasource with a mutex. */
  178. } storageType; ///< Shall the data be deleted together with the variant
  179. size_t arrayLength; ///< the number of elements in the data-pointer
  180. void *data; ///< points to the scalar or array data
  181. size_t arrayDimensionsSize; ///< the number of dimensions the data-array has
  182. UA_UInt32 *arrayDimensions; ///< the length of each dimension of the data-array
  183. } UA_Variant;
  184. /** A data value with an associated status code and timestamps. */
  185. typedef struct {
  186. UA_Boolean hasValue : 1;
  187. UA_Boolean hasStatus : 1;
  188. UA_Boolean hasSourceTimestamp : 1;
  189. UA_Boolean hasServerTimestamp : 1;
  190. UA_Boolean hasSourcePicoseconds : 1;
  191. UA_Boolean hasServerPicoseconds : 1;
  192. UA_Variant value;
  193. UA_StatusCode status;
  194. UA_DateTime sourceTimestamp;
  195. UA_Int16 sourcePicoseconds;
  196. UA_DateTime serverTimestamp;
  197. UA_Int16 serverPicoseconds;
  198. } UA_DataValue;
  199. /** A structure that contains detailed error and diagnostic information associated with a StatusCode. */
  200. typedef struct UA_DiagnosticInfo {
  201. UA_Boolean hasSymbolicId : 1;
  202. UA_Boolean hasNamespaceUri : 1;
  203. UA_Boolean hasLocalizedText : 1;
  204. UA_Boolean hasLocale : 1;
  205. UA_Boolean hasAdditionalInfo : 1;
  206. UA_Boolean hasInnerStatusCode : 1;
  207. UA_Boolean hasInnerDiagnosticInfo : 1;
  208. UA_Int32 symbolicId;
  209. UA_Int32 namespaceUri;
  210. UA_Int32 localizedText;
  211. UA_Int32 locale;
  212. UA_String additionalInfo;
  213. UA_StatusCode innerStatusCode;
  214. struct UA_DiagnosticInfo *innerDiagnosticInfo;
  215. } UA_DiagnosticInfo;
  216. /*************************/
  217. /* Generic Type Handling */
  218. /*************************/
  219. #define UA_MAX_TYPE_MEMBERS 13 // Maximum number of members per structured type
  220. typedef struct {
  221. #ifdef ENABLE_TYPEINTROSPECTION
  222. const char *memberName;
  223. #endif
  224. UA_UInt16 memberTypeIndex; ///< Index of the member in the datatypetable
  225. UA_Byte padding; /**< How much padding is there before this member element? For arrays this is
  226. split into 2 bytes padding before the length index (max 4 bytes) and 3
  227. bytes padding before the pointer (max 8 bytes) */
  228. UA_Boolean namespaceZero : 1; /**< The type of the member is defined in namespace zero. In this
  229. implementation, types from custom namespace may contain
  230. members from the same namespace or ns0 only.*/
  231. UA_Boolean isArray : 1; ///< The member is an array of the given type
  232. } UA_DataTypeMember;
  233. struct UA_DataType {
  234. #ifdef ENABLE_TYPEINTROSPECTION
  235. const char *typeName;
  236. #endif
  237. UA_NodeId typeId; ///< The nodeid of the type
  238. UA_UInt16 memSize; ///< Size of the struct in memory
  239. UA_UInt16 typeIndex; ///< Index of the type in the datatypetable
  240. UA_Byte membersSize; ///< How many members does the type have?
  241. UA_Boolean builtin : 1; ///< The type is "builtin" and has dedicated de- and encoding functions
  242. UA_Boolean fixedSize : 1; ///< The type (and its members) contains no pointers
  243. UA_Boolean zeroCopyable : 1; ///< The type can be copied directly off the stream (given that the endianness matches)
  244. UA_DataTypeMember members[UA_MAX_TYPE_MEMBERS];
  245. };
  246. /**
  247. * Allocates and initializes a variable of type dataType
  248. *
  249. * @param type The datatype description
  250. * @return Returns the memory location of the variable or (void*)0 if no memory is available
  251. */
  252. void UA_EXPORT * UA_new(const UA_DataType *type) UA_FUNC_ATTR_MALLOC;
  253. /**
  254. * Initializes a variable to default values
  255. *
  256. * @param p The memory location of the variable
  257. * @param type The datatype description
  258. */
  259. void UA_EXPORT UA_init(void *p, const UA_DataType *type);
  260. /**
  261. * Copies the content of two variables. If copying fails (e.g. because no memory was available for
  262. * an array), then dst is emptied and initialized to prevent memory leaks.
  263. *
  264. * @param src The memory location of the source variable
  265. * @param dst The memory location of the destination variable
  266. * @param type The datatype description
  267. * @return Indicates whether the operation succeeded or returns an error code
  268. */
  269. UA_StatusCode UA_EXPORT
  270. UA_copy(const void *src, void *dst, const UA_DataType *type) UA_FUNC_ATTR_WARN_UNUSED_RESULT;
  271. /**
  272. * Deletes the dynamically assigned content of a variable (e.g. a member-array).
  273. * Afterwards, the variable can be safely deleted without causing memory leaks.
  274. * But the variable is not initialized and may contain old data that is not
  275. * memory-relevant.
  276. *
  277. * @param p The memory location of the variable
  278. * @param type The datatype description of the variable
  279. */
  280. void UA_EXPORT UA_deleteMembers(void *p, const UA_DataType *type);
  281. /**
  282. * Deletes (frees) a variable and all of its content.
  283. *
  284. * @param p The memory location of the variable
  285. * @param type The datatype description of the variable
  286. */
  287. void UA_EXPORT UA_delete(void *p, const UA_DataType *type);
  288. /********************/
  289. /* Array operations */
  290. /********************/
  291. #define MAX_ARRAY_SIZE 104857600 // arrays must be smaller than 100MB
  292. /**
  293. * Allocates and initializes an array of variables of a specific type
  294. *
  295. * @param size The requested array length
  296. * @param type The datatype description
  297. * @return Returns the memory location of the variable or (void*)0 if no memory could be allocated
  298. */
  299. void UA_EXPORT * UA_Array_new(size_t size, const UA_DataType *type) UA_FUNC_ATTR_MALLOC;
  300. /**
  301. * Allocates and copies an array. dst is set to (void*)0 if not enough memory is available.
  302. *
  303. * @param src The memory location of the source array
  304. * @param src_size The size of the array
  305. * @param dst The location of the pointer to the new array
  306. * @param type The datatype of the array members
  307. * @return Returns whether copying succeeded
  308. */
  309. UA_StatusCode UA_EXPORT
  310. UA_Array_copy(const void *src, size_t src_size, void **dst,
  311. const UA_DataType *type) UA_FUNC_ATTR_WARN_UNUSED_RESULT;
  312. /**
  313. * Deletes an array.
  314. *
  315. * @param p The memory location of the array
  316. * @param size The size of the array
  317. * @param type The datatype of the array members
  318. */
  319. void UA_EXPORT UA_Array_delete(void *p, size_t size, const UA_DataType *type);
  320. /***********************************/
  321. /* Builtin Type Handling Functions */
  322. /***********************************/
  323. #include "ua_types_generated.h"
  324. /* Boolean */
  325. static UA_INLINE UA_Boolean * UA_Boolean_new(void) { return UA_new(&UA_TYPES[UA_TYPES_BOOLEAN]); }
  326. static UA_INLINE void UA_Boolean_init(UA_Boolean *p) { *p = UA_FALSE; }
  327. static UA_INLINE void UA_Boolean_delete(UA_Boolean *p) { UA_delete(p, &UA_TYPES[UA_TYPES_BOOLEAN]); }
  328. static UA_INLINE void UA_Boolean_deleteMembers(UA_Boolean *p) { }
  329. static UA_INLINE UA_StatusCode UA_Boolean_copy(const UA_Boolean *src, UA_Boolean *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  330. /* SByte */
  331. static UA_INLINE UA_SByte * UA_SByte_new(void) { return UA_new(&UA_TYPES[UA_TYPES_SBYTE]); }
  332. static UA_INLINE void UA_SByte_init(UA_SByte *p) { *p = 0; }
  333. static UA_INLINE void UA_SByte_delete(UA_SByte *p) { UA_delete(p, &UA_TYPES[UA_TYPES_SBYTE]); }
  334. static UA_INLINE void UA_SByte_deleteMembers(UA_SByte *p) { }
  335. static UA_INLINE UA_StatusCode UA_SByte_copy(const UA_SByte *src, UA_SByte *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  336. /* Byte */
  337. static UA_INLINE UA_Byte * UA_Byte_new(void) { return UA_new(&UA_TYPES[UA_TYPES_BYTE]); }
  338. static UA_INLINE void UA_Byte_init(UA_Byte *p) { *p = 0; }
  339. static UA_INLINE void UA_Byte_delete(UA_Byte *p) { UA_delete(p, &UA_TYPES[UA_TYPES_BYTE]); }
  340. static UA_INLINE void UA_Byte_deleteMembers(UA_Byte *p) { }
  341. static UA_INLINE UA_StatusCode UA_Byte_copy(const UA_Byte *src, UA_Byte *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  342. /* Int16 */
  343. static UA_INLINE UA_Int16 * UA_Int16_new(void) { return UA_new(&UA_TYPES[UA_TYPES_INT16]); }
  344. static UA_INLINE void UA_Int16_init(UA_Int16 *p) { *p = 0; }
  345. static UA_INLINE void UA_Int16_delete(UA_Int16 *p) { UA_delete(p, &UA_TYPES[UA_TYPES_INT16]); }
  346. static UA_INLINE void UA_Int16_deleteMembers(UA_Int16 *p) { }
  347. static UA_INLINE UA_StatusCode UA_Int16_copy(const UA_Int16 *src, UA_Int16 *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  348. /* UInt16 */
  349. static UA_INLINE UA_UInt16 * UA_UInt16_new(void) { return UA_new(&UA_TYPES[UA_TYPES_UINT16]); }
  350. static UA_INLINE void UA_UInt16_init(UA_UInt16 *p) { *p = 0; }
  351. static UA_INLINE void UA_UInt16_delete(UA_UInt16 *p) { UA_delete(p, &UA_TYPES[UA_TYPES_UINT16]); }
  352. static UA_INLINE void UA_UInt16_deleteMembers(UA_UInt16 *p) { }
  353. static UA_INLINE UA_StatusCode UA_UInt16_copy(const UA_UInt16 *src, UA_UInt16 *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  354. /* Int32 */
  355. static UA_INLINE UA_Int32 * UA_Int32_new(void) { return UA_new(&UA_TYPES[UA_TYPES_INT32]); }
  356. static UA_INLINE void UA_Int32_init(UA_Int32 *p) { *p = 0; }
  357. static UA_INLINE void UA_Int32_delete(UA_Int32 *p) { UA_delete(p, &UA_TYPES[UA_TYPES_INT32]); }
  358. static UA_INLINE void UA_Int32_deleteMembers(UA_Int32 *p) { }
  359. static UA_INLINE UA_StatusCode UA_Int32_copy(const UA_Int32 *src, UA_Int32 *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  360. /* UInt32 */
  361. static UA_INLINE UA_UInt32 * UA_UInt32_new(void) { return UA_new(&UA_TYPES[UA_TYPES_UINT32]); }
  362. static UA_INLINE void UA_UInt32_init(UA_UInt32 *p) { *p = 0; }
  363. static UA_INLINE void UA_UInt32_delete(UA_UInt32 *p) { UA_delete(p, &UA_TYPES[UA_TYPES_UINT32]); }
  364. static UA_INLINE void UA_UInt32_deleteMembers(UA_UInt32 *p) { }
  365. static UA_INLINE UA_StatusCode UA_UInt32_copy(const UA_UInt32 *src, UA_UInt32 *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  366. /* Int64 */
  367. static UA_INLINE UA_Int64 * UA_Int64_new(void) { return UA_new(&UA_TYPES[UA_TYPES_INT64]); }
  368. static UA_INLINE void UA_Int64_init(UA_Int64 *p) { *p = 0; }
  369. static UA_INLINE void UA_Int64_delete(UA_Int64 *p) { UA_delete(p, &UA_TYPES[UA_TYPES_INT64]); }
  370. static UA_INLINE void UA_Int64_deleteMembers(UA_Int64 *p) { }
  371. static UA_INLINE UA_StatusCode UA_Int64_copy(const UA_Int64 *src, UA_Int64 *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  372. /* UInt64 */
  373. static UA_INLINE UA_UInt64 * UA_UInt64_new(void) { return UA_new(&UA_TYPES[UA_TYPES_UINT64]); }
  374. static UA_INLINE void UA_UInt64_init(UA_UInt64 *p) { *p = 0; }
  375. static UA_INLINE void UA_UInt64_delete(UA_UInt64 *p) { UA_delete(p, &UA_TYPES[UA_TYPES_UINT64]); }
  376. static UA_INLINE void UA_UInt64_deleteMembers(UA_UInt64 *p) { }
  377. static UA_INLINE UA_StatusCode UA_UInt64_copy(const UA_UInt64 *src, UA_UInt64 *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  378. /* Float */
  379. static UA_INLINE UA_Float * UA_Float_new(void) { return UA_new(&UA_TYPES[UA_TYPES_FLOAT]); }
  380. static UA_INLINE void UA_Float_init(UA_Float *p) { *p = 0.0f; }
  381. static UA_INLINE void UA_Float_delete(UA_Float *p) { UA_delete(p, &UA_TYPES[UA_TYPES_FLOAT]); }
  382. static UA_INLINE void UA_Float_deleteMembers(UA_Float *p) { }
  383. static UA_INLINE UA_StatusCode UA_Float_copy(const UA_Float *src, UA_Float *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  384. /* Double */
  385. static UA_INLINE UA_Double * UA_Double_new(void) { return UA_new(&UA_TYPES[UA_TYPES_DOUBLE]); }
  386. static UA_INLINE void UA_Double_init(UA_Double *p) { *p = 0.0f; }
  387. static UA_INLINE void UA_Double_delete(UA_Double *p) { UA_delete(p, &UA_TYPES[UA_TYPES_DOUBLE]); }
  388. static UA_INLINE void UA_Double_deleteMembers(UA_Double *p) { }
  389. static UA_INLINE UA_StatusCode UA_Double_copy(const UA_Double *src, UA_Double *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  390. /* String */
  391. static UA_INLINE UA_String * UA_String_new(void) { return UA_new(&UA_TYPES[UA_TYPES_STRING]); }
  392. static UA_INLINE void UA_String_init(UA_String *p) { memset(p, 0, sizeof(UA_String)); }
  393. static UA_INLINE void UA_String_delete(UA_String *p) { UA_delete(p, &UA_TYPES[UA_TYPES_STRING]); }
  394. static UA_INLINE void UA_String_deleteMembers(UA_String *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_STRING]); }
  395. static UA_INLINE UA_StatusCode UA_String_copy(const UA_String *src, UA_String *dst) {return UA_copy(src, dst, &UA_TYPES[UA_TYPES_STRING]); }
  396. /** Copies the content on the heap. Returns a null-string when alloc fails */
  397. UA_String UA_EXPORT UA_String_fromChars(char const src[]);
  398. UA_Boolean UA_EXPORT UA_String_equal(const UA_String *s1, const UA_String *s2);
  399. UA_EXPORT extern const UA_String UA_STRING_NULL;
  400. static UA_INLINE UA_String UA_STRING(char *chars) {
  401. UA_String str;
  402. str.length = strlen(chars);
  403. str.data = (UA_Byte*)chars;
  404. return str; }
  405. #define UA_STRING_ALLOC(CHARS) UA_String_fromChars(CHARS)
  406. /* DateTime */
  407. static UA_INLINE UA_DateTime * UA_DateTime_new(void) { return UA_new(&UA_TYPES[UA_TYPES_DATETIME]); }
  408. static UA_INLINE void UA_DateTime_init(UA_DateTime *p) { *p = 0; }
  409. static UA_INLINE void UA_DateTime_delete(UA_DateTime *p) { UA_delete(p, &UA_TYPES[UA_TYPES_DATETIME]); }
  410. static UA_INLINE void UA_DateTime_deleteMembers(UA_DateTime *p) { }
  411. static UA_INLINE UA_StatusCode UA_DateTime_copy(const UA_DateTime *src, UA_DateTime *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  412. UA_DateTime UA_EXPORT UA_DateTime_now(void); ///> The current time
  413. typedef struct UA_DateTimeStruct {
  414. UA_UInt16 nanoSec;
  415. UA_UInt16 microSec;
  416. UA_UInt16 milliSec;
  417. UA_UInt16 sec;
  418. UA_UInt16 min;
  419. UA_UInt16 hour;
  420. UA_UInt16 day;
  421. UA_UInt16 month;
  422. UA_UInt16 year;
  423. } UA_DateTimeStruct;
  424. UA_DateTimeStruct UA_EXPORT UA_DateTime_toStruct(UA_DateTime time);
  425. UA_String UA_EXPORT UA_DateTime_toString(UA_DateTime time);
  426. /* Guid */
  427. static UA_INLINE UA_Guid * UA_Guid_new(void) { return UA_new(&UA_TYPES[UA_TYPES_GUID]); }
  428. static UA_INLINE void UA_Guid_init(UA_Guid *p) { memset(p, 0, sizeof(UA_Guid)); }
  429. static UA_INLINE void UA_Guid_delete(UA_Guid *p) { UA_delete(p, &UA_TYPES[UA_TYPES_GUID]); }
  430. static UA_INLINE void UA_Guid_deleteMembers(UA_Guid *p) { }
  431. static UA_INLINE UA_StatusCode UA_Guid_copy(const UA_Guid *src, UA_Guid *dst) { *dst = *src; return UA_STATUSCODE_GOOD; }
  432. UA_Boolean UA_EXPORT UA_Guid_equal(const UA_Guid *g1, const UA_Guid *g2);
  433. UA_Guid UA_EXPORT UA_Guid_random(UA_UInt32 *seed);
  434. /* ByteString */
  435. static UA_INLINE UA_ByteString * UA_ByteString_new(void) { return UA_new(&UA_TYPES[UA_TYPES_BYTESTRING]); }
  436. static UA_INLINE void UA_ByteString_init(UA_ByteString *p) { memset(p, 0, sizeof(UA_ByteString)); }
  437. static UA_INLINE void UA_ByteString_delete(UA_ByteString *p) { UA_delete(p, &UA_TYPES[UA_TYPES_BYTESTRING]); }
  438. static UA_INLINE void UA_ByteString_deleteMembers(UA_ByteString *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_BYTESTRING]); }
  439. static UA_INLINE UA_StatusCode UA_ByteString_copy(const UA_ByteString *src, UA_ByteString *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_BYTESTRING]); }
  440. static UA_INLINE UA_Boolean UA_ByteString_equal(const UA_ByteString *string1, const UA_ByteString *string2) {
  441. return UA_String_equal((const UA_String*)string1, (const UA_String*)string2); }
  442. /* Allocates memory of size length for the bytestring. The content is not set to zero. */
  443. UA_ByteString UA_EXPORT UA_ByteString_withSize(size_t length);
  444. UA_EXPORT extern const UA_ByteString UA_BYTESTRING_NULL;
  445. static UA_INLINE UA_ByteString UA_BYTESTRING(char *chars) {
  446. UA_ByteString str;
  447. str.length = strlen(chars);
  448. str.data = (UA_Byte*)chars;
  449. return str; }
  450. static UA_INLINE UA_ByteString UA_BYTESTRING_ALLOC(const char *chars) {
  451. UA_String str = UA_String_fromChars(chars);
  452. UA_ByteString bstr;
  453. bstr.length = str.length;
  454. bstr.data = str.data;
  455. return bstr;
  456. }
  457. /* XmlElement */
  458. static UA_INLINE UA_XmlElement * UA_XmlElement_new(void) { return UA_new(&UA_TYPES[UA_TYPES_XMLELEMENT]); }
  459. static UA_INLINE void UA_XmlElement_init(UA_XmlElement *p) { memset(p, 0, sizeof(UA_XmlElement)); }
  460. static UA_INLINE void UA_XmlElement_delete(UA_XmlElement *p) { UA_delete(p, &UA_TYPES[UA_TYPES_XMLELEMENT]); }
  461. static UA_INLINE void UA_XmlElement_deleteMembers(UA_XmlElement *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_XMLELEMENT]); }
  462. static UA_INLINE UA_StatusCode UA_XmlElement_copy(const UA_XmlElement *src, UA_XmlElement *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_XMLELEMENT]); }
  463. /* NodeId */
  464. static UA_INLINE UA_NodeId * UA_NodeId_new(void) { return UA_new(&UA_TYPES[UA_TYPES_NODEID]); }
  465. static UA_INLINE void UA_NodeId_init(UA_NodeId *p) { memset(p, 0, sizeof(UA_NodeId)); }
  466. static UA_INLINE void UA_NodeId_delete(UA_NodeId *p) { UA_delete(p, &UA_TYPES[UA_TYPES_NODEID]); }
  467. static UA_INLINE void UA_NodeId_deleteMembers(UA_NodeId *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_NODEID]); }
  468. static UA_INLINE UA_StatusCode UA_NodeId_copy(const UA_NodeId *src, UA_NodeId *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_NODEID]); }
  469. UA_Boolean UA_EXPORT UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2);
  470. static UA_INLINE UA_Boolean UA_NodeId_isNull(const UA_NodeId *p) {
  471. return (p->namespaceIndex == 0 && p->identifierType == UA_NODEIDTYPE_NUMERIC &&
  472. p->identifier.numeric == 0);
  473. }
  474. UA_EXPORT extern const UA_NodeId UA_NODEID_NULL;
  475. static UA_INLINE UA_NodeId UA_NODEID_NUMERIC(UA_UInt16 nsIndex, UA_Int32 identifier) {
  476. UA_NodeId id;
  477. id.namespaceIndex = nsIndex;
  478. id.identifierType = UA_NODEIDTYPE_NUMERIC;
  479. id.identifier.numeric = identifier;
  480. return id; }
  481. static UA_INLINE UA_NodeId UA_NODEID_STRING(UA_UInt16 nsIndex, char *chars) {
  482. UA_NodeId id;
  483. id.namespaceIndex = nsIndex;
  484. id.identifierType = UA_NODEIDTYPE_STRING;
  485. id.identifier.string = UA_STRING(chars);
  486. return id; }
  487. static UA_INLINE UA_NodeId UA_NODEID_STRING_ALLOC(UA_UInt16 nsIndex, const char *chars) {
  488. UA_NodeId id;
  489. id.namespaceIndex = nsIndex;
  490. id.identifierType = UA_NODEIDTYPE_STRING;
  491. id.identifier.string = UA_STRING_ALLOC(chars);
  492. return id; }
  493. static UA_INLINE UA_NodeId UA_NODEID_GUID(UA_UInt16 nsIndex, UA_Guid guid) {
  494. UA_NodeId id;
  495. id.namespaceIndex = nsIndex;
  496. id.identifierType = UA_NODEIDTYPE_GUID;
  497. id.identifier.guid = guid;
  498. return id; }
  499. static UA_INLINE UA_NodeId UA_NODEID_BYTESTRING(UA_UInt16 nsIndex, char *chars) {
  500. UA_NodeId id;
  501. id.namespaceIndex = nsIndex;
  502. id.identifierType = UA_NODEIDTYPE_BYTESTRING;
  503. id.identifier.byteString = UA_BYTESTRING(chars);
  504. return id; }
  505. static UA_INLINE UA_NodeId UA_NODEID_BYTESTRING_ALLOC(UA_UInt16 nsIndex, const char *chars) {
  506. UA_NodeId id;
  507. id.namespaceIndex = nsIndex;
  508. id.identifierType = UA_NODEIDTYPE_BYTESTRING;
  509. id.identifier.byteString = UA_BYTESTRING_ALLOC(chars);
  510. return id; }
  511. /* ExpandedNodeId */
  512. static UA_INLINE UA_ExpandedNodeId * UA_ExpandedNodeId_new(void) { return UA_new(&UA_TYPES[UA_TYPES_EXPANDEDNODEID]); }
  513. static UA_INLINE void UA_ExpandedNodeId_init(UA_ExpandedNodeId *p) { memset(p, 0, sizeof(UA_ExpandedNodeId)); }
  514. static UA_INLINE void UA_ExpandedNodeId_delete(UA_ExpandedNodeId *p) { UA_delete(p, &UA_TYPES[UA_TYPES_EXPANDEDNODEID]); }
  515. static UA_INLINE void UA_ExpandedNodeId_deleteMembers(UA_ExpandedNodeId *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_EXPANDEDNODEID]); }
  516. static UA_INLINE UA_StatusCode UA_ExpandedNodeId_copy(const UA_ExpandedNodeId *src, UA_ExpandedNodeId *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_EXPANDEDNODEID]); }
  517. static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_NUMERIC(UA_UInt16 nsIndex, UA_Int32 identifier) {
  518. UA_ExpandedNodeId id;
  519. id.nodeId = UA_NODEID_NUMERIC(nsIndex, identifier);
  520. id.serverIndex = 0;
  521. id.namespaceUri = UA_STRING_NULL;
  522. return id; }
  523. static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_STRING(UA_UInt16 nsIndex, char *chars) {
  524. UA_ExpandedNodeId id;
  525. id.nodeId = UA_NODEID_STRING(nsIndex, chars);
  526. id.serverIndex = 0;
  527. id.namespaceUri = UA_STRING_NULL;
  528. return id; }
  529. static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_STRING_ALLOC(UA_UInt16 nsIndex, const char *chars) {
  530. UA_ExpandedNodeId id;
  531. id.nodeId = UA_NODEID_STRING_ALLOC(nsIndex, chars);
  532. id.serverIndex = 0;
  533. id.namespaceUri = UA_STRING_NULL;
  534. return id; }
  535. static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_STRING_GUID(UA_UInt16 nsIndex, UA_Guid guid) {
  536. UA_ExpandedNodeId id;
  537. id.nodeId = UA_NODEID_GUID(nsIndex, guid);
  538. id.serverIndex = 0;
  539. id.namespaceUri = UA_STRING_NULL;
  540. return id; }
  541. static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_BYTESTRING(UA_UInt16 nsIndex, char *chars) {
  542. UA_ExpandedNodeId id;
  543. id.nodeId = UA_NODEID_BYTESTRING(nsIndex, chars);
  544. id.serverIndex = 0;
  545. id.namespaceUri = UA_STRING_NULL;
  546. return id; }
  547. static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_BYTESTRING_ALLOC(UA_UInt16 nsIndex, const char *chars) {
  548. UA_ExpandedNodeId id;
  549. id.nodeId = UA_NODEID_BYTESTRING_ALLOC(nsIndex, chars);
  550. id.serverIndex = 0;
  551. id.namespaceUri = UA_STRING_NULL;
  552. return id; }
  553. /* StatusCode */
  554. static UA_INLINE UA_StatusCode * UA_StatusCode_new(void) { return UA_new(&UA_TYPES[UA_TYPES_STATUSCODE]); }
  555. static UA_INLINE void UA_StatusCode_init(UA_StatusCode *p) { *p = UA_STATUSCODE_GOOD; }
  556. static UA_INLINE void UA_StatusCode_delete(UA_StatusCode *p) { UA_delete(p, &UA_TYPES[UA_TYPES_STATUSCODE]); }
  557. static UA_INLINE void UA_StatusCode_deleteMembers(UA_StatusCode *p) { }
  558. static UA_INLINE UA_StatusCode UA_StatusCode_copy(const UA_StatusCode *src, UA_StatusCode *dst) {*dst = *src; return UA_STATUSCODE_GOOD; }
  559. /* QualifiedName */
  560. static UA_INLINE UA_QualifiedName * UA_QualifiedName_new(void) { return UA_new(&UA_TYPES[UA_TYPES_QUALIFIEDNAME]); }
  561. static UA_INLINE void UA_QualifiedName_init(UA_QualifiedName *p) { memset(p, 0, sizeof(UA_QualifiedName)); }
  562. static UA_INLINE void UA_QualifiedName_delete(UA_QualifiedName *p) { UA_delete(p, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]); }
  563. static UA_INLINE void UA_QualifiedName_deleteMembers(UA_QualifiedName *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]); }
  564. static UA_INLINE UA_StatusCode UA_QualifiedName_copy(const UA_QualifiedName *src, UA_QualifiedName *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]); }
  565. static UA_INLINE UA_QualifiedName UA_QUALIFIEDNAME(UA_UInt16 nsIndex, char *chars) {
  566. UA_QualifiedName qn;
  567. qn.namespaceIndex = nsIndex;
  568. qn.name = UA_STRING(chars);
  569. return qn; }
  570. static UA_INLINE UA_QualifiedName UA_QUALIFIEDNAME_ALLOC(UA_UInt16 nsIndex, const char *chars) {
  571. UA_QualifiedName qn;
  572. qn.namespaceIndex = nsIndex;
  573. qn.name = UA_STRING_ALLOC(chars);
  574. return qn; }
  575. /* LocalizedText */
  576. static UA_INLINE UA_LocalizedText * UA_LocalizedText_new(void) { return UA_new(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  577. static UA_INLINE void UA_LocalizedText_init(UA_LocalizedText *p) { memset(p, 0, sizeof(UA_LocalizedText)); }
  578. static UA_INLINE void UA_LocalizedText_delete(UA_LocalizedText *p) { UA_delete(p, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  579. static UA_INLINE void UA_LocalizedText_deleteMembers(UA_LocalizedText *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  580. static UA_INLINE UA_StatusCode UA_LocalizedText_copy(const UA_LocalizedText *src, UA_LocalizedText *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]); }
  581. static UA_INLINE UA_LocalizedText UA_LOCALIZEDTEXT(char *locale, char *text) {
  582. UA_LocalizedText lt;
  583. lt.locale = UA_STRING(locale);
  584. lt.text = UA_STRING(text);
  585. return lt; }
  586. static UA_INLINE UA_LocalizedText UA_LOCALIZEDTEXT_ALLOC(const char *locale, const char *text) {
  587. UA_LocalizedText lt;
  588. lt.locale = UA_STRING_ALLOC(locale);
  589. lt.text = UA_STRING_ALLOC(text);
  590. return lt; }
  591. /* ExtensionObject */
  592. static UA_INLINE UA_ExtensionObject * UA_ExtensionObject_new(void) { return UA_new(&UA_TYPES[UA_TYPES_EXTENSIONOBJECT]); }
  593. static UA_INLINE void UA_ExtensionObject_init(UA_ExtensionObject *p) { memset(p, 0, sizeof(UA_ExtensionObject)); }
  594. static UA_INLINE void UA_ExtensionObject_delete(UA_ExtensionObject *p) { UA_delete(p, &UA_TYPES[UA_TYPES_EXTENSIONOBJECT]); }
  595. static UA_INLINE void UA_ExtensionObject_deleteMembers(UA_ExtensionObject *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_EXTENSIONOBJECT]); }
  596. static UA_INLINE UA_StatusCode UA_ExtensionObject_copy(const UA_ExtensionObject *src, UA_ExtensionObject *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_EXTENSIONOBJECT]); }
  597. /* Variant */
  598. static UA_INLINE UA_Variant * UA_Variant_new(void) { return UA_new(&UA_TYPES[UA_TYPES_VARIANT]); }
  599. static UA_INLINE void UA_Variant_init(UA_Variant *p) { memset(p, 0, sizeof(UA_Variant)); }
  600. static UA_INLINE void UA_Variant_delete(UA_Variant *p) { UA_delete(p, &UA_TYPES[UA_TYPES_VARIANT]); }
  601. static UA_INLINE void UA_Variant_deleteMembers(UA_Variant *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_VARIANT]); }
  602. static UA_INLINE UA_StatusCode UA_Variant_copy(const UA_Variant *src, UA_Variant *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_VARIANT]); }
  603. /**
  604. * Returns true if the variant contains a scalar value. Note that empty variants contain an array of
  605. * length -1 (undefined).
  606. *
  607. * @param v The variant
  608. * @return Does the variant contain a scalar value.
  609. */
  610. static UA_INLINE UA_Boolean UA_Variant_isScalar(const UA_Variant *v) {
  611. return (v->arrayLength == 0 && v->data >= UA_EMPTY_ARRAY_SENTINEL); }
  612. /**
  613. * Set the variant to a scalar value that already resides in memory. The value takes on the
  614. * lifecycle of the variant and is deleted with it.
  615. *
  616. * @param v The variant
  617. * @param p A pointer to the value data
  618. * @param type The datatype of the value in question
  619. * @return Indicates whether the operation succeeded or returns an error code
  620. */
  621. UA_StatusCode UA_EXPORT UA_Variant_setScalar(UA_Variant *v, void * UA_RESTRICT p, const UA_DataType *type);
  622. /**
  623. * Set the variant to a scalar value that is copied from an existing variable.
  624. *
  625. * @param v The variant
  626. * @param p A pointer to the value data
  627. * @param type The datatype of the value
  628. * @return Indicates whether the operation succeeded or returns an error code
  629. */
  630. UA_StatusCode UA_EXPORT UA_Variant_setScalarCopy(UA_Variant *v, const void *p, const UA_DataType *type);
  631. /**
  632. * Set the variant to an array that already resides in memory. The array takes on the lifecycle of
  633. * the variant and is deleted with it.
  634. *
  635. * @param v The variant
  636. * @param array A pointer to the array data
  637. * @param arraySize The size of the array
  638. * @param type The datatype of the array
  639. * @return Indicates whether the operation succeeded or returns an error code
  640. */
  641. UA_StatusCode UA_EXPORT
  642. UA_Variant_setArray(UA_Variant *v, void * UA_RESTRICT array, size_t arraySize, const UA_DataType *type);
  643. /**
  644. * Set the variant to an array that is copied from an existing array.
  645. *
  646. * @param v The variant
  647. * @param array A pointer to the array data
  648. * @param arraySize The size of the array
  649. * @param type The datatype of the array
  650. * @return Indicates whether the operation succeeded or returns an error code
  651. */
  652. UA_StatusCode UA_EXPORT
  653. UA_Variant_setArrayCopy(UA_Variant *v, const void *array, size_t arraySize, const UA_DataType *type);
  654. /**
  655. * Copy the variant, but use only a subset of the (multidimensional) array into a variant. Returns
  656. * an error code if the variant is not an array or if the indicated range does not fit.
  657. *
  658. * @param src The source variant
  659. * @param dst The target variant
  660. * @param range The range of the copied data
  661. * @return Returns UA_STATUSCODE_GOOD or an error code
  662. */
  663. UA_StatusCode UA_EXPORT
  664. UA_Variant_copyRange(const UA_Variant *src, UA_Variant *dst, const UA_NumericRange range);
  665. /**
  666. * Insert a range of data into an existing variant. The data array can't be reused afterwards if it
  667. * contains types without a fixed size (e.g. strings) since the members are moved into the variant
  668. * and take on its lifecycle.
  669. *
  670. * @param v The variant
  671. * @param dataArray The data array. The type must match the variant
  672. * @param dataArraySize The length of the data array. This is checked to match the range size.
  673. * @param range The range of where the new data is inserted
  674. * @return Returns UA_STATUSCODE_GOOD or an error code
  675. */
  676. UA_StatusCode UA_EXPORT
  677. UA_Variant_setRange(UA_Variant *v, void * UA_RESTRICT array, size_t arraySize, const UA_NumericRange range);
  678. /**
  679. * Deep-copy a range of data into an existing variant.
  680. *
  681. * @param v The variant
  682. * @param dataArray The data array. The type must match the variant
  683. * @param dataArraySize The length of the data array. This is checked to match the range size.
  684. * @param range The range of where the new data is inserted
  685. * @return Returns UA_STATUSCODE_GOOD or an error code
  686. */
  687. UA_StatusCode UA_EXPORT
  688. UA_Variant_setRangeCopy(UA_Variant *v, const void *array, size_t arraySize, const UA_NumericRange range);
  689. /* DataValue */
  690. static UA_INLINE UA_DataValue * UA_DataValue_new(void) { return UA_new(&UA_TYPES[UA_TYPES_DATAVALUE]); }
  691. static UA_INLINE void UA_DataValue_init(UA_DataValue *p) { memset(p, 0, sizeof(UA_DataValue)); }
  692. static UA_INLINE void UA_DataValue_delete(UA_DataValue *p) { UA_delete(p, &UA_TYPES[UA_TYPES_DATAVALUE]); }
  693. static UA_INLINE void UA_DataValue_deleteMembers(UA_DataValue *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_DATAVALUE]); }
  694. static UA_INLINE UA_StatusCode UA_DataValue_copy(const UA_DataValue *src, UA_DataValue *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_DATAVALUE]); }
  695. /* DiagnosticInfo */
  696. static UA_INLINE UA_DiagnosticInfo * UA_DiagnosticInfo_new(void) { return UA_new(&UA_TYPES[UA_TYPES_DIAGNOSTICINFO]); }
  697. static UA_INLINE void UA_DiagnosticInfo_init(UA_DiagnosticInfo *p) { memset(p, 0, sizeof(UA_DiagnosticInfo)); }
  698. static UA_INLINE void UA_DiagnosticInfo_delete(UA_DiagnosticInfo *p) { UA_delete(p, &UA_TYPES[UA_TYPES_DIAGNOSTICINFO]); }
  699. static UA_INLINE void UA_DiagnosticInfo_deleteMembers(UA_DiagnosticInfo *p) { UA_deleteMembers(p, &UA_TYPES[UA_TYPES_DIAGNOSTICINFO]); }
  700. static UA_INLINE UA_StatusCode UA_DiagnosticInfo_copy(const UA_DiagnosticInfo *src, UA_DiagnosticInfo *dst) { return UA_copy(src, dst, &UA_TYPES[UA_TYPES_DIAGNOSTICINFO]); }
  701. /**********************/
  702. /* Node Attribute Ids */
  703. /**********************/
  704. /* These are not generated from XML. Server *and* client need them. */
  705. typedef enum {
  706. UA_ATTRIBUTEID_NODEID = 1,
  707. UA_ATTRIBUTEID_NODECLASS = 2,
  708. UA_ATTRIBUTEID_BROWSENAME = 3,
  709. UA_ATTRIBUTEID_DISPLAYNAME = 4,
  710. UA_ATTRIBUTEID_DESCRIPTION = 5,
  711. UA_ATTRIBUTEID_WRITEMASK = 6,
  712. UA_ATTRIBUTEID_USERWRITEMASK = 7,
  713. UA_ATTRIBUTEID_ISABSTRACT = 8,
  714. UA_ATTRIBUTEID_SYMMETRIC = 9,
  715. UA_ATTRIBUTEID_INVERSENAME = 10,
  716. UA_ATTRIBUTEID_CONTAINSNOLOOPS = 11,
  717. UA_ATTRIBUTEID_EVENTNOTIFIER = 12,
  718. UA_ATTRIBUTEID_VALUE = 13,
  719. UA_ATTRIBUTEID_DATATYPE = 14,
  720. UA_ATTRIBUTEID_VALUERANK = 15,
  721. UA_ATTRIBUTEID_ARRAYDIMENSIONS = 16,
  722. UA_ATTRIBUTEID_ACCESSLEVEL = 17,
  723. UA_ATTRIBUTEID_USERACCESSLEVEL = 18,
  724. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL = 19,
  725. UA_ATTRIBUTEID_HISTORIZING = 20,
  726. UA_ATTRIBUTEID_EXECUTABLE = 21,
  727. UA_ATTRIBUTEID_USEREXECUTABLE = 22
  728. } UA_AttributeId;
  729. /***************************/
  730. /* Random Number Generator */
  731. /***************************/
  732. /**
  733. * If UA_MULTITHREADING is enabled, then the seed is stored in thread local storage. The seed is
  734. * initialized for every thread in the server/client.
  735. */
  736. UA_EXPORT void UA_random_seed(UA_UInt64 seed);
  737. UA_EXPORT UA_UInt32 UA_random(void);
  738. #ifdef __cplusplus
  739. } // extern "C"
  740. #endif
  741. #endif /* UA_TYPES_H_ */