made escape_string build without exception support

This commit is contained in:
Arvid Norberg 2007-12-29 01:35:50 +00:00
parent eb8ea0f461
commit 588d59b9f2
1 changed files with 20 additions and 2 deletions

View File

@ -63,23 +63,41 @@ namespace libtorrent
{
++i;
if (i == s.end())
#ifdef BOOST_NO_EXCEPTIONS
return ret;
#else
throw std::runtime_error("invalid escaped string");
#endif
int high;
if(*i >= '0' && *i <= '9') high = *i - '0';
else if(*i >= 'A' && *i <= 'F') high = *i + 10 - 'A';
else if(*i >= 'a' && *i <= 'f') high = *i + 10 - 'a';
else throw std::runtime_error("invalid escaped string");
else
#ifdef BOOST_NO_EXCEPTIONS
return ret;
#else
throw std::runtime_error("invalid escaped string");
#endif
++i;
if (i == s.end())
#ifdef BOOST_NO_EXCEPTIONS
return ret;
#else
throw std::runtime_error("invalid escaped string");
#endif
int low;
if(*i >= '0' && *i <= '9') low = *i - '0';
else if(*i >= 'A' && *i <= 'F') low = *i + 10 - 'A';
else if(*i >= 'a' && *i <= 'f') low = *i + 10 - 'a';
else throw std::runtime_error("invalid escaped string");
else
#ifdef BOOST_NO_EXCEPTIONS
return ret;
#else
throw std::runtime_error("invalid escaped string");
#endif
ret += char(high * 16 + low);
}