]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMUSimulator/include/FMIL/Util/FMI2/fmi2_xml_callbacks.h
Mavenized FMIL projects.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMUSimulator / include / FMIL / Util / FMI2 / fmi2_xml_callbacks.h
1 /*
2     Copyright (C) 2012 Modelon AB
3
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the BSD style license.
6
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.
11
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>.
14 */
15
16 #ifndef FMI2_XML_CALLBACKS_H
17 #define FMI2_XML_CALLBACKS_H
18
19 #include <fmilib_config.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 /** \file fmi2_xml_callbacks.h Definition of ::fmi2_xml_callbacks_t and supporting functions
25         *
26         * \addtogroup fmi2_utils
27         * @{
28                 \addtogroup fmi2_xml_callbacks
29         * @}
30 */
31 /** \addtogroup fmi2_xml_callbacks Definition of XML callbacks struct
32 * @{  */
33 typedef struct fmi2_xml_callbacks_t fmi2_xml_callbacks_t;
34
35 /** \name XML handling callbacks
36 * @{ 
37 */
38 /** \brief Handle start of an XML element within tool annotation in a SAX parser.
39 *
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).
46 */
47 typedef int (*fmi2_xml_element_start_handle_ft)(        void *context, const char *toolName, void *parent, const char *elm, const char **attr);
48
49 /** \brief Handle data of an XML element within tool annotation in a SAX parser.
50 *
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).
55 */
56 typedef int (*fmi2_xml_element_data_handle_ft)(void* context, const char *s, int len);
57
58 /** \brief Handle end of an XML element within tool annotation in a SAX parser.
59 *
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).
63 */
64 typedef int (*fmi2_xml_element_end_handle_ft)(void *context, const char *elm);
65
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. */
72 };
73 /* @}
74 */
75
76 #ifdef __cplusplus
77 }
78 #endif
79 /* JM_CONTEXT_H */
80 #endif