2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 FMILIB_License.txt file for more details.
12 You should have received a copy of the FMILIB_License.txt file
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
16 #ifndef FMI2_XML_CALLBACKS_H
17 #define FMI2_XML_CALLBACKS_H
19 #include <fmilib_config.h>
24 /** \file fmi2_xml_callbacks.h Definition of ::fmi2_xml_callbacks_t and supporting functions
26 * \addtogroup fmi2_utils
28 \addtogroup fmi2_xml_callbacks
31 /** \addtogroup fmi2_xml_callbacks Definition of XML callbacks struct
33 typedef struct fmi2_xml_callbacks_t fmi2_xml_callbacks_t;
35 /** \name XML handling callbacks
38 /** \brief Handle start of an XML element within tool annotation in a SAX parser.
40 * @param context as specified when setting up the callbacks,
41 * @param parentName - tool name as given by name attibute to the Tool elelent,
42 * @param parent - NULL for model level annotations; fmi2_import_variable_t * variable pointer for variable annotations.
43 * @param elm - name of the element,
44 * @param attr - attributes (names and values).
45 * The function should return 0 on success or error code on exit (in which case parsing will be aborted).
47 typedef int (*fmi2_xml_element_start_handle_ft)( void *context, const char *toolName, void *parent, const char *elm, const char **attr);
49 /** \brief Handle data of an XML element within tool annotation in a SAX parser.
51 * @param context as specified when setting up the callbacks
52 * @param s - data string
53 * @param len - length of the data.
54 * The function should return 0 on success or error code on exit (in which case parsing will be aborted).
56 typedef int (*fmi2_xml_element_data_handle_ft)(void* context, const char *s, int len);
58 /** \brief Handle end of an XML element within tool annotation in a SAX parser.
60 * @param context as specified when setting up the callbacks
61 * @param elm - name of the element.
62 * The function should return 0 on success or error code on exit (in which case parsing will be aborted).
64 typedef int (*fmi2_xml_element_end_handle_ft)(void *context, const char *elm);
66 /** \brief XML callbacks are used to process parts of XML that are not handled by the library */
67 struct fmi2_xml_callbacks_t {
68 fmi2_xml_element_start_handle_ft startHandle; /** \brief Handle start of an XML element within tool annotation in a SAX parser. */
69 fmi2_xml_element_data_handle_ft dataHandle; /** \brief Handle data of an XML element within tool annotation in a SAX parser. */
70 fmi2_xml_element_end_handle_ft endHandle; /** \brief Handle end of an XML element within tool annotation in a SAX parser. */
71 void* context; /** \breif Context ponter is forwarded to the handle functions. */