#include "html_builder.h" HTMLTag *HTMLTag::str(const String &str) { result += " " + str; return this; } HTMLTag *HTMLTag::style(const String &val) { attrib("style", val); return this; } HTMLTag *HTMLTag::href(const String &val) { attrib("href", val); return this; } HTMLTag *HTMLTag::cls(const String &val) { attrib("class", val); return this; } HTMLTag *HTMLTag::id(const String &val) { attrib("id", val); return this; } HTMLTag *HTMLTag::name(const String &val) { attrib("name", val); return this; } HTMLTag *HTMLTag::content(const String &val) { attrib("content", val); return this; } HTMLTag *HTMLTag::value(const String &val) { attrib("value", val); return this; } HTMLTag *HTMLTag::method(const String &val) { attrib("method", val); return this; } HTMLTag *HTMLTag::type(const String &val) { attrib("type", val); return this; } HTMLTag *HTMLTag::placeholder(const String &val) { attrib("placeholder", val); return this; } HTMLTag *HTMLTag::rel(const String &val) { attrib("rel", val); return this; } HTMLTag *HTMLTag::rel_stylesheet() { attrib("rel", "stylesheet"); return this; } HTMLTag *HTMLTag::charset(const String &val) { attrib("charset", val); return this; } HTMLTag *HTMLTag::charset_utf_8() { attrib("charset", "utf-8"); return this; } HTMLTag *HTMLTag::attrib(const String &attr, const String &val) { result += " " + attr + "=\"" + val + "\""; return this; } HTMLTag *HTMLTag::start(const 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; } HTMLBuilder *HTMLTag::f() { return owner; } bool HTMLTag::has_data() { return result.size() > 0; } HTMLTag::HTMLTag() { simple = true; owner = nullptr; } HTMLBuilder *HTMLBuilder::comment(const String &val) { write_tag(); result += ""; return this; } HTMLTag *HTMLBuilder::doctype() { write_tag(); return tag.start("!DOCTYPE"); } HTMLBuilder *HTMLBuilder::doctype(const String &val) { write_tag(); result += ""; return this; } 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 "; return this; } HTMLBuilder *HTMLBuilder::c_ol() { write_tag(); result += ""; return this; } HTMLBuilder *HTMLBuilder::coptgroup() { write_tag(); result += ""; return this; } HTMLBuilder *HTMLBuilder::coption() { write_tag(); result += ""; return this; } HTMLBuilder *HTMLBuilder::coutput() { write_tag(); result += ""; return this; } HTMLBuilder *HTMLBuilder::cp() { write_tag(); result += "

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