00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _HTMLELEMENT_H_
00023 #define _HTMLELEMENT_H_ 1
00024
00025 #ifdef __GNUG__
00026 # pragma interface
00027 #endif
00028
00035 #include <string>
00036
00037 #include "cgicc/CgiDefs.h"
00038 #include "cgicc/MStreamable.h"
00039 #include "cgicc/HTMLAttributeList.h"
00040
00041 CGICC_BEGIN_NAMESPACE
00042
00043 class HTMLElementList;
00044
00045
00046
00047
00048
00058 class CGICC_API HTMLElement : public MStreamable
00059 {
00060 public:
00061
00069 enum EElementType {
00071 eAtomic,
00073 eBoolean
00074 };
00075
00076
00077
00080
00087 HTMLElement(const HTMLElement& element);
00088
00094 virtual ~HTMLElement();
00096
00097
00098
00101
00109 bool
00110 operator== (const HTMLElement& element) const;
00111
00119 inline bool
00120 operator!= (const HTMLElement& element) const
00121 { return ! operator==(element); }
00122
00123 #ifdef WIN32
00124
00125 inline bool
00126 operator< (const HTMLElement& element) const
00127 { return false; }
00128 #endif
00129
00137 HTMLElement&
00138 operator= (const HTMLElement& element);
00140
00141
00142
00147
00154 virtual const char*
00155 getName() const = 0;
00156
00163 inline STDNS string
00164 getData() const
00165 { return fData; }
00166
00173 inline EElementType
00174 getType() const
00175 { return fType; }
00177
00178
00179
00184
00191 inline void
00192 setData(const STDNS string& data)
00193 { fData = data; }
00195
00196
00197
00204 virtual HTMLElement*
00205 clone() const = 0;
00206
00207
00208
00213
00220 inline const HTMLElementList*
00221 getEmbedded() const
00222 { return fEmbedded; }
00223
00231 void
00232 setEmbedded(const HTMLElementList& embedded);
00233
00241 HTMLElement&
00242 add(const HTMLElement& element);
00243
00251 HTMLElement&
00252 add(HTMLElement *element);
00254
00255
00256
00261
00268 inline const HTMLAttributeList*
00269 getAttributes() const
00270 { return fAttributes; }
00271
00279 void
00280 setAttributes(const HTMLAttributeList& attributes);
00281
00289 HTMLElement&
00290 set(const STDNS string& name);
00291
00300 HTMLElement&
00301 set(const STDNS string& name,
00302 const STDNS string& value);
00304
00305
00306
00311
00317 virtual void
00318 swapState() const
00319 {}
00320
00327 virtual bool
00328 getState() const
00329 { return false; }
00331
00338 virtual void
00339 render(STDNS ostream& out) const;
00340
00341 protected:
00342
00353 HTMLElement(const HTMLAttributeList *attributes,
00354 const HTMLElement *embedded,
00355 const STDNS string *data,
00356 EElementType type);
00357
00364 inline bool
00365 dataSpecified() const
00366 { return fDataSpecified; }
00367
00368 private:
00369 HTMLElement() {}
00370
00371 HTMLAttributeList *fAttributes;
00372 HTMLElementList *fEmbedded;
00373 STDNS string fData;
00374 EElementType fType;
00375 bool fDataSpecified;
00376 };
00377
00378 CGICC_END_NAMESPACE
00379
00380 #endif