// Represent // // Douglas Thrift // // $Id$ #include "Hexadecimal.hpp" #include #include struct Environment { ext::String get(const ext::String& name) { try { return api::TheEnvironment.Get(name); } catch (ext::Exception) { return ext::String(); } } } env; int Main(const app::Options& options) { Represent represent; return 0; } Represent::Represent() { parse(); api::Cout << "Content-Type: text/html; charset=UTF-8\r\n\r\n" << ios::Flush; xml::TextWriter xhtml(api::Cout); xml::ScopeElement table(xhtml, "table"); { xml::ScopeElement tr(xhtml, "tr"); ext::String headings[] = { "Type", "Data Representation", "Storage" }; _foru (index, 0, sizeof (headings) / sizeof (ext::String)) { xml::ScopeElement th(xhtml, "th"); xhtml.OutputText(headings[index]); } } } void Represent::parse() { ext::String query(env.get("QUERY_STRING")); if (env.get("REQUEST_METHOD") == "POST") { ext::Buffer content(lexical_cast(env.get("CONTENT_LENGTH"))); api::Cin.ReadFully(content.Begin(), content.GetSize()); query = content; } ext::Vector pairs(query.Split('&')); _foreach (ext::Vector, pair, pairs) { ext::String::ConstIterator equal(pair->FindFirst('=')); ext::String name(pair->Begin(), equal), value(equal != pair->End() ? equal + 1 : equal, pair->End()); cgi.insert(std::pair(name, value)); } }