32#include "FGXMLParse.h"
33#include "input_output/string_utilities.h"
34#include "input_output/FGLog.h"
44void FGXMLParse::reset(
void)
46 current_element = document =
nullptr;
47 working_string.erase();
52void FGXMLParse::dumpDataLines(
void)
54 if (!working_string.empty()) {
55 for (
auto s: split(working_string,
'\n'))
56 current_element->AddData(s);
58 working_string.erase();
63void FGXMLParse::startElement (
const char * name,
const XMLAttributes &atts)
66 document =
new Element(name);
67 current_element = document;
71 Element* temp_element =
new Element(name);
73 temp_element->SetParent(current_element);
76 current_element = temp_element;
79 if (!current_element) {
81 err <<
"In file " << getPath() <<
": line " << getLine() <<
"\n"
82 <<
"No current element read (running out of memory?)\n";
89 for (
int i=0; i<atts.size();i++) {
90 current_element->
AddAttribute(atts.getName(i), atts.getValue(i));
96void FGXMLParse::endElement (
const char * name)
99 current_element = current_element->
GetParent();
104void FGXMLParse::data (
const char * s,
int length)
106 working_string += string(s, length);
111void FGXMLParse::warning (
const char * message,
int line,
int column)
113 FGLogging log(LogLevel::WARN);
114 log <<
"Warning: " << message <<
" line: " << line <<
" column: " << column
void SetFileName(const std::string &name)
Set the name of the file in which the element has been read.
Element * GetParent(void)
Returns a pointer to the parent of an element.
void AddAttribute(const std::string &name, const std::string &value)
Stores an attribute belonging to this element.
void SetLineNumber(int line)
Set the line number at which the element has been read.
void AddChildElement(Element *el)
Adds a child element to the list of children stored for this element.
Main namespace for the JSBSim Flight Dynamics Model.