1 /* 2 3 Copyright (c) 2017, Arvid Norberg, Alden Torres 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions 8 are met: 9 10 * Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 12 * Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in 14 the documentation and/or other materials provided with the distribution. 15 * Neither the name of the author nor the names of its 16 contributors may be used to endorse or promote products derived 17 from this software without specific prior written permission. 18 19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 POSSIBILITY OF SUCH DAMAGE. 30 31 */ 32 33 #include "libtorrent/add_torrent_params.hpp" 34 35 namespace libtorrent { 36 add_torrent_params(storage_constructor_type sc)37 add_torrent_params::add_torrent_params(storage_constructor_type sc) 38 : storage(std::move(sc)) {} 39 add_torrent_params::add_torrent_params(add_torrent_params&&) noexcept = default; 40 add_torrent_params::add_torrent_params(add_torrent_params const&) = default; 41 add_torrent_params& add_torrent_params::operator=(add_torrent_params const&) = default; 42 43 #if TORRENT_ABI_VERSION == 1 44 #define DECL_FLAG(name) \ 45 constexpr torrent_flags_t add_torrent_params::flag_##name 46 47 DECL_FLAG(seed_mode); 48 DECL_FLAG(upload_mode); 49 DECL_FLAG(share_mode); 50 DECL_FLAG(apply_ip_filter); 51 DECL_FLAG(paused); 52 DECL_FLAG(auto_managed); 53 DECL_FLAG(duplicate_is_error); 54 DECL_FLAG(update_subscribe); 55 DECL_FLAG(super_seeding); 56 DECL_FLAG(sequential_download); 57 DECL_FLAG(pinned); 58 DECL_FLAG(stop_when_ready); 59 DECL_FLAG(override_trackers); 60 DECL_FLAG(override_web_seeds); 61 DECL_FLAG(need_save_resume); 62 DECL_FLAG(override_resume_data); 63 DECL_FLAG(merge_resume_trackers); 64 DECL_FLAG(use_resume_save_path); 65 DECL_FLAG(merge_resume_http_seeds); 66 DECL_FLAG(default_flags); 67 #undef DECL_FLAG 68 #endif // TORRENT_ABI_VERSION 69 70 static_assert(std::is_nothrow_move_constructible<add_torrent_params>::value 71 , "should be nothrow move constructible"); 72 73 static_assert(std::is_nothrow_move_constructible<std::string>::value 74 , "should be nothrow move constructible"); 75 76 // TODO: pre C++17, GCC and msvc does not make std::string nothrow move 77 // assignable, which means no type containing a string will be nothrow move 78 // assignable by default either 79 // static_assert(std::is_nothrow_move_assignable<add_torrent_params>::value 80 // , "should be nothrow move assignable"); 81 82 // TODO: it would be nice if this was nothrow default constructible 83 // static_assert(std::is_nothrow_default_constructible<add_torrent_params>::value 84 // , "should be nothrow default constructible"); 85 86 namespace aux { 87 88 // returns whether this add_torrent_params object has "resume-data", i.e. 89 // information about which pieces we have. contains_resume_data(add_torrent_params const & atp)90 bool contains_resume_data(add_torrent_params const& atp) 91 { 92 return !atp.have_pieces.empty() 93 || (atp.flags & torrent_flags::seed_mode); 94 } 95 } 96 97 } 98