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 392 by douglas, 2004-12-24T20:46:32-08:00 vs.
Revision 393 by douglas, 2004-12-24T22:32:04-08:00

# Line 75 | Line 75 | void Represent::parse()
75                  query = content;
76          }
77  
78 //      api::Cout << query << ios::NewLine;
79
78          ext::Vector<ext::String> pairs(query.Split('&'));
79  
80          _foreach (ext::Vector<ext::String>, pair, pairs)
# Line 84 | Line 82 | void Represent::parse()
82                  ext::String::ConstIterator equal(pair->FindFirst('='));
83                  ext::String name(pair->Begin(), equal), value(equal != pair->End() ? equal + 1 : equal, pair->End());
84  
85 <                // XXX: clean up %20, etc.
85 >                cgi.insert(std::pair<std::string, std::string>(decode(name), decode(value)));
86 >        }
87 > }
88 >
89 > std::string Represent::decode(const ext::String& encoded)
90 > {
91 >        std::string decoded(encoded);
92 >        std::string::size_type pos(0);
93  
94 <                cgi.insert(std::pair<std::string, std::string>(name, value));
94 >        while ((pos = decoded.find_first_of("%+", pos)) != std::string::npos) switch (decoded[pos])
95 >        {
96 >        case '%':
97 >                decoded.replace(pos, 3, 1, Hexadecimal(decoded.substr(pos + 1, 2), false).convert<char>(false));
98 >                break;
99 >        case '+':
100 >                decoded[pos] = ' ';
101          }
102 +
103 +        return decoded;
104   }
105  
106   void Represent::headings(xml::TextWriter& xhtml)
# Line 173 | Line 186 | void Represent::output(xml::TextWriter&
186          MultiMapConstIterator type(cgi.lower_bound("type")), type_(cgi.upper_bound("type")), data(cgi.lower_bound("data")), data_(cgi.upper_bound("data")), input(cgi.lower_bound("input")), input_(cgi.upper_bound("input"));
187          ext::Vector<Item> items;
188  
189 <        _foru (index, 0, *count.begin())
189 >        _foru (index, 0, *count.begin() < 128 ? *count.begin() : 128)
190          {
191                  Item item(DataType(type != type_ ? type->second : std::string()), data != data_ ? data->second : std::string(), InputType(input != input_ ? input->second : std::string()));
192  
# Line 364 | Line 377 | void Represent::normal(xml::TextWriter&
377          xhtml.OutputText(lexical_cast<ext::String>(type));
378   }
379  
380 + // XXX: damn, this one is really quite screwy
381   template <>
382   void Represent::normal(xml::TextWriter& xhtml, const char& char_)
383   {
384 <        xhtml.OutputText(ext::CodePoint(char_));
384 >        xhtml.OutputText("'");
385 >        xhtml.OutputText(std::string(1, char_).c_str());
386 >        xhtml.OutputText("'");
387   }
388  
389   template <>
390   void Represent::normal(xml::TextWriter& xhtml, const std::string& string)
391   {
392 +        xhtml.OutputText("\"");
393          xhtml.OutputText(string);
394 +        xhtml.OutputText("\"");
395   }
396  
397   template <>
398   void Represent::normal(xml::TextWriter& xhtml, const ext::String& string)
399   {
400 +        xhtml.OutputText("\"");
401          xhtml.OutputText(string);
402 +        xhtml.OutputText("\"");
403   }
404  
405   template <typename Type>
# Line 400 | Line 420 | void Represent::binary(xml::TextWriter&
420                  xml::ScopeElement(xhtml, "br");
421  
422                  xhtml.OutputText(Binary(*atom));
423 +                xhtml.OutputText(" = '");
424 +                xhtml.OutputText(ext::CodePoint(*atom));
425 +                xhtml.OutputText("'");
426          }
427   }
428  
# Line 415 | Line 438 | void Represent::binary(xml::TextWriter&
438                  xml::ScopeElement(xhtml, "br");
439  
440                  xhtml.OutputText(Binary(*atom));
441 +                xhtml.OutputText(" = '");
442 +                xhtml.OutputText(ext::CodePoint(*atom));
443 +                xhtml.OutputText("'");
444          }
445   }
446  
# Line 435 | Line 461 | void Represent::hexadecimal(xml::TextWri
461          {
462                  xml::ScopeElement(xhtml, "br");
463  
464 <                xhtml.OutputText(Hexadecimal(string));
464 >                xhtml.OutputText(Hexadecimal(*atom));
465 >                xhtml.OutputText(" = '");
466 >                xhtml.OutputText(ext::CodePoint(*atom));
467 >                xhtml.OutputText("'");
468          }
469   }
470  
# Line 450 | Line 479 | void Represent::hexadecimal(xml::TextWri
479          {
480                  xml::ScopeElement(xhtml, "br");
481  
482 <                xhtml.OutputText(Hexadecimal(string));
482 >                xhtml.OutputText(Hexadecimal(*atom));
483 >                xhtml.OutputText(" = '");
484 >                xhtml.OutputText(ext::CodePoint(*atom));
485 >                xhtml.OutputText("'");
486          }
487   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines