JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGXMLParse Class Reference

Detailed Description

Encapsulates an XML parser based on the EasyXML parser from the SimGear library.

Author
Jon S. Berndt

Definition at line 67 of file FGXMLParse.h.

#include <FGXMLParse.h>

+ Inheritance diagram for FGXMLParse:
+ Collaboration diagram for FGXMLParse:

Public Member Functions

void data (const char *s, int length) override
 
void endElement (const char *name) override
 
ElementGetDocument (void)
 
void reset (void)
 
void startElement (const char *name, const XMLAttributes &atts) override
 
void warning (const char *message, int line, int column) override
 

Constructor & Destructor Documentation

◆ FGXMLParse()

FGXMLParse ( void  )
inline

Definition at line 70 of file FGXMLParse.h.

70: current_element(nullptr) {}

Member Function Documentation

◆ data()

void data ( const char *  s,
int  length 
)
override

Definition at line 104 of file FGXMLParse.cpp.

105{
106 working_string += string(s, length);
107}

◆ endElement()

void endElement ( const char *  name)
override

Definition at line 96 of file FGXMLParse.cpp.

97{
98 dumpDataLines();
99 current_element = current_element->GetParent();
100}
Element * GetParent(void)
Returns a pointer to the parent of an element.

◆ GetDocument()

Element * GetDocument ( void  )
inline

Definition at line 72 of file FGXMLParse.h.

72{return document;}

◆ reset()

void reset ( void  )

Definition at line 44 of file FGXMLParse.cpp.

45{
46 current_element = document = nullptr;
47 working_string.erase();
48}

◆ startElement()

void startElement ( const char *  name,
const XMLAttributes &  atts 
)
override

Definition at line 63 of file FGXMLParse.cpp.

64{
65 if (!document) {
66 document = new Element(name);
67 current_element = document;
68 } else {
69 dumpDataLines();
70
71 Element* temp_element = new Element(name);
72 if (temp_element) {
73 temp_element->SetParent(current_element);
74 current_element->AddChildElement(temp_element);
75 }
76 current_element = temp_element;
77 }
78
79 if (!current_element) {
80 LogException err;
81 err << "In file " << getPath() << ": line " << getLine() << "\n"
82 << "No current element read (running out of memory?)\n";
83 throw err;
84 }
85
86 current_element->SetLineNumber(getLine());
87 current_element->SetFileName(getPath());
88
89 for (int i=0; i<atts.size();i++) {
90 current_element->AddAttribute(atts.getName(i), atts.getValue(i));
91 }
92}
void SetFileName(const std::string &name)
Set the name of the file in which the element has been read.
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.

◆ warning()

void warning ( const char *  message,
int  line,
int  column 
)
override

Definition at line 111 of file FGXMLParse.cpp.

112{
113 FGLogging log(LogLevel::WARN);
114 log << "Warning: " << message << " line: " << line << " column: " << column
115 << "\n";
116}

The documentation for this class was generated from the following files: