|
Computing 4 Assignment 5 - David Lordan
|
#include <Element.h>
Public Member Functions | |
| Element () | |
| Element (const Element &orig) | |
| virtual | ~Element () |
| Element (string strElementName, int nLineNo, string content, string currentLine) | |
| int | getLineNo () const |
| string | getTagName () const |
| string | getStrContent () const |
| void | setStrContent (string content) |
| void | setTagName (string tagName) |
| void | displayAttributes () |
| void | addChild (Element *newChild) |
| void | setParent (Element *Parent) |
| Element * | getParent () |
| int | getNoOfChildren () |
| int | getLevel () |
| void | setLevel (int newLevel) |
| bool | hasAttributes () |
Public Attributes | |
| vector< Attribute * > | vecAttribute |
| vector< Element * > | vecChildren |
| Element::Element | ( | ) |
Default constructor. Sets strTagName and strContent to be an empty string, sets lineNumber to 0.
Definition at line 22 of file Element.cpp.
| Element::Element | ( | const Element & | orig | ) |
Copy constructor Creates a new Element object setting each element variable to match the object it is copied from.
| orig | - Original element object which is copied. |
Definition at line 34 of file Element.cpp.
|
virtual |
Standard destructor.
Definition at line 69 of file Element.cpp.
| Element::Element | ( | string | tagName, |
| int | nLineNo, | ||
| string | content, | ||
| string | currentLine | ||
| ) |
Custom constructor. Assigns the passed parameters to the newly created element's member variables. Used in the program whenever a new element is created. Also calls the 'findAttributes' function which will scan the line on which the element was found for attributes and populate a vector of found attributes. Also sets the to element's level to 0 as the 'setLevel' function is called after the new element is created. This should be re-factored in future versions.
| tagName | - A string which is used to store the element's tag name. |
| nLineNo | - The line number of the XML file on which the element was found. |
| content | - A string which is used to store the element's content. |
| currentLine | - The entire line of an XML file on which the element was found, used when 'findAttributes' is called. |
Definition at line 53 of file Element.cpp.
| void Element::addChild | ( | Element * | newChild | ) |
Function to store pointers to children of the element. Pointers are pushed on to the element's 'vecChildren' vector and the number of children is incremented. This is called in the program just after a new element is created. In future versions this should be called in the element's constructor.
| newChild | - A pointer to an element that is the child of the element object. |
Definition at line 204 of file Element.cpp.
| void Element::displayAttributes | ( | ) |
Function used to output the element's attribute names and values. This is used during the tree building process and after the tree has been built. During tree building, this function is called before the element's level has been set. The function uses this default level to determine if the tree is currently being built. This behavior is not reliable and should be updated in future versions.
Definition at line 122 of file Element.cpp.
| int Element::getLevel | ( | ) |
A function that returns the level on which an element was found. This is called when new element objects are being created to retrieve the level of their parent. This is also called as the element tree is being displayed.
Definition at line 243 of file Element.cpp.
| int Element::getLineNo | ( | ) | const |
Standard getter for the line number that a element is found on in an XML file. Used throughout the program for output and organizes the the building of the tree.
Definition at line 86 of file Element.cpp.
| int Element::getNoOfChildren | ( | ) |
Returns the number of children that an element object contains. This is called as the element tree is being displayed.
Definition at line 233 of file Element.cpp.
| Element * Element::getParent | ( | ) |
Function that returns a pointer to the current element's parent. This is used for creating the element tree as well as setting the element object's level.
Definition at line 224 of file Element.cpp.
| string Element::getStrContent | ( | ) | const |
Standard getter for the content of an element. If the element has no content this will simply return "Empty". Used when displaying the tree structure.
Definition at line 95 of file Element.cpp.
| string Element::getTagName | ( | ) | const |
Standard getter for the element's tag name, used throughout the program for output and for building the tree.
Definition at line 77 of file Element.cpp.
| bool Element::hasAttributes | ( | ) |
A simple boolean function that determines if the element object contains attributes or not. This is done by checking if the 'vecAttribute' vector is empty. This is called as the tree is being displayed.
Definition at line 263 of file Element.cpp.
| void Element::setLevel | ( | int | newLevel | ) |
Sets an element objects level as the element tree is being created. In future versions this should be called within the element constructor.
| newLevel | - The level in which an element is found within the element tree. This parameter is always passed as the element object's parent's level + 1. |
Definition at line 253 of file Element.cpp.
| void Element::setParent | ( | Element * | Parent | ) |
Function to store a pointer to the current element's parent. This is called in the program just after a new element is created. In future versions this should be called in the element's constructor.
| Parent | - A pointer to an element that is the parent of the element object. |
Definition at line 215 of file Element.cpp.
| void Element::setStrContent | ( | string | content | ) |
Standard setter for the element's content. Called when a new element is created.
| content | - A string which is to be stored as the element's content. |
Definition at line 111 of file Element.cpp.
| void Element::setTagName | ( | string | tagName | ) |
Standard setter for the element's tag name. Called when a new element is created.
| tagName | - A string which is to be stored as the element's tag name. |
Definition at line 103 of file Element.cpp.
| vector<Attribute*> Element::vecAttribute |
| vector<Element*> Element::vecChildren |
1.8.8