Skip to content

Commit d138f02

Browse files
committed
introduce lt namespace alias
1 parent e4dbd28 commit d138f02

File tree

189 files changed

+516
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+516
-583
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* introduce "lt" namespace alias
12
* need_save_resume_data() will no longer return true every 15 minutes
23
* make the file_status interface explicitly public types
34
* added resolver_cache_timeout setting for internal host name resolver

bindings/python/src/alert.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "bytes.hpp"
1212

1313
using namespace boost::python;
14-
using namespace libtorrent;
14+
using namespace lt;
1515

1616
#ifdef _MSC_VER
1717
#pragma warning(push)
@@ -143,7 +143,7 @@ namespace boost
143143
// types are indeed polymorphic, no need to derive from
144144
// them.
145145
#define POLY(x) template<> \
146-
struct is_polymorphic<libtorrent:: x > : boost::mpl::true_ {};
146+
struct is_polymorphic<lt:: x > : boost::mpl::true_ {};
147147

148148
POLY(torrent_alert)
149149
POLY(tracker_alert)

bindings/python/src/converters.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
using namespace boost::python;
1717
namespace bp = boost::python;
18-
namespace lt = libtorrent;
1918

2019
template<class T>
2120
struct endpoint_to_tuple
@@ -73,9 +72,9 @@ struct pair_to_tuple
7372

7473
struct address_to_tuple
7574
{
76-
static PyObject* convert(libtorrent::address const& addr)
75+
static PyObject* convert(lt::address const& addr)
7776
{
78-
libtorrent::error_code ec;
77+
lt::error_code ec;
7978
return incref(bp::object(addr.to_string(ec)).ptr());
8079
}
8180
};

bindings/python/src/create_torrent.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "bytes.hpp"
1111

1212
using namespace boost::python;
13-
using namespace libtorrent;
13+
using namespace lt;
1414

1515
#ifdef _MSC_VER
1616
#pragma warning(push)
@@ -65,16 +65,16 @@ namespace
6565

6666
struct FileIter
6767
{
68-
typedef libtorrent::file_entry value_type;
69-
typedef libtorrent::file_entry reference;
70-
typedef libtorrent::file_entry* pointer;
68+
typedef lt::file_entry value_type;
69+
typedef lt::file_entry reference;
70+
typedef lt::file_entry* pointer;
7171
typedef int difference_type;
7272
typedef std::forward_iterator_tag iterator_category;
7373

7474
FileIter(file_storage const& fs, file_index_t i) : m_fs(&fs), m_i(i) {}
7575
FileIter(FileIter const&) = default;
7676
FileIter() : m_fs(nullptr), m_i(0) {}
77-
libtorrent::file_entry operator*() const
77+
lt::file_entry operator*() const
7878
{ return m_fs->at(m_i); }
7979

8080
FileIter operator++() { m_i++; return *this; }
@@ -200,7 +200,7 @@ void bind_create_torrent()
200200
.def(init<file_storage&>())
201201
.def(init<torrent_info const&>(arg("ti")))
202202
.def(init<file_storage&, int, int, int>((arg("storage"), arg("piece_size") = 0
203-
, arg("pad_file_limit") = -1, arg("flags") = int(libtorrent::create_torrent::optimize_alignment))))
203+
, arg("pad_file_limit") = -1, arg("flags") = int(lt::create_torrent::optimize_alignment))))
204204

205205
.def("generate", &create_torrent::generate)
206206

bindings/python/src/datetime.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <ctime>
1111

1212
using namespace boost::python;
13-
namespace lt = libtorrent;
1413

1514
#if BOOST_VERSION < 103400
1615

bindings/python/src/entry.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "bytes.hpp"
88

99
using namespace boost::python;
10-
using namespace libtorrent;
10+
using namespace lt;
1111

1212
struct entry_to_python
1313
{
@@ -172,7 +172,7 @@ struct entry_from_python
172172

173173
void bind_entry()
174174
{
175-
to_python_converter<std::shared_ptr<libtorrent::entry>, entry_to_python>();
175+
to_python_converter<std::shared_ptr<lt::entry>, entry_to_python>();
176176
to_python_converter<entry, entry_to_python>();
177177
entry_from_python();
178178
}

bindings/python/src/error_code.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace boost
5252
#include "boost_python.hpp"
5353

5454
using namespace boost::python;
55-
using namespace libtorrent;
55+
using namespace lt;
5656
using boost::system::error_category;
5757

5858
namespace {
@@ -86,17 +86,17 @@ namespace {
8686
int const value = extract<int>(state[0]);
8787
std::string const category = extract<std::string>(state[1]);
8888
if (category == "system")
89-
ec.assign(value, libtorrent::system_category());
89+
ec.assign(value, lt::system_category());
9090
else if (category == "generic")
91-
ec.assign(value, libtorrent::generic_category());
91+
ec.assign(value, lt::generic_category());
9292
else if (category == "libtorrent")
93-
ec.assign(value, libtorrent::libtorrent_category());
93+
ec.assign(value, lt::libtorrent_category());
9494
else if (category == "http error")
95-
ec.assign(value, libtorrent::http_category());
95+
ec.assign(value, lt::http_category());
9696
else if (category == "UPnP error")
97-
ec.assign(value, libtorrent::upnp_category());
97+
ec.assign(value, lt::upnp_category());
9898
else if (category == "bdecode error")
99-
ec.assign(value, libtorrent::bdecode_category());
99+
ec.assign(value, lt::bdecode_category());
100100
else if (category == "asio.netdb")
101101
ec.assign(value, boost::asio::error::get_netdb_category());
102102
else if (category == "asio.addinfo")

bindings/python/src/fingerprint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
void bind_fingerprint()
99
{
1010
using namespace boost::python;
11-
using namespace libtorrent;
11+
using namespace lt;
1212

1313
def("generate_fingerprint", &generate_fingerprint);
1414

bindings/python/src/ip_filter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "gil.hpp"
88

99
using namespace boost::python;
10-
using namespace libtorrent;
10+
using namespace lt;
1111

1212
namespace
1313
{

bindings/python/src/magnet_uri.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include "bytes.hpp"
1212

1313
using namespace boost::python;
14-
using namespace libtorrent;
15-
namespace lt = libtorrent;
14+
using namespace lt;
1615

1716
extern void dict_to_add_torrent_params(dict params, add_torrent_params& p);
1817

bindings/python/src/peer_info.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <boost/python/iterator.hpp>
99

1010
using namespace boost::python;
11-
using namespace libtorrent;
11+
using namespace lt;
1212

1313
std::int64_t get_last_active(peer_info const& pi)
1414
{

bindings/python/src/session.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
namespace boost
2828
{
2929
// this fixes mysterious link error on msvc
30-
libtorrent::alert const volatile*
31-
get_pointer(libtorrent::alert const volatile* p)
30+
lt::alert const volatile*
31+
get_pointer(lt::alert const volatile* p)
3232
{
3333
return p;
3434
}
@@ -45,8 +45,7 @@ namespace boost
4545
#endif
4646

4747
using namespace boost::python;
48-
using namespace libtorrent;
49-
namespace lt = libtorrent;
48+
using namespace lt;
5049

5150
namespace
5251
{
@@ -523,7 +522,7 @@ namespace
523522
, std::string const& salt, std::string pk, std::string sk
524523
, std::string data)
525524
{
526-
using libtorrent::dht::sign_mutable_item;
525+
using lt::dht::sign_mutable_item;
527526

528527
e = data;
529528
std::vector<char> buf;

bindings/python/src/session_settings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <libtorrent/session.hpp>
77

88
using namespace boost::python;
9-
using namespace libtorrent;
9+
using namespace lt;
1010

1111
void bind_session_settings()
1212
{

bindings/python/src/sha1_hash.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ long get_hash(boost::python::object o)
1414
return long(PyObject_Hash(str(o).ptr()));
1515
}
1616

17-
using namespace libtorrent;
17+
using namespace lt;
1818

1919
bytes sha1_hash_bytes(const sha1_hash& bn) {
2020
return bytes(bn.to_string());
@@ -23,7 +23,7 @@ bytes sha1_hash_bytes(const sha1_hash& bn) {
2323
void bind_sha1_hash()
2424
{
2525
using namespace boost::python;
26-
using namespace libtorrent;
26+
using namespace lt;
2727

2828
class_<sha1_hash>("sha1_hash")
2929
.def(self == self)

bindings/python/src/torrent_handle.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "gil.hpp"
1818

1919
using namespace boost::python;
20-
using namespace libtorrent;
20+
using namespace lt;
2121

2222
#ifdef _MSC_VER
2323
#pragma warning(push)

bindings/python/src/torrent_info.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
#endif
2020

2121
using namespace boost::python;
22-
using namespace libtorrent;
23-
namespace lt = libtorrent;
22+
using namespace lt;
2423

2524
namespace
2625
{

bindings/python/src/torrent_status.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <libtorrent/bitfield.hpp>
99

1010
using namespace boost::python;
11-
using namespace libtorrent;
11+
using namespace lt;
1212

1313
object bitfield_to_list(bitfield const& bf)
1414
{

bindings/python/src/utility.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "bytes.hpp"
99

1010
using namespace boost::python;
11-
using namespace libtorrent;
11+
using namespace lt;
1212

1313
#ifdef _MSC_VER
1414
#pragma warning(push)
@@ -91,7 +91,7 @@ void bind_utility()
9191
bytes_from_python();
9292

9393
#ifndef TORRENT_NO_DEPRECATE
94-
def("identify_client", &libtorrent::identify_client);
94+
def("identify_client", &lt::identify_client);
9595
def("client_fingerprint", &client_fingerprint_);
9696
#endif
9797
def("bdecode", &bdecode_);

bindings/python/src/version.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "boost_python.hpp"
77

88
using namespace boost::python;
9-
using libtorrent::version;
9+
using lt::version;
1010

1111
void bind_version()
1212
{

docs/manual.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ for system errors. That is, errors that belong to the generic or system category
129129

130130
Errors that belong to the libtorrent error category are not localized however, they
131131
are only available in english. In order to translate libtorrent errors, compare the
132-
error category of the ``error_code`` object against ``libtorrent::libtorrent_category()``,
132+
error category of the ``error_code`` object against ``lt::libtorrent_category()``,
133133
and if matches, you know the error code refers to the list above. You can provide
134134
your own mapping from error code to string, which is localized. In this case, you
135135
cannot rely on ``error_code::message()`` to generate your strings.
@@ -143,7 +143,7 @@ Here's a simple example of how to translate error codes:
143143

144144
std::string error_code_to_string(boost::system::error_code const& ec)
145145
{
146-
if (ec.category() != libtorrent::libtorrent_category())
146+
if (ec.category() != lt::libtorrent_category())
147147
{
148148
return ec.message();
149149
}

docs/python_binding.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ asio::tcp::endpoint
8383
The endpoint type is represented as a tuple of a string (as the address) and an int for
8484
the port number. E.g. ``('127.0.0.1', 6881)`` represents the localhost port 6881.
8585

86-
libtorrent::time_duration
86+
lt::time_duration
8787
The time duration is represented as a number of seconds in a regular integer.
8888

8989
The following functions takes a reference to a container that is filled with

docs/tutorial.rst

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ For example:
3131
#include <libtorrent/torrent_handle.hpp>
3232
#include <libtorrent/magnet_uri.hpp>
3333

34-
namespace lt = libtorrent;
3534
int main(int argc, char const* argv[])
3635
{
3736
if (argc != 2) {

examples/bt-get.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
4040
#include <libtorrent/alert_types.hpp>
4141
#include <libtorrent/magnet_uri.hpp>
4242

43-
namespace lt = libtorrent;
4443
int main(int argc, char const* argv[])
4544
{
4645
if (argc != 2) {

examples/bt-get2.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
4646
#include <libtorrent/error_code.hpp>
4747
#include <libtorrent/magnet_uri.hpp>
4848

49-
namespace lt = libtorrent;
5049
using clk = std::chrono::steady_clock;
5150

5251
// return the name of a torrent status enum

0 commit comments

Comments
 (0)