00001 /* -*- mode: c++; c-basic-offset: 4; -*- */ 00002 #ifndef HTML_ATTRIB_HH 00003 #define HTML_ATTRIB_HH 00004 00005 #include <time.h> 00006 #include <map> 00007 #include <string> 00008 00009 namespace html { 00010 class writer; 00011 00018 class attrib { 00019 public: 00023 attrib(void); 00024 00028 attrib(const attrib& x); 00029 00033 virtual ~attrib(void); 00034 00039 virtual attrib* clone(void) const = 0; 00040 00045 virtual void setWrite(writer& w) const; 00046 00051 virtual bool isDefault(void) const; 00052 00057 virtual bool hasArg(void) const; 00058 00063 virtual void putAttr(writer& w) const; 00064 00065 private: 00066 }; 00067 00075 class attList { 00076 public: 00077 00081 attList(void); 00082 00087 attList(const attList& x); 00088 00093 virtual ~attList(void); 00094 00102 attrib& addAttr(const std::string& name, const attrib& a); 00103 00111 attrib& repAttr(const std::string& name, const attrib& a); 00112 00117 void remAttr(const std::string& name); 00118 00122 void clear(void); 00123 00128 bool empty(void) const; 00129 00135 bool exists(const std::string& key) const; 00136 00143 const attrib& find(const std::string& key) const; 00144 00148 bool isDefault(void) const; 00149 00154 virtual void putAttr(writer& w) const; 00155 00160 virtual void setWrite(writer& w) const; 00161 00168 virtual void merge(const attList& x); 00169 00170 private: 00171 typedef std::map<std::string, attrib*> AttrList; 00172 typedef AttrList::iterator attr_iter; 00173 00174 public: 00178 typedef AttrList::const_iterator const_attr_iter; 00179 00183 const_attr_iter begin(void) const; 00184 00188 const_attr_iter end(void) const; 00189 00190 private: 00191 AttrList mList; 00192 }; 00193 00194 } 00195 00196 inline bool 00197 html::attList::empty(void) const { 00198 return mList.empty(); 00199 } 00200 00201 inline html::attList::const_attr_iter 00202 html::attList::begin(void) const { 00203 return mList.begin(); 00204 } 00205 00206 inline html::attList::const_attr_iter 00207 html::attList::end(void) const { 00208 return mList.end(); 00209 } 00210 00211 #endif // HTML_ATTRIB_HH
1.5.4