#include "html_builder.h" HTMLTag *HTMLTag::str(const std::string &str) { result += " " + str; return this; } HTMLTag *HTMLTag::style(const std::string &val) { attrib("style", val); return this; } HTMLTag *HTMLTag::href(const std::string &val) { attrib("href", val); return this; } HTMLTag *HTMLTag::cls(const std::string &val) { attrib("class", val); return this; } HTMLTag *HTMLTag::id(const std::string &val) { attrib("id", val); return this; } HTMLTag *HTMLTag::name(const std::string &val) { attrib("name", val); return this; } HTMLTag *HTMLTag::method(const std::string &val) { attrib("method", val); return this; } HTMLTag *HTMLTag::type(const std::string &val) { attrib("type", val); return this; } HTMLTag *HTMLTag::attrib(const std::string &attr, const std::string &val) { result += " " + attr + "=\"" + val + "\""; return this; } HTMLTag *HTMLTag::start(const std::string &p_tag, const bool p_simple) { simple = p_simple; result = "<" + p_tag; return this; } HTMLTag *HTMLTag::reset() { result.clear(); return this; } HTMLTag *HTMLTag::close() { if (simple) result += "/>"; else result += ">"; return this; } bool HTMLTag::has_data() { return result.size() > 0; } HTMLTag::HTMLTag() { simple = true; } void HTMLBuilder::comment(const std::string &val) { write_tag(); result += ""; } HTMLTag *HTMLBuilder::doctype() { write_tag(); return tag.start("!DOCTYPE"); } void HTMLBuilder::doctype(const std::string &val) { write_tag(); result += ""; } HTMLTag *HTMLBuilder::a() { write_tag(); return tag.start("a"); } HTMLTag *HTMLBuilder::abbr() { write_tag(); return tag.start("abbr"); } HTMLTag *HTMLBuilder::acronym() { //Not supported in HTML5. Use instead. Defines an acronym write_tag(); return tag.start("acronym"); } HTMLTag *HTMLBuilder::address() { write_tag(); return tag.start("address"); } HTMLTag *HTMLBuilder::applet() { //Not supported in HTML5. Use or instead. Defines an embedded applet write_tag(); return tag.start("applet"); } HTMLTag *HTMLBuilder::area() { write_tag(); return tag.start("area"); } HTMLTag *HTMLBuilder::article() { write_tag(); return tag.start("article"); } HTMLTag *HTMLBuilder::aside() { write_tag(); return tag.start("aside"); } HTMLTag *HTMLBuilder::audio() { write_tag(); return tag.start("audio"); } HTMLTag *HTMLBuilder::b() { write_tag(); return tag.start("b"); } HTMLTag *HTMLBuilder::basefont() { //Not supported in HTML5. Use CSS instead. Specifies a default color, size, and font for all text in a document write_tag(); return tag.start("basefont"); } HTMLTag *HTMLBuilder::bdi() { write_tag(); return tag.start("bdi"); } HTMLTag *HTMLBuilder::bdo() { write_tag(); return tag.start("bdo"); } HTMLTag *HTMLBuilder::big() { //Not supported in HTML5. Use CSS instead. Defines big text write_tag(); return tag.start("big"); } HTMLTag *HTMLBuilder::blockquote() { write_tag(); return tag.start("blockquote"); } HTMLTag *HTMLBuilder::body() { write_tag(); return tag.start("body"); } HTMLTag *HTMLBuilder::br() { write_tag(); return tag.start("br", true); } HTMLTag *HTMLBuilder::button() { write_tag(); return tag.start("button"); } HTMLTag *HTMLBuilder::canvas() { write_tag(); return tag.start("canvas"); } HTMLTag *HTMLBuilder::caption() { write_tag(); return tag.start("caption"); } HTMLTag *HTMLBuilder::center() { //Not supported in HTML5. Use CSS instead. Defines centered text write_tag(); return tag.start("center"); } HTMLTag *HTMLBuilder::cite() { write_tag(); return tag.start("cite"); } HTMLTag *HTMLBuilder::code() { write_tag(); return tag.start("code"); } HTMLTag *HTMLBuilder::col() { write_tag(); return tag.start("col"); } HTMLTag *HTMLBuilder::colgroup() { write_tag(); return tag.start("colgroup"); } HTMLTag *HTMLBuilder::data() { write_tag(); return tag.start("cite"); } HTMLTag *HTMLBuilder::datalist() { write_tag(); return tag.start("datalist"); } HTMLTag *HTMLBuilder::dd() { write_tag(); return tag.start("dd"); } HTMLTag *HTMLBuilder::del() { write_tag(); return tag.start("del"); } HTMLTag *HTMLBuilder::details() { write_tag(); return tag.start("details"); } HTMLTag *HTMLBuilder::dfn() { write_tag(); return tag.start("dfn"); } HTMLTag *HTMLBuilder::dialog() { write_tag(); return tag.start("dialog"); } HTMLTag *HTMLBuilder::dir() { // Not supported in HTML5. Use "; } void HTMLBuilder::c_ol() { write_tag(); result += ""; } void HTMLBuilder::coptgroup() { write_tag(); result += ""; } void HTMLBuilder::coption() { write_tag(); result += ""; } void HTMLBuilder::coutput() { write_tag(); result += ""; } void HTMLBuilder::cp() { write_tag(); result += "

"; } void HTMLBuilder::cparam() { write_tag(); result += ""; } void HTMLBuilder::cpicture() { write_tag(); result += ""; } void HTMLBuilder::cpre() { write_tag(); result += ""; } void HTMLBuilder::cprogress() { write_tag(); result += ""; } void HTMLBuilder::cq() { write_tag(); result += ""; } void HTMLBuilder::crp() { write_tag(); result += ""; } void HTMLBuilder::crt() { write_tag(); result += ""; } void HTMLBuilder::cruby() { write_tag(); result += ""; } void HTMLBuilder::cs() { write_tag(); result += ""; } void HTMLBuilder::csamp() { write_tag(); result += ""; } void HTMLBuilder::cscript() { write_tag(); result += ""; } void HTMLBuilder::csection() { write_tag(); result += ""; } void HTMLBuilder::cselect() { write_tag(); result += ""; } void HTMLBuilder::csmall() { write_tag(); result += ""; } void HTMLBuilder::csource() { write_tag(); result += ""; } void HTMLBuilder::cspan() { write_tag(); result += ""; } void HTMLBuilder::cstrike() { write_tag(); result += ""; } void HTMLBuilder::cstrong() { write_tag(); result += ""; } void HTMLBuilder::cstyle() { write_tag(); result += ""; } void HTMLBuilder::csub() { write_tag(); result += ""; } void HTMLBuilder::csummary() { write_tag(); result += ""; } void HTMLBuilder::csup() { write_tag(); result += ""; } void HTMLBuilder::csvg() { write_tag(); result += ""; } void HTMLBuilder::ctable() { write_tag(); result += ""; } void HTMLBuilder::ctbody() { write_tag(); result += ""; } void HTMLBuilder::ctd() { write_tag(); result += ""; } void HTMLBuilder::ctemplateh() { write_tag(); result += ""; } void HTMLBuilder::ctextarea() { write_tag(); result += ""; } void HTMLBuilder::ctfoot() { write_tag(); result += ""; } void HTMLBuilder::cth() { write_tag(); result += ""; } void HTMLBuilder::cthead() { write_tag(); result += ""; } void HTMLBuilder::ctime() { write_tag(); result += ""; } void HTMLBuilder::ctitle() { write_tag(); result += ""; } void HTMLBuilder::ctr() { write_tag(); result += ""; } void HTMLBuilder::ctrack() { write_tag(); result += ""; } void HTMLBuilder::ctt() { write_tag(); result += ""; } void HTMLBuilder::cu() { write_tag(); result += ""; } void HTMLBuilder::cul() { write_tag(); result += ""; } void HTMLBuilder::cvar() { write_tag(); result += ""; } void HTMLBuilder::cvideo() { write_tag(); result += ""; } void HTMLBuilder::cwbr() { write_tag(); result += ""; } void HTMLBuilder::w(const std::string &val) { write_tag(); result += val; } //TODO! void HTMLBuilder::we(const std::string &val) { printf("HTMLBuilder::write_excaped NYI!"); write_tag(); result += val; } void HTMLBuilder::write_tag() { if (tag.has_data()) { tag.close(); result += tag.result; tag.reset(); } } HTMLBuilder::HTMLBuilder() { } HTMLBuilder::~HTMLBuilder() { }