#include <Element.h>
Inheritance diagram for Cgi::Element:
Public Member Functions | |
Element (const std::string &tag) | |
virtual | ~Element () |
virtual std::string | ToString () const |
Generate full tag including content and closing tag. | |
virtual void | SetClass (Class *cl) |
Class * | GetClass () const |
virtual void | SetId (const std::string &id) |
const std::string & | GetId () const |
virtual void | SetStyle (const std::string &style) |
const std::string & | GetStyle () const |
virtual void | SetParent (Element *parent) |
Element * | GetParent () const |
virtual Element * | Copy ()=0 |
std::string | GetAttributes (const std::string &tag="") const |
Get class, id, style, and other attributes. | |
const std::string & | GetElementName () const |
void | SetAttribute (const std::string &key, const std::string &value) |
const std::string & | GetAttribute (const std::string &key) |
void | SetContent (const std::string &content) |
const std::string & | GetContent () const |
virtual doctype_t | GetDoctype () |
Get Document type from HtmlDocument. | |
Private Attributes | |
std::string | m_tag |
element name | |
Element * | m_parent |
Class * | m_class |
std::string | m_id |
std::string | m_style |
attrmap_t | m_attrs |
std::string | m_content |
std::string | m_temporary |
Definition at line 25 of file Element.h.
Cgi::Element::Element | ( | const std::string & | tag | ) |
Cgi::Element::~Element | ( | ) | [virtual] |
std::string Cgi::Element::ToString | ( | ) | const [virtual] |
Generate full tag including content and closing tag.
Reimplemented in Cgi::ElementList, and Cgi::HtmlDocument.
Definition at line 133 of file Element.cpp.
References GetAttributes(), GetContent(), and GetElementName().
00134 { 00135 return GetAttributes( GetElementName() ) + GetContent() + "</" + GetElementName() + ">"; 00136 }
void Cgi::Element::SetClass | ( | Class * | cl | ) | [virtual] |
Class * Cgi::Element::GetClass | ( | ) | const |
void Cgi::Element::SetId | ( | const std::string & | id | ) | [virtual] |
const std::string & Cgi::Element::GetId | ( | ) | const |
void Cgi::Element::SetStyle | ( | const std::string & | style | ) | [virtual] |
Definition at line 46 of file Element.cpp.
References m_style.
00047 { 00048 m_style = style; 00049 }
const std::string & Cgi::Element::GetStyle | ( | ) | const |
void Cgi::Element::SetParent | ( | Element * | parent | ) | [virtual] |
Definition at line 58 of file Element.cpp.
References m_parent.
Referenced by Cgi::ElementList::Add(), and Cgi::ElementList::ElementList().
00059 { 00060 m_parent = parent; 00061 }
Element * Cgi::Element::GetParent | ( | ) | const |
Definition at line 64 of file Element.cpp.
References m_parent.
00065 { 00066 return m_parent; 00067 }
virtual Element* Cgi::Element::Copy | ( | ) | [pure virtual] |
Implemented in Cgi::Body, Cgi::Head, Cgi::HtmlDocument, Cgi::Style, and Cgi::Title.
Referenced by Cgi::ElementList::Add().
std::string Cgi::Element::GetAttributes | ( | const std::string & | tag = "" |
) | const |
Get class, id, style, and other attributes.
tag | Element name |
Definition at line 70 of file Element.cpp.
References m_attrs, m_class, m_id, and m_style.
Referenced by Cgi::ElementList::ToString(), and ToString().
00071 { 00072 std::string r; 00073 if (tag.size()) 00074 { 00075 r += "<" + tag; 00076 } 00077 if (m_class) 00078 { 00079 // %! htmlsafestr ( m_class -> GetName() ) 00080 r += " class='" + m_class -> GetName() + "'"; 00081 } 00082 if (m_id.size()) 00083 { 00084 // %! htmlsafestr ( m_id ) 00085 r += " id='" + m_id + "'"; 00086 } 00087 if (m_style.size()) 00088 { 00089 // %! htmlsafestr ( m_style ) 00090 r += " style='" + m_style + "'"; 00091 } 00092 for (attrmap_t::const_iterator it = m_attrs.begin(); it != m_attrs.end(); it++) 00093 { 00094 // %! htmlsafestr ( it -> second ) 00095 r += " " + it -> first + "='" + it -> second + "'"; 00096 } 00097 if (tag.size()) 00098 { 00099 r += ">"; 00100 } 00101 return r; 00102 }
const std::string & Cgi::Element::GetElementName | ( | ) | const |
Definition at line 145 of file Element.cpp.
References m_tag.
Referenced by Cgi::ElementList::ToString(), and ToString().
00146 { 00147 return m_tag; 00148 }
void Cgi::Element::SetAttribute | ( | const std::string & | key, | |
const std::string & | value | |||
) |
Definition at line 105 of file Element.cpp.
References m_attrs.
Referenced by Cgi::Style::SetType().
00106 { 00107 m_attrs[key] = value; 00108 }
const std::string & Cgi::Element::GetAttribute | ( | const std::string & | key | ) |
Definition at line 111 of file Element.cpp.
References m_attrs, and m_temporary.
Referenced by Cgi::Style::GetType().
00112 { 00113 if (m_attrs.find(key) != m_attrs.end()) 00114 { 00115 return m_attrs[key]; 00116 } 00117 return m_temporary; 00118 }
void Cgi::Element::SetContent | ( | const std::string & | content | ) |
Definition at line 121 of file Element.cpp.
References m_content.
Referenced by Cgi::Title::SetTitle(), Cgi::Style::Style(), and Cgi::Title::Title().
00122 { 00123 m_content = content; 00124 }
const std::string & Cgi::Element::GetContent | ( | ) | const |
Definition at line 127 of file Element.cpp.
References m_content.
Referenced by Cgi::Title::GetTitle(), and ToString().
00128 { 00129 return m_content; 00130 }
doctype_t Cgi::Element::GetDoctype | ( | ) | [virtual] |
Get Document type from HtmlDocument.
Reimplemented in Cgi::HtmlDocument.
Definition at line 139 of file Element.cpp.
References m_parent.
00140 { 00141 return m_parent -> GetDoctype(); 00142 }
std::string Cgi::Element::m_tag [private] |
Element* Cgi::Element::m_parent [private] |
Class* Cgi::Element::m_class [private] |
std::string Cgi::Element::m_id [private] |
std::string Cgi::Element::m_style [private] |
attrmap_t Cgi::Element::m_attrs [private] |
Definition at line 69 of file Element.h.
Referenced by GetAttribute(), GetAttributes(), and SetAttribute().
std::string Cgi::Element::m_content [private] |
std::string Cgi::Element::m_temporary [private] |