removed the last dependency on iostream and lexical cast

This commit is contained in:
Arvid Norberg 2009-08-25 18:13:46 +00:00
parent 8c4cf8bffa
commit 6078dd06b0
18 changed files with 39 additions and 28 deletions

View File

@ -41,8 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/identify_client.hpp"
#include <boost/lexical_cast.hpp>
namespace libtorrent
{
struct TORRENT_EXPORT torrent_alert: alert

View File

@ -797,9 +797,9 @@ namespace libtorrent
, int response_code
, const std::string& str)
{
debug_log(std::string("*** tracker error: ")
+ boost::lexical_cast<std::string>(response_code) + ": "
+ str);
char msg[256];
snprintf(msg, sizeof(msg), "*** tracker error: %d: %s", response_code, str.c_str());
debug_log(msg);
}
void debug_log(const std::string& line)

View File

@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
@ -70,7 +69,9 @@ namespace libtorrent
try
{
#endif
fs::path dir(fs::complete(logpath / ("libtorrent_logs" + boost::lexical_cast<std::string>(instance))));
char log_name[256];
snprintf(log_name, sizeof(log_name), "libtorrent_logs%d", instance);
fs::path dir(fs::complete(logpath / log_name));
if (!fs::exists(dir)) fs::create_directories(dir);
m_file.open((dir / filename).string().c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::out));
*this << "\n\n\n*** starting log ***\n";

View File

@ -71,6 +71,7 @@ namespace libtorrent
TORRENT_EXPORT boost::optional<std::string> url_has_argument(
std::string const& url, std::string argument);
TORRENT_EXPORT std::string read_until(char const*& str, char delim, char const* end);
TORRENT_EXPORT std::string to_hex(std::string const& s);
TORRENT_EXPORT bool is_hex(char const *in, int len);
TORRENT_EXPORT void to_hex(char const *in, int len, char* out);

View File

@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/cstdint.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/lexical_cast.hpp>
#ifdef _MSC_VER
#pragma warning(pop)

View File

@ -72,8 +72,7 @@ public:
// store it in a shaed_ptr
boost::shared_ptr<handler_type> h(new handler_type(handler));
tcp::resolver::query q(m_hostname
, boost::lexical_cast<std::string>(m_port));
tcp::resolver::query q(m_hostname, to_string(m_port).elems);
m_resolver.async_resolve(q, boost::bind(
&http_stream::name_lookup, this, _1, _2, h));
}

View File

@ -113,8 +113,7 @@ public:
// store it in a shaed_ptr
boost::shared_ptr<handler_type> h(new handler_type(handler));
tcp::resolver::query q(m_hostname
, boost::lexical_cast<std::string>(m_port));
tcp::resolver::query q(m_hostname, to_string(m_port).elems);
m_resolver.async_resolve(q, boost::bind(
&i2p_stream::do_connect, this, _1, _2, h));
}

View File

@ -41,7 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/optional.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/detail/atomic_count.hpp>

View File

@ -58,7 +58,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/limits.hpp>
#include <boost/next_prior.hpp>
#include <boost/noncopyable.hpp>

View File

@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io.hpp"
#include "libtorrent/socket.hpp"
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/function.hpp>
#if BOOST_VERSION < 103500
#include <asio/read.hpp>

View File

@ -116,8 +116,7 @@ public:
// store it in a shaed_ptr
boost::shared_ptr<handler_type> h(new handler_type(handler));
tcp::resolver::query q(m_hostname
, boost::lexical_cast<std::string>(m_port));
tcp::resolver::query q(m_hostname, to_string(m_port).elems);
m_resolver.async_resolve(q, boost::bind(
&socks5_stream::name_lookup, this, _1, _2, h));
}

View File

@ -240,6 +240,21 @@ namespace libtorrent
return false;
}
std::string read_until(char const*& str, char delim, char const* end)
{
TORRENT_ASSERT(str <= end);
std::string ret;
while (str != end && *str != delim)
{
ret += *str;
++str;
}
// skip the delimiter as well
while (str != end && *str == delim) ++str;
return ret;
}
std::string maybe_url_encode(std::string const& url)
{
std::string protocol, host, auth, path;

View File

@ -96,18 +96,18 @@ namespace libtorrent
char const* line_end = newline;
if (pos != line_end && *(line_end - 1) == '\r') --line_end;
std::istringstream line(std::string(pos, line_end));
char const* line = pos;
++newline;
int incoming = (int)std::distance(pos, newline);
m_recv_pos += incoming;
boost::get<1>(ret) += newline - (m_recv_buffer.begin + start_pos);
pos = newline;
line >> m_protocol;
m_protocol = read_until(line, ' ', line_end);
if (m_protocol.substr(0, 5) == "HTTP/")
{
line >> m_status_code;
std::getline(line, m_server_message);
m_status_code = atoi(read_until(line, ' ', line_end).c_str());
m_server_message = read_until(line, '\r', line_end);
}
else
{
@ -116,7 +116,8 @@ namespace libtorrent
// the content length is assumed to be 0 for requests
m_content_length = 0;
m_protocol.clear();
line >> m_path >> m_protocol;
m_path = read_until(line, ' ', line_end);
m_protocol = read_until(line, ' ', line_end);
m_status_code = 0;
}
m_state = read_header;

View File

@ -74,7 +74,7 @@ namespace libtorrent
// send CONNECT
std::back_insert_iterator<std::vector<char> > p(m_buffer);
write_string("CONNECT " + boost::lexical_cast<std::string>(m_remote_endpoint)
write_string("CONNECT " + print_endpoint(m_remote_endpoint)
+ " HTTP/1.0\r\n", p);
if (!m_user.empty())
{

View File

@ -303,7 +303,12 @@ namespace libtorrent
for (char const* i = data, *end(data + size); i != end; ++i)
{
if (*i >= ' ' && *i <= '~') error_str += *i;
else error_str += "0x" + boost::lexical_cast<std::string>((unsigned int)*i) + " ";
else
{
char val[30];
snprintf(val, sizeof(val), "0x%02x ", *i);
error_str += val;
}
}
error_str += "\"";
fail(parser.status_code(), error_str.c_str());

View File

@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/limits.hpp>

View File

@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/limits.hpp>
@ -987,7 +986,7 @@ namespace aux {
tcp::endpoint ep = listener->local_endpoint(ec);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
std::string msg = "error accepting connection on '"
+ boost::lexical_cast<std::string>(ep) + "' " + e.message();
+ print_endpoint(ep) + "' " + e.message();
(*m_logger) << msg << "\n";
#endif
#ifdef TORRENT_WINDOWS

View File

@ -42,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/ref.hpp>