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>.
18 #include "fmi2_xml_parser.h"
19 #include "fmi2_xml_model_description_impl.h"
21 static const char* module = "FMI2XML";
24 int fmi2_xml_handle_VendorAnnotations(fmi2_xml_parser_context_t *context, const char* data) {
26 jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations");
29 /* might give out a warning if(data[0] != 0) */
34 int fmi2_xml_handle_Annotations(fmi2_xml_parser_context_t *context, const char* data) {
36 jm_log_verbose(context->callbacks, module, "Parsing XML element Annotations");
39 /* might give out a warning if(data[0] != 0) */
44 int fmi2_xml_handle_VariableTool(fmi2_xml_parser_context_t *context, const char* data) {
47 fmi2_xml_model_description_t* md = context->modelDescription;
48 jm_vector(char)* bufName = fmi2_xml_reserve_parse_buffer(context,1,100);
52 if(!bufName) return -1;
53 /* <xs:attribute name="name" type="xs:normalizedString" use="required"> */
54 if( fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Tool, fmi_attr_id_name, 1, bufName))
56 pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor);
57 len = jm_vector_get_size(char)(bufName);
59 *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1));
60 if(!pvendor || !vendor) {
61 fmi2_xml_parse_fatal(context, "Could not allocate memory");
64 memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len);
67 context->anyToolName = vendor;
68 context->anyParent = jm_vector_get_last(jm_named_ptr)(&md->variablesByName).ptr;
69 context->useAnyHandleFlg = 1;
72 /* don't do anything. might give out a warning if(data[0] != 0) */
73 context->useAnyHandleFlg = 0;
79 int fmi2_xml_handle_Tool(fmi2_xml_parser_context_t *context, const char* data) {
82 fmi2_xml_model_description_t* md = context->modelDescription;
83 jm_vector(char)* bufName = fmi2_xml_reserve_parse_buffer(context,1,100);
87 if(!bufName) return -1;
88 /* <xs:attribute name="name" type="xs:normalizedString" use="required"> */
89 if( fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Tool, fmi_attr_id_name, 1, bufName))
91 pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor);
92 len = jm_vector_get_size(char)(bufName);
94 *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1));
95 if(!pvendor || !vendor) {
96 fmi2_xml_parse_fatal(context, "Could not allocate memory");
99 memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len);
102 context->anyToolName = vendor;
103 context->anyParent = 0;
104 context->useAnyHandleFlg = 1;
107 /* don't do anything. might give out a warning if(data[0] != 0) */
108 context->useAnyHandleFlg = 0;