123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- #ifndef UA_TYPES_H_
- #define UA_TYPES_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdint.h>
- #include <stdbool.h>
- #include <stddef.h>
- #include "ua_config.h"
- typedef bool UA_Boolean;
- #define UA_TRUE true
- #define UA_FALSE false
- typedef int8_t UA_SByte;
- #define UA_SBYTE_MAX 127
- #define UA_SBYTE_MIN -128
- typedef uint8_t UA_Byte;
- #define UA_BYTE_MAX 256
- #define UA_BYTE_MIN 0
- typedef int16_t UA_Int16;
- #define UA_INT16_MAX 32767
- #define UA_INT16_MIN -32768
- typedef uint16_t UA_UInt16;
- #define UA_UINT16_MAX 65535
- #define UA_UINT16_MIN 0
- typedef int32_t UA_Int32;
- #define UA_INT32_MAX 2147483647
- #define UA_INT32_MIN -2147483648
- typedef uint32_t UA_UInt32;
- #define UA_UINT32_MAX 4294967295
- #define UA_UINT32_MIN 0
- typedef int64_t UA_Int64;
- #define UA_INT64_MAX 9223372036854775807
- #define UA_INT64_MIN -9223372036854775808
- typedef uint64_t UA_UInt64;
- #define UA_UINT64_MAX = 18446744073709551615
- #define UA_UINT64_MIN = 0
- typedef float UA_Float;
- typedef double UA_Double;
- typedef struct {
- UA_Int32 length;
- UA_Byte *data;
- } UA_String;
- typedef UA_Int64 UA_DateTime;
- typedef struct {
- UA_UInt32 data1;
- UA_UInt16 data2;
- UA_UInt16 data3;
- UA_Byte data4[8];
- } UA_Guid;
- typedef UA_String UA_ByteString;
- typedef UA_String UA_XmlElement;
- typedef struct {
- UA_UInt16 namespaceIndex;
- enum {
- UA_NODEIDTYPE_NUMERIC = 2,
- UA_NODEIDTYPE_STRING = 3,
- UA_NODEIDTYPE_GUID = 4,
- UA_NODEIDTYPE_BYTESTRING = 5
- } identifierType;
- union {
- UA_UInt32 numeric;
- UA_String string;
- UA_Guid guid;
- UA_ByteString byteString;
- } identifier;
- } UA_NodeId;
- typedef struct {
- UA_NodeId nodeId;
- UA_String namespaceUri;
- UA_UInt32 serverIndex;
- } UA_ExpandedNodeId;
- #include "ua_statuscodes.h"
- typedef enum UA_StatusCode UA_StatusCode;
- typedef struct {
- UA_UInt16 namespaceIndex;
- UA_String name;
- } UA_QualifiedName;
- typedef struct {
- UA_String locale;
- UA_String text;
- } UA_LocalizedText;
- typedef struct {
- UA_NodeId typeId;
- enum {
- UA_EXTENSIONOBJECT_ENCODINGMASK_NOBODYISENCODED = 0,
- UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISBYTESTRING = 1,
- UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISXML = 2
- } encoding;
- UA_ByteString body;
- } UA_ExtensionObject;
- struct UA_DataType;
- typedef struct UA_DataType UA_DataType;
- typedef struct {
- const UA_DataType *type;
- enum {
- UA_VARIANT_DATA,
- UA_VARIANT_DATA_NODELETE,
- } storageType;
- UA_Int32 arrayLength;
- void *dataPtr;
- UA_Int32 arrayDimensionsSize;
- UA_Int32 *arrayDimensions;
- } UA_Variant;
- typedef struct {
- UA_Boolean hasVariant : 1;
- UA_Boolean hasStatus : 1;
- UA_Boolean hasSourceTimestamp : 1;
- UA_Boolean hasServerTimestamp : 1;
- UA_Boolean hasSourcePicoseconds : 1;
- UA_Boolean hasServerPicoseconds : 1;
- UA_Variant value;
- UA_StatusCode status;
- UA_DateTime sourceTimestamp;
- UA_Int16 sourcePicoseconds;
- UA_DateTime serverTimestamp;
- UA_Int16 serverPicoseconds;
- } UA_DataValue;
- typedef struct UA_DiagnosticInfo {
- UA_Boolean hasSymbolicId : 1;
- UA_Boolean hasNamespaceUri : 1;
- UA_Boolean hasLocalizedText : 1;
- UA_Boolean hasLocale : 1;
- UA_Boolean hasAdditionalInfo : 1;
- UA_Boolean hasInnerStatusCode : 1;
- UA_Boolean hasInnerDiagnosticInfo : 1;
- UA_Int32 symbolicId;
- UA_Int32 namespaceUri;
- UA_Int32 localizedText;
- UA_Int32 locale;
- UA_String additionalInfo;
- UA_StatusCode innerStatusCode;
- struct UA_DiagnosticInfo *innerDiagnosticInfo;
- } UA_DiagnosticInfo;
- #define UA_TYPE_HANDLING_FUNCTIONS(TYPE) \
- TYPE UA_EXPORT * TYPE##_new(void); \
- void UA_EXPORT TYPE##_init(TYPE * p); \
- void UA_EXPORT TYPE##_delete(TYPE * p); \
- void UA_EXPORT TYPE##_deleteMembers(TYPE * p); \
- UA_StatusCode UA_EXPORT TYPE##_copy(const TYPE *src, TYPE *dst);
- UA_TYPE_HANDLING_FUNCTIONS(UA_Boolean)
- UA_TYPE_HANDLING_FUNCTIONS(UA_SByte)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Byte)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Int16)
- UA_TYPE_HANDLING_FUNCTIONS(UA_UInt16)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Int32)
- UA_TYPE_HANDLING_FUNCTIONS(UA_UInt32)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Int64)
- UA_TYPE_HANDLING_FUNCTIONS(UA_UInt64)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Float)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Double)
- UA_TYPE_HANDLING_FUNCTIONS(UA_String)
- #define UA_DateTime_new UA_Int64_new
- #define UA_DateTime_init UA_Int64_init
- #define UA_DateTime_delete UA_Int64_delete
- #define UA_DateTime_deleteMembers UA_Int64_deleteMembers
- #define UA_DateTime_copy UA_Int64_copy
- UA_TYPE_HANDLING_FUNCTIONS(UA_Guid)
- #define UA_ByteString_new UA_String_new
- #define UA_ByteString_init UA_String_init
- #define UA_ByteString_delete UA_String_delete
- #define UA_ByteString_deleteMembers UA_String_deleteMembers
- #define UA_ByteString_copy UA_String_copy
- #define UA_XmlElement_new UA_String_new
- #define UA_XmlElement_init UA_String_init
- #define UA_XmlElement_delete UA_String_delete
- #define UA_XmlElement_deleteMembers UA_String_deleteMembers
- #define UA_XmlElement_copy UA_String_copy
- UA_TYPE_HANDLING_FUNCTIONS(UA_NodeId)
- UA_TYPE_HANDLING_FUNCTIONS(UA_ExpandedNodeId)
- #define UA_StatusCode_new UA_Int32_new
- #define UA_StatusCode_init UA_Int32_init
- #define UA_StatusCode_delete UA_Int32_delete
- #define UA_StatusCode_deleteMembers UA_Int32_deleteMembers
- #define UA_StatusCode_copy UA_Int32_copy
- UA_TYPE_HANDLING_FUNCTIONS(UA_QualifiedName)
- UA_TYPE_HANDLING_FUNCTIONS(UA_LocalizedText)
- UA_TYPE_HANDLING_FUNCTIONS(UA_ExtensionObject)
- UA_TYPE_HANDLING_FUNCTIONS(UA_DataValue)
- UA_TYPE_HANDLING_FUNCTIONS(UA_Variant)
- UA_TYPE_HANDLING_FUNCTIONS(UA_DiagnosticInfo)
- #ifdef __cplusplus
- #define CPP_ONLY(STR) STR
- #else
- #define CPP_ONLY(STR)
- #endif
- UA_StatusCode UA_EXPORT UA_String_copycstring(char const *src, UA_String *dst);
- UA_StatusCode UA_EXPORT UA_String_copyprintf(char const *fmt, UA_String *dst, ...);
- UA_Boolean UA_EXPORT UA_String_equal(const UA_String *string1, const UA_String *string2);
- #define UA_STRING_NULL (UA_String) {-1, (UA_Byte*)0 }
- #define UA_STRING_ASSIGN(VARIABLE, STRING) do { \
- VARIABLE.length = sizeof(STRING)-1; \
- VARIABLE.data = (UA_Byte *)STRING; } while(0)
- UA_DateTime UA_EXPORT UA_DateTime_now(void);
- typedef struct UA_DateTimeStruct {
- UA_Int16 nanoSec;
- UA_Int16 microSec;
- UA_Int16 milliSec;
- UA_Int16 sec;
- UA_Int16 min;
- UA_Int16 hour;
- UA_Int16 day;
- UA_Int16 month;
- UA_Int16 year;
- } UA_DateTimeStruct;
- UA_DateTimeStruct UA_EXPORT UA_DateTime_toStruct(UA_DateTime time);
- UA_StatusCode UA_EXPORT UA_DateTime_toString(UA_DateTime time, UA_String *timeString);
- UA_Boolean UA_EXPORT UA_Guid_equal(const UA_Guid *g1, const UA_Guid *g2);
-
- UA_Guid UA_EXPORT UA_Guid_random(UA_UInt32 *seed);
- #define UA_ByteString_equal(string1, string2) \
- UA_String_equal((const UA_String*) string1, (const UA_String*)string2)
- UA_StatusCode UA_EXPORT UA_ByteString_newMembers(UA_ByteString *p, UA_Int32 length);
- UA_Boolean UA_EXPORT UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2);
- UA_Boolean UA_EXPORT UA_NodeId_isNull(const UA_NodeId *p);
- #define UA_NODEID_ASSIGN(VARIABLE, NAMESPACE, NUMERICID) do { \
- VARIABLE.namespaceIndex = NAMESPACE; \
- VARIABLE.identifierType = CPP_ONLY(UA_NodeId::)UA_NODEIDTYPE_NUMERIC; \
- VARIABLE.identifier.numeric = NUMERICID; } while(0);
- #define UA_NODEID_STATIC(NAMESPACE, NUMERICID) (UA_NodeId) { \
- .namespaceIndex = NAMESPACE, .identifierType = UA_NODEIDTYPE_NUMERIC, \
- .identifier.numeric = NUMERICID }
- #define UA_NODEID_NULL UA_NODEID_STATIC(0,0)
- UA_Boolean UA_EXPORT UA_ExpandedNodeId_isNull(const UA_ExpandedNodeId *p);
- #define UA_EXPANDEDNODEID_STATIC(NAMESPACE, NUMERICID) (UA_ExpandedNodeId) { \
- .nodeId = {.namespaceIndex = NAMESPACE, .identifierType = UA_NODEIDTYPE_NUMERIC, \
- .identifier.numeric = NUMERICID }, \
- .serverIndex = 0, .namespaceUri = {.data = (UA_Byte*)0, .length = -1} }
-
- UA_StatusCode UA_EXPORT UA_QualifiedName_copycstring(char const *src, UA_QualifiedName *dst);
- #define UA_QUALIFIEDNAME_ASSIGN(VARIABLE, STRING) do { \
- VARIABLE.namespaceIndex = 0; \
- UA_STRING_ASSIGN(VARIABLE.name, STRING); } while(0)
- UA_StatusCode UA_EXPORT UA_LocalizedText_copycstring(char const *src, UA_LocalizedText *dst);
- UA_StatusCode UA_EXPORT UA_Variant_setValue(UA_Variant *v, void *p, const UA_DataType *type);
- UA_StatusCode UA_EXPORT UA_Variant_copySetValue(UA_Variant *v, const void *p, const UA_DataType *type);
- UA_StatusCode UA_EXPORT UA_Variant_setArray(UA_Variant *v, void *array,
- UA_Int32 noElements, const UA_DataType *type);
- UA_StatusCode UA_EXPORT UA_Variant_copySetArray(UA_Variant *v, const void *array,
- UA_Int32 noElements, const UA_DataType *type);
- #define UA_MAX_TYPE_MEMBERS 13
- #ifndef _WIN32
- # define UA_BITFIELD(SIZE) : SIZE
- #else
- # define UA_BITFIELD(SIZE)
- #endif
- typedef struct {
- UA_UInt16 memberTypeIndex UA_BITFIELD(9);
- UA_Boolean namespaceZero UA_BITFIELD(1);
- UA_Byte padding UA_BITFIELD(5);
- UA_Boolean isArray UA_BITFIELD(1);
- } UA_DataTypeMember;
-
- struct UA_DataType {
- UA_NodeId typeId;
- size_t memSize UA_BITFIELD(16);
- size_t typeIndex UA_BITFIELD(12);
- UA_Boolean namespaceZero UA_BITFIELD(1);
- UA_Boolean fixedSize UA_BITFIELD(1);
- UA_Boolean zeroCopyable UA_BITFIELD(1);
- UA_Boolean isStructure UA_BITFIELD(1);
- UA_Byte membersSize;
- UA_DataTypeMember members[UA_MAX_TYPE_MEMBERS];
- };
- void UA_EXPORT * UA_new(const UA_DataType *dataType);
- void UA_EXPORT UA_init(void *p, const UA_DataType *dataType);
- UA_StatusCode UA_EXPORT UA_copy(const void *src, void *dst, const UA_DataType *dataType);
- void UA_EXPORT UA_deleteMembers(void *p, const UA_DataType *dataType);
- void UA_EXPORT UA_delete(void *p, const UA_DataType *dataType);
- #define MAX_ARRAY_SIZE 104857600
- void UA_EXPORT * UA_Array_new(const UA_DataType *dataType, UA_Int32 noElements);
- UA_StatusCode UA_EXPORT UA_Array_copy(const void *src, void **dst, const UA_DataType *dataType, UA_Int32 noElements);
- void UA_EXPORT UA_Array_delete(void *p, const UA_DataType *dataType, UA_Int32 noElements);
- #ifdef __cplusplus
- }
- #endif
- #endif
|