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 379 by douglas, 2004-12-22T20:42:52-08:00 vs.
Revision 380 by douglas, 2004-12-23T01:07:33-08:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "Hexadecimal.hpp"
8 + #include "DataType.hpp"
9  
10   #include <menes-api/environment.hpp>
11   #include <menes-app/simple.hpp>
# Line 30 | Line 31 | Represent::Represent()
31          xml::TextWriter xhtml(api::Cout);
32          xml::ScopeElement table(xhtml, "table");
33  
34 <        {
35 <                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");
34 >        headings(xhtml);
35 >        form(xhtml);
36  
37 <                        xhtml.OutputText(headings[index]);
42 <                }
43 <        }
37 >        //
38   }
39  
40   void Represent::parse()
# Line 66 | Line 60 | void Represent::parse()
60                  cgi.insert(std::pair<std::string, std::string>(name, value));
61          }
62   }
63 +
64 + void Represent::headings(xml::TextWriter& xhtml)
65 + {
66 +        xml::ScopeElement tr(xhtml, "tr");
67 +        ext::String headings[] = { "Data Type", "Data Representation", "Input", "Storage" };
68 +
69 +        _foru (index, 0, sizeof (headings) / sizeof (ext::String))
70 +        {
71 +                xml::ScopeElement th(xhtml, "th");
72 +
73 +                xhtml.OutputText(headings[index]);
74 +        }
75 + }
76 +
77 + void Represent::form(xml::TextWriter& xhtml)
78 + {
79 +        xml::ScopeElement tr(xhtml, "tr");
80 +
81 +        {
82 +                xml::ScopeElement td(xhtml, "td"), select(xhtml, "select");
83 +
84 +                xhtml.SetAttribute("name", "type");
85 +
86 +                DataType type(cgi.find("type") != cgi.end() ? DataType::Type(lexical_cast<unsigned>(cgi.find("type")->second)) : DataType::TYPE_bool);
87 +
88 +                _foreach (ext::Vector<DataType>, type_, DataType::enumerate())
89 +                {
90 +                        xml::ScopeElement option(xhtml, "option");
91 +
92 +                        if (*type_ == type) xhtml.SetAttribute("selected", "selected");
93 +
94 +                        xhtml.SetAttribute("value", lexical_cast<ext::String>(DataType::Type(*type_)));
95 +                        xhtml.OutputText(*type_);
96 +                }
97 +        }
98 +
99 +        {
100 +                xml::ScopeElement td(xhtml, "td"), input(xhtml, "input");
101 +
102 +                xhtml.SetAttribute("name", "data");
103 +                xhtml.SetAttribute("size", "64");
104 +                xhtml.SetAttribute("type", "text");
105 +
106 +                ext::String data(cgi.find("data") != cgi.end() ? cgi.find("data")->second : std::string());
107 +
108 +                xhtml.SetAttribute("value", data);
109 +        }
110 +
111 +        {
112 +                xml::ScopeElement td(xhtml, "td"), select(xhtml, "select");
113 +
114 +                ext::String inputs[] = { "Binary", "Hexadecimal", "std::istream", "ios::PrintReader" };
115 +                unsigned input(cgi.find("input") != cgi.end() ? lexical_cast<unsigned>(cgi.find("input")->second) : 0);
116 +
117 +                _foru (input_, 0, sizeof (inputs) / sizeof (ext::String))
118 +                {
119 +                        xml::ScopeElement option(xhtml, "option");
120 +
121 +                        if (input_ == input) xhtml.SetAttribute("selected", "selected");
122 +
123 +                        xhtml.SetAttribute("value", lexical_cast<ext::String>(input_));
124 +                        xhtml.OutputText(inputs[input_]);
125 +                }
126 +        }
127 +
128 +        xml::ScopeElement td(xhtml, "td"), input(xhtml, "input");
129 +
130 +        xhtml.SetAttribute("type", "submit");
131 +        xhtml.SetAttribute("value", "Store");
132 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines