ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Represent/Represent.cpp
(Generate patch)

Comparing Represent/Represent.cpp (file contents):
Revision 371 by douglas, 2004-12-21T23:19:54-08:00 vs.
Revision 379 by douglas, 2004-12-22T20:42:52-08:00

# Line 6 | Line 6
6  
7   #include "Hexadecimal.hpp"
8  
9 + #include <menes-api/environment.hpp>
10   #include <menes-app/simple.hpp>
11  
12 + struct Environment
13 + {
14 +        ext::String get(const ext::String& name) { try { return api::TheEnvironment.Get(name); } catch (ext::Exception) { return ext::String(); } }
15 + } env;
16 +
17   int Main(const app::Options& options)
18   {
19          Represent represent;
# Line 17 | Line 23 | int Main(const app::Options& options)
23  
24   Represent::Represent()
25   {
26 <        ext::String string("1001");
27 <        Binary sign(string, true), unsign(string, false);
26 >        parse();
27 >
28 >        api::Cout << "Content-Type: text/html; charset=UTF-8\r\n\r\n" << ios::Flush;
29 >
30 >        xml::TextWriter xhtml(api::Cout);
31 >        xml::ScopeElement table(xhtml, "table");
32 >
33 >        {
34 >                xml::ScopeElement tr(xhtml, "tr");
35 >                ext::String headings[] = { "Type", "Data Representation", "Storage" };
36 >
37 >                _foru (index, 0, sizeof (headings) / sizeof (ext::String))
38 >                {
39 >                        xml::ScopeElement th(xhtml, "th");
40 >
41 >                        xhtml.OutputText(headings[index]);
42 >                }
43 >        }
44 > }
45 >
46 > void Represent::parse()
47 > {
48 >        ext::String query(env.get("QUERY_STRING"));
49  
50 <        api::Cerr << string << ios::NewLine << ext::String(sign) << ios::NewLine << ext::String(unsign) << ios::NewLine;
50 >        if (env.get("REQUEST_METHOD") == "POST")
51 >        {
52 >                ext::Buffer content(lexical_cast<size_t>(env.get("CONTENT_LENGTH")));
53  
54 <        string = "deadbeef";
54 >                api::Cin.ReadFully(content.Begin(), content.GetSize());
55  
56 <        Hexadecimal test(string, false);
56 >                query = content;
57 >        }
58  
59 <        api::Cerr << string << ios::NewLine << ext::String(test) << ios::NewLine;
59 >        ext::Vector<ext::String> pairs(query.Split('&'));
60  
61 <        Hexadecimal sign_(sign), unsign_(unsign);
61 >        _foreach (ext::Vector<ext::String>, pair, pairs)
62 >        {
63 >                ext::String::ConstIterator equal(pair->FindFirst('='));
64 >                ext::String name(pair->Begin(), equal), value(equal != pair->End() ? equal + 1 : equal, pair->End());
65  
66 <        api::Cerr << ext::String(sign_) << ios::NewLine << ext::String(unsign_) << ios::NewLine;
66 >                cgi.insert(std::pair<std::string, std::string>(name, value));
67 >        }
68   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines