00001 #ifndef _CGI_ELEMENT_H 00002 #define _CGI_ELEMENT_H 00003 00004 #include <string> 00005 #include <map> 00006 00007 namespace Cgi 00008 { 00009 00010 class Class; 00011 00012 typedef std::map<std::string, std::string> attrmap_t; 00013 00014 typedef enum { 00015 DOCTYPE_HTML_20 = 1, 00016 DOCTYPE_HTML_32, 00017 DOCTYPE_HTML_401_TRANSITIONAL, 00018 DOCTYPE_HTML_401_STRICT, 00019 DOCTYPE_HTML_401_FRAMESET, 00020 DOCTYPE_XHTML_1_0_TRANSITIONAL, 00021 DOCTYPE_XHTML_1_0_STRICT, 00022 DOCTYPE_XHTML_1_0_FRAMESET 00023 } doctype_t; 00024 00025 class Element 00026 { 00027 public: 00028 Element(const std::string& tag); 00029 virtual ~Element(); 00030 00032 virtual std::string ToString() const; 00033 00034 virtual void SetClass(Class *cl); 00035 Class *GetClass() const; 00036 00037 virtual void SetId(const std::string& id); 00038 const std::string& GetId() const; 00039 00040 virtual void SetStyle(const std::string& style); 00041 const std::string& GetStyle() const; 00042 00043 virtual void SetParent(Element *parent); 00044 Element *GetParent() const; 00045 00046 virtual Element *Copy() = 0; 00047 00050 std::string GetAttributes(const std::string& tag = "") const; 00051 00052 const std::string& GetElementName() const; 00053 00054 void SetAttribute(const std::string& key, const std::string& value); 00055 const std::string& GetAttribute(const std::string& key); 00056 00057 void SetContent(const std::string& content); 00058 const std::string& GetContent() const; 00059 00061 virtual doctype_t GetDoctype(); 00062 00063 private: 00064 std::string m_tag; 00065 Element *m_parent; 00066 Class *m_class; 00067 std::string m_id; 00068 std::string m_style; 00069 attrmap_t m_attrs; 00070 std::string m_content; 00071 std::string m_temporary; 00072 }; 00073 00074 00075 } // namespace Cgi 00076 00077 00078 #endif // _CGI_ELEMENT_H