Move qHash helper for libtorrent types to its own file

This commit is contained in:
Chocobo1 2020-10-22 03:07:13 +08:00
parent 39c61327b5
commit 71827fe4e6
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
5 changed files with 52 additions and 12 deletions

View File

@ -10,6 +10,7 @@ add_library(qbt_base STATIC
bittorrent/downloadpriority.h bittorrent/downloadpriority.h
bittorrent/filterparserthread.h bittorrent/filterparserthread.h
bittorrent/infohash.h bittorrent/infohash.h
bittorrent/ltqhash.h
bittorrent/ltunderlyingtype.h bittorrent/ltunderlyingtype.h
bittorrent/magneturi.h bittorrent/magneturi.h
bittorrent/nativesessionextension.h bittorrent/nativesessionextension.h

View File

@ -9,6 +9,7 @@ HEADERS += \
$$PWD/bittorrent/downloadpriority.h \ $$PWD/bittorrent/downloadpriority.h \
$$PWD/bittorrent/filterparserthread.h \ $$PWD/bittorrent/filterparserthread.h \
$$PWD/bittorrent/infohash.h \ $$PWD/bittorrent/infohash.h \
$$PWD/bittorrent/ltqhash.h \
$$PWD/bittorrent/ltunderlyingtype.h \ $$PWD/bittorrent/ltunderlyingtype.h \
$$PWD/bittorrent/magneturi.h \ $$PWD/bittorrent/magneturi.h \
$$PWD/bittorrent/nativesessionextension.h \ $$PWD/bittorrent/nativesessionextension.h \

View File

@ -40,6 +40,8 @@
#include <libtorrent/io_context.hpp> #include <libtorrent/io_context.hpp>
#include <QHash> #include <QHash>
#include "ltqhash.h"
#else #else
#include <libtorrent/storage.hpp> #include <libtorrent/storage.hpp>
#endif #endif

View File

@ -0,0 +1,47 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2020 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#pragma once
#include <functional>
#include <libtorrent/units.hpp>
#include <QHash>
namespace libtorrent
{
namespace aux
{
template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed)
{
return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed);
}
}
}

View File

@ -61,6 +61,7 @@
#include "base/utils/string.h" #include "base/utils/string.h"
#include "common.h" #include "common.h"
#include "downloadpriority.h" #include "downloadpriority.h"
#include "ltqhash.h"
#include "ltunderlyingtype.h" #include "ltunderlyingtype.h"
#include "peeraddress.h" #include "peeraddress.h"
#include "peerinfo.h" #include "peerinfo.h"
@ -71,18 +72,6 @@ const QString QB_EXT {QStringLiteral(".!qB")};
using namespace BitTorrent; using namespace BitTorrent;
namespace libtorrent
{
namespace aux
{
template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed)
{
return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed);
}
}
}
namespace namespace
{ {
std::vector<lt::download_priority_t> toLTDownloadPriorities(const QVector<DownloadPriority> &priorities) std::vector<lt::download_priority_t> toLTDownloadPriorities(const QVector<DownloadPriority> &priorities)