Class representing an HTML element. More...
#include <cgicc/HTMLElement.h>
Public Types | |
| enum | EElementType { eAtomic, eBoolean } |
| Possible types of HTMLElements. More... | |
Public Member Functions | |
Constructors and Destructor | |
| HTMLElement (const HTMLElement &element) | |
| Copy constructor. More... | |
| virtual | ~HTMLElement () |
| Destructor. More... | |
Overloaded Operators | |
| bool | operator== (const HTMLElement &element) const |
| Compare two HTMLElements for equality. More... | |
| bool | operator!= (const HTMLElement &element) const |
| Compare two HTMLElements for inequality. More... | |
| HTMLElement & | operator= (const HTMLElement &element) |
| Assignment operator. More... | |
Accessor Methods | |
Information on the element | |
| virtual const char * | getName () const =0 |
| Get the name of this element. More... | |
| std::string | getData () const |
| Get the data contained in this element, if any. More... | |
| EElementType | getType () const |
| Get the type of this element. More... | |
Mutator Methods | |
Set properties of the element | |
| void | setData (const std::string &data) |
| Set the data contained in this element. More... | |
| virtual HTMLElement * | clone () const =0 |
| Clone this HTMLElement. More... | |
Embedded HTMLElement Management | |
Manage elements embedded in this one | |
| const HTMLElementList * | getEmbedded () const |
| Get the HTMLElementList embedded in this element, if any. More... | |
| void | setEmbedded (const HTMLElementList &embedded) |
| Set the HTMLElementList associated with this element. More... | |
| HTMLElement & | add (const HTMLElement &element) |
| Add an embedded HTMLElement in this one. More... | |
| HTMLElement & | add (HTMLElement *element) |
| Add an embedded HTMLElement in this one. More... | |
HTMLAttribute Management | |
Manage attributes embedded in this element | |
| const HTMLAttributeList * | getAttributes () const |
| Get the attributes associated with this element. More... | |
| void | setAttributes (const HTMLAttributeList &attributes) |
| Set the attributes associated with this element. More... | |
| HTMLElement & | set (const std::string &name) |
| Set an HTMLAttribute on this HTMLElement. More... | |
| HTMLElement & | set (const std::string &name, const std::string &value) |
| Set an HTMLAttribute on this HTMLElement. More... | |
Public Member Functions inherited from cgicc::MStreamable | |
| MStreamable () | |
| Empty constructor. More... | |
| virtual | ~MStreamable () |
| Empty destructor. More... | |
Boolean element methods | |
| virtual void | swapState () const |
| Swap the state of the boolean element. More... | |
| virtual bool | getState () const |
| Get the state of this boolean element. More... | |
| virtual void | render (std::ostream &out) const |
| Render this HTMLElement to an ostream. More... | |
| HTMLElement (const HTMLAttributeList *attributes, const HTMLElement *embedded, const std::string *data, EElementType type) | |
| Subclass constructor. More... | |
| bool | dataSpecified () const |
| For subclasses only. More... | |
Class representing an HTML element.
An HTML element is any entity enclosed in angle brackets (< and >) interpreted as HTML, for example a, img, html, and body.
This class is an abstract base class that defines the interface for all HTMLElement subclasses.
Definition at line 60 of file HTMLElement.h.
Possible types of HTMLElements.
An HTMLElement is either atomic, meaning it has no corresponding closing tag (elements such as hr and br are atomic) or boolean (elements such as a and ol are boolean)
| Enumerator | |
|---|---|
| eAtomic | Atomic element, such as |
| eBoolean | Boolean element, such as |
Definition at line 71 of file HTMLElement.h.
| cgicc::HTMLElement::HTMLElement | ( | const HTMLElement & | element | ) |
Copy constructor.
Sets the name and internal state of this element to those of element
| element | The HTMLElement to copy. |
|
virtual |
Destructor.
Delete this HTMLElement object
|
protected |
Subclass constructor.
This allows the subclasses to fully specify all properties
| attributes | A pointer to an HTMLAttributeList containing the HTMLAttributes for this HTMLElement, if any |
| embedded | A pointer to the embedded HTMLElement, if any |
| data | A pointer to the data, if any |
| type | The type of element |
| HTMLElement& cgicc::HTMLElement::add | ( | const HTMLElement & | element | ) |
Add an embedded HTMLElement in this one.
| element | A reference to an HTMLElement to embed in this one |
this | HTMLElement& cgicc::HTMLElement::add | ( | HTMLElement * | element | ) |
Add an embedded HTMLElement in this one.
This element takes ownership of element, which should not be deleted.
| element | A pointer to an HTMLElement to embed. |
this
|
pure virtual |
Clone this HTMLElement.
This performs a deep copy of the element
this. Implemented in cgicc::HTMLBooleanElement< Tag >, and cgicc::HTMLAtomicElement< Tag >.
|
inlineprotected |
For subclasses only.
Returns true if data was specified in the constructor.
true if data was specified in the constructor, false otherwise Definition at line 367 of file HTMLElement.h.
|
inline |
Get the attributes associated with this element.
If this method returns 0, no attributes are embedded
Definition at line 271 of file HTMLElement.h.
|
inline |
Get the data contained in this element, if any.
This is only applicable for boolean elements
Definition at line 166 of file HTMLElement.h.
|
inline |
Get the HTMLElementList embedded in this element, if any.
If this method returns 0, no elements are embedded
Definition at line 223 of file HTMLElement.h.
|
pure virtual |
Get the name of this element.
For example, html or body.
Implemented in cgicc::HTMLBooleanElement< Tag >, and cgicc::HTMLAtomicElement< Tag >.
|
inlinevirtual |
Get the state of this boolean element.
true if the element is active, false otherwise Reimplemented in cgicc::HTMLBooleanElement< Tag >.
Definition at line 330 of file HTMLElement.h.
|
inline |
Get the type of this element.
Most HTMLElements are boolean
Definition at line 176 of file HTMLElement.h.
|
inline |
Compare two HTMLElements for inequality.
HTMLElements are equal if they have the same name
| element | The HTMLElement to compare to this one. |
false if the two HTMLElements are equal, true otherwise. Definition at line 122 of file HTMLElement.h.
| HTMLElement& cgicc::HTMLElement::operator= | ( | const HTMLElement & | element | ) |
Assignment operator.
Sets the name and internal state of this element to those of element
| element | The HTMLElement to copy |
this | bool cgicc::HTMLElement::operator== | ( | const HTMLElement & | element | ) | const |
Compare two HTMLElements for equality.
HTMLElements are equal if they have the same name
| element | The HTMLElement to compare to this one. |
true if the two HTMLElements are equal, false otherwise.
|
virtual |
Render this HTMLElement to an ostream.
This is used for output
| out | The ostream to which to write |
Implements cgicc::MStreamable.
| HTMLElement& cgicc::HTMLElement::set | ( | const std::string & | name | ) |
Set an HTMLAttribute on this HTMLElement.
| name | The name of the HTMLAttribute to set |
this | HTMLElement& cgicc::HTMLElement::set | ( | const std::string & | name, |
| const std::string & | value | ||
| ) |
Set an HTMLAttribute on this HTMLElement.
| name | The name of the HTMLAttribute |
| value | The value of the HTMLAttribute |
this | void cgicc::HTMLElement::setAttributes | ( | const HTMLAttributeList & | attributes | ) |
Set the attributes associated with this element.
This is usually called by subclass constructors
| attributes | The HTMLAttributeList containing the HTMLAttributes belonging to this element. |
|
inline |
Set the data contained in this element.
The data is the text contained between the opening and closing tags
| data | The data to store in this element. |
Definition at line 194 of file HTMLElement.h.
| void cgicc::HTMLElement::setEmbedded | ( | const HTMLElementList & | embedded | ) |
Set the HTMLElementList associated with this element.
This is usually called by subclass constructors
| embedded | The HTMLElementList containing the HTMLElements embedded in this element. |
|
inlinevirtual |
Swap the state of the boolean element.
A state of true means the element is active
Reimplemented in cgicc::HTMLBooleanElement< Tag >.
Definition at line 320 of file HTMLElement.h.