123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /*
- * ua_xml.h
- *
- * Created on: 03.05.2014
- * Author: mrt
- */
- #ifndef __UA_XML_H__
- #define __UA_XML_H__
- #include <expat.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h> // strlen
- #include <ctype.h> // isspace
- #include <unistd.h> // read
- #include "opcua.h"
- #include "ua_namespace.h"
- UA_Int32 UA_Boolean_copycstring(cstring src, UA_Boolean* dst);
- UA_Int32 UA_Int16_copycstring(cstring src, UA_Int16* dst);
- UA_Int32 UA_UInt16_copycstring(cstring src, UA_UInt16* dst) ;
- UA_Boolean UA_NodeId_isBuiltinType(UA_NodeId* nodeid);
- void print_node(UA_Node const * node);
- /** @brief an object to hold a typed array */
- typedef struct UA_TypedArray {
- UA_Int32 size;
- UA_VTable* vt;
- void** elements;
- } UA_TypedArray;
- /** @brief init typed array with size=-1 and an UA_INVALIDTYPE */
- UA_Int32 UA_TypedArray_init(UA_TypedArray* p);
- /** @brief allocate memory for the array header only */
- UA_Int32 UA_TypedArray_new(UA_TypedArray** p);
- UA_Int32 UA_TypedArray_setType(UA_TypedArray* p, UA_Int32 type);
- UA_Int32 UA_TypedArray_decodeXML(XML_Stack* s, XML_Attr* attr, UA_TypedArray* dst, _Bool isStart);
- UA_Int32 UA_NodeSetAlias_init(UA_NodeSetAlias* p);
- UA_Int32 UA_NodeSetAlias_new(UA_NodeSetAlias** p);
- UA_Int32 UA_NodeSetAlias_decodeXML(XML_Stack* s, XML_Attr* attr, UA_NodeSetAlias* dst, _Bool isStart);
- UA_Int32 UA_NodeSetAliases_init(UA_NodeSetAliases* p);
- UA_Int32 UA_NodeSetAliases_new(UA_NodeSetAliases** p);
- UA_Int32 UA_NodeSetAliases_println(cstring label, UA_NodeSetAliases *p);
- UA_Int32 UA_NodeSetAliases_decodeXML(XML_Stack* s, XML_Attr* attr, UA_NodeSetAliases* dst, _Bool isStart);
- typedef struct UA_NodeSet {
- Namespace* ns;
- UA_NodeSetAliases aliases;
- } UA_NodeSet;
- /** @brief init typed array with size=-1 and an UA_INVALIDTYPE */
- UA_Int32 UA_NodeSet_init(UA_NodeSet* p, UA_UInt32 nsid);
- UA_Int32 UA_NodeSet_new(UA_NodeSet** p, UA_UInt32 nsid);
- UA_Int32 UA_NodeId_copycstring(cstring src, UA_NodeId* dst, UA_NodeSetAliases* aliases);
- UA_Int32 UA_NodeSet_decodeXML(XML_Stack* s, XML_Attr* attr, UA_NodeSet* dst, _Bool isStart);
- UA_Int32 UA_ExpandedNodeId_copycstring(cstring src, UA_ExpandedNodeId* dst, UA_NodeSetAliases* aliases);
- void XML_Stack_init(XML_Stack* p, cstring name);
- void XML_Stack_print(XML_Stack* s);
- /** @brief add a reference to a handler (@see XML_Stack_addChildHandler) for text data
- *
- * Assume a XML structure such as
- * <LocalizedText>
- * <Locale></Locale>
- * <Text>Server</Text>
- * </LocalizedText>
- * which might be abbreviated as
- * <LocalizedText>Server</LocalizedText>
- *
- * We would add two (@ref XML_Stack_addChildHandler), one for Locale (index 0) and one for Text (index 1),
- * both to be handled by (@ref UA_String_decodeXML) with elements "Data" and "Length". To handle the
- * abbreviation we add
- * XML_Stack_handleTextAsElementOf(s,"Data",1)
- *
- * @param[in] s the stack
- * @param[in] textAttrib the name of the element of the handler at position textAttribIdx
- * @param[in] textAttribIdx the index of the handler
- */
- void XML_Stack_handleTextAsElementOf(XML_Stack* p, cstring textAttrib, unsigned int textAttribIdx);
- /** @brief make a handler known to the XML-stack on the current level
- *
- * The current level is given by s->depth, the maximum number of children is a predefined constant.
- * A combination of type=UA_INVALIDTYPE and dst=UA_NULL is valid for special handlers only
- *
- * @param[in] s the stack
- * @param[in] name the name of the element
- * @param[in] nameLength the length of the element name
- * @param[in] handler the decoder routine for this element
- * @param[in] type the open62541-type of the element, UA_INVALIDTYPE if not in the VTable
- * @param[out] dst the address of the object for the data, handlers will allocate object if UA_NULL
- */
- void XML_Stack_addChildHandler(XML_Stack* p, cstring name, UA_Int32 nameLength, XML_decoder handler, UA_Int32 type, void* dst);
- void XML_Stack_startElement(void * data, const char *el, const char **attr);
- UA_Int32 XML_isSpace(cstring s, int len);
- void XML_Stack_handleText(void * data, const char *txt, int len);
- void XML_Stack_endElement(void *data, const char *el);
- #endif // __UA_XML_H__
|