![]() |
Doxygen_Assn4
4
91.204 Assignment No.4
|
#include <XMLElement.h>
Public Member Functions | |
| XMLElement () | |
| XMLElement (int line, string str) | |
| XMLElement (int line, string strElementName, string strContent) | |
| virtual | ~XMLElement () |
| ParserState | GetXMLData (int nLineNo, string strLine, string &strElementName, string &strContent, int nStartPos, int nEndPos, ParserState currentState) |
| int | ReadFiles (string strFileName) |
| int | GetLineNumber () const |
| string | getStrElement () |
| string | getStrContent () const |
| string | trim (string &str) |
| string | reverseString (string str) |
| void | addChildtoVec (XMLElement *children) |
| void | getAttribute (string strLine) |
| void | SetStrContent (string strContent) |
| void | SetVecChildren (vector< XMLElement * > vecChildren) |
| void | ShowAttributes (vector< Attributes * > vecAttr) |
| void | ShowXMLTree (XMLElement *elem, int treeLevel) |
| vector< Attributes * > | getVecAttribute () |
| vector< XMLElement * > | getVecChildren () const |
Definition at line 27 of file XMLElement.h.
| XMLElement::XMLElement | ( | ) |
Default constructor
Definition at line 30 of file XMLElement.cpp.
| XMLElement::XMLElement | ( | int | line, |
| string | str | ||
| ) |
A constructor taking two parameters to store an element
| line | is a line number of each string line |
| str | is an element of each string line |
Definition at line 33 of file XMLElement.cpp.
| XMLElement::XMLElement | ( | int | line, |
| string | strElementName, | ||
| string | strContent | ||
| ) |
A constructor taking three parameters to store an element and an content
| line | is a line number of each string line. |
| strElementName | is an element name. |
| strContent | is a content associated with the strLElement if there is one between the opening tag and closing tag of the XML file. |
Definition at line 38 of file XMLElement.cpp.
|
virtual |
Default destructor
Definition at line 495 of file XMLElement.cpp.
| void XMLElement::addChildtoVec | ( | XMLElement * | children | ) |
Add an element to children vector. This function push_back the element to the children vector
| children | is a child element to add |
Definition at line 475 of file XMLElement.cpp.
| void XMLElement::getAttribute | ( | string | strLine | ) |
This function is to get attributes in a strLine by searching for an equal sign in each line. If an equal sign is found, take elements on the left as the key and elements on the right which is between the double quot as value. Then store it into a vector of an attribute.
| strLine |
Definition at line 335 of file XMLElement.cpp.
| int XMLElement::GetLineNumber | ( | ) | const |
Get a line number from each line of the XML File.
Definition at line 467 of file XMLElement.cpp.
| string XMLElement::getStrContent | ( | ) | const |
Get a string content.
Definition at line 471 of file XMLElement.cpp.
| string XMLElement::getStrElement | ( | ) |
Get a string element.
Definition at line 44 of file XMLElement.cpp.
| vector< Attributes * > XMLElement::getVecAttribute | ( | ) |
Get the vector of attributes.
Definition at line 487 of file XMLElement.cpp.
| vector< XMLElement * > XMLElement::getVecChildren | ( | ) | const |
Get the vector of children.
Definition at line 491 of file XMLElement.cpp.
| ParserState XMLElement::GetXMLData | ( | int | nLineNo, |
| string | strLine, | ||
| string & | strElementName, | ||
| string & | strContent, | ||
| int | nStartPos, | ||
| int | nEndPos, | ||
| ParserState | currentState | ||
| ) |
This function parses a line read from the XML file and returns the appropriate data for that line. N.B. Assumptions: (1) The XML file being processed must be well-formed. (2) There is at most one complete element per line. (3) All element opening tags start on new lines. (4) The element closing tag, if present, is the last thing on a line. (5) If there is no element closing tag on the same line as an element opening tag, there is no content on that line. (6) Attributes and their values are ignored.
| strLine | line read from XML file |
| strElementName | name of element found |
| strContent | content of an element |
| nStartPos | position at which to start search |
| nEndPos | position at which search ended |
| currentState | state of parser on entry into this function |
Definition at line 144 of file XMLElement.cpp.
| int XMLElement::ReadFiles | ( | string | strFileName | ) |
This function reads the file passed to it as a parameter.
| strFileName | name of file to read |
Definition at line 98 of file XMLElement.cpp.
| string XMLElement::reverseString | ( | string | str | ) |
ReverseString function is to reverse string elements and this is used for reversing strContent after backwardly stored This code was token from the cplusplus web-site http://www.cplusplus.com/forum/beginner/68197/
| str | is an argument of the string content that has stored backwardly |
Definition at line 399 of file XMLElement.cpp.
| void XMLElement::SetStrContent | ( | string | strContent | ) |
Set the string content
| strContent | is the content to set, read from the XML file |
Definition at line 479 of file XMLElement.cpp.
| void XMLElement::SetVecChildren | ( | vector< XMLElement * > | vecChildren | ) |
| void XMLElement::ShowAttributes | ( | vector< Attributes * > | vecAttr | ) |
This function takes the vector Attribute and print out all the attributes that been stored
| vecAttr | is the attribute vector |
Definition at line 450 of file XMLElement.cpp.
| void XMLElement::ShowXMLTree | ( | XMLElement * | elem, |
| int | treeLevel | ||
| ) |
In this function, I have used Prof. Jesse Heines's code and modified couple things to make this function works the way it should be.
This function prints the XML tree as required by Assignment No. 4. It is called recursively when a child Element itself has children.
| elem | the current Element to process |
| treeLevel | the indentation level |
Definition at line 416 of file XMLElement.cpp.
| string XMLElement::trim | ( | string & | str | ) |
Trim leading and trailing white space (spaces and tabs) from the string passed as an argument and return the trimmed string.
| str | string to trim |
Definition at line 48 of file XMLElement.cpp.
1.8.10