]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/input_output/FGXMLElement.cpp
Improve timing statistics
[flightgear.git] / src / FDM / JSBSim / input_output / FGXMLElement.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Author:       Jon Berndt
4  Date started: 09/28/2004
5  Purpose:      XML element class
6  Called by:    FGXMLParse
7
8  ------------- Copyright (C) 2001  Jon S. Berndt (jon@jsbsim.org) -------------
9
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
18  details.
19
20  You should have received a copy of the GNU Lesser General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU Lesser General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 INCLUDES
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
30
31 #include "FGXMLElement.h"
32
33 #include <cmath>
34 #include <cstdlib>
35 #include <iostream>
36
37 using namespace std;
38
39 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 FORWARD DECLARATIONS
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 namespace JSBSim {
44
45 static const char *IdSrc = "$Id: FGXMLElement.cpp,v 1.31 2010/09/29 02:22:03 jberndt Exp $";
46 static const char *IdHdr = ID_XMLELEMENT;
47
48 bool Element::converterIsInitialized = false;
49 map <string, map <string, double> > Element::convert;
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 CLASS IMPLEMENTATION
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 Element::Element(const string& nm)
56 {
57   name   = nm;
58   parent = 0L;
59   element_index = 0;
60
61   if (!converterIsInitialized) {
62     converterIsInitialized = true;
63     // convert ["from"]["to"] = factor, so: from * factor = to
64     // Length
65     convert["M"]["FT"] = 3.2808399;
66     convert["FT"]["M"] = 1.0/convert["M"]["FT"];
67     convert["FT"]["IN"] = 12.0;
68     convert["IN"]["FT"] = 1.0/convert["FT"]["IN"];
69     convert["IN"]["M"] = convert["IN"]["FT"] * convert["FT"]["M"];
70     convert["M"]["IN"] = convert["M"]["FT"] * convert["FT"]["IN"];
71     // Area
72     convert["M2"]["FT2"] = convert["M"]["FT"]*convert["M"]["FT"];
73     convert["FT2"]["M2"] = 1.0/convert["M2"]["FT2"];
74     convert["M2"]["IN2"] = convert["M"]["IN"]*convert["M"]["IN"];
75     convert["IN2"]["M2"] = 1.0/convert["M2"]["IN2"];
76     convert["FT2"]["IN2"] = 144.0;
77     convert["IN2"]["FT2"] = 1.0/convert["FT2"]["IN2"];
78     // Volume
79     convert["IN3"]["CC"] = 16.387064;
80     convert["CC"]["IN3"] = 1.0/convert["IN3"]["CC"];
81     convert["FT3"]["IN3"] = 1728.0;
82     convert["IN3"]["FT3"] = 1.0/convert["FT3"]["IN3"];
83     convert["M3"]["FT3"] = 35.3146667;
84     convert["FT3"]["M3"] = 1.0/convert["M3"]["FT3"];
85     convert["LTR"]["IN3"] = 61.0237441;
86     convert["IN3"]["LTR"] = 1.0/convert["LTR"]["IN3"];
87     // Mass & Weight
88     convert["LBS"]["KG"] = 0.45359237;
89     convert["KG"]["LBS"] = 1.0/convert["LBS"]["KG"];
90     convert["SLUG"]["KG"] = 14.59390;
91     convert["KG"]["SLUG"] = 1.0/convert["SLUG"]["KG"];
92     // Moments of Inertia
93     convert["SLUG*FT2"]["KG*M2"] = 1.35594;
94     convert["KG*M2"]["SLUG*FT2"] = 1.0/convert["SLUG*FT2"]["KG*M2"];
95     // Angles
96     convert["RAD"]["DEG"] = 180.0/M_PI;
97     convert["DEG"]["RAD"] = 1.0/convert["RAD"]["DEG"];
98     // Angular rates
99     convert["RAD/SEC"]["DEG/SEC"] = convert["RAD"]["DEG"];
100     convert["DEG/SEC"]["RAD/SEC"] = 1.0/convert["RAD/SEC"]["DEG/SEC"];
101     // Spring force
102     convert["LBS/FT"]["N/M"] = 14.5939;
103     convert["N/M"]["LBS/FT"] = 1.0/convert["LBS/FT"]["N/M"];
104     // Damping force
105     convert["LBS/FT/SEC"]["N/M/SEC"] = 14.5939;
106     convert["N/M/SEC"]["LBS/FT/SEC"] = 1.0/convert["LBS/FT/SEC"]["N/M/SEC"];
107     // Damping force (Square Law)
108     convert["LBS/FT2/SEC2"]["N/M2/SEC2"] = 47.880259;
109     convert["N/M2/SEC2"]["LBS/FT2/SEC2"] = 1.0/convert["LBS/FT2/SEC2"]["N/M2/SEC2"];
110     // Power
111     convert["WATTS"]["HP"] = 0.001341022;
112     convert["HP"]["WATTS"] = 1.0/convert["WATTS"]["HP"];
113     // Force
114     convert["N"]["LBS"] = 0.22482;
115     convert["LBS"]["N"] = 1.0/convert["N"]["LBS"];
116     // Velocity
117     convert["KTS"]["FT/SEC"] = 1.68781;
118     convert["FT/SEC"]["KTS"] = 1.0/convert["KTS"]["FT/SEC"];
119     convert["M/S"]["FT/S"] = 3.2808399;
120     convert["M/SEC"]["FT/SEC"] = 3.2808399;
121     convert["FT/S"]["M/S"] = 1.0/convert["M/S"]["FT/S"];
122     convert["M/SEC"]["FT/SEC"] = 3.2808399;
123     convert["FT/SEC"]["M/SEC"] = 1.0/convert["M/SEC"]["FT/SEC"];
124     // Torque
125     convert["FT*LBS"]["N*M"] = 1.35581795;
126     convert["N*M"]["FT*LBS"] = 1/convert["FT*LBS"]["N*M"];
127     // Valve
128     convert["M4*SEC/KG"]["FT4*SEC/SLUG"] = convert["M"]["FT"]*convert["M"]["FT"]*
129       convert["M"]["FT"]*convert["M"]["FT"]/convert["KG"]["SLUG"];
130     convert["FT4*SEC/SLUG"]["M4*SEC/KG"] =
131       1.0/convert["M4*SEC/KG"]["FT4*SEC/SLUG"];
132     // Pressure
133     convert["INHG"]["PSF"] = 70.7180803;
134     convert["PSF"]["INHG"] = 1.0/convert["INHG"]["PSF"];
135     convert["ATM"]["INHG"] = 29.9246899;
136     convert["INHG"]["ATM"] = 1.0/convert["ATM"]["INHG"];
137     convert["PSI"]["INHG"] = 2.03625437;
138     convert["INHG"]["PSI"] = 1.0/convert["PSI"]["INHG"];
139     convert["INHG"]["PA"] = 3386.0; // inches Mercury to pascals
140     convert["PA"]["INHG"] = 1.0/convert["INHG"]["PA"];
141     convert["LBS/FT2"]["N/M2"] = 14.5939/convert["FT"]["M"];
142     convert["N/M2"]["LBS/FT2"] = 1.0/convert["LBS/FT2"]["N/M2"];
143     convert["LBS/FT2"]["PA"] = convert["LBS/FT2"]["N/M2"];
144     convert["PA"]["LBS/FT2"] = 1.0/convert["LBS/FT2"]["PA"];
145     // Mass flow
146     convert["KG/MIN"]["LBS/MIN"] = convert["KG"]["LBS"];
147     // Fuel Consumption
148     convert["LBS/HP*HR"]["KG/KW*HR"] = 0.6083;
149     convert["KG/KW*HR"]["LBS/HP*HR"] = 1.0/convert["LBS/HP*HR"]["KG/KW*HR"];
150     // Density
151     convert["KG/L"]["LBS/GAL"] = 8.3454045;
152     convert["LBS/GAL"]["KG/L"] = 1.0/convert["KG/L"]["LBS/GAL"];
153
154     // Length
155     convert["M"]["M"] = 1.00;
156     convert["FT"]["FT"] = 1.00;
157     convert["IN"]["IN"] = 1.00;
158     // Area
159     convert["M2"]["M2"] = 1.00;
160     convert["FT2"]["FT2"] = 1.00;
161     // Volume
162     convert["IN3"]["IN3"] = 1.00;
163     convert["CC"]["CC"] = 1.0;
164     convert["M3"]["M3"] = 1.0;
165     convert["FT3"]["FT3"] = 1.0;
166     convert["LTR"]["LTR"] = 1.0;
167     // Mass & Weight
168     convert["KG"]["KG"] = 1.00;
169     convert["LBS"]["LBS"] = 1.00;
170     // Moments of Inertia
171     convert["KG*M2"]["KG*M2"] = 1.00;
172     convert["SLUG*FT2"]["SLUG*FT2"] = 1.00;
173     // Angles
174     convert["DEG"]["DEG"] = 1.00;
175     convert["RAD"]["RAD"] = 1.00;
176     // Angular rates
177     convert["DEG/SEC"]["DEG/SEC"] = 1.00;
178     convert["RAD/SEC"]["RAD/SEC"] = 1.00;
179     // Spring force
180     convert["LBS/FT"]["LBS/FT"] = 1.00;
181     convert["N/M"]["N/M"] = 1.00;
182     // Damping force
183     convert["LBS/FT/SEC"]["LBS/FT/SEC"] = 1.00;
184     convert["N/M/SEC"]["N/M/SEC"] = 1.00;
185     // Damping force (Square law)
186     convert["LBS/FT2/SEC2"]["LBS/FT2/SEC2"] = 1.00;
187     convert["N/M2/SEC2"]["N/M2/SEC2"] = 1.00;
188     // Power
189     convert["HP"]["HP"] = 1.00;
190     convert["WATTS"]["WATTS"] = 1.00;
191     // Force
192     convert["N"]["N"] = 1.00;
193     // Velocity
194     convert["FT/SEC"]["FT/SEC"] = 1.00;
195     convert["KTS"]["KTS"] = 1.00;
196     convert["M/S"]["M/S"] = 1.0;
197     convert["M/SEC"]["M/SEC"] = 1.0;
198     // Torque
199     convert["FT*LBS"]["FT*LBS"] = 1.00;
200     convert["N*M"]["N*M"] = 1.00;
201     // Valve
202     convert["M4*SEC/KG"]["M4*SEC/KG"] = 1.0;
203     convert["FT4*SEC/SLUG"]["FT4*SEC/SLUG"] = 1.0;
204     // Pressure
205     convert["PSI"]["PSI"] = 1.00;
206     convert["PSF"]["PSF"] = 1.00;
207     convert["INHG"]["INHG"] = 1.00;
208     convert["ATM"]["ATM"] = 1.0;
209     convert["PA"]["PA"] = 1.0;
210     convert["N/M2"]["N/M2"] = 1.00;
211     convert["LBS/FT2"]["LBS/FT2"] = 1.00;
212     // Mass flow
213     convert["LBS/SEC"]["LBS/SEC"] = 1.00;
214     convert["KG/MIN"]["KG/MIN"] = 1.0;
215     convert["LBS/MIN"]["LBS/MIN"] = 1.0;
216     // Fuel Consumption
217     convert["LBS/HP*HR"]["LBS/HP*HR"] = 1.0;
218     convert["KG/KW*HR"]["KG/KW*HR"] = 1.0;
219     // Density
220     convert["KG/L"]["KG/L"] = 1.0;
221     convert["LBS/GAL"]["LBS/GAL"] = 1.0;
222   }
223 }
224
225 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226
227 Element::~Element(void)
228 {
229   for (unsigned int i=0; i<children.size(); i++) delete children[i];
230   data_lines.clear();
231   attributes.clear();
232   attribute_key.clear();
233 }
234
235 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236
237 string Element::GetAttributeValue(const string& attr)
238 {
239   int select=-1;
240   for (unsigned int i=0; i<attribute_key.size(); i++) {
241     if (attribute_key[i] == attr) select = i;
242   }
243   if (select < 0) return string("");
244   else return attributes[attr];
245 }
246
247 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248
249 double Element::GetAttributeValueAsNumber(const string& attr)
250 {
251   string attribute = GetAttributeValue(attr);
252
253   if (attribute.empty()) return HUGE_VAL;
254   else return (atof(attribute.c_str()));
255 }
256
257 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258
259 Element* Element::GetElement(unsigned int el)
260 {
261   if (children.size() > el) {
262     element_index = el;
263     return children[el];
264   }
265   else {
266     element_index = 0;
267     return 0L;
268   }
269 }
270
271 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272
273 Element* Element::GetNextElement(void)
274 {
275   if (children.size() > element_index+1) {
276     element_index++;
277     return children[element_index];
278   } else {
279     element_index = 0;
280     return 0L;
281   }
282 }
283
284 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285
286 string Element::GetDataLine(unsigned int i)
287 {
288   if (data_lines.size() > 0) return data_lines[i];
289   else return string("");
290 }
291
292 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293
294 double Element::GetDataAsNumber(void)
295 {
296   if (data_lines.size() == 1) {
297     return atof(data_lines[0].c_str());
298   } else if (data_lines.size() == 0) {
299     return HUGE_VAL;
300   } else {
301     cerr << "Attempting to get single data value from multiple lines in element " << name << endl;
302     return HUGE_VAL;
303   }
304 }
305
306 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307
308 unsigned int Element::GetNumElements(const string& element_name)
309 {
310   unsigned int number_of_elements=0;
311   Element* el=FindElement(element_name);
312   while (el) {
313     number_of_elements++;
314     el=FindNextElement(element_name);
315   }
316   return number_of_elements;
317 }
318
319 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320
321 Element* Element::FindElement(const string& el)
322 {
323   if (el.empty() && children.size() >= 1) {
324     element_index = 1;
325     return children[0];
326   }
327   for (unsigned int i=0; i<children.size(); i++) {
328     if (el == children[i]->GetName()) {
329       element_index = i+1;
330       return children[i];
331     }
332   }
333   element_index = 0;
334   return 0L;
335 }
336
337 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
338
339 Element* Element::FindNextElement(const string& el)
340 {
341   if (el.empty()) {
342     if (element_index < children.size()) {
343       return children[element_index++];
344     } else {
345       element_index = 0;
346       return 0L;
347     }
348   }
349   for (unsigned int i=element_index; i<children.size(); i++) {
350     if (el == children[i]->GetName()) {
351       element_index = i+1;
352       return children[i];
353     }
354   }
355   element_index = 0;
356   return 0L;
357 }
358
359 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
360
361 double Element::FindElementValueAsNumber(const string& el)
362 {
363   Element* element = FindElement(el);
364   if (element) {
365     return element->GetDataAsNumber();
366   } else {
367     cerr << "Attempting to get single data value from multiple lines" << endl;
368     return 0;
369   }
370 }
371
372 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373
374 string Element::FindElementValue(const string& el)
375 {
376   Element* element = FindElement(el);
377   if (element) {
378     return element->GetDataLine();
379   } else {
380     return "";
381   }
382 }
383
384 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
385
386 double Element::FindElementValueAsNumberConvertTo(const string& el, const string& target_units)
387 {
388   Element* element = FindElement(el);
389
390   if (!element) {
391     cerr << "Attempting to get non-existent element " << el << endl;
392     exit(0);
393   }
394
395   string supplied_units = element->GetAttributeValue("unit");
396
397   if (!supplied_units.empty()) {
398     if (convert.find(supplied_units) == convert.end()) {
399       cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
400            << " conversion in FGXMLElement.cpp." << endl;
401       exit(-1);
402     }
403     if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
404       cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
405                    << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
406       exit(-1);
407     }
408   }
409
410   double value = element->GetDataAsNumber();
411   if (!supplied_units.empty()) {
412     value *= convert[supplied_units][target_units];
413   }
414
415   return value;
416 }
417
418 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419
420 double Element::FindElementValueAsNumberConvertFromTo( const string& el,
421                                                        const string& supplied_units,
422                                                        const string& target_units)
423 {
424   Element* element = FindElement(el);
425
426   if (!element) {
427     cerr << "Attempting to get non-existent element " << el << endl;
428     exit(0);
429   }
430
431   if (!supplied_units.empty()) {
432     if (convert.find(supplied_units) == convert.end()) {
433       cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
434            << " conversion in FGXMLElement.cpp." << endl;
435       exit(-1);
436     }
437     if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
438       cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
439                    << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
440       exit(-1);
441     }
442   }
443
444   double value = element->GetDataAsNumber();
445   if (!supplied_units.empty()) {
446     value *= convert[supplied_units][target_units];
447   }
448
449   return value;
450 }
451
452 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
453
454 FGColumnVector3 Element::FindElementTripletConvertTo( const string& target_units)
455 {
456   FGColumnVector3 triplet;
457   Element* item;
458   double value=0.0;
459   string supplied_units = GetAttributeValue("unit");
460
461   if (!supplied_units.empty()) {
462     if (convert.find(supplied_units) == convert.end()) {
463       cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
464            << " conversion in FGXMLElement.cpp." << endl;
465       exit(-1);
466     }
467     if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
468       cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
469                    << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
470       exit(-1);
471     }
472   }
473
474   item = FindElement("x");
475   if (!item) item = FindElement("roll");
476   if (item) {
477     value = item->GetDataAsNumber();
478     if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
479   } else {
480     value = 0.0;
481   }
482   triplet(1) = value;
483
484   item = FindElement("y");
485   if (!item) item = FindElement("pitch");
486   if (item) {
487     value = item->GetDataAsNumber();
488     if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
489   } else {
490     value = 0.0;
491   }
492   triplet(2) = value;
493
494   item = FindElement("z");
495   if (!item) item = FindElement("yaw");
496   if (item) {
497     value = item->GetDataAsNumber();
498     if (!supplied_units.empty()) value *= convert[supplied_units][target_units];
499   } else {
500     value = 0.0;
501   }
502   triplet(3) = value;
503
504   return triplet;
505 }
506
507 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
508
509 void Element::Print(unsigned int level)
510 {
511   unsigned int i, spaces;
512
513   level+=2;
514   for (spaces=0; spaces<=level; spaces++) cout << " "; // format output
515   cout << "Element Name: " << name;
516   for (i=0; i<attributes.size(); i++) {
517     cout << "  " << attribute_key[i] << " = " << attributes[attribute_key[i]];
518   }
519   cout << endl;
520   for (i=0; i<data_lines.size(); i++) {
521     for (spaces=0; spaces<=level; spaces++) cout << " "; // format output
522     cout << data_lines[i] << endl;
523   }
524   for (i=0; i<children.size(); i++) {
525     children[i]->Print(level);
526   }
527 }
528
529 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530
531 void Element::AddAttribute(const string& name, const string& value)
532 {
533   attribute_key.push_back(name);
534   attributes[name] = value;
535 }
536
537 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
538
539 void Element::AddData(string d)
540 {
541   string::size_type string_start = d.find_first_not_of(" \t");
542   if (string_start != string::npos && string_start > 0) {
543     d.erase(0,string_start);
544   }
545   data_lines.push_back(d);
546 }
547
548 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549
550 } // end namespace JSBSim