diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index dc47f8bc0..637c80df2 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -47,8 +47,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/units.hpp" -namespace libtorrent -{ +namespace libtorrent { + class torrent_info; struct torrent_plugin; struct torrent_handle; diff --git a/include/libtorrent/address.hpp b/include/libtorrent/address.hpp index 737152baf..a898c8dad 100644 --- a/include/libtorrent/address.hpp +++ b/include/libtorrent/address.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #endif // SIMULATOR -namespace libtorrent -{ +namespace libtorrent { + #if defined TORRENT_BUILD_SIMULATOR using address = sim::asio::ip::address; using address_v4 = sim::asio::ip::address_v4; diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index e3b05691f..c75c941ff 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -64,8 +64,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/config.hpp" -namespace libtorrent -{ +namespace libtorrent { // The ``alert`` class is the base class that specific messages are derived from. // alert types are not copyable, and cannot be constructed by the client. The diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index d30355a25..ed2b9e577 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -57,8 +57,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + // maps an operation id (from peer_error_alert and peer_disconnected_alert) // to its name. See peer_connection for the constants TORRENT_EXPORT char const* operation_name(int op); diff --git a/include/libtorrent/allocator.hpp b/include/libtorrent/allocator.hpp index 625f28b4e..838c9079d 100644 --- a/include/libtorrent/allocator.hpp +++ b/include/libtorrent/allocator.hpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" -namespace libtorrent -{ +namespace libtorrent { TORRENT_EXTRA_EXPORT int page_size(); diff --git a/include/libtorrent/announce_entry.hpp b/include/libtorrent/announce_entry.hpp index 179627388..a8b80d752 100644 --- a/include/libtorrent/announce_entry.hpp +++ b/include/libtorrent/announce_entry.hpp @@ -41,8 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + // this class holds information about one bittorrent tracker, as it // relates to a specific torrent. struct TORRENT_EXPORT announce_entry diff --git a/include/libtorrent/aux_/allocating_handler.hpp b/include/libtorrent/aux_/allocating_handler.hpp index d97536f4f..bf8ba1d7f 100644 --- a/include/libtorrent/aux_/allocating_handler.hpp +++ b/include/libtorrent/aux_/allocating_handler.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + // this is meant to provide the actual storage for the handler allocator. // There's only a single slot, so the allocator is only supposed to be used // for handlers where there's only a single outstanding operation at a time, diff --git a/include/libtorrent/aux_/byteswap.hpp b/include/libtorrent/aux_/byteswap.hpp index e0e5c2b53..d597fd5a8 100644 --- a/include/libtorrent/aux_/byteswap.hpp +++ b/include/libtorrent/aux_/byteswap.hpp @@ -50,9 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -namespace libtorrent { -namespace aux { - +namespace libtorrent { namespace aux { // these need to be within the disabled warnings because on OSX // the htonl and ntohl macros cause lots of old-style case warnings inline std::uint32_t host_to_network(std::uint32_t x) diff --git a/include/libtorrent/aux_/cppint_import_export.hpp b/include/libtorrent/aux_/cppint_import_export.hpp index 3f3545897..b19367736 100644 --- a/include/libtorrent/aux_/cppint_import_export.hpp +++ b/include/libtorrent/aux_/cppint_import_export.hpp @@ -8,6 +8,7 @@ namespace boost { + namespace multiprecision { namespace detail { diff --git a/include/libtorrent/aux_/cpuid.hpp b/include/libtorrent/aux_/cpuid.hpp index 6a5f22954..6e8ea5437 100644 --- a/include/libtorrent/aux_/cpuid.hpp +++ b/include/libtorrent/aux_/cpuid.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + // initialized by static initializers (in cpuid.cpp) TORRENT_EXTRA_EXPORT extern bool const sse42_support; TORRENT_EXTRA_EXPORT extern bool const mmx_support; diff --git a/include/libtorrent/aux_/disk_job_fence.hpp b/include/libtorrent/aux_/disk_job_fence.hpp index dc286db41..0a6211280 100644 --- a/include/libtorrent/aux_/disk_job_fence.hpp +++ b/include/libtorrent/aux_/disk_job_fence.hpp @@ -44,8 +44,8 @@ namespace libtorrent { struct disk_io_job; struct counters; -namespace aux -{ +namespace aux { + // implements the disk I/O job fence used by the storage_interface // to provide to the disk thread. Whenever a disk job needs // exclusive access to the storage for that torrent, it raises diff --git a/include/libtorrent/aux_/escape_string.hpp b/include/libtorrent/aux_/escape_string.hpp index d87688090..83e772df1 100644 --- a/include/libtorrent/aux_/escape_string.hpp +++ b/include/libtorrent/aux_/escape_string.hpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/string_view.hpp" -namespace libtorrent -{ +namespace libtorrent { + namespace string { enum flags_t diff --git a/include/libtorrent/aux_/ffs.hpp b/include/libtorrent/aux_/ffs.hpp index 1358025cf..88d05aab2 100644 --- a/include/libtorrent/aux_/ffs.hpp +++ b/include/libtorrent/aux_/ffs.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/export.hpp" #include "libtorrent/span.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + // For a general reference of the problems these routines are about // see http://en.wikipedia.org/wiki/Find_first_set diff --git a/include/libtorrent/aux_/file_progress.hpp b/include/libtorrent/aux_/file_progress.hpp index de3443d19..f8b32ee4a 100644 --- a/include/libtorrent/aux_/file_progress.hpp +++ b/include/libtorrent/aux_/file_progress.hpp @@ -50,15 +50,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bitfield.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { + class piece_picker; class file_storage; class alert_manager; struct torrent_handle; -namespace aux -{ +namespace aux { + struct TORRENT_EXTRA_EXPORT file_progress { file_progress(); diff --git a/include/libtorrent/aux_/has_block.hpp b/include/libtorrent/aux_/has_block.hpp index eac64abdc..054ef0a6d 100644 --- a/include/libtorrent/aux_/has_block.hpp +++ b/include/libtorrent/aux_/has_block.hpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/piece_block.hpp" namespace libtorrent { namespace aux { + struct has_block { has_block(has_block const&) = default; diff --git a/include/libtorrent/aux_/io.hpp b/include/libtorrent/aux_/io.hpp index 42f2a8125..9d04157eb 100644 --- a/include/libtorrent/aux_/io.hpp +++ b/include/libtorrent/aux_/io.hpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/span.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + template struct type {}; // reads an integer from a byte stream diff --git a/include/libtorrent/aux_/ip_notifier.hpp b/include/libtorrent/aux_/ip_notifier.hpp index 1f49bd266..105dcd1bc 100644 --- a/include/libtorrent/aux_/ip_notifier.hpp +++ b/include/libtorrent/aux_/ip_notifier.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/io_service.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + struct TORRENT_EXTRA_EXPORT ip_change_notifier { // cb will be invoked when a change is detected in the diff --git a/include/libtorrent/aux_/lsd.hpp b/include/libtorrent/aux_/lsd.hpp index 7f91dd564..5e433bbb8 100644 --- a/include/libtorrent/aux_/lsd.hpp +++ b/include/libtorrent/aux_/lsd.hpp @@ -35,9 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent { -namespace aux -{ +namespace libtorrent { namespace aux { struct TORRENT_EXTRA_EXPORT lsd_callback { virtual void on_lsd_peer(tcp::endpoint const& peer, sha1_hash const& ih) = 0; diff --git a/include/libtorrent/aux_/merkle.hpp b/include/libtorrent/aux_/merkle.hpp index af73d3df1..02b1a1011 100644 --- a/include/libtorrent/aux_/merkle.hpp +++ b/include/libtorrent/aux_/merkle.hpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { + TORRENT_EXTRA_EXPORT int merkle_num_leafs(int); TORRENT_EXTRA_EXPORT int merkle_num_nodes(int); TORRENT_EXTRA_EXPORT int merkle_get_parent(int); diff --git a/include/libtorrent/aux_/openssl.hpp b/include/libtorrent/aux_/openssl.hpp index 59b23bcf6..d9d985b34 100644 --- a/include/libtorrent/aux_/openssl.hpp +++ b/include/libtorrent/aux_/openssl.hpp @@ -63,9 +63,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for sk_GENERAL_NAME_value #include // for GENERAL_NAME -namespace libtorrent { -namespace aux { - +namespace libtorrent { namespace aux { inline void openssl_set_tlsext_hostname(SSL* s, char const* name) { #if OPENSSL_VERSION_NUMBER >= 0x90812f diff --git a/include/libtorrent/aux_/path.hpp b/include/libtorrent/aux_/path.hpp index 720663b24..f301364db 100644 --- a/include/libtorrent/aux_/path.hpp +++ b/include/libtorrent/aux_/path.hpp @@ -84,8 +84,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/time.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct file_status { std::int64_t file_size = 0; diff --git a/include/libtorrent/aux_/portmap.hpp b/include/libtorrent/aux_/portmap.hpp index 836b6c238..57483e01f 100644 --- a/include/libtorrent/aux_/portmap.hpp +++ b/include/libtorrent/aux_/portmap.hpp @@ -35,9 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent { -namespace aux -{ +namespace libtorrent { namespace aux { // TODO: move this for a better place and integrate it with // portmap error alerts enum class portmap_transport : std::uint8_t diff --git a/include/libtorrent/aux_/proxy_settings.hpp b/include/libtorrent/aux_/proxy_settings.hpp index de17a4eea..124ccaf32 100644 --- a/include/libtorrent/aux_/proxy_settings.hpp +++ b/include/libtorrent/aux_/proxy_settings.hpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include namespace libtorrent { + struct settings_pack; namespace aux { diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index d997aacd1..b7038eae3 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -100,8 +100,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for va_start, va_end #include -namespace libtorrent -{ +namespace libtorrent { struct plugin; struct upnp; @@ -112,8 +111,8 @@ namespace libtorrent struct cache_info; struct torrent_handle; - namespace dht - { +namespace dht { + struct dht_tracker; class item; } @@ -176,8 +175,8 @@ namespace libtorrent std::shared_ptr udp_sock; }; - namespace aux - { +namespace aux { + struct session_impl; struct session_settings; diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index 73d88cdd9..565110024 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -52,8 +52,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { + class peer_connection; class torrent; #ifndef TORRENT_NO_DEPRECATE @@ -82,15 +82,15 @@ namespace libtorrent struct resolver_interface; #ifndef TORRENT_DISABLE_DHT - namespace dht - { +namespace dht { + struct dht_tracker; } #endif } -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + struct proxy_settings; struct session_settings; diff --git a/include/libtorrent/aux_/session_settings.hpp b/include/libtorrent/aux_/session_settings.hpp index 5c205638d..c50afcdbb 100644 --- a/include/libtorrent/aux_/session_settings.hpp +++ b/include/libtorrent/aux_/session_settings.hpp @@ -41,13 +41,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + TORRENT_EXTRA_EXPORT void initialize_default_settings(aux::session_settings& s); } -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { struct TORRENT_EXTRA_EXPORT session_settings { diff --git a/include/libtorrent/aux_/storage_utils.hpp b/include/libtorrent/aux_/storage_utils.hpp index 95d031c03..3ae72f27e 100644 --- a/include/libtorrent/aux_/storage_utils.hpp +++ b/include/libtorrent/aux_/storage_utils.hpp @@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for iovec #endif -namespace libtorrent -{ +namespace libtorrent { + class file_storage; struct part_file; struct storage_error; diff --git a/include/libtorrent/aux_/suggest_piece.hpp b/include/libtorrent/aux_/suggest_piece.hpp index c95455824..a2af61bb5 100644 --- a/include/libtorrent/aux_/suggest_piece.hpp +++ b/include/libtorrent/aux_/suggest_piece.hpp @@ -42,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace aux { - struct suggest_piece { // pick at most n piece indices that are _not_ in p (which represents diff --git a/include/libtorrent/aux_/throw.hpp b/include/libtorrent/aux_/throw.hpp index 6123bf0f7..f653fe01d 100644 --- a/include/libtorrent/aux_/throw.hpp +++ b/include/libtorrent/aux_/throw.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + template void TORRENT_NO_RETURN throw_ex(Args&&... args) { diff --git a/include/libtorrent/aux_/time.hpp b/include/libtorrent/aux_/time.hpp index 407eacecf..763a8b7e3 100644 --- a/include/libtorrent/aux_/time.hpp +++ b/include/libtorrent/aux_/time.hpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/time.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + // returns the current time, as represented by time_point. The // resolution of this timer is about 100 ms. TORRENT_EXTRA_EXPORT time_point time_now(); diff --git a/include/libtorrent/aux_/win_crypto_provider.hpp b/include/libtorrent/aux_/win_crypto_provider.hpp index fdbc0164c..f522eda04 100644 --- a/include/libtorrent/aux_/win_crypto_provider.hpp +++ b/include/libtorrent/aux_/win_crypto_provider.hpp @@ -42,8 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { inline HCRYPTPROV crypt_acquire_provider(DWORD provider_type) { diff --git a/include/libtorrent/aux_/win_util.hpp b/include/libtorrent/aux_/win_util.hpp index b6a953fd4..9cd76d426 100644 --- a/include/libtorrent/aux_/win_util.hpp +++ b/include/libtorrent/aux_/win_util.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + template HMODULE get_library_handle() { diff --git a/include/libtorrent/bandwidth_socket.hpp b/include/libtorrent/bandwidth_socket.hpp index c83e30906..510f10ee1 100644 --- a/include/libtorrent/bandwidth_socket.hpp +++ b/include/libtorrent/bandwidth_socket.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/export.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct TORRENT_EXTRA_EXPORT bandwidth_socket { virtual void assign_bandwidth(int channel, int amount) = 0; diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index 9a5f220ee..9a1b5b66c 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -156,8 +156,8 @@ TORRENT_EXTRA_EXPORT char const* parse_int(char const* start , char const* end, char delimiter, std::int64_t& val , bdecode_errors::error_code_enum& ec); -namespace detail -{ +namespace detail { + // internal struct bdecode_token { diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 814446745..d99fa38cf 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -77,15 +77,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/io.hpp" // for write_string #include "libtorrent/string_util.hpp" // for is_digit -namespace libtorrent -{ +namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE using invalid_encoding = system_error; #endif - namespace detail - { +namespace detail { + template ::value>::type> int write_integer(OutIt& out, In data) diff --git a/include/libtorrent/bitfield.hpp b/include/libtorrent/bitfield.hpp index 2c5a36232..dfa3bd233 100644 --- a/include/libtorrent/bitfield.hpp +++ b/include/libtorrent/bitfield.hpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for memset and memcpy #include // uint32_t -namespace libtorrent -{ +namespace libtorrent { + // The bitfield type stores any number of bits as a bitfield // in a heap allocated array. struct TORRENT_EXPORT bitfield diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index aee767236..98511ef86 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -53,14 +53,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/vector.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { + struct disk_io_job; struct storage_interface; struct cache_status; struct counters; - namespace aux - { +namespace aux { + struct session_settings; struct block_cache_reference; } diff --git a/include/libtorrent/bloom_filter.hpp b/include/libtorrent/bloom_filter.hpp index 26ee279ff..7c2b49c24 100644 --- a/include/libtorrent/bloom_filter.hpp +++ b/include/libtorrent/bloom_filter.hpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for log() #include -namespace libtorrent -{ +namespace libtorrent { + TORRENT_EXTRA_EXPORT void set_bits(std::uint8_t const* b, std::uint8_t* bits, int len); TORRENT_EXTRA_EXPORT bool has_bits(std::uint8_t const* b, std::uint8_t const* bits, int len); TORRENT_EXTRA_EXPORT int count_zero_bits(std::uint8_t const* bits, int len); diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index 754717fcd..bdf141b6e 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + // TODO: 2 factor these functions out TORRENT_EXTRA_EXPORT bool is_local(address const& a); TORRENT_EXTRA_EXPORT bool is_loopback(address const& addr); diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index fbd599e0a..3dfed3439 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/pe_crypto.hpp" -namespace libtorrent -{ +namespace libtorrent { + class torrent; #ifndef TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/chained_buffer.hpp b/include/libtorrent/chained_buffer.hpp index 845c8dfd6..950a4e580 100644 --- a/include/libtorrent/chained_buffer.hpp +++ b/include/libtorrent/chained_buffer.hpp @@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_CPP98_DEQUE 0 #endif -namespace libtorrent -{ +namespace libtorrent { + // TODO: 2 this type should probably be renamed to send_buffer struct TORRENT_EXTRA_EXPORT chained_buffer : private single_threaded { diff --git a/include/libtorrent/choker.hpp b/include/libtorrent/choker.hpp index 880820729..1e5016e85 100644 --- a/include/libtorrent/choker.hpp +++ b/include/libtorrent/choker.hpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" // for time_duration #include -namespace libtorrent -{ +namespace libtorrent { + namespace aux { struct session_settings; } class peer_connection; diff --git a/include/libtorrent/close_reason.hpp b/include/libtorrent/close_reason.hpp index c557fc089..620459afb 100644 --- a/include/libtorrent/close_reason.hpp +++ b/include/libtorrent/close_reason.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { + // internal: these are all the reasons to disconnect a peer // all reasons caused by the peer sending unexpected data // are 256 and up. diff --git a/include/libtorrent/copy_ptr.hpp b/include/libtorrent/copy_ptr.hpp index 7aa9903e6..73e73552c 100644 --- a/include/libtorrent/copy_ptr.hpp +++ b/include/libtorrent/copy_ptr.hpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_COPY_PTR #define TORRENT_COPY_PTR -namespace libtorrent -{ +namespace libtorrent { + template struct copy_ptr { diff --git a/include/libtorrent/crc32c.hpp b/include/libtorrent/crc32c.hpp index 08e2b0615..1e263d557 100644 --- a/include/libtorrent/crc32c.hpp +++ b/include/libtorrent/crc32c.hpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/export.hpp" -namespace libtorrent -{ +namespace libtorrent { + // this is the crc32c (Castagnoli) polynomial TORRENT_EXTRA_EXPORT std::uint32_t crc32c_32(std::uint32_t v); TORRENT_EXTRA_EXPORT std::uint32_t crc32c(std::uint64_t const* v diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index feb2617ed..299dfd75f 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -88,8 +88,8 @@ POSSIBILITY OF SUCH DAMAGE. // ofstream out("my_torrent.torrent", std::ios_base::binary); // bencode(std::ostream_iterator(out), t.generate()); // -namespace libtorrent -{ +namespace libtorrent { + class torrent_info; // This class holds state for creating a torrent. After having added @@ -366,8 +366,8 @@ namespace libtorrent bool m_include_symlinks:1; }; - namespace detail - { +namespace detail { + inline void nop(piece_index_t) {} } diff --git a/include/libtorrent/deadline_timer.hpp b/include/libtorrent/deadline_timer.hpp index 5fedf8452..4d75a365f 100644 --- a/include/libtorrent/deadline_timer.hpp +++ b/include/libtorrent/deadline_timer.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #endif // SIMULATOR -namespace libtorrent -{ +namespace libtorrent { + #if defined TORRENT_BUILD_SIMULATOR typedef sim::asio::high_resolution_timer deadline_timer; #else diff --git a/include/libtorrent/debug.hpp b/include/libtorrent/debug.hpp index d01708a6c..46b2b85b3 100644 --- a/include/libtorrent/debug.hpp +++ b/include/libtorrent/debug.hpp @@ -62,8 +62,8 @@ const mach_msg_type_number_t task_events_info_count = TASK_EVENTS_INFO_COUNT; std::string demangle(char const* name); -namespace libtorrent -{ +namespace libtorrent { + struct async_t { async_t() : refs(0) {} @@ -173,8 +173,8 @@ namespace libtorrent #endif // TORRENT_ASIO_DEBUGGING -namespace libtorrent -{ +namespace libtorrent { + #if TORRENT_USE_ASSERTS struct TORRENT_EXTRA_EXPORT single_threaded { diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp index cef10fa73..23829e130 100644 --- a/include/libtorrent/disk_buffer_holder.hpp +++ b/include/libtorrent/disk_buffer_holder.hpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + struct disk_io_thread; struct disk_observer; struct disk_buffer_holder; diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index ad6c925de..9f98992fb 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -56,8 +56,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/span.hpp" #include "libtorrent/aux_/storage_utils.hpp" // for iovec_t -namespace libtorrent -{ +namespace libtorrent { + namespace aux { struct session_settings; } class alert; struct disk_observer; diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index f05948fcb..fefef7130 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/sha1_hash.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct storage_interface; struct peer_request; struct disk_observer; diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 6c9523cf8..b30d1772a 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -51,8 +51,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct storage_interface; struct cached_piece_entry; class torrent_info; diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 2a72645d0..edd634ce0 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -53,15 +53,15 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + class alert; struct add_torrent_params; struct counters; class alert_manager; - namespace aux - { +namespace aux { + struct block_cache_reference; } diff --git a/include/libtorrent/disk_io_thread_pool.hpp b/include/libtorrent/disk_io_thread_pool.hpp index 729dd55ec..a35183978 100644 --- a/include/libtorrent/disk_io_thread_pool.hpp +++ b/include/libtorrent/disk_io_thread_pool.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct disk_io_thread_pool; struct pool_thread_interface diff --git a/include/libtorrent/disk_job_pool.hpp b/include/libtorrent/disk_job_pool.hpp index dc7eab021..dd45ee23c 100644 --- a/include/libtorrent/disk_job_pool.hpp +++ b/include/libtorrent/disk_job_pool.hpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct disk_io_job; struct TORRENT_EXTRA_EXPORT disk_job_pool diff --git a/include/libtorrent/disk_observer.hpp b/include/libtorrent/disk_observer.hpp index 6478f01f2..c0b4e210b 100644 --- a/include/libtorrent/disk_observer.hpp +++ b/include/libtorrent/disk_observer.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct TORRENT_EXTRA_EXPORT disk_observer { // called when the disk cache size has dropped diff --git a/include/libtorrent/ed25519.hpp b/include/libtorrent/ed25519.hpp index 350de92e2..654ed8f74 100644 --- a/include/libtorrent/ed25519.hpp +++ b/include/libtorrent/ed25519.hpp @@ -4,8 +4,8 @@ #include "libtorrent/export.hpp" // for TORRENT_EXPORT #include // for size_t -namespace libtorrent -{ +namespace libtorrent { + enum { ed25519_seed_size = 32, diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 287922662..6c4ffef40 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -76,8 +76,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_view.hpp" #include "libtorrent/aux_/aligned_union.hpp" -namespace libtorrent -{ +namespace libtorrent { + #ifndef TORRENT_NO_DEPRECATE struct lazy_entry; // backwards compatibility @@ -85,8 +85,8 @@ namespace libtorrent #endif struct bdecode_node; - namespace aux - { +namespace aux { + #if (__cplusplus > 201103) || (defined _MSC_VER && _MSC_VER >= 1900) // this enables us to compare a string_view against the std::string that's // held by the std::map @@ -342,8 +342,8 @@ namespace libtorrent mutable std::uint8_t m_type_queried:1; }; - namespace detail - { +namespace detail { + TORRENT_EXPORT char const* integer_to_str(char* buf, int size , entry::integer_type val); } diff --git a/include/libtorrent/enum_net.hpp b/include/libtorrent/enum_net.hpp index 3ea7d598a..431b05be0 100644 --- a/include/libtorrent/enum_net.hpp +++ b/include/libtorrent/enum_net.hpp @@ -51,8 +51,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + struct socket_type; // the interface should not have a netmask diff --git a/include/libtorrent/error.hpp b/include/libtorrent/error.hpp index 42240a60d..d9a56f783 100644 --- a/include/libtorrent/error.hpp +++ b/include/libtorrent/error.hpp @@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + namespace error = boost::asio::error; } diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index f5598e285..2b3cf90e8 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/units.hpp" -namespace libtorrent -{ +namespace libtorrent { namespace errors { diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index 9d0ec6bd9..9a499191e 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -168,8 +168,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct peer_plugin; struct peer_request; class entry; diff --git a/include/libtorrent/extensions/smart_ban.hpp b/include/libtorrent/extensions/smart_ban.hpp index 634cb0f09..0f04ca0b2 100644 --- a/include/libtorrent/extensions/smart_ban.hpp +++ b/include/libtorrent/extensions/smart_ban.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + struct torrent_plugin; struct torrent_handle; diff --git a/include/libtorrent/extensions/ut_metadata.hpp b/include/libtorrent/extensions/ut_metadata.hpp index becdf6d14..635c0b6f9 100644 --- a/include/libtorrent/extensions/ut_metadata.hpp +++ b/include/libtorrent/extensions/ut_metadata.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + struct torrent_plugin; struct torrent_handle; diff --git a/include/libtorrent/extensions/ut_pex.hpp b/include/libtorrent/extensions/ut_pex.hpp index 97e7075df..c928804ad 100644 --- a/include/libtorrent/extensions/ut_pex.hpp +++ b/include/libtorrent/extensions/ut_pex.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + struct torrent_plugin; struct torrent_handle; diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 5106cf8d7..927c16855 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -84,8 +84,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/time.hpp" -namespace libtorrent -{ +namespace libtorrent { + #ifdef TORRENT_WINDOWS using handle_type = HANDLE; #else diff --git a/include/libtorrent/file_pool.hpp b/include/libtorrent/file_pool.hpp index 60fa59406..be5c4067a 100644 --- a/include/libtorrent/file_pool.hpp +++ b/include/libtorrent/file_pool.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/storage_defs.hpp" #include "libtorrent/disk_interface.hpp" // for open_file_state -namespace libtorrent -{ +namespace libtorrent { + class file_storage; struct open_file_state; diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index a63b0e186..c83848da8 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_view.hpp" #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { + #ifndef TORRENT_NO_DEPRECATE // information about a file in a file_storage struct TORRENT_DEPRECATED_EXPORT file_entry diff --git a/include/libtorrent/fingerprint.hpp b/include/libtorrent/fingerprint.hpp index 525e7589a..dad5b34d4 100644 --- a/include/libtorrent/fingerprint.hpp +++ b/include/libtorrent/fingerprint.hpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_id.hpp" #include "libtorrent/export.hpp" -namespace libtorrent -{ +namespace libtorrent { // This is a utility function to produce a client ID fingerprint formatted to // the most common convention. diff --git a/include/libtorrent/gzip.hpp b/include/libtorrent/gzip.hpp index 8596c70d7..7348ff154 100644 --- a/include/libtorrent/gzip.hpp +++ b/include/libtorrent/gzip.hpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { TORRENT_EXTRA_EXPORT void inflate_gzip( char const* in, int size diff --git a/include/libtorrent/hasher.hpp b/include/libtorrent/hasher.hpp index 102600d99..bf93b6ced 100644 --- a/include/libtorrent/hasher.hpp +++ b/include/libtorrent/hasher.hpp @@ -60,8 +60,8 @@ extern "C" { #endif #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + // this is a SHA-1 hash class. // // You use it by first instantiating it, then call ``update()`` to feed it diff --git a/include/libtorrent/hasher512.hpp b/include/libtorrent/hasher512.hpp index 8e5aea80b..2bec938f7 100644 --- a/include/libtorrent/hasher512.hpp +++ b/include/libtorrent/hasher512.hpp @@ -61,8 +61,8 @@ extern "C" { #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + using sha512_hash = digest32<512>; // this is a SHA-512 hash class. diff --git a/include/libtorrent/heterogeneous_queue.hpp b/include/libtorrent/heterogeneous_queue.hpp index 030eda0ed..63b0a20ee 100644 --- a/include/libtorrent/heterogeneous_queue.hpp +++ b/include/libtorrent/heterogeneous_queue.hpp @@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace aux { + struct free_deleter { void operator()(char* ptr) { return std::free(ptr); } }; diff --git a/include/libtorrent/hex.hpp b/include/libtorrent/hex.hpp index fe50a12cb..cf7dc3aab 100644 --- a/include/libtorrent/hex.hpp +++ b/include/libtorrent/hex.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + namespace aux { TORRENT_EXTRA_EXPORT int hex_to_int(char in); diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index 1c5dc7852..911d18bc2 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -57,8 +57,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/i2p_stream.hpp" #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { struct http_connection; struct resolver_interface; diff --git a/include/libtorrent/http_parser.hpp b/include/libtorrent/http_parser.hpp index 4210c3bc7..7adb12d7a 100644 --- a/include/libtorrent/http_parser.hpp +++ b/include/libtorrent/http_parser.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/buffer.hpp" -namespace libtorrent -{ +namespace libtorrent { + // return true if the status code is 200, 206, or in the 300-400 range TORRENT_EXTRA_EXPORT bool is_ok_status(int http_status); diff --git a/include/libtorrent/http_seed_connection.hpp b/include/libtorrent/http_seed_connection.hpp index 471f644ed..8af1ff62a 100644 --- a/include/libtorrent/http_seed_connection.hpp +++ b/include/libtorrent/http_seed_connection.hpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/web_connection_base.hpp" #include "libtorrent/piece_block_progress.hpp" -namespace libtorrent -{ +namespace libtorrent { + class torrent; struct peer_request; diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp index 0873518c1..cfe12c0c7 100644 --- a/include/libtorrent/http_tracker_connection.hpp +++ b/include/libtorrent/http_tracker_connection.hpp @@ -44,8 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/i2p_stream.hpp" #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { struct http_connection; class entry; diff --git a/include/libtorrent/identify_client.hpp b/include/libtorrent/identify_client.hpp index 53a41c674..aa8bd5161 100644 --- a/include/libtorrent/identify_client.hpp +++ b/include/libtorrent/identify_client.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. // TODO: hide this declaration when deprecated functions are disabled, and // remove its internal use -namespace libtorrent -{ +namespace libtorrent { + // these functions don't really need to be public. This mechanism of // advertising client software and version is also out-dated. diff --git a/include/libtorrent/instantiate_connection.hpp b/include/libtorrent/instantiate_connection.hpp index 6bd3b6ee3..8ba4d7a15 100644 --- a/include/libtorrent/instantiate_connection.hpp +++ b/include/libtorrent/instantiate_connection.hpp @@ -35,9 +35,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_type.hpp" -namespace libtorrent -{ +namespace libtorrent { + namespace aux { + struct proxy_settings; } diff --git a/include/libtorrent/invariant_check.hpp b/include/libtorrent/invariant_check.hpp index 5ed70ff48..2960fbff8 100644 --- a/include/libtorrent/invariant_check.hpp +++ b/include/libtorrent/invariant_check.hpp @@ -11,8 +11,7 @@ #if TORRENT_USE_INVARIANT_CHECKS -namespace libtorrent -{ +namespace libtorrent { class invariant_access { diff --git a/include/libtorrent/io.hpp b/include/libtorrent/io.hpp index 8c5774ee2..63e79eecb 100644 --- a/include/libtorrent/io.hpp +++ b/include/libtorrent/io.hpp @@ -42,10 +42,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "assert.hpp" -namespace libtorrent -{ - namespace detail - { +namespace libtorrent { + +namespace detail { template struct type {}; // reads an integer from a byte stream diff --git a/include/libtorrent/io_service.hpp b/include/libtorrent/io_service.hpp index f527aeed8..d56113005 100644 --- a/include/libtorrent/io_service.hpp +++ b/include/libtorrent/io_service.hpp @@ -41,8 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #endif // SIMULATOR -namespace libtorrent -{ +namespace libtorrent { + #if defined TORRENT_BUILD_SIMULATOR using sim::asio::io_service; #else diff --git a/include/libtorrent/io_service_fwd.hpp b/include/libtorrent/io_service_fwd.hpp index 6b4922742..64c458ff0 100644 --- a/include/libtorrent/io_service_fwd.hpp +++ b/include/libtorrent/io_service_fwd.hpp @@ -37,16 +37,18 @@ POSSIBILITY OF SUCH DAMAGE. #if defined TORRENT_BUILD_SIMULATOR namespace sim { namespace asio { + struct io_service; }} #else namespace boost { namespace asio { + class io_service; }} #endif -namespace libtorrent -{ +namespace libtorrent { + #if defined TORRENT_BUILD_SIMULATOR typedef sim::asio::io_service io_service; #else diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index e795e9d90..5e8576bba 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -45,8 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { // hidden inline bool operator<=(address const& lhs @@ -63,8 +62,7 @@ struct ip_range std::uint32_t flags; }; -namespace detail -{ +namespace detail { template Addr zero() diff --git a/include/libtorrent/ip_voter.hpp b/include/libtorrent/ip_voter.hpp index c0d05fa0c..717e1a4db 100644 --- a/include/libtorrent/ip_voter.hpp +++ b/include/libtorrent/ip_voter.hpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bloom_filter.hpp" #include "libtorrent/time.hpp" // for time_point -namespace libtorrent -{ +namespace libtorrent { + // this is an object that keeps the state for a single external IP // based on peoples votes struct TORRENT_EXTRA_EXPORT ip_voter diff --git a/include/libtorrent/kademlia/dht_observer.hpp b/include/libtorrent/kademlia/dht_observer.hpp index 03d12e524..d09b3f569 100644 --- a/include/libtorrent/kademlia/dht_observer.hpp +++ b/include/libtorrent/kademlia/dht_observer.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/kademlia/msg.hpp" -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + struct TORRENT_EXTRA_EXPORT dht_logger { #ifndef TORRENT_DISABLE_LOGGING diff --git a/include/libtorrent/kademlia/dht_state.hpp b/include/libtorrent/kademlia/dht_state.hpp index 86a8013b4..b5ce2d70b 100644 --- a/include/libtorrent/kademlia/dht_state.hpp +++ b/include/libtorrent/kademlia/dht_state.hpp @@ -41,14 +41,12 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + struct bdecode_node; } -namespace libtorrent { -namespace dht -{ +namespace libtorrent { namespace dht { // This structure helps to store and load the state // of the ``dht_tracker``. // At this moment the library is only a dual stack diff --git a/include/libtorrent/kademlia/dht_storage.hpp b/include/libtorrent/kademlia/dht_storage.hpp index cec7448b7..9c3450c49 100644 --- a/include/libtorrent/kademlia/dht_storage.hpp +++ b/include/libtorrent/kademlia/dht_storage.hpp @@ -43,15 +43,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct dht_settings; class entry; } -namespace libtorrent { -namespace dht -{ +namespace libtorrent { namespace dht { // This structure hold the relevant counters for the storage struct TORRENT_EXPORT dht_storage_counters { diff --git a/include/libtorrent/kademlia/dht_tracker.hpp b/include/libtorrent/kademlia/dht_tracker.hpp index 5b90fcd05..3827b0ea9 100644 --- a/include/libtorrent/kademlia/dht_tracker.hpp +++ b/include/libtorrent/kademlia/dht_tracker.hpp @@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct counters; struct dht_settings; #ifndef TORRENT_NO_DEPRECATE @@ -53,8 +53,8 @@ namespace libtorrent #endif } -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + struct TORRENT_EXTRA_EXPORT dht_tracker final : udp_socket_interface , std::enable_shared_from_this diff --git a/include/libtorrent/kademlia/direct_request.hpp b/include/libtorrent/kademlia/direct_request.hpp index 44e5f7534..dacea41e7 100644 --- a/include/libtorrent/kademlia/direct_request.hpp +++ b/include/libtorrent/kademlia/direct_request.hpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { struct direct_traversal : traversal_algorithm { diff --git a/include/libtorrent/kademlia/dos_blocker.hpp b/include/libtorrent/kademlia/dos_blocker.hpp index 8b10449be..84a35ea21 100644 --- a/include/libtorrent/kademlia/dos_blocker.hpp +++ b/include/libtorrent/kademlia/dos_blocker.hpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/assert.hpp" -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { struct dht_logger; diff --git a/include/libtorrent/kademlia/ed25519.hpp b/include/libtorrent/kademlia/ed25519.hpp index d921f558c..37719cae2 100644 --- a/include/libtorrent/kademlia/ed25519.hpp +++ b/include/libtorrent/kademlia/ed25519.hpp @@ -40,9 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { -namespace dht -{ +namespace libtorrent { namespace dht { // See documentation of internal random_bytes TORRENT_EXPORT std::array ed25519_create_seed(); diff --git a/include/libtorrent/kademlia/find_data.hpp b/include/libtorrent/kademlia/find_data.hpp index 02a188143..d62b52b14 100644 --- a/include/libtorrent/kademlia/find_data.hpp +++ b/include/libtorrent/kademlia/find_data.hpp @@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { class node; diff --git a/include/libtorrent/kademlia/get_item.hpp b/include/libtorrent/kademlia/get_item.hpp index 256275961..fbffae790 100644 --- a/include/libtorrent/kademlia/get_item.hpp +++ b/include/libtorrent/kademlia/get_item.hpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { class get_item : public find_data { diff --git a/include/libtorrent/kademlia/get_peers.hpp b/include/libtorrent/kademlia/get_peers.hpp index 51e8f094a..d9ca89495 100644 --- a/include/libtorrent/kademlia/get_peers.hpp +++ b/include/libtorrent/kademlia/get_peers.hpp @@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { struct get_peers : find_data { diff --git a/include/libtorrent/kademlia/item.hpp b/include/libtorrent/kademlia/item.hpp index 65af4060d..06b47e440 100644 --- a/include/libtorrent/kademlia/item.hpp +++ b/include/libtorrent/kademlia/item.hpp @@ -39,8 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { // calculate the target hash for an immutable item. TORRENT_EXTRA_EXPORT sha1_hash item_target_id(span v); diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index ee0a4940f..b95f59378 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -50,13 +50,13 @@ POSSIBILITY OF SUCH DAMAGE. #include namespace libtorrent { + struct counters; struct dht_routing_bucket; struct dht_settings; } -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { struct traversal_algorithm; struct dht_observer; diff --git a/include/libtorrent/kademlia/node_entry.hpp b/include/libtorrent/kademlia/node_entry.hpp index 5988e6430..061d0554f 100644 --- a/include/libtorrent/kademlia/node_entry.hpp +++ b/include/libtorrent/kademlia/node_entry.hpp @@ -39,8 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/union_endpoint.hpp" #include "libtorrent/time.hpp" // for time_point -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { struct TORRENT_EXTRA_EXPORT node_entry { diff --git a/include/libtorrent/kademlia/node_id.hpp b/include/libtorrent/kademlia/node_id.hpp index 580be7b51..34febe04d 100644 --- a/include/libtorrent/kademlia/node_id.hpp +++ b/include/libtorrent/kademlia/node_id.hpp @@ -39,8 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { using node_id = libtorrent::sha1_hash; diff --git a/include/libtorrent/kademlia/observer.hpp b/include/libtorrent/kademlia/observer.hpp index ac8ed9d51..8373ca21a 100644 --- a/include/libtorrent/kademlia/observer.hpp +++ b/include/libtorrent/kademlia/observer.hpp @@ -39,9 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { -namespace dht { - +namespace libtorrent { namespace dht { struct dht_observer; struct observer; struct msg; diff --git a/include/libtorrent/kademlia/put_data.hpp b/include/libtorrent/kademlia/put_data.hpp index fb7864387..88657a4b5 100644 --- a/include/libtorrent/kademlia/put_data.hpp +++ b/include/libtorrent/kademlia/put_data.hpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + struct msg; class node; diff --git a/include/libtorrent/kademlia/refresh.hpp b/include/libtorrent/kademlia/refresh.hpp index be7b09c74..318ccd9b5 100644 --- a/include/libtorrent/kademlia/refresh.hpp +++ b/include/libtorrent/kademlia/refresh.hpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { class bootstrap : public get_peers { diff --git a/include/libtorrent/kademlia/routing_table.hpp b/include/libtorrent/kademlia/routing_table.hpp index 9dfcd37ba..4eb2fceca 100644 --- a/include/libtorrent/kademlia/routing_table.hpp +++ b/include/libtorrent/kademlia/routing_table.hpp @@ -47,16 +47,16 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + #ifndef TORRENT_NO_DEPRECATE struct session_status; #endif struct dht_routing_bucket; } -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + struct dht_logger; typedef aux::vector bucket_t; diff --git a/include/libtorrent/kademlia/rpc_manager.hpp b/include/libtorrent/kademlia/rpc_manager.hpp index 326c9db7c..88467d1a7 100644 --- a/include/libtorrent/kademlia/rpc_manager.hpp +++ b/include/libtorrent/kademlia/rpc_manager.hpp @@ -47,8 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct dht_settings; class entry; } -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { struct dht_logger; struct udp_socket_interface; diff --git a/include/libtorrent/kademlia/traversal_algorithm.hpp b/include/libtorrent/kademlia/traversal_algorithm.hpp index 5eed1b2b1..377bff734 100644 --- a/include/libtorrent/kademlia/traversal_algorithm.hpp +++ b/include/libtorrent/kademlia/traversal_algorithm.hpp @@ -47,8 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { struct dht_lookup; } -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { class node; diff --git a/include/libtorrent/kademlia/types.hpp b/include/libtorrent/kademlia/types.hpp index 872cb0f7e..6e183f7c9 100644 --- a/include/libtorrent/kademlia/types.hpp +++ b/include/libtorrent/kademlia/types.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + struct public_key { public_key() = default; diff --git a/include/libtorrent/lazy_entry.hpp b/include/libtorrent/lazy_entry.hpp index 848e2a49c..bbe7569a5 100644 --- a/include/libtorrent/lazy_entry.hpp +++ b/include/libtorrent/lazy_entry.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/bdecode.hpp" // for error codes -namespace libtorrent -{ +namespace libtorrent { + struct lazy_entry; // This function decodes bencoded_ data. diff --git a/include/libtorrent/link.hpp b/include/libtorrent/link.hpp index e819027e1..ae0dbf03e 100644 --- a/include/libtorrent/link.hpp +++ b/include/libtorrent/link.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct link { link() : index(-1) {} diff --git a/include/libtorrent/linked_list.hpp b/include/libtorrent/linked_list.hpp index fba3e5f73..663948335 100644 --- a/include/libtorrent/linked_list.hpp +++ b/include/libtorrent/linked_list.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { + template struct list_node { diff --git a/include/libtorrent/lsd.hpp b/include/libtorrent/lsd.hpp index 3914022f1..f128b26ec 100644 --- a/include/libtorrent/lsd.hpp +++ b/include/libtorrent/lsd.hpp @@ -39,8 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/deadline_timer.hpp" #include "libtorrent/aux_/lsd.hpp" -namespace libtorrent -{ +namespace libtorrent { class lsd : public std::enable_shared_from_this { diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index aebe4143e..aec73c23e 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/add_torrent_params.hpp" #include "libtorrent/string_view.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct torrent_handle; class session; diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index d2f44e88d..1a9742e3d 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/portmap.hpp" #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { struct TORRENT_EXTRA_EXPORT natpmp : std::enable_shared_from_this diff --git a/include/libtorrent/netlink.hpp b/include/libtorrent/netlink.hpp index 7950fcaaa..9e26622d8 100644 --- a/include/libtorrent/netlink.hpp +++ b/include/libtorrent/netlink.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + template class basic_nl_endpoint { diff --git a/include/libtorrent/operations.hpp b/include/libtorrent/operations.hpp index b747bcde7..943fa5e55 100644 --- a/include/libtorrent/operations.hpp +++ b/include/libtorrent/operations.hpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_OPERATIONS_HPP_INCLUDED #define TORRENT_OPERATIONS_HPP_INCLUDED -namespace libtorrent -{ +namespace libtorrent { + // these constants are used to identify the operation that failed, causing a // peer to disconnect enum operation_t diff --git a/include/libtorrent/packet_buffer.hpp b/include/libtorrent/packet_buffer.hpp index c7cdfa843..932689326 100644 --- a/include/libtorrent/packet_buffer.hpp +++ b/include/libtorrent/packet_buffer.hpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for unique_ptr -namespace libtorrent -{ +namespace libtorrent { + struct packet; // this is a circular buffer that automatically resizes diff --git a/include/libtorrent/packet_pool.hpp b/include/libtorrent/packet_pool.hpp index f5f8c89e9..b0556397a 100644 --- a/include/libtorrent/packet_pool.hpp +++ b/include/libtorrent/packet_pool.hpp @@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + // internal: some MTU and protocol header sizes constants constexpr int TORRENT_IPV4_HEADER = 20; constexpr int TORRENT_IPV6_HEADER = 40; diff --git a/include/libtorrent/parse_url.hpp b/include/libtorrent/parse_url.hpp index 492e73e02..e120434bb 100644 --- a/include/libtorrent/parse_url.hpp +++ b/include/libtorrent/parse_url.hpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { // returns protocol, auth, hostname, port, path TORRENT_EXTRA_EXPORT std::tuple; diff --git a/include/libtorrent/pe_crypto.hpp b/include/libtorrent/pe_crypto.hpp index 07adb8534..ea898e217 100644 --- a/include/libtorrent/pe_crypto.hpp +++ b/include/libtorrent/pe_crypto.hpp @@ -53,8 +53,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + namespace mp = boost::multiprecision; using key_t = mp::number>; diff --git a/include/libtorrent/peer.hpp b/include/libtorrent/peer.hpp index fa0234a31..e033f6247 100644 --- a/include/libtorrent/peer.hpp +++ b/include/libtorrent/peer.hpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_id.hpp" #include "libtorrent/address.hpp" -namespace libtorrent -{ +namespace libtorrent { struct TORRENT_EXTRA_EXPORT peer_entry { diff --git a/include/libtorrent/peer_class.hpp b/include/libtorrent/peer_class.hpp index 73914a038..8eee1bd8d 100644 --- a/include/libtorrent/peer_class.hpp +++ b/include/libtorrent/peer_class.hpp @@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace aux { + struct peer_class_tag; } diff --git a/include/libtorrent/peer_class_type_filter.hpp b/include/libtorrent/peer_class_type_filter.hpp index a9758bf9c..1629f59ae 100644 --- a/include/libtorrent/peer_class_type_filter.hpp +++ b/include/libtorrent/peer_class_type_filter.hpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for memset #include -namespace libtorrent -{ +namespace libtorrent { // ``peer_class_type_filter`` is a simple container for rules for adding and subtracting // peer-classes from peers. It is applied *after* the peer class filter is applied (which diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 6b814ee29..4f3134985 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -75,8 +75,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + class torrent; struct torrent_peer; struct disk_interface; @@ -85,8 +85,8 @@ namespace libtorrent struct peer_plugin; #endif - namespace aux - { +namespace aux { + struct session_interface; } diff --git a/include/libtorrent/peer_connection_handle.hpp b/include/libtorrent/peer_connection_handle.hpp index 341406d6f..d49145ece 100644 --- a/include/libtorrent/peer_connection_handle.hpp +++ b/include/libtorrent/peer_connection_handle.hpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection.hpp" // for connection_type #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { class bt_peer_connection; struct torrent_handle; diff --git a/include/libtorrent/peer_connection_interface.hpp b/include/libtorrent/peer_connection_interface.hpp index 45789ab2e..03b692194 100644 --- a/include/libtorrent/peer_connection_interface.hpp +++ b/include/libtorrent/peer_connection_interface.hpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/operations.hpp" // for operation_t enum -namespace libtorrent -{ +namespace libtorrent { + struct torrent_peer; class stat; struct peer_info; diff --git a/include/libtorrent/peer_id.hpp b/include/libtorrent/peer_id.hpp index 3027416d6..9126e6825 100644 --- a/include/libtorrent/peer_id.hpp +++ b/include/libtorrent/peer_id.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" -namespace libtorrent -{ +namespace libtorrent { + using peer_id = sha1_hash; } diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index a6f02889c..33e087df1 100644 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -41,8 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/units.hpp" -namespace libtorrent -{ +namespace libtorrent { + // holds information and statistics about one peer // that libtorrent is connected to struct TORRENT_EXPORT peer_info diff --git a/include/libtorrent/peer_list.hpp b/include/libtorrent/peer_list.hpp index b8213eaca..c9f72c267 100644 --- a/include/libtorrent/peer_list.hpp +++ b/include/libtorrent/peer_list.hpp @@ -48,8 +48,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection_interface.hpp" #include "libtorrent/aux_/deque.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct ip_filter; class port_filter; struct torrent_peer_allocator_interface; diff --git a/include/libtorrent/peer_request.hpp b/include/libtorrent/peer_request.hpp index 8377e1ce6..ed2c67a47 100644 --- a/include/libtorrent/peer_request.hpp +++ b/include/libtorrent/peer_request.hpp @@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/units.hpp" -namespace libtorrent -{ +namespace libtorrent { // represents a byte range within a piece. Internally this is // is used for incoming piece requests. diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 318616299..c4bebff48 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct TORRENT_EXTRA_EXPORT counters { // TODO: move this out of counters diff --git a/include/libtorrent/piece_block.hpp b/include/libtorrent/piece_block.hpp index 3d2cd54e7..0fe8f274f 100644 --- a/include/libtorrent/piece_block.hpp +++ b/include/libtorrent/piece_block.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/units.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct TORRENT_EXTRA_EXPORT piece_block { static const piece_block invalid; diff --git a/include/libtorrent/piece_block_progress.hpp b/include/libtorrent/piece_block_progress.hpp index 3e26af739..d2b48ae73 100644 --- a/include/libtorrent/piece_block_progress.hpp +++ b/include/libtorrent/piece_block_progress.hpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/units.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct piece_block_progress { constexpr static piece_index_t invalid_index{-1}; diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 5ba255340..83235b477 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -58,8 +58,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/vector.hpp" #include "libtorrent/aux_/typed_span.hpp" -namespace libtorrent -{ +namespace libtorrent { class torrent; class peer_connection; diff --git a/include/libtorrent/platform_util.hpp b/include/libtorrent/platform_util.hpp index d7dc72842..a988fd8e8 100644 --- a/include/libtorrent/platform_util.hpp +++ b/include/libtorrent/platform_util.hpp @@ -3,8 +3,8 @@ #include -namespace libtorrent -{ +namespace libtorrent { + int max_open_files(); std::int64_t total_physical_ram(); diff --git a/include/libtorrent/random.hpp b/include/libtorrent/random.hpp index bba162228..fe24b0b09 100644 --- a/include/libtorrent/random.hpp +++ b/include/libtorrent/random.hpp @@ -37,10 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ - namespace aux - { +namespace libtorrent { namespace aux { + TORRENT_EXTRA_EXPORT std::mt19937& random_engine(); template diff --git a/include/libtorrent/read_resume_data.hpp b/include/libtorrent/read_resume_data.hpp index a711686bf..b3cd64573 100644 --- a/include/libtorrent/read_resume_data.hpp +++ b/include/libtorrent/read_resume_data.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/export.hpp" #include "libtorrent/span.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct add_torrent_params; struct bdecode_node; diff --git a/include/libtorrent/request_blocks.hpp b/include/libtorrent/request_blocks.hpp index a5070d8d2..6cad74e74 100644 --- a/include/libtorrent/request_blocks.hpp +++ b/include/libtorrent/request_blocks.hpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_REQUEST_BLOCKS_HPP_INCLUDED #define TORRENT_REQUEST_BLOCKS_HPP_INCLUDED -namespace libtorrent -{ +namespace libtorrent { + class torrent; class peer_connection; diff --git a/include/libtorrent/resolve_links.hpp b/include/libtorrent/resolve_links.hpp index c53cda967..0e62d2393 100644 --- a/include/libtorrent/resolve_links.hpp +++ b/include/libtorrent/resolve_links.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/units.hpp" #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { + class torrent_info; #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS diff --git a/include/libtorrent/resolver.hpp b/include/libtorrent/resolver.hpp index 5b70bf4a7..0d873e56e 100644 --- a/include/libtorrent/resolver.hpp +++ b/include/libtorrent/resolver.hpp @@ -46,8 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/resolver_interface.hpp" #include "libtorrent/address.hpp" -namespace libtorrent -{ +namespace libtorrent { struct TORRENT_EXTRA_EXPORT resolver final : resolver_interface { diff --git a/include/libtorrent/resolver_interface.hpp b/include/libtorrent/resolver_interface.hpp index 2910741bb..b01d8724c 100644 --- a/include/libtorrent/resolver_interface.hpp +++ b/include/libtorrent/resolver_interface.hpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/time.hpp" -namespace libtorrent -{ +namespace libtorrent { struct TORRENT_EXTRA_EXPORT resolver_interface { diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 8c02020ff..4be1a72ae 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -49,8 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for snprintf #endif -namespace libtorrent -{ +namespace libtorrent { + struct plugin; // The default values of the session settings are set for a regular @@ -93,8 +93,8 @@ namespace libtorrent void TORRENT_EXPORT TORRENT_CFG(); - namespace aux - { +namespace aux { + struct session_impl; } diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 54281e296..352fddaac 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -51,8 +51,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -namespace libtorrent -{ +namespace libtorrent { + struct plugin; struct torrent_plugin; class torrent; diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 468d334ab..d2fb345c9 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -42,8 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE diff --git a/include/libtorrent/session_stats.hpp b/include/libtorrent/session_stats.hpp index dc03737a6..b22dec75e 100644 --- a/include/libtorrent/session_stats.hpp +++ b/include/libtorrent/session_stats.hpp @@ -37,8 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { // describes one statistics metric from the session. For more information, // see the session-statistics_ section. diff --git a/include/libtorrent/session_status.hpp b/include/libtorrent/session_status.hpp index 1d708762a..40432ec52 100644 --- a/include/libtorrent/session_status.hpp +++ b/include/libtorrent/session_status.hpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE // holds counters and gauges for the uTP sockets diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index d287f738f..4f44b7dad 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -53,8 +53,8 @@ POSSIBILITY OF SUCH DAMAGE. // that will be sent to the tracker. The user-agent will also be used to identify the // client with other peers. // -namespace libtorrent -{ +namespace libtorrent { + namespace aux { struct session_impl; struct session_settings; } struct settings_pack; diff --git a/include/libtorrent/sha1.hpp b/include/libtorrent/sha1.hpp index c22c5087c..b2eb67a87 100644 --- a/include/libtorrent/sha1.hpp +++ b/include/libtorrent/sha1.hpp @@ -16,8 +16,7 @@ changelog at the end of sha1.cpp #include "libtorrent/config.hpp" #include -namespace libtorrent -{ +namespace libtorrent { struct sha1_ctx { diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 292e6bca8..214d1c08b 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -48,11 +48,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif // TORRENT_USE_IOSTREAM -namespace libtorrent -{ +namespace libtorrent { + // TODO: find a better place for these functions - namespace aux - { +namespace aux { + TORRENT_EXTRA_EXPORT void bits_shift_left(typed_span number, int n); TORRENT_EXTRA_EXPORT void bits_shift_right(typed_span number, int n); } diff --git a/include/libtorrent/sha512.hpp b/include/libtorrent/sha512.hpp index 39613f0db..09461d5f8 100644 --- a/include/libtorrent/sha512.hpp +++ b/include/libtorrent/sha512.hpp @@ -4,8 +4,7 @@ #include "libtorrent/config.hpp" #include -namespace libtorrent -{ +namespace libtorrent { struct sha512_ctx { diff --git a/include/libtorrent/sliding_average.hpp b/include/libtorrent/sliding_average.hpp index 7ea6243b8..14174057c 100644 --- a/include/libtorrent/sliding_average.hpp +++ b/include/libtorrent/sliding_average.hpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for std::abs -namespace libtorrent -{ +namespace libtorrent { // an exponential moving average accumulator. Add samples to it and it keeps // track of a moving mean value and an average deviation diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index 17b0d17d4..e522137aa 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -65,8 +65,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { #if defined TORRENT_BUILD_SIMULATOR using sim::asio::ip::udp; diff --git a/include/libtorrent/socket_io.hpp b/include/libtorrent/socket_io.hpp index d89f70a92..c2974618f 100644 --- a/include/libtorrent/socket_io.hpp +++ b/include/libtorrent/socket_io.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_view.hpp" #include -namespace libtorrent -{ +namespace libtorrent { + TORRENT_EXTRA_EXPORT std::string print_address(address const& addr); TORRENT_EXTRA_EXPORT std::string print_endpoint(address const& addr, int port); TORRENT_EXTRA_EXPORT std::string print_endpoint(tcp::endpoint const& ep); @@ -55,8 +55,8 @@ namespace libtorrent TORRENT_EXTRA_EXPORT std::string endpoint_to_bytes(udp::endpoint const& ep); TORRENT_EXTRA_EXPORT sha1_hash hash_address(address const& ip); - namespace detail - { +namespace detail { + template size_t address_size(Proto p) { diff --git a/include/libtorrent/socket_type.hpp b/include/libtorrent/socket_type.hpp index 84d2e4f49..6673e2222 100644 --- a/include/libtorrent/socket_type.hpp +++ b/include/libtorrent/socket_type.hpp @@ -129,8 +129,7 @@ POSSIBILITY OF SUCH DAMAGE. default: TORRENT_ASSERT_FAIL(); return def; \ } -namespace libtorrent -{ +namespace libtorrent { template struct socket_type_int_impl diff --git a/include/libtorrent/socket_type_fwd.hpp b/include/libtorrent/socket_type_fwd.hpp index a2d16ad79..cf6098b67 100644 --- a/include/libtorrent/socket_type_fwd.hpp +++ b/include/libtorrent/socket_type_fwd.hpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SOCKET_TYPE_FWD_HPP #define TORRENT_SOCKET_TYPE_FWD_HPP -namespace libtorrent -{ +namespace libtorrent { + struct socket_type; } diff --git a/include/libtorrent/socks5_stream.hpp b/include/libtorrent/socks5_stream.hpp index b5f7cbbb8..1c078335d 100644 --- a/include/libtorrent/socks5_stream.hpp +++ b/include/libtorrent/socks5_stream.hpp @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" // for to_string namespace libtorrent { + namespace socks_error { // SOCKS5 error values. If an error_code has the diff --git a/include/libtorrent/span.hpp b/include/libtorrent/span.hpp index 8e5bb375c..0bfe6375b 100644 --- a/include/libtorrent/span.hpp +++ b/include/libtorrent/span.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { + template struct span { diff --git a/include/libtorrent/ssl_stream.hpp b/include/libtorrent/ssl_stream.hpp index aff321a19..7f0908d0f 100644 --- a/include/libtorrent/ssl_stream.hpp +++ b/include/libtorrent/ssl_stream.hpp @@ -52,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace ssl { + #if defined TORRENT_BUILD_SIMULATOR using sim::asio::ssl::context; using sim::asio::ssl::stream_base; diff --git a/include/libtorrent/stack_allocator.hpp b/include/libtorrent/stack_allocator.hpp index 2f3698137..d7cf2159e 100644 --- a/include/libtorrent/stack_allocator.hpp +++ b/include/libtorrent/stack_allocator.hpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for vsnprintf #include -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + struct allocation_slot { allocation_slot() : m_idx(-1) {} diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index 5657657d3..fe908cd3d 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { + class TORRENT_EXTRA_EXPORT stat_channel { public: diff --git a/include/libtorrent/stat_cache.hpp b/include/libtorrent/stat_cache.hpp index 4c8e8fb16..1ca33b161 100644 --- a/include/libtorrent/stat_cache.hpp +++ b/include/libtorrent/stat_cache.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/units.hpp" #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct TORRENT_EXTRA_EXPORT stat_cache { stat_cache(); diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index e0ba9f00b..260be586d 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -126,8 +126,8 @@ POSSIBILITY OF SUCH DAMAGE. // { // return new temp_storage(*params.files); // } -namespace libtorrent -{ +namespace libtorrent { + class session; struct file_pool; namespace aux { struct session_settings; } diff --git a/include/libtorrent/storage_defs.hpp b/include/libtorrent/storage_defs.hpp index e48f1b16d..db2250fa8 100644 --- a/include/libtorrent/storage_defs.hpp +++ b/include/libtorrent/storage_defs.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct TORRENT_EXPORT storage_interface; class file_storage; struct file_pool; diff --git a/include/libtorrent/string_util.hpp b/include/libtorrent/string_util.hpp index a62fba78a..4ae4034e5 100644 --- a/include/libtorrent/string_util.hpp +++ b/include/libtorrent/string_util.hpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for std::array -namespace libtorrent -{ +namespace libtorrent { + TORRENT_EXTRA_EXPORT bool is_alpha(char c); TORRENT_EXTRA_EXPORT diff --git a/include/libtorrent/string_view.hpp b/include/libtorrent/string_view.hpp index 9b70a03af..0df020475 100644 --- a/include/libtorrent/string_view.hpp +++ b/include/libtorrent/string_view.hpp @@ -40,19 +40,23 @@ POSSIBILITY OF SUCH DAMAGE. #if BOOST_VERSION < 106100 #include namespace libtorrent { + using string_view = boost::string_ref; using wstring_view = boost::wstring_ref; } #else #include namespace libtorrent { + using string_view = boost::string_view; using wstring_view = boost::wstring_view; } #endif namespace libtorrent { + inline namespace literals { + constexpr string_view operator""_sv(char const* str, std::size_t len) { return string_view(str, len); } } diff --git a/include/libtorrent/tailqueue.hpp b/include/libtorrent/tailqueue.hpp index 71a3a8682..0a3651ce5 100644 --- a/include/libtorrent/tailqueue.hpp +++ b/include/libtorrent/tailqueue.hpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { + template struct tailqueue_node { diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 5abc53a55..4301a59c2 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -82,8 +82,8 @@ POSSIBILITY OF SUCH DAMAGE. // logic #define TORRENT_DEBUG_STREAMING 0 -namespace libtorrent -{ +namespace libtorrent { + class http_parser; struct storage_interface; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 731e7cc90..936f7ef3e 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -54,10 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/units.hpp" #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ - namespace aux - { +namespace libtorrent { namespace aux { + struct session_impl; } diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index ec2321e50..152b3f306 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -55,8 +55,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/announce_entry.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { + class peer_connection; class entry; struct announce_entry; diff --git a/include/libtorrent/torrent_peer.hpp b/include/libtorrent/torrent_peer.hpp index 5834249ac..4491bc7d9 100644 --- a/include/libtorrent/torrent_peer.hpp +++ b/include/libtorrent/torrent_peer.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/socket.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct peer_connection_interface; struct external_ip; diff --git a/include/libtorrent/torrent_peer_allocator.hpp b/include/libtorrent/torrent_peer_allocator.hpp index 66513e99b..c548e7b08 100644 --- a/include/libtorrent/torrent_peer_allocator.hpp +++ b/include/libtorrent/torrent_peer_allocator.hpp @@ -42,8 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { struct TORRENT_EXTRA_EXPORT torrent_peer_allocator_interface { diff --git a/include/libtorrent/torrent_status.hpp b/include/libtorrent/torrent_status.hpp index e03e722c7..45d81d2c2 100644 --- a/include/libtorrent/torrent_status.hpp +++ b/include/libtorrent/torrent_status.hpp @@ -45,8 +45,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + // holds a snapshot of the status of a torrent, as queried by // torrent_handle::status(). struct TORRENT_EXPORT torrent_status diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 8b1da8ca3..a733175a2 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -63,8 +63,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct request_callback; class tracker_manager; struct timeout_handler; diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index 7e2d1f1fe..3c7deadc8 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { + struct socks5; class TORRENT_EXTRA_EXPORT udp_socket : single_threaded diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index f5946c36c..4bdf68dc4 100644 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/span.hpp" -namespace libtorrent -{ +namespace libtorrent { + class TORRENT_EXTRA_EXPORT udp_tracker_connection: public tracker_connection { friend class tracker_manager; diff --git a/include/libtorrent/union_endpoint.hpp b/include/libtorrent/union_endpoint.hpp index 912139cab..3410d15a1 100644 --- a/include/libtorrent/union_endpoint.hpp +++ b/include/libtorrent/union_endpoint.hpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/address.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct union_address { union_address() { *this = address(); } diff --git a/include/libtorrent/units.hpp b/include/libtorrent/units.hpp index d9a0fc2e6..eacca0fa4 100644 --- a/include/libtorrent/units.hpp +++ b/include/libtorrent/units.hpp @@ -41,9 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -namespace libtorrent { -namespace aux { - +namespace libtorrent { namespace aux { template struct difference_tag {}; diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index 7daca369e..d207760a7 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -48,8 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { namespace upnp_errors { diff --git a/include/libtorrent/utf8.hpp b/include/libtorrent/utf8.hpp index ff1208a84..22e6527df 100644 --- a/include/libtorrent/utf8.hpp +++ b/include/libtorrent/utf8.hpp @@ -45,8 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_view.hpp" #include "libtorrent/error_code.hpp" -namespace libtorrent -{ +namespace libtorrent { namespace utf8_errors { diff --git a/include/libtorrent/utp_socket_manager.hpp b/include/libtorrent/utp_socket_manager.hpp index b50b84e1d..882238f25 100644 --- a/include/libtorrent/utp_socket_manager.hpp +++ b/include/libtorrent/utp_socket_manager.hpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/span.hpp" #include "libtorrent/packet_pool.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct utp_stream; struct utp_socket_impl; struct counters; diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index ec443768e..bccdad2f4 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -49,8 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { + #ifndef TORRENT_UTP_LOG_ENABLE #define TORRENT_UTP_LOG 0 #define TORRENT_VERBOSE_UTP_LOG 0 diff --git a/include/libtorrent/web_connection_base.hpp b/include/libtorrent/web_connection_base.hpp index 92bf5661f..175de072f 100644 --- a/include/libtorrent/web_connection_base.hpp +++ b/include/libtorrent/web_connection_base.hpp @@ -45,8 +45,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/http_parser.hpp" -namespace libtorrent -{ +namespace libtorrent { + class torrent; class TORRENT_EXTRA_EXPORT web_connection_base diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index 4bb8bb94f..b5129c9c3 100644 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/operations.hpp" // for operation_t enum #include "libtorrent/aux_/vector.hpp" -namespace libtorrent -{ +namespace libtorrent { + class TORRENT_EXTRA_EXPORT web_peer_connection : public web_connection_base { diff --git a/include/libtorrent/write_resume_data.hpp b/include/libtorrent/write_resume_data.hpp index 11028c155..b081c15db 100644 --- a/include/libtorrent/write_resume_data.hpp +++ b/include/libtorrent/write_resume_data.hpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/export.hpp" #include "libtorrent/bencode.hpp" -namespace libtorrent -{ +namespace libtorrent { + struct add_torrent_params; class entry; diff --git a/include/libtorrent/xml_parse.hpp b/include/libtorrent/xml_parse.hpp index 8168eaa7e..44ace5734 100644 --- a/include/libtorrent/xml_parse.hpp +++ b/include/libtorrent/xml_parse.hpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/string_view.hpp" -namespace libtorrent -{ +namespace libtorrent { + enum { xml_start_tag, diff --git a/src/alert.cpp b/src/alert.cpp index cae51e7c0..fc55bb53b 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -53,8 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/escape_string.hpp" // for convert_from_native #include "libtorrent/aux_/max_path.hpp" // for TORRENT_MAX_PATH -namespace libtorrent -{ +namespace libtorrent { alert::alert() : m_timestamp(clock_type::now()) {} alert::~alert() = default; @@ -762,8 +761,8 @@ namespace libtorrent return torrent_alert::message() + " checked"; } - namespace - { +namespace { + int sock_type_idx(socket_type_t type) { int idx = @@ -1114,8 +1113,8 @@ namespace libtorrent return msg; } - namespace - { +namespace { + std::array stat_to_array(stat const& s) { std::array arr; @@ -1728,8 +1727,8 @@ namespace libtorrent return "Local Service Discovery error: " + convert_from_native(error.message()); } - namespace - { +namespace { + aux::array counters_to_array(counters const& cnt) { aux::array arr; @@ -2140,8 +2139,8 @@ namespace libtorrent return buf; } - namespace - { +namespace { + using nodes_slot = std::tuple; nodes_slot write_nodes(aux::stack_allocator& alloc diff --git a/src/alert_manager.cpp b/src/alert_manager.cpp index a5d8e1f92..7e213e2ef 100644 --- a/src/alert_manager.cpp +++ b/src/alert_manager.cpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/extensions.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { alert_manager::alert_manager(int const queue_limit, std::uint32_t const alert_mask) : m_alert_mask(alert_mask) diff --git a/src/allocator.cpp b/src/allocator.cpp index e1ce6aaba..c53c43b8e 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -72,8 +72,7 @@ struct alloc_header #endif -namespace libtorrent -{ +namespace libtorrent { int page_size() { diff --git a/src/announce_entry.cpp b/src/announce_entry.cpp index 4b1eab19f..2227401d9 100644 --- a/src/announce_entry.cpp +++ b/src/announce_entry.cpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/session_settings.hpp" -namespace libtorrent -{ +namespace libtorrent { + namespace { // wait at least 5 seconds before retrying a failed tracker seconds32 constexpr tracker_retry_delay_min{5}; diff --git a/src/bandwidth_limit.cpp b/src/bandwidth_limit.cpp index 55e961301..a79752918 100644 --- a/src/bandwidth_limit.cpp +++ b/src/bandwidth_limit.cpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bandwidth_limit.hpp" #include -namespace libtorrent -{ +namespace libtorrent { + bandwidth_channel::bandwidth_channel() : tmp(0) , distribute_quota(0) diff --git a/src/bandwidth_manager.cpp b/src/bandwidth_manager.cpp index 5dd9fd4a6..7119877c8 100644 --- a/src/bandwidth_manager.cpp +++ b/src/bandwidth_manager.cpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -namespace libtorrent -{ +namespace libtorrent { bandwidth_manager::bandwidth_manager(int channel) : m_queued_bytes(0) diff --git a/src/bandwidth_queue_entry.cpp b/src/bandwidth_queue_entry.cpp index 5213577cf..bdcfe0cde 100644 --- a/src/bandwidth_queue_entry.cpp +++ b/src/bandwidth_queue_entry.cpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bandwidth_queue_entry.hpp" -namespace libtorrent -{ +namespace libtorrent { + bw_request::bw_request(std::shared_ptr const& pe , int blk, int prio) : peer(pe) diff --git a/src/bdecode.cpp b/src/bdecode.cpp index 065fcaf90..cd3e39f78 100644 --- a/src/bdecode.cpp +++ b/src/bdecode.cpp @@ -42,12 +42,12 @@ POSSIBILITY OF SUCH DAMAGE. #define BOOST_SYSTEM_NOEXCEPT throw() #endif -namespace libtorrent -{ +namespace libtorrent { + using detail::bdecode_token; - namespace - { +namespace { + bool numeric(char c) { return c >= '0' && c <= '9'; } // finds the end of an integer and verifies that it looks valid this does diff --git a/src/bitfield.cpp b/src/bitfield.cpp index 2a537d046..078453f4f 100644 --- a/src/bitfield.cpp +++ b/src/bitfield.cpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -namespace libtorrent -{ +namespace libtorrent { + bool bitfield::all_set() const { if(size() == 0) return false; diff --git a/src/bloom_filter.cpp b/src/bloom_filter.cpp index 21da0f0c0..05f886c52 100644 --- a/src/bloom_filter.cpp +++ b/src/bloom_filter.cpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bloom_filter.hpp" #include "libtorrent/aux_/numeric_cast.hpp" -namespace libtorrent -{ +namespace libtorrent { + bool has_bits(std::uint8_t const* k, std::uint8_t const* bits, int const len) { std::uint32_t idx1 = std::uint32_t(k[0]) | (std::uint32_t(k[1]) << 8); diff --git a/src/broadcast_socket.cpp b/src/broadcast_socket.cpp index deedbab3b..c1cc04a7d 100644 --- a/src/broadcast_socket.cpp +++ b/src/broadcast_socket.cpp @@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + bool is_ip_address(std::string const& host) { error_code ec; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 67183f7fb..d9272ab0d 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -73,8 +73,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { + namespace mp = boost::multiprecision; #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) diff --git a/src/chained_buffer.cpp b/src/chained_buffer.cpp index 124079065..aa32e0eab 100644 --- a/src/chained_buffer.cpp +++ b/src/chained_buffer.cpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for memcpy -namespace libtorrent -{ +namespace libtorrent { + void chained_buffer::pop_front(int bytes_to_pop) { TORRENT_ASSERT(is_single_thread()); diff --git a/src/choker.cpp b/src/choker.cpp index ee08e10d9..cd395397c 100644 --- a/src/choker.cpp +++ b/src/choker.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { namespace { diff --git a/src/close_reason.cpp b/src/close_reason.cpp index 14f7876ba..70b262593 100644 --- a/src/close_reason.cpp +++ b/src/close_reason.cpp @@ -34,8 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error.hpp" #include "libtorrent/assert.hpp" -namespace libtorrent -{ +namespace libtorrent { close_reason_t error_to_close_reason(error_code const& ec) { diff --git a/src/cpuid.cpp b/src/cpuid.cpp index dd0dce2c9..243c0850f 100644 --- a/src/cpuid.cpp +++ b/src/cpuid.cpp @@ -59,8 +59,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + namespace { #if TORRENT_HAS_SSE diff --git a/src/crc32c.cpp b/src/crc32c.cpp index c1213efe4..9ce553290 100644 --- a/src/crc32c.cpp +++ b/src/crc32c.cpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -namespace libtorrent -{ +namespace libtorrent { + std::uint32_t crc32c_32(std::uint32_t v) { #if TORRENT_HAS_SSE diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 61d3d8f2a..ea9e33ef0 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -49,10 +49,10 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ - namespace - { +namespace libtorrent { + +namespace { + inline bool default_pred(std::string const&) { return true; } inline bool ignore_subdir(std::string const& leaf) diff --git a/src/disk_buffer_holder.cpp b/src/disk_buffer_holder.cpp index eff9be279..64eff8474 100644 --- a/src/disk_buffer_holder.cpp +++ b/src/disk_buffer_holder.cpp @@ -34,8 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/storage.hpp" // for storage_interface #include "libtorrent/aux_/block_cache_reference.hpp" -namespace libtorrent -{ +namespace libtorrent { disk_buffer_holder::disk_buffer_holder(buffer_allocator_interface& alloc, char* buf) noexcept : m_allocator(&alloc), m_buf(buf) diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index ec505eab9..54fb59846 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -51,8 +51,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + namespace { // this is posted to the network thread diff --git a/src/disk_io_job.cpp b/src/disk_io_job.cpp index a355968c0..793f8cf99 100644 --- a/src/disk_io_job.cpp +++ b/src/disk_io_job.cpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/disk_io_job.hpp" #include "libtorrent/block_cache.hpp" // for cached_piece_entry -namespace libtorrent -{ +namespace libtorrent { + struct buffer_allocator_interface; namespace { diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 3cfa8724d..fccc437ea 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -66,8 +66,7 @@ POSSIBILITY OF SUCH DAMAGE. #define DLOG(...) do {} while(false) #endif -namespace libtorrent -{ +namespace libtorrent { #if TORRENT_USE_ASSERTS diff --git a/src/disk_io_thread_pool.cpp b/src/disk_io_thread_pool.cpp index ef07ea87c..a3b58935d 100644 --- a/src/disk_io_thread_pool.cpp +++ b/src/disk_io_thread_pool.cpp @@ -35,13 +35,13 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace -{ +namespace { + constexpr std::chrono::seconds reap_idle_threads_interval(60); } -namespace libtorrent -{ +namespace libtorrent { + disk_io_thread_pool::disk_io_thread_pool(pool_thread_interface& thread_iface , io_service& ios) : m_thread_iface(thread_iface) diff --git a/src/disk_job_fence.cpp b/src/disk_job_fence.cpp index 4f57ef855..9946e2774 100644 --- a/src/disk_job_fence.cpp +++ b/src/disk_job_fence.cpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #define DLOG(...) do {} while (false) #endif -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + disk_job_fence::disk_job_fence() {} int disk_job_fence::job_complete(disk_io_job* j, tailqueue& jobs) diff --git a/src/disk_job_pool.cpp b/src/disk_job_pool.cpp index 67e1ef52c..9539c4cd9 100644 --- a/src/disk_job_pool.cpp +++ b/src/disk_job_pool.cpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/disk_job_pool.hpp" #include "libtorrent/disk_io_job.hpp" -namespace libtorrent -{ +namespace libtorrent { + disk_job_pool::disk_job_pool() : m_jobs_in_use(0) , m_read_jobs(0) diff --git a/src/entry.cpp b/src/entry.cpp index 5f9a72e70..390e59791 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -45,10 +45,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" #include "libtorrent/aux_/throw.hpp" -namespace libtorrent -{ - namespace detail - { +namespace libtorrent { + +namespace detail { char const* integer_to_str(char* buf, int size , entry::integer_type val) { @@ -70,8 +69,8 @@ namespace libtorrent } } - namespace - { +namespace { + inline void TORRENT_NO_RETURN throw_error() { aux::throw_ex(errors::invalid_entry_type); } diff --git a/src/enum_net.cpp b/src/enum_net.cpp index 0536854e8..3eaa71de5 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -100,8 +100,8 @@ const unsigned long siocgifmtu = SIOCGIFMTU; #define IF_NAMESIZE IFNAMSIZ #endif -namespace libtorrent { namespace -{ +namespace libtorrent {namespace { + #if !defined TORRENT_BUILD_SIMULATOR address_v4 inaddr_to_address(in_addr const* ina, int const len = 4) @@ -336,8 +336,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl }} // -namespace libtorrent -{ +namespace libtorrent { // return (a1 & mask) == (a2 & mask) bool match_addr_mask(address const& a1, address const& a2, address const& mask) diff --git a/src/error_code.cpp b/src/error_code.cpp index 4cebbc13c..144b4ebb3 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/string_util.hpp" // for to_string() -namespace libtorrent -{ +namespace libtorrent { + struct libtorrent_error_category : boost::system::error_category { const char* name() const BOOST_SYSTEM_NOEXCEPT override; diff --git a/src/escape_string.cpp b/src/escape_string.cpp index b0149a453..c86525d61 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -59,10 +59,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" // for to_string #include "libtorrent/aux_/array.hpp" -namespace libtorrent -{ +namespace libtorrent { + // defined in hex.cpp namespace aux { + extern const char hex_chars[]; } diff --git a/src/ffs.cpp b/src/ffs.cpp index c6bf3f9af..970babf11 100644 --- a/src/ffs.cpp +++ b/src/ffs.cpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + int count_leading_zeros_sw(span buf) { int const num = int(buf.size()); diff --git a/src/file.cpp b/src/file.cpp index b46914cc4..349f0eacf 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -145,8 +145,8 @@ static_assert(sizeof(lseek(0, 0, 0)) >= 8, "64 bit file operations are required" #if TORRENT_USE_PREADV # if defined TORRENT_WINDOWS -namespace -{ +namespace { + // wrap the windows function in something that looks // like preadv() and pwritev() @@ -328,8 +328,8 @@ static_assert((libtorrent::file::sparse & libtorrent::file::attribute_mask) == 0 #endif // TORRENT_WINDOWS -namespace libtorrent -{ +namespace libtorrent { + template std::unique_ptr make_free_holder(T* ptr) { diff --git a/src/file_pool.cpp b/src/file_pool.cpp index d8d2bf099..ca6c29e25 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -45,8 +45,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + file_pool::file_pool(int size) : m_size(size) {} file_pool::~file_pool() = default; diff --git a/src/file_progress.cpp b/src/file_progress.cpp index 349c77b1c..e33c8074b 100644 --- a/src/file_progress.cpp +++ b/src/file_progress.cpp @@ -37,8 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/invariant_check.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { file_progress::file_progress() { diff --git a/src/file_storage.cpp b/src/file_storage.cpp index 50b8d8d3c..b550b50fd 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + file_storage::file_storage() : m_piece_length(0) , m_num_pieces(0) @@ -92,8 +92,8 @@ namespace libtorrent return piece_length(); } - namespace - { +namespace { + bool compare_file_offset(internal_file_entry const& lhs , internal_file_entry const& rhs) { @@ -633,8 +633,8 @@ namespace libtorrent return m_mtime[index]; } - namespace - { +namespace { + template void process_string_lowercase(CRC& crc, string_view str) { @@ -1105,8 +1105,7 @@ namespace libtorrent if (index != cur_index) reorder_file(index, cur_index); } - namespace aux - { +namespace aux { std::tuple file_piece_range_exclusive(file_storage const& fs, file_index_t const file) diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp index 5c1af5f36..aacfb9eaf 100644 --- a/src/fingerprint.cpp +++ b/src/fingerprint.cpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" namespace libtorrent { + namespace { char version_to_char(int const v) diff --git a/src/gzip.cpp b/src/gzip.cpp index 917836cfd..0d4e4fb50 100644 --- a/src/gzip.cpp +++ b/src/gzip.cpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace -{ +namespace { + enum { FTEXT = 0x01, @@ -54,8 +54,8 @@ namespace } -namespace libtorrent -{ +namespace libtorrent { + struct gzip_error_category : boost::system::error_category { const char* name() const BOOST_SYSTEM_NOEXCEPT override; @@ -109,8 +109,8 @@ namespace libtorrent } } - namespace - { +namespace { + // returns -1 if gzip header is invalid or the header size in bytes int gzip_header(const char* buf, int size) { diff --git a/src/hasher.cpp b/src/hasher.cpp index d9e309ced..16c984733 100644 --- a/src/hasher.cpp +++ b/src/hasher.cpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/aux_/openssl.hpp" -namespace libtorrent -{ +namespace libtorrent { + #ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" diff --git a/src/hasher512.cpp b/src/hasher512.cpp index 977a22be0..a4a22de1b 100644 --- a/src/hasher512.cpp +++ b/src/hasher512.cpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/aux_/openssl.hpp" -namespace libtorrent -{ +namespace libtorrent { + #ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" diff --git a/src/hex.cpp b/src/hex.cpp index c950c7cba..0f71f6523 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -32,8 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hex.hpp" -namespace libtorrent -{ +namespace libtorrent { namespace aux { diff --git a/src/http_parser.cpp b/src/http_parser.cpp index 1c3c49566..bc7531c3d 100644 --- a/src/http_parser.cpp +++ b/src/http_parser.cpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" // for allocate_string_copy #include "libtorrent/aux_/escape_string.hpp" // for read_until -namespace libtorrent -{ +namespace libtorrent { bool is_ok_status(int http_status) { diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 30edf84d2..f5dc731aa 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_info.hpp" #include "libtorrent/hex.hpp" // for is_hex -namespace libtorrent -{ +namespace libtorrent { + http_seed_connection::http_seed_connection(peer_connection_args const& pack , web_seed_t& web) : web_connection_base(pack, web) diff --git a/src/http_stream.cpp b/src/http_stream.cpp index 4401693c2..982c60dca 100644 --- a/src/http_stream.cpp +++ b/src/http_stream.cpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { void http_stream::name_lookup(error_code const& e, tcp::resolver::iterator i , handler_type& h) diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index df51f2773..0a7d195f7 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -58,8 +58,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + http_tracker_connection::http_tracker_connection( io_service& ios , tracker_manager& man diff --git a/src/i2p_stream.cpp b/src/i2p_stream.cpp index 7ef15fe9a..ab3bed890 100644 --- a/src/i2p_stream.cpp +++ b/src/i2p_stream.cpp @@ -47,8 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { struct i2p_error_category : boost::system::error_category { diff --git a/src/identify_client.cpp b/src/identify_client.cpp index cbfa696ae..b7f8e8351 100644 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" #include "libtorrent/aux_/numeric_cast.hpp" -namespace -{ +namespace { + using namespace libtorrent; @@ -290,8 +290,8 @@ namespace || ((lhs.id[0] == rhs.id[0]) && (lhs.id[1] < rhs.id[1])); } -namespace -{ +namespace { + static std::string lookup(fingerprint const& f) { char identity[200]; @@ -343,8 +343,7 @@ namespace } } -namespace libtorrent -{ +namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE diff --git a/src/instantiate_connection.cpp b/src/instantiate_connection.cpp index bc4e04dfa..751a0b47e 100644 --- a/src/instantiate_connection.cpp +++ b/src/instantiate_connection.cpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/utp_socket_manager.hpp" #include "libtorrent/instantiate_connection.hpp" -namespace libtorrent -{ +namespace libtorrent { + // TODO: 2 peer_connection and tracker_connection should probably be flags // TODO: 2 move this function into libtorrent::aux namespace bool instantiate_connection(io_service& ios diff --git a/src/ip_filter.cpp b/src/ip_filter.cpp index 52ef97530..c42fab29a 100644 --- a/src/ip_filter.cpp +++ b/src/ip_filter.cpp @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/ip_filter.hpp" -namespace libtorrent -{ +namespace libtorrent { + void ip_filter::add_rule(address first, address last, std::uint32_t flags) { if (first.is_v4()) diff --git a/src/ip_notifier.cpp b/src/ip_notifier.cpp index 8296134bc..d4e9970dd 100644 --- a/src/ip_notifier.cpp +++ b/src/ip_notifier.cpp @@ -48,10 +48,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #endif -namespace libtorrent { namespace aux -{ -namespace -{ +namespace libtorrent { namespace aux { + +namespace { + #if defined TORRENT_BUILD_SIMULATOR // TODO: ip_change_notifier_sim #elif TORRENT_USE_NETLINK diff --git a/src/ip_voter.cpp b/src/ip_voter.cpp index b28318dd0..da09564c7 100644 --- a/src/ip_voter.cpp +++ b/src/ip_voter.cpp @@ -36,8 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/random.hpp" // for random() #include "libtorrent/aux_/time.hpp" // for aux::time_now() -namespace libtorrent -{ +namespace libtorrent { + ip_voter::ip_voter() : m_total_votes(0) , m_valid_external(false) diff --git a/src/kademlia/dht_state.cpp b/src/kademlia/dht_state.cpp index f4ef6062d..37471ab49 100644 --- a/src/kademlia/dht_state.cpp +++ b/src/kademlia/dht_state.cpp @@ -35,11 +35,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { -namespace dht -{ -namespace -{ +namespace libtorrent { namespace dht { +namespace { + node_id extract_node_id(bdecode_node const& e, string_view key) { if (e.type() != bdecode_node::dict_t) return node_id(); diff --git a/src/kademlia/dht_storage.cpp b/src/kademlia/dht_storage.cpp index 1c409c184..a04598d08 100644 --- a/src/kademlia/dht_storage.cpp +++ b/src/kademlia/dht_storage.cpp @@ -48,10 +48,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { -namespace dht { -namespace -{ +namespace libtorrent { namespace dht { +namespace { + // this is the entry for every peer // the timestamp is there to make it possible // to remove stale peers diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index 43e536644..e86c0a379 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -51,8 +51,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + namespace { // generate a new write token key every 5 minutes diff --git a/src/kademlia/dos_blocker.cpp b/src/kademlia/dos_blocker.cpp index a87d3cbcf..a06ca4561 100644 --- a/src/kademlia/dos_blocker.cpp +++ b/src/kademlia/dos_blocker.cpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/dht_observer.hpp" // for dht_logger #endif -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + dos_blocker::dos_blocker() : m_message_rate_limit(5) , m_block_timeout(5 * 60) diff --git a/src/kademlia/ed25519.cpp b/src/kademlia/ed25519.cpp index b47f72ad8..183514db0 100644 --- a/src/kademlia/ed25519.cpp +++ b/src/kademlia/ed25519.cpp @@ -34,9 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { -namespace dht -{ +namespace libtorrent { namespace dht { std::array ed25519_create_seed() { diff --git a/src/kademlia/find_data.cpp b/src/kademlia/find_data.cpp index 475992829..aceeafc7a 100644 --- a/src/kademlia/find_data.cpp +++ b/src/kademlia/find_data.cpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // to_hex #endif -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { void find_data_observer::reply(msg const& m) { diff --git a/src/kademlia/get_item.cpp b/src/kademlia/get_item.cpp index 0ea1523f5..0f122095e 100644 --- a/src/kademlia/get_item.cpp +++ b/src/kademlia/get_item.cpp @@ -37,8 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { void get_item::got_data(bdecode_node const& v, public_key const& pk, diff --git a/src/kademlia/get_peers.cpp b/src/kademlia/get_peers.cpp index d64ed2302..8da65a53f 100644 --- a/src/kademlia/get_peers.cpp +++ b/src/kademlia/get_peers.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // to_hex #endif -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { void get_peers_observer::reply(msg const& m) { diff --git a/src/kademlia/item.cpp b/src/kademlia/item.cpp index 3066bbf05..33454ee4b 100644 --- a/src/kademlia/item.cpp +++ b/src/kademlia/item.cpp @@ -44,11 +44,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bdecode.hpp" #endif -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { + +namespace { -namespace -{ int canonical_string(span v , sequence_number const seq , span salt diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index f429b8e08..e06efe670 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -66,8 +66,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { namespace { @@ -354,8 +353,8 @@ void node::incoming(msg const& m) } } -namespace -{ +namespace { + void announce_fun(std::vector> const& v , node& node, int const listen_port, sha1_hash const& ih, int const flags) { diff --git a/src/kademlia/node_entry.cpp b/src/kademlia/node_entry.cpp index 9ea080c4f..04436774e 100644 --- a/src/kademlia/node_entry.cpp +++ b/src/kademlia/node_entry.cpp @@ -33,8 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/node_entry.hpp" #include "libtorrent/aux_/time.hpp" // for aux::time_now() -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { node_entry::node_entry(node_id const& id_, udp::endpoint const& ep , int roundtriptime diff --git a/src/kademlia/node_id.cpp b/src/kademlia/node_id.cpp index d7184da63..a7785002c 100644 --- a/src/kademlia/node_id.cpp +++ b/src/kademlia/node_id.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" // for hasher #include "libtorrent/crc32c.hpp" // for crc32c -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { // returns the distance between the two nodes // using the kademlia XOR-metric diff --git a/src/kademlia/put_data.cpp b/src/kademlia/put_data.cpp index 5e19f4b87..d9bf4b669 100644 --- a/src/kademlia/put_data.cpp +++ b/src/kademlia/put_data.cpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { put_data::put_data(node& dht_node, put_callback const& callback) : traversal_algorithm(dht_node, (node_id::min)()) diff --git a/src/kademlia/refresh.cpp b/src/kademlia/refresh.cpp index b364d1fa8..ce46c7384 100644 --- a/src/kademlia/refresh.cpp +++ b/src/kademlia/refresh.cpp @@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { observer_ptr bootstrap::new_observer(udp::endpoint const& ep , node_id const& id) diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 368142cf1..c733dfdd2 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -55,10 +55,10 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent { namespace dht -{ -namespace -{ +namespace libtorrent { namespace dht { + +namespace { + template void erase_one(T& container, K const& key) { diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index 828a37853..3e655ad9d 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -59,8 +59,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { // TODO: 3 move this into it's own .cpp file dht_observer* observer::get_observer() const diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index 065f07b55..cc1a0fe54 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -46,8 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent { namespace dht -{ +namespace libtorrent { namespace dht { #if TORRENT_USE_ASSERTS template diff --git a/src/lazy_bdecode.cpp b/src/lazy_bdecode.cpp index f57480f5e..8ac76e829 100644 --- a/src/lazy_bdecode.cpp +++ b/src/lazy_bdecode.cpp @@ -41,18 +41,17 @@ POSSIBILITY OF SUCH DAMAGE. #include // for snprintf #include // for PRId64 et.al. -namespace -{ +namespace { + const int lazy_entry_grow_factor = 150; // percent const int lazy_entry_dict_init = 5; const int lazy_entry_list_init = 5; } -namespace libtorrent -{ +namespace libtorrent { + +namespace { - namespace - { int fail(int* error_pos , std::vector& stack , char const* start @@ -283,8 +282,8 @@ namespace libtorrent if (m_size > 0) --m_size; } - namespace - { +namespace { + // the number of decimal digits needed // to represent the given value int num_digits(int val) @@ -310,8 +309,8 @@ namespace libtorrent m_len = std::uint32_t(start - m_begin + length); } - namespace - { +namespace { + // str1 is 0-terminated // str2 is not, str2 is len2 chars bool string_equal(char const* str1, char const* str2, int len2) diff --git a/src/lsd.cpp b/src/lsd.cpp index 061266576..2eb277dfc 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + namespace { int render_lsd_packet(char* dst, int const len, int const listen_port diff --git a/src/magnet_uri.cpp b/src/magnet_uri.cpp index f275fd88a..84d55b3aa 100644 --- a/src/magnet_uri.cpp +++ b/src/magnet_uri.cpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/socket_io.hpp" -namespace libtorrent -{ +namespace libtorrent { + std::string make_magnet_uri(torrent_handle const& handle) { if (!handle.is_valid()) return ""; diff --git a/src/merkle.cpp b/src/merkle.cpp index 71771a203..d48b7e97b 100644 --- a/src/merkle.cpp +++ b/src/merkle.cpp @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/merkle.hpp" -namespace libtorrent -{ +namespace libtorrent { + int merkle_get_parent(int tree_node) { // node 0 doesn't have a parent diff --git a/src/parse_url.cpp b/src/parse_url.cpp index 0c8509844..5ba852b12 100644 --- a/src/parse_url.cpp +++ b/src/parse_url.cpp @@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/parse_url.hpp" #include "libtorrent/string_util.hpp" -namespace libtorrent -{ +namespace libtorrent { // returns protocol, auth, hostname, port, path std::tuple diff --git a/src/part_file.cpp b/src/part_file.cpp index 672f6540c..39d7e4ee3 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -67,15 +67,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/vector.hpp" #include "libtorrent/aux_/path.hpp" -namespace -{ +namespace { + // round up to even kilobyte int round_up(int n) { return (n + 1023) & ~0x3ff; } } -namespace libtorrent -{ +namespace libtorrent { + part_file::part_file(std::string const& path, std::string const& name , int num_pieces, int piece_size) : m_path(path) diff --git a/src/path.cpp b/src/path.cpp index 6a8a2d0bc..4335db08d 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -125,8 +125,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { + int bufs_size(span bufs) { std::size_t size = 0; diff --git a/src/pe_crypto.cpp b/src/pe_crypto.cpp index 526c83846..626e4345c 100644 --- a/src/pe_crypto.cpp +++ b/src/pe_crypto.cpp @@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pe_crypto.hpp" #include "libtorrent/hasher.hpp" -namespace libtorrent -{ +namespace libtorrent { + namespace mp = boost::multiprecision; namespace { diff --git a/src/peer_class.cpp b/src/peer_class.cpp index 44cecda4c..22d4849bd 100644 --- a/src/peer_class.cpp +++ b/src/peer_class.cpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_class.hpp" #include "libtorrent/peer_connection.hpp" -namespace libtorrent -{ +namespace libtorrent { + void peer_class::set_upload_limit(int limit) { TORRENT_ASSERT(limit >= -1); diff --git a/src/peer_class_set.cpp b/src/peer_class_set.cpp index 6c4d4ac0d..86149cc77 100644 --- a/src/peer_class_set.cpp +++ b/src/peer_class_set.cpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for find -namespace libtorrent -{ +namespace libtorrent { + void peer_class_set::add_class(peer_class_pool& pool, peer_class_t c) { if (std::find(m_class.begin(), m_class.begin() + m_size, c) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 0db17ee59..55e9346ed 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -84,8 +84,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { namespace { diff --git a/src/peer_connection_handle.cpp b/src/peer_connection_handle.cpp index d6431d630..9c088c509 100644 --- a/src/peer_connection_handle.cpp +++ b/src/peer_connection_handle.cpp @@ -37,8 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for va_start, va_end #endif -namespace libtorrent -{ +namespace libtorrent { connection_type peer_connection_handle::type() const { diff --git a/src/peer_list.cpp b/src/peer_list.cpp index a7f991168..d2be86ae0 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -59,8 +59,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace -{ +namespace { + using namespace libtorrent; struct match_peer_endpoint @@ -112,8 +112,8 @@ namespace } -namespace libtorrent -{ +namespace libtorrent { + peer_list::peer_list() : m_locked_peer(nullptr) , m_num_seeds(0) diff --git a/src/performance_counters.cpp b/src/performance_counters.cpp index 1b2a6d01b..421d32a68 100644 --- a/src/performance_counters.cpp +++ b/src/performance_counters.cpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - counters::counters() { #ifdef ATOMIC_LLONG_LOCK_FREE diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 130e887e1..e5c08437f 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -59,8 +59,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + // TODO: find a better place for this const piece_block piece_block::invalid( std::numeric_limits::max() @@ -1772,8 +1772,8 @@ namespace libtorrent } } - namespace - { +namespace { + int append_blocks(std::vector& dst, std::vector& src , int const num_blocks) { diff --git a/src/platform_util.cpp b/src/platform_util.cpp index 32400295c..846290dee 100644 --- a/src/platform_util.cpp +++ b/src/platform_util.cpp @@ -60,8 +60,7 @@ const rlim_t rlim_infinity = RLIM_INFINITY; #include "libtorrent/aux_/disable_warnings_pop.hpp" -namespace libtorrent -{ +namespace libtorrent { int max_open_files() { diff --git a/src/proxy_base.cpp b/src/proxy_base.cpp index ae236767a..4b11a64ce 100644 --- a/src/proxy_base.cpp +++ b/src/proxy_base.cpp @@ -32,8 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/proxy_base.hpp" -namespace libtorrent -{ +namespace libtorrent { proxy_base::proxy_base(io_service& io_service) : m_sock(io_service) diff --git a/src/proxy_settings.cpp b/src/proxy_settings.cpp index 2a5d0c6f8..c1ed50ef3 100644 --- a/src/proxy_settings.cpp +++ b/src/proxy_settings.cpp @@ -34,9 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/settings_pack.hpp" #include "libtorrent/aux_/session_settings.hpp" -namespace libtorrent { -namespace aux { - +namespace libtorrent { namespace aux { proxy_settings::proxy_settings() : type(0) , port(0) diff --git a/src/random.cpp b/src/random.cpp index 0f242d516..cfda9f7c0 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -54,10 +54,8 @@ extern "C" { #include "libtorrent/aux_/dev_random.hpp" #endif -namespace libtorrent -{ - namespace aux - { +namespace libtorrent { namespace aux { + std::mt19937& random_engine() { #ifdef TORRENT_BUILD_SIMULATOR diff --git a/src/read_resume_data.cpp b/src/read_resume_data.cpp index 2c9ce65c2..e2c71c201 100644 --- a/src/read_resume_data.cpp +++ b/src/read_resume_data.cpp @@ -41,10 +41,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/numeric_cast.hpp" #include "libtorrent/torrent.hpp" // for default_piece_priority -namespace libtorrent -{ - namespace - { +namespace libtorrent { + +namespace { + void apply_flag(std::uint64_t& current_flags , bdecode_node const& n , char const* name diff --git a/src/request_blocks.cpp b/src/request_blocks.cpp index e5a1bbd8b..a8df89557 100644 --- a/src/request_blocks.cpp +++ b/src/request_blocks.cpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace libtorrent -{ +namespace libtorrent { + int source_rank(int source_bitmask) { int ret = 0; diff --git a/src/resolve_links.cpp b/src/resolve_links.cpp index e3d59b0fd..ef9d5f630 100644 --- a/src/resolve_links.cpp +++ b/src/resolve_links.cpp @@ -34,8 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/aux_/numeric_cast.hpp" -namespace libtorrent -{ +namespace libtorrent { #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS resolve_links::resolve_links(std::shared_ptr ti) diff --git a/src/resolver.cpp b/src/resolver.cpp index f7d88db41..1ad558368 100644 --- a/src/resolver.cpp +++ b/src/resolver.cpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #include "libtorrent/aux_/time.hpp" -namespace libtorrent -{ +namespace libtorrent { + resolver::resolver(io_service& ios) : m_ios(ios) , m_resolver(ios) diff --git a/src/session.cpp b/src/session.cpp index 7f31dcfe5..bb68ac9e6 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/aux_/session_call.hpp" -namespace libtorrent -{ +namespace libtorrent { + settings_pack min_memory_usage() { settings_pack set; @@ -331,8 +331,8 @@ namespace libtorrent } } - namespace - { +namespace { + std::vector> default_plugins( bool empty = false) { diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 668f13a4d..da3eab4d7 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -45,8 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. using libtorrent::aux::session_impl; -namespace libtorrent -{ +namespace libtorrent { peer_class_t constexpr session_handle::global_peer_class_id; peer_class_t constexpr session_handle::tcp_peer_class_id; @@ -190,8 +189,8 @@ namespace libtorrent } #ifndef TORRENT_NO_DEPRECATE - namespace - { +namespace { + void handle_backwards_compatible_resume_data(add_torrent_params& atp) { // if there's no resume data set, there's nothing to do. It's either diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 580ddcc05..273a75713 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -116,8 +116,8 @@ extern "C" { GCRY_THREAD_OPTION_PTHREAD_IMPL; } -namespace -{ +namespace { + // libgcrypt requires this to initialize the library struct gcrypt_setup { @@ -139,8 +139,8 @@ namespace #include #include -namespace -{ +namespace { + // openssl requires this to clean up internal // structures it allocates struct openssl_cleanup @@ -167,6 +167,7 @@ using namespace std::placeholders; #ifdef BOOST_NO_EXCEPTIONS namespace boost { + void throw_exception(std::exception const& e) { ::abort(); } } #endif @@ -1060,8 +1061,8 @@ namespace aux { return m_port_filter; } - namespace - { +namespace { + template void set_socket_buffer_size(Socket& s, session_settings const& sett, error_code& ec) @@ -4969,8 +4970,8 @@ namespace aux { } #ifndef TORRENT_NO_DEPRECATE - namespace - { +namespace { + listen_interface_t set_ssl_flag(listen_interface_t in) { in.ssl = true; diff --git a/src/session_settings.cpp b/src/session_settings.cpp index cd506422d..527521b3b 100644 --- a/src/session_settings.cpp +++ b/src/session_settings.cpp @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_settings.hpp" -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + session_settings::session_settings() { initialize_default_settings(*this); diff --git a/src/session_stats.cpp b/src/session_stats.cpp index be6453f44..e4906ce59 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -37,10 +37,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ - namespace - { +namespace libtorrent { + +namespace { + struct stats_metric_impl { diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 6febde45a..bfeeea26d 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -62,8 +62,8 @@ namespace { { return str == nullptr ? "" : str; } } -namespace libtorrent -{ +namespace libtorrent { + struct str_setting_entry_t { // the name of this setting. used for serialization and deserialization diff --git a/src/sha1.cpp b/src/sha1.cpp index 1f7705440..8348e1359 100644 --- a/src/sha1.cpp +++ b/src/sha1.cpp @@ -22,11 +22,10 @@ changelog at the end of the file. typedef std::uint32_t u32; typedef std::uint8_t u8; -namespace libtorrent -{ +namespace libtorrent { + +namespace { -namespace -{ union CHAR64LONG16 { u8 c[64]; diff --git a/src/sha1_hash.cpp b/src/sha1_hash.cpp index 8a4ed4f88..2396ecc05 100644 --- a/src/sha1_hash.cpp +++ b/src/sha1_hash.cpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif // TORRENT_USE_IOSTREAM -namespace libtorrent -{ +namespace libtorrent { + #if TORRENT_USE_IOSTREAM // print a sha1_hash object to an ostream as 40 hexadecimal digits @@ -60,8 +60,8 @@ namespace libtorrent #endif // TORRENT_USE_IOSTREAM -namespace aux -{ +namespace aux { + void bits_shift_left(typed_span number, int n) { TORRENT_ASSERT(n >= 0); diff --git a/src/sha512.cpp b/src/sha512.cpp index 0336cbfd1..40836beba 100644 --- a/src/sha512.cpp +++ b/src/sha512.cpp @@ -25,8 +25,7 @@ using i32 = std::int32_t; #define UINT64_C(x) x ## LL #endif -namespace libtorrent -{ +namespace libtorrent { /* the K array */ static const u64 K[80] = { diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 8753b7b04..acde87cb1 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -62,8 +62,8 @@ namespace libtorrent { class torrent; -namespace -{ +namespace { + struct smart_ban_plugin final : torrent_plugin @@ -326,8 +326,8 @@ namespace } } -namespace libtorrent -{ +namespace libtorrent { + std::shared_ptr create_smart_ban_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); diff --git a/src/socket_io.cpp b/src/socket_io.cpp index 1c638be15..1e2485f10 100644 --- a/src/socket_io.cpp +++ b/src/socket_io.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" // for hasher #include "libtorrent/aux_/escape_string.hpp" // for trim -namespace libtorrent -{ +namespace libtorrent { std::string print_address(address const& addr) { diff --git a/src/socket_type.cpp b/src/socket_type.cpp index e51d8ee3f..c1b18c1bb 100644 --- a/src/socket_type.cpp +++ b/src/socket_type.cpp @@ -42,8 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" -namespace libtorrent -{ +namespace libtorrent { bool is_ssl(socket_type const& s) { diff --git a/src/socks5_stream.cpp b/src/socks5_stream.cpp index b8f85382c..ffebac4ef 100644 --- a/src/socks5_stream.cpp +++ b/src/socks5_stream.cpp @@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { namespace socks_error { diff --git a/src/stat_cache.cpp b/src/stat_cache.cpp index 81f640ca2..42998d505 100644 --- a/src/stat_cache.cpp +++ b/src/stat_cache.cpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/aux_/path.hpp" -namespace libtorrent -{ +namespace libtorrent { + stat_cache::stat_cache() {} stat_cache::~stat_cache() = default; diff --git a/src/storage.cpp b/src/storage.cpp index 72e0fb563..950276af0 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -75,8 +75,8 @@ POSSIBILITY OF SUCH DAMAGE. // for convert_to_wstring and convert_to_native #include "libtorrent/aux_/escape_string.hpp" -namespace libtorrent -{ +namespace libtorrent { + void clear_bufs(span bufs) { for (auto buf : bufs) @@ -747,8 +747,8 @@ namespace libtorrent // -- disabled_storage -------------------------------------------------- - namespace - { +namespace { + // this storage implementation does not write anything to disk // and it pretends to read, and just leaves garbage in the buffers // this is useful when simulating many clients on the same machine @@ -795,8 +795,8 @@ namespace libtorrent // -- zero_storage ------------------------------------------------------ - namespace - { +namespace { + // this storage implementation always reads zeroes, and always discards // anything written to it struct zero_storage final : storage_interface diff --git a/src/storage_piece_set.cpp b/src/storage_piece_set.cpp index 489803041..c5424cd1d 100644 --- a/src/storage_piece_set.cpp +++ b/src/storage_piece_set.cpp @@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/block_cache.hpp" #include "libtorrent/storage.hpp" // for storage_interface -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + void storage_piece_set::add_piece(cached_piece_entry* p) { TORRENT_ASSERT(p->in_storage == false); diff --git a/src/storage_utils.cpp b/src/storage_utils.cpp index 9b7af5421..4894de5e2 100644 --- a/src/storage_utils.cpp +++ b/src/storage_utils.cpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + int copy_bufs(span bufs, int const bytes, span target) { int size = 0; diff --git a/src/string_util.cpp b/src/string_util.cpp index db0257d06..d3fdd84eb 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for malloc #include // for memmov/strcpy/strlen -namespace libtorrent -{ +namespace libtorrent { // lexical_cast's result depends on the locale. We need // a well defined result diff --git a/src/time.cpp b/src/time.cpp index b7b3dd154..9b64b0e24 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -33,8 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/time.hpp" #include -namespace libtorrent { namespace aux -{ +namespace libtorrent { namespace aux { + // used to cache the current time regularly (update_time_now() is called by // the session_impl main thread). This is cheaper than a system call and can // be used where more accurate time is not necessary diff --git a/src/torrent.cpp b/src/torrent.cpp index a300bad8a..63b5b26bc 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -105,8 +105,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + namespace { std::uint32_t root2(int x) @@ -10182,8 +10182,8 @@ namespace libtorrent if (m_peer_list) m_peer_list->clear_peer_prio(); } - namespace - { +namespace { + bool is_downloading_state(int st) { switch (st) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index b2d6b43ac..231d8ea93 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -55,8 +55,7 @@ POSSIBILITY OF SUCH DAMAGE. using libtorrent::aux::session_impl; -namespace libtorrent -{ +namespace libtorrent { #ifndef BOOST_NO_EXCEPTIONS void TORRENT_NO_RETURN throw_invalid_handle() diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 3d83970cc..fa397b7cd 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -65,8 +65,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace libtorrent -{ +namespace libtorrent { namespace { @@ -1533,8 +1532,8 @@ namespace libtorrent } #ifndef TORRENT_NO_DEPRECATE - namespace - { +namespace { + struct filter_web_seed_type { explicit filter_web_seed_type(web_seed_entry::type_t t_) : t(t_) {} diff --git a/src/torrent_peer.cpp b/src/torrent_peer.cpp index db21a49ea..1224dd1f4 100644 --- a/src/torrent_peer.cpp +++ b/src/torrent_peer.cpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // for BIG_ENDIAN and LITTLE_ENDIAN macros -namespace libtorrent -{ +namespace libtorrent { + namespace { void apply_mask(std::uint8_t* b, std::uint8_t const* mask, int size) diff --git a/src/torrent_peer_allocator.cpp b/src/torrent_peer_allocator.cpp index 77a64a677..17e5cb16f 100644 --- a/src/torrent_peer_allocator.cpp +++ b/src/torrent_peer_allocator.cpp @@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/torrent_peer_allocator.hpp" -namespace libtorrent -{ +namespace libtorrent { torrent_peer_allocator::torrent_peer_allocator() : m_ipv4_peer_pool(sizeof(libtorrent::ipv4_peer), 500) diff --git a/src/torrent_status.cpp b/src/torrent_status.cpp index f24c1155c..44d1bd45c 100644 --- a/src/torrent_status.cpp +++ b/src/torrent_status.cpp @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_status.hpp" -namespace libtorrent -{ +namespace libtorrent { + file_index_t constexpr torrent_status::error_file_none; file_index_t constexpr torrent_status::error_file_url; file_index_t constexpr torrent_status::error_file_ssl_ctx; diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 97358ce9b..cf30e4515 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. using namespace std::placeholders; -namespace libtorrent -{ +namespace libtorrent { + timeout_handler::timeout_handler(io_service& ios) : m_start_time(clock_type::now()) , m_read_time(m_start_time) diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index d9edbfb9e..0970c4886 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -50,8 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" #endif -namespace libtorrent -{ +namespace libtorrent { std::map udp_tracker_connection::m_connection_cache; diff --git a/src/upnp.cpp b/src/upnp.cpp index c46bf582f..8558f8bd7 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -1128,8 +1128,8 @@ void find_ip_address(int const type, string_view string, ip_address_parse_state& } } -namespace -{ +namespace { + struct error_code_t { int code; diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index cb2e255f5..d312ddab7 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/non_owning_handle.hpp" -namespace libtorrent { namespace -{ +namespace libtorrent {namespace { + enum { // this is the max number of bytes we'll @@ -625,8 +625,8 @@ namespace libtorrent { namespace } } -namespace libtorrent -{ +namespace libtorrent { + std::shared_ptr create_ut_metadata_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 3a52f00ff..ecf512f84 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -46,8 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -namespace libtorrent { namespace -{ +namespace libtorrent {namespace { + static const char extension_name[] = "ut_pex"; enum @@ -646,8 +646,8 @@ namespace libtorrent { namespace } } } -namespace libtorrent -{ +namespace libtorrent { + std::shared_ptr create_ut_pex_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); diff --git a/src/utf8.cpp b/src/utf8.cpp index edb5290cf..6afdc15e8 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -50,10 +50,10 @@ POSSIBILITY OF SUCH DAMAGE. #pragma clang diagnostic ignored "-Wunused-member-function" #endif -namespace libtorrent -{ - namespace - { +namespace libtorrent { + +namespace { + // ==== utf-8 -> wide === template struct convert_to_wide diff --git a/src/utp_socket_manager.cpp b/src/utp_socket_manager.cpp index 5664ed231..d03cd77b9 100644 --- a/src/utp_socket_manager.cpp +++ b/src/utp_socket_manager.cpp @@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. // #define TORRENT_DEBUG_MTU 1135 -namespace libtorrent -{ +namespace libtorrent { + using namespace libtorrent::aux; utp_socket_manager::utp_socket_manager( diff --git a/src/web_connection_base.cpp b/src/web_connection_base.cpp index 3b07bd54a..96b7737a8 100644 --- a/src/web_connection_base.cpp +++ b/src/web_connection_base.cpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/parse_url.hpp" #include "libtorrent/peer_info.hpp" -namespace libtorrent -{ +namespace libtorrent { + web_connection_base::web_connection_base( peer_connection_args const& pack , web_seed_t& web) diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index c1a8fae79..0769a120f 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -53,8 +53,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent.hpp" #include "libtorrent/http_parser.hpp" -namespace libtorrent -{ +namespace libtorrent { + constexpr int request_size_overhead = 5000; std::string escape_file_path(file_storage const& storage, file_index_t index); diff --git a/src/write_resume_data.cpp b/src/write_resume_data.cpp index a87cebdeb..e1ef1a57e 100644 --- a/src/write_resume_data.cpp +++ b/src/write_resume_data.cpp @@ -42,8 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent.hpp" // for default_piece_priority #include "libtorrent/aux_/numeric_cast.hpp" // for clamp -namespace libtorrent -{ +namespace libtorrent { + entry write_resume_data(add_torrent_params const& atp) { entry ret; diff --git a/src/xml_parse.cpp b/src/xml_parse.cpp index a984fdc4f..6af9838e2 100644 --- a/src/xml_parse.cpp +++ b/src/xml_parse.cpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_util.hpp" #include "libtorrent/string_view.hpp" -namespace libtorrent -{ +namespace libtorrent { TORRENT_EXTRA_EXPORT void xml_parse(string_view input , std::function callback)