FlightGear next
|
#include <FGXMLElement.h>
Inherits SGReferenced.
Public Member Functions | |
Element (const std::string &nm) | |
Constructor. | |
~Element (void) | |
Destructor. | |
bool | HasAttribute (const std::string &key) |
Determines if an element has the supplied attribute. | |
std::string | GetAttributeValue (const std::string &key) |
Retrieves an attribute. | |
bool | SetAttributeValue (const std::string &key, const std::string &value) |
Modifies an attribute. | |
double | GetAttributeValueAsNumber (const std::string &key) |
Retrieves an attribute value as a double precision real number. | |
const std::string & | GetName (void) const |
Retrieves the element name. | |
void | ChangeName (const std::string &_name) |
std::string | GetDataLine (unsigned int i=0) |
Gets a line of data belonging to an element. | |
unsigned int | GetNumDataLines (void) |
Returns the number of lines of data stored. | |
unsigned int | GetNumElements (void) |
Returns the number of child elements for this element. | |
unsigned int | GetNumElements (const std::string &element_name) |
Returns the number of named child elements for this element. | |
double | GetDataAsNumber (void) |
Converts the element data to a number. | |
Element * | GetElement (unsigned int el=0) |
Returns a pointer to the element requested by index. | |
Element * | GetNextElement (void) |
Returns a pointer to the next element in the list. | |
Element * | GetParent (void) |
Returns a pointer to the parent of an element. | |
int | GetLineNumber (void) const |
Returns the line number at which the element has been defined. | |
const std::string & | GetFileName (void) const |
Returns the name of the file in which the element has been read. | |
Element * | FindElement (const std::string &el="") |
Searches for a specified element. | |
Element * | FindNextElement (const std::string &el="") |
Searches for the next element as specified. | |
std::string | FindElementValue (const std::string &el="") |
Searches for the named element and returns the string data belonging to it. | |
double | FindElementValueAsNumber (const std::string &el="") |
Searches for the named element and returns the data belonging to it as a number. | |
bool | FindElementValueAsBoolean (const std::string &el="") |
Searches for the named element and returns the data belonging to it as a bool. | |
double | FindElementValueAsNumberConvertTo (const std::string &el, const std::string &target_units) |
Searches for the named element and converts and returns the data belonging to it. | |
double | FindElementValueAsNumberConvertFromTo (const std::string &el, const std::string &supplied_units, const std::string &target_units) |
Searches for the named element and converts and returns the data belonging to it. | |
FGColumnVector3 | FindElementTripletConvertTo (const std::string &target_units) |
Composes a 3-element column vector for the supplied location or orientation. | |
double | DisperseValue (Element *e, double val, const std::string &supplied_units="", const std::string &target_units="") |
void | SetParent (Element *p) |
This function sets the value of the parent class attribute to the supplied Element pointer. | |
void | AddChildElement (Element *el) |
Adds a child element to the list of children stored for this element. | |
void | AddAttribute (const std::string &name, const std::string &value) |
Stores an attribute belonging to this element. | |
void | AddData (std::string d) |
Stores data belonging to this element. | |
void | Print (unsigned int level=0) |
Prints the element. | |
void | SetLineNumber (int line) |
Set the line number at which the element has been read. | |
void | SetFileName (const std::string &name) |
Set the name of the file in which the element has been read. | |
std::string | ReadFrom (void) const |
Return a string that contains a description of the location where the current XML element was read from. | |
void | MergeAttributes (Element *el) |
Merges the attributes of the current element with another element. | |
Definition at line 143 of file FGXMLElement.h.
JSBSim::Element::Element | ( | const std::string & | nm | ) |
Constructor.
nm | the name of this element (if given) |
Definition at line 51 of file FGXMLElement.cpp.
JSBSim::Element::~Element | ( | void | ) |
Destructor.
Definition at line 252 of file FGXMLElement.cpp.
void JSBSim::Element::AddAttribute | ( | const std::string & | name, |
const std::string & | value ) |
Stores an attribute belonging to this element.
Definition at line 720 of file FGXMLElement.cpp.
|
inline |
Adds a child element to the list of children stored for this element.
el | Child element to add. |
Definition at line 345 of file FGXMLElement.h.
void JSBSim::Element::AddData | ( | std::string | d | ) |
Stores data belonging to this element.
d | the data to store. |
Definition at line 727 of file FGXMLElement.cpp.
|
inline |
Definition at line 180 of file FGXMLElement.h.
double JSBSim::Element::DisperseValue | ( | Element * | e, |
double | val, | ||
const std::string & | supplied_units = "", | ||
const std::string & | target_units = "" ) |
Definition at line 649 of file FGXMLElement.cpp.
Element * JSBSim::Element::FindElement | ( | const std::string & | el = "" | ) |
Searches for a specified element.
Finds the first element that matches the supplied string, or simply the first element if no search string is supplied. This function call resets the internal element counter to the first element.
el | the search string (empty string by default). |
Definition at line 389 of file FGXMLElement.cpp.
FGColumnVector3 JSBSim::Element::FindElementTripletConvertTo | ( | const std::string & | target_units | ) |
Composes a 3-element column vector for the supplied location or orientation.
This function processes a LOCATION or ORIENTATION construct, returning a filled-out 3-element column vector containing the X, Y, Z or ROLL, PITCH, YAW elements found in the supplied element. If one of the mentioned components is not found, that component is set to zero and a warning message is printed. All three elements should be supplied.
target_units | the string representing the native units used by JSBSim to which the value returned will be converted. |
Definition at line 589 of file FGXMLElement.cpp.
string JSBSim::Element::FindElementValue | ( | const std::string & | el = "" | ) |
Searches for the named element and returns the string data belonging to it.
This function allows the data belonging to a named element to be returned as a string. If no element is found, the empty string is returned. If no argument is supplied, the data string for the first element is returned.
el | the name of the element being searched for (the empty string by default) |
Definition at line 468 of file FGXMLElement.cpp.
bool JSBSim::Element::FindElementValueAsBoolean | ( | const std::string & | el = "" | ) |
Searches for the named element and returns the data belonging to it as a bool.
This function allows the data belonging to a named element to be returned as a bool. If no element is found, false is returned. If no argument is supplied, the data for the first element is returned.
el | the name of the element being searched for (the empty string by default) |
Definition at line 446 of file FGXMLElement.cpp.
double JSBSim::Element::FindElementValueAsNumber | ( | const std::string & | el = "" | ) |
Searches for the named element and returns the data belonging to it as a number.
This function allows the data belonging to a named element to be returned as a double. If no element is found, HUGE_VAL is returned. If no argument is supplied, the data for the first element is returned.
el | the name of the element being searched for (the empty string by default) |
Definition at line 429 of file FGXMLElement.cpp.
double JSBSim::Element::FindElementValueAsNumberConvertFromTo | ( | const std::string & | el, |
const std::string & | supplied_units, | ||
const std::string & | target_units ) |
Searches for the named element and converts and returns the data belonging to it.
This function allows the data belonging to a named element to be returned as a double. If no element is found, HUGE_VAL is returned. If no argument is supplied, the data for the first element is returned. Additionally, this function converts the value from the units specified in the supplied_units parameter to the units specified in the target_units parameter. JSBSim itself, as specified by the target_units parameter. The currently allowable unit conversions are seen in the source file FGXMLElement.cpp. Also, see above in the main documentation for this class.
el | the name of the element being searched for (the empty string by default) |
supplied_units | the string representing the units of the value as supplied by the config file. |
target_units | the string representing the native units used by JSBSim to which the value returned will be converted. |
Definition at line 547 of file FGXMLElement.cpp.
double JSBSim::Element::FindElementValueAsNumberConvertTo | ( | const std::string & | el, |
const std::string & | target_units ) |
Searches for the named element and converts and returns the data belonging to it.
This function allows the data belonging to a named element to be returned as a double. If no element is found, HUGE_VAL is returned. If no argument is supplied, the data for the first element is returned. Additionally, this function converts the value from the units specified in the config file (via the UNITS="" attribute in the element definition) to the native units used by JSBSim itself, as specified by the target_units parameter. The currently allowable unit conversions are seen in the source file FGXMLElement.cpp. Also, see above in the main documentation for this class.
el | the name of the element being searched for (the empty string by default) |
target_units | the string representing the native units used by JSBSim to which the value returned will be converted. |
Definition at line 480 of file FGXMLElement.cpp.
Element * JSBSim::Element::FindNextElement | ( | const std::string & | el = "" | ) |
Searches for the next element as specified.
This function would be called after FindElement() is first called (in order to reset the internal counter). If no argument is supplied (or the empty string) a pointer to the very next element is returned. Otherwise, the next occurence of the named element is returned. If the end of the list is reached, 0 is returned.
el | the name of the next element to find. |
Definition at line 407 of file FGXMLElement.cpp.
string JSBSim::Element::GetAttributeValue | ( | const std::string & | key | ) |
Retrieves an attribute.
key | specifies the attribute key to retrieve the value of. |
Definition at line 260 of file FGXMLElement.cpp.
double JSBSim::Element::GetAttributeValueAsNumber | ( | const std::string & | key | ) |
Retrieves an attribute value as a double precision real number.
key | specifies the attribute key to retrieve the value of. |
Definition at line 279 of file FGXMLElement.cpp.
double JSBSim::Element::GetDataAsNumber | ( | void | ) |
Converts the element data to a number.
This function attempts to convert the first (and presumably only) line of data "owned" by the element into a real number. If there is not exactly one line of data owned by the element, then HUGE_VAL is returned.
Definition at line 341 of file FGXMLElement.cpp.
string JSBSim::Element::GetDataLine | ( | unsigned int | i = 0 | ) |
Gets a line of data belonging to an element.
i | the index of the data line to return (0 by default). |
Definition at line 333 of file FGXMLElement.cpp.
Element * JSBSim::Element::GetElement | ( | unsigned int | el = 0 | ) |
Returns a pointer to the element requested by index.
This function also resets an internal counter to the index, so that subsequent calls to GetNextElement() will return the following elements sequentially, until the last element is reached. At that point, GetNextElement() will return NULL.
el | the index of the requested element (0 by default) |
Definition at line 306 of file FGXMLElement.cpp.
|
inline |
Returns the name of the file in which the element has been read.
Definition at line 235 of file FGXMLElement.h.
|
inline |
Returns the line number at which the element has been defined.
Definition at line 230 of file FGXMLElement.h.
|
inline |
Retrieves the element name.
Definition at line 179 of file FGXMLElement.h.
Element * JSBSim::Element::GetNextElement | ( | void | ) |
Returns a pointer to the next element in the list.
The function GetElement() must be called first to be sure that this function will return the correct element. The call to GetElement() resets the internal counter to zero. Subsequent calls to GetNextElement() return a pointer to subsequent elements in the list. When the final element is reached, 0 is returned.
Definition at line 320 of file FGXMLElement.cpp.
|
inline |
Returns the number of lines of data stored.
Definition at line 189 of file FGXMLElement.h.
unsigned int JSBSim::Element::GetNumElements | ( | const std::string & | element_name | ) |
Returns the number of named child elements for this element.
|
inline |
Returns the number of child elements for this element.
Definition at line 192 of file FGXMLElement.h.
|
inline |
Returns a pointer to the parent of an element.
Definition at line 225 of file FGXMLElement.h.
|
inline |
Determines if an element has the supplied attribute.
key | specifies the attribute key to retrieve the value of. |
Definition at line 155 of file FGXMLElement.h.
void JSBSim::Element::MergeAttributes | ( | Element * | el | ) |
Merges the attributes of the current element with another element.
The attributes from the current element override the element that is passed as a parameter. In other words if the two elements have an attribute with the same name, the attribute from the current element is kept and the corresponding attribute of the other element is ignored.
el | element with which the current element will merge its attributes. |
Definition at line 751 of file FGXMLElement.cpp.
void JSBSim::Element::Print | ( | unsigned int | level = 0 | ) |
Prints the element.
Prints this element and calls the Print routine for child elements.
d | The tab level. A level corresponds to a single space. |
Definition at line 696 of file FGXMLElement.cpp.
string JSBSim::Element::ReadFrom | ( | void | ) | const |
Return a string that contains a description of the location where the current XML element was read from.
Definition at line 738 of file FGXMLElement.cpp.
bool JSBSim::Element::SetAttributeValue | ( | const std::string & | key, |
const std::string & | value ) |
Modifies an attribute.
key | specifies the attribute key to modify the value of. |
value | new key value (as a string). |
Definition at line 268 of file FGXMLElement.cpp.
|
inline |
Set the name of the file in which the element has been read.
name | file name |
Definition at line 369 of file FGXMLElement.h.
|
inline |
Set the line number at which the element has been read.
line | line number. |
Definition at line 364 of file FGXMLElement.h.
|
inline |
This function sets the value of the parent class attribute to the supplied Element pointer.
p | pointer to the parent Element. |
Definition at line 341 of file FGXMLElement.h.