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) |
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 |
< |
cgi.insert(std::pair<std::string, std::string>(name, value)); |
89 |
> |
std::string Represent::decode(const ext::String& encoded) |
90 |
> |
{ |
91 |
> |
std::string decoded(encoded); |
92 |
> |
std::string::size_type pos(0); |
93 |
> |
|
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) |
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 |
|
|
199 |
|
|
200 |
|
_rfor (MultiMapConstIterator, delete_, cgi.lower_bound("delete"), cgi.upper_bound("delete")) items.RemoveAt(lexical_cast<size_t>(delete_->second)); |
201 |
|
|
202 |
+ |
if (!items.IsEmpty() && items.First().data.IsEmpty()) items.RemoveFirst(); |
203 |
+ |
|
204 |
|
size_t index(0); |
205 |
|
|
206 |
|
_foreach (ext::Vector<Item>, item, items) switch (item->type) |
355 |
|
case InputType::INPUT_Binary: |
356 |
|
return Binary(item.data, false).convert<char>(false); |
357 |
|
case InputType::INPUT_Hexadecimal: |
358 |
< |
return Hexadecimal(input.data, false).convert<char>(false); |
358 |
> |
return Hexadecimal(item.data, false).convert<char>(false); |
359 |
|
} |
360 |
|
} |
361 |
|
|
347 |
– |
// XXX: constructing a string from Binary or Hexadecimal seems too dangerous |
362 |
|
template <> |
363 |
|
std::string Represent::input(const Item& item) |
364 |
|
{ |
365 |
< |
return item.data; |
365 |
> |
std::string string; |
366 |
> |
|
367 |
> |
switch (item.input) |
368 |
> |
{ |
369 |
> |
default: |
370 |
> |
return item.data; |
371 |
> |
case InputType::INPUT_Binary: |
372 |
> |
_foreach (_L<ext::String>, atom, item.data.Split(' ')) string += Binary(*atom, false).convert<char>(false); |
373 |
> |
break; |
374 |
> |
case InputType::INPUT_Hexadecimal: |
375 |
> |
_foreach (_L<ext::String>, atom, item.data.Split(' ')) string += Hexadecimal(*atom, false).convert<char>(false); |
376 |
> |
} |
377 |
> |
|
378 |
> |
return string; |
379 |
|
} |
380 |
|
|
354 |
– |
// XXX: constructing a string from Binary or Hexadecimal seems too dangerous |
381 |
|
template <> |
382 |
|
ext::String Represent::input(const Item& item) |
383 |
|
{ |
384 |
< |
return item.data; |
384 |
> |
ext::String string; |
385 |
> |
|
386 |
> |
switch (item.input) |
387 |
> |
{ |
388 |
> |
default: |
389 |
> |
return item.data; |
390 |
> |
case InputType::INPUT_Binary: |
391 |
> |
_foreach (_L<ext::String>, atom, item.data.Split(' ')) string.InsertLast(Binary(*atom, false).convert<ext::CodePoint>(false)); |
392 |
> |
break; |
393 |
> |
case InputType::INPUT_Hexadecimal: |
394 |
> |
_foreach (_L<ext::String>, atom, item.data.Split(' ')) string.InsertLast(Hexadecimal(*atom, false).convert<ext::CodePoint>(false)); |
395 |
> |
} |
396 |
> |
|
397 |
> |
return string; |
398 |
|
} |
399 |
|
|
400 |
|
template <typename Type> |
403 |
|
xhtml.OutputText(lexical_cast<ext::String>(type)); |
404 |
|
} |
405 |
|
|
406 |
+ |
// XXX: damn, this one is really quite screwy |
407 |
|
template <> |
408 |
|
void Represent::normal(xml::TextWriter& xhtml, const char& char_) |
409 |
|
{ |
410 |
< |
xhtml.OutputText(ext::CodePoint(char_)); |
410 |
> |
xhtml.OutputText("'"); |
411 |
> |
xhtml.OutputText(std::string(1, char_).c_str()); |
412 |
> |
xhtml.OutputText("'"); |
413 |
|
} |
414 |
|
|
415 |
|
template <> |
416 |
|
void Represent::normal(xml::TextWriter& xhtml, const std::string& string) |
417 |
|
{ |
418 |
+ |
xhtml.OutputText("\""); |
419 |
|
xhtml.OutputText(string); |
420 |
+ |
xhtml.OutputText("\""); |
421 |
|
} |
422 |
|
|
423 |
|
template <> |
424 |
|
void Represent::normal(xml::TextWriter& xhtml, const ext::String& string) |
425 |
|
{ |
426 |
+ |
xhtml.OutputText("\""); |
427 |
|
xhtml.OutputText(string); |
428 |
+ |
xhtml.OutputText("\""); |
429 |
|
} |
430 |
|
|
431 |
|
template <typename Type> |
446 |
|
xml::ScopeElement(xhtml, "br"); |
447 |
|
|
448 |
|
xhtml.OutputText(Binary(*atom)); |
449 |
+ |
xhtml.OutputText(" = '"); |
450 |
+ |
xhtml.OutputText(ext::CodePoint(*atom)); |
451 |
+ |
xhtml.OutputText("'"); |
452 |
|
} |
453 |
|
} |
454 |
|
|
464 |
|
xml::ScopeElement(xhtml, "br"); |
465 |
|
|
466 |
|
xhtml.OutputText(Binary(*atom)); |
467 |
+ |
xhtml.OutputText(" = '"); |
468 |
+ |
xhtml.OutputText(ext::CodePoint(*atom)); |
469 |
+ |
xhtml.OutputText("'"); |
470 |
|
} |
471 |
|
} |
472 |
|
|
487 |
|
{ |
488 |
|
xml::ScopeElement(xhtml, "br"); |
489 |
|
|
490 |
< |
xhtml.OutputText(Hexadecimal(string)); |
490 |
> |
xhtml.OutputText(Hexadecimal(*atom)); |
491 |
> |
xhtml.OutputText(" = '"); |
492 |
> |
xhtml.OutputText(ext::CodePoint(*atom)); |
493 |
> |
xhtml.OutputText("'"); |
494 |
|
} |
495 |
|
} |
496 |
|
|
505 |
|
{ |
506 |
|
xml::ScopeElement(xhtml, "br"); |
507 |
|
|
508 |
< |
xhtml.OutputText(Hexadecimal(string)); |
508 |
> |
xhtml.OutputText(Hexadecimal(*atom)); |
509 |
> |
xhtml.OutputText(" = '"); |
510 |
> |
xhtml.OutputText(ext::CodePoint(*atom)); |
511 |
> |
xhtml.OutputText("'"); |
512 |
|
} |
513 |
|
} |