00001 #ifndef HTML_WRITER_HH
00002 #define HTML_WRITER_HH
00003
00004 #include "html/Attrib.hh"
00005 #include <iosfwd>
00006 #include <string>
00007 #include <vector>
00008
00009 namespace html {
00010
00020 class writer {
00021 public:
00026 writer(std::ostream& ostr);
00027
00031 ~writer(void);
00032
00037 void text(const std::string& data);
00038
00043 void endLine(void);
00044
00055 void tag(const char* tagname, int nattr=0, const char** attr=0,
00056 const char** value=0);
00057
00066 void tag(const char* tagname, const attList& attr);
00067
00078 void tagNData(const char* tagname, int nattr=0, const char** attr=0,
00079 const char** value=0);
00080
00089 void tagNData(const char* tagname, const attList& attr);
00090
00097 void meta(const char* name, const char* value);
00098
00105 void meta(const char* name, double value);
00106
00111 void Integer(int N);
00112
00118 void endTag(const std::string& tagname);
00119
00126 void pushDefault(const attList& x);
00127
00132 const attList& refDefault(void) const;
00133
00138 attList& refDefault(void);
00139
00144 void popDefault(void);
00145
00150 void sync(void);
00151
00152 private:
00156 void indent(void);
00157
00158 private:
00159 static const int MAXDEPTH=128;
00163 std::ostream* mStream;
00164
00168 int mDepth;
00169
00173 int mCursor;
00174
00178 const char* mNest[MAXDEPTH];
00179
00183 std::vector<attList> mFont;
00184
00187 std::string mDocType;
00188
00189 };
00190
00191 }
00192
00193 inline html::attList&
00194 html::writer::refDefault(void) {
00195 return mFont.back();
00196 }
00197
00198 const inline html::attList&
00199 html::writer::refDefault(void) const {
00200 return mFont.back();
00201 }
00202
00203
00204 #endif // HTML_WRITER_HH