From 0863bc1aa68ee43091799c65ac701e574c51d1a2 Mon Sep 17 00:00:00 2001
From: Arvid Norberg
Date: Tue, 10 Apr 2007 09:11:32 +0000
Subject: [PATCH] removed the dependency on the compiled boost.date_time
library
---
Jamfile | 1 -
docs/manual.html | 3 ++-
docs/manual.rst | 3 ++-
examples/client_test.cpp | 13 +++++--------
include/libtorrent/http_tracker_connection.hpp | 1 +
include/libtorrent/time.hpp | 2 +-
include/libtorrent/torrent_handle.hpp | 2 +-
include/libtorrent/torrent_info.hpp | 4 ++++
src/http_connection.cpp | 2 ++
src/torrent_info.cpp | 8 ++++++--
10 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/Jamfile b/Jamfile
index 68823b620..fd6d64f7e 100755
--- a/Jamfile
+++ b/Jamfile
@@ -133,7 +133,6 @@ project torrent
$(DEFINES)
/boost/thread//boost_thread #/static
/boost/filesystem//boost_filesystem #/static
- /boost/date_time//boost_date_time #/static
multi
# ======= compiler settings =======
diff --git a/docs/manual.html b/docs/manual.html
index 445e8586f..884cc8ba0 100644
--- a/docs/manual.html
+++ b/docs/manual.html
@@ -1117,7 +1117,8 @@ void print(std::ostream& os) const;
The print() function is there for debug purposes only. It will print the info from
-the torrent file to the given outstream.
+the torrent file to the given outstream. This function has been deprecated and will
+be removed from future releases.
diff --git a/docs/manual.rst b/docs/manual.rst
index c834cc1b4..06f53d466 100644
--- a/docs/manual.rst
+++ b/docs/manual.rst
@@ -1045,7 +1045,8 @@ print()
void print(std::ostream& os) const;
The ``print()`` function is there for debug purposes only. It will print the info from
-the torrent file to the given outstream.
+the torrent file to the given outstream. This function has been deprecated and will
+be removed from future releases.
trackers()
diff --git a/examples/client_test.cpp b/examples/client_test.cpp
index 08c781f48..d3322de9d 100644
--- a/examples/client_test.cpp
+++ b/examples/client_test.cpp
@@ -147,8 +147,6 @@ void clear_home()
#endif
-namespace pt = boost::posix_time;
-
std::string esc(char const* code)
{
#ifdef ANSI_TERMINAL_COLORS
@@ -577,7 +575,7 @@ int main(int ac, char* av[])
std::deque
events;
- boost::posix_time::ptime next_dir_scan = boost::posix_time::second_clock::universal_time();
+ ptime next_dir_scan = time_now();
// the string is the filename of the .torrent file, but only if
// it was added through the directory monitor. It is used to
@@ -775,7 +773,7 @@ int main(int ac, char* av[])
// loop through the alert queue to see if anything has happened.
std::auto_ptr a;
a = ses.pop_alert();
- std::string now = to_simple_string(boost::posix_time::second_clock::local_time());
+ std::string now = time_now_string();
while (a.get())
{
std::stringstream event_string;
@@ -916,7 +914,7 @@ int main(int ac, char* av[])
{
boost::posix_time::time_duration t = s.next_announce;
out << " next announce: " << esc("37") <<
- boost::posix_time::to_simple_string(t) << esc("0") << " ";
+ t.hours() << ":" << t.minutes() << ":" << t.seconds() << esc("0") << " ";
out << "tracker: " << s.current_tracker << "\n";
}
@@ -997,12 +995,11 @@ int main(int ac, char* av[])
puts(out.str().c_str());
if (!monitor_dir.empty()
- && next_dir_scan < boost::posix_time::second_clock::universal_time())
+ && next_dir_scan < time_now())
{
scan_dir(monitor_dir, ses, handles, preferred_ratio
, compact_allocation_mode, save_path);
- next_dir_scan = boost::posix_time::second_clock::universal_time()
- + boost::posix_time::seconds(poll_interval);
+ next_dir_scan = time_now() + seconds(poll_interval);
}
}
diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp
index e823d8ff7..151e12cba 100755
--- a/include/libtorrent/http_tracker_connection.hpp
+++ b/include/libtorrent/http_tracker_connection.hpp
@@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
+#include
#ifdef _MSC_VER
#pragma warning(pop)
diff --git a/include/libtorrent/time.hpp b/include/libtorrent/time.hpp
index 02d0be35e..b4ad2d675 100644
--- a/include/libtorrent/time.hpp
+++ b/include/libtorrent/time.hpp
@@ -50,7 +50,7 @@ namespace libtorrent
#if (!defined (__MACH__) && !defined (_WIN32) && !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0) || defined (TORRENT_USE_BOOST_DATE_TIME)
-#include
+#include
namespace libtorrent
{
diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp
index 2a87907af..c645fae9c 100755
--- a/include/libtorrent/torrent_handle.hpp
+++ b/include/libtorrent/torrent_handle.hpp
@@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(push, 1)
#endif
-#include
+#include
#ifdef _MSC_VER
#pragma warning(pop)
diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp
index 779f221a4..cac8544a2 100755
--- a/include/libtorrent/torrent_info.hpp
+++ b/include/libtorrent/torrent_info.hpp
@@ -138,7 +138,11 @@ namespace libtorrent
int num_pieces() const { assert(m_piece_length > 0); return (int)m_piece_hash.size(); }
const sha1_hash& info_hash() const { return m_info_hash; }
const std::string& name() const { assert(m_piece_length > 0); return m_name; }
+
+// ------- start deprecation -------
void print(std::ostream& os) const;
+// ------- end deprecation -------
+
bool is_valid() const { return m_piece_length > 0; }
bool priv() const { return m_private; }
diff --git a/src/http_connection.cpp b/src/http_connection.cpp
index 35e71728c..6e15b22d8 100644
--- a/src/http_connection.cpp
+++ b/src/http_connection.cpp
@@ -33,7 +33,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/http_connection.hpp"
#include
+#include
#include
+#include
using boost::bind;
diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp
index 22a95f76d..4083a24ca 100755
--- a/src/torrent_info.cpp
+++ b/src/torrent_info.cpp
@@ -736,6 +736,8 @@ namespace libtorrent
assert(false);
}
+// ------- start deprecation -------
+
void torrent_info::print(std::ostream& os) const
{
os << "trackers:\n";
@@ -746,8 +748,8 @@ namespace libtorrent
}
if (!m_comment.empty())
os << "comment: " << m_comment << "\n";
- if (m_creation_date != pt::ptime(gr::date(pt::not_a_date_time)))
- os << "creation date: " << to_simple_string(m_creation_date) << "\n";
+// if (m_creation_date != pt::ptime(gr::date(pt::not_a_date_time)))
+// os << "creation date: " << to_simple_string(m_creation_date) << "\n";
os << "private: " << (m_private?"yes":"no") << "\n";
os << "number of pieces: " << num_pieces() << "\n";
os << "piece length: " << piece_length() << "\n";
@@ -756,6 +758,8 @@ namespace libtorrent
os << " " << std::setw(11) << i->size << " " << i->path.string() << "\n";
}
+// ------- end deprecation -------
+
size_type torrent_info::piece_size(int index) const
{
assert(index >= 0 && index < num_pieces());