summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-04-09 17:38:25 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:41 (GMT)
commitfdfe10dc9dde522e82d381e4641eb98063c4b47f (patch)
tree20c7637852b554994f8168ba174879bf14d67ee0 /SwifTools
parent83f360b98d28e3a34dcabce170e1e4d9577e50d3 (diff)
downloadswift-contrib-fdfe10dc9dde522e82d381e4641eb98063c4b47f.zip
swift-contrib-fdfe10dc9dde522e82d381e4641eb98063c4b47f.tar.bz2
Fixed compilation on older GCCs.
Diffstat (limited to 'SwifTools')
-rw-r--r--SwifTools/URIHandler/XMPPURI.cpp57
1 files changed, 28 insertions, 29 deletions
diff --git a/SwifTools/URIHandler/XMPPURI.cpp b/SwifTools/URIHandler/XMPPURI.cpp
index d9fde07..496871c 100644
--- a/SwifTools/URIHandler/XMPPURI.cpp
+++ b/SwifTools/URIHandler/XMPPURI.cpp
@@ -18,42 +18,41 @@
using namespace Swift;
-namespace {
-
- struct PercentEncodedCharacterFinder {
- template<typename Iterator>
- boost::iterator_range<Iterator> operator()(Iterator begin, Iterator end) {
- boost::iterator_range<Iterator> r = boost::first_finder("%")(begin, end);
- if (r.end() == end) {
- return r;
+// Should be in anonymous namespace, but older GCCs complain if we do that
+struct PercentEncodedCharacterFinder {
+ template<typename Iterator>
+ boost::iterator_range<Iterator> operator()(Iterator begin, Iterator end) {
+ boost::iterator_range<Iterator> r = boost::first_finder("%")(begin, end);
+ if (r.end() == end) {
+ return r;
+ }
+ else {
+ if (r.end() + 1 == end || r.end() + 2 == end) {
+ throw std::runtime_error("Incomplete escape character");
}
else {
- if (r.end() + 1 == end || r.end() + 2 == end) {
- throw std::runtime_error("Incomplete escape character");
- }
- else {
- r.advance_end(2);
- return r;
- }
+ r.advance_end(2);
+ return r;
}
}
- };
+ }
+};
- struct PercentUnencodeFormatter {
- template<typename FindResult>
- std::string operator()(const FindResult& match) const {
- std::stringstream s;
- s << std::hex << std::string(match.begin() + 1, match.end());
- unsigned int value;
- s >> value;
- if (s.fail() || s.bad()) {
- throw std::runtime_error("Invalid escape character");
- }
- return std::string(reinterpret_cast<const char*>(&value), 1);
+struct PercentUnencodeFormatter {
+ template<typename FindResult>
+ std::string operator()(const FindResult& match) const {
+ std::stringstream s;
+ s << std::hex << std::string(match.begin() + 1, match.end());
+ unsigned int value;
+ s >> value;
+ if (s.fail() || s.bad()) {
+ throw std::runtime_error("Invalid escape character");
}
- };
-
+ return std::string(reinterpret_cast<const char*>(&value), 1);
+ }
+};
+namespace {
std::string unescape(const std::string& s) {
try {
return boost::find_format_all_copy(s, PercentEncodedCharacterFinder(), PercentUnencodeFormatter());