1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00
transmission/libtransmission/magnet-metainfo.h
Charles Kerr 2996e223dd
refactor: strbuf for metainfo files (#2833)
* refactor: tr_ctorSaveContents takes a string_view filename

* refactor: remove tr_ctorSaveMagnetContents

* refactor: announce_list::save takes a std::string_view

* refactor: magnet() takes an OutputIt arg

Generate the magnet link URL into an output iterator

* refactor: remove deprecated calls to tr_http_escape

* refactor: tr_torrent.torrentFile takes an OutputIterator

* refactor: tr_torrent.torrentFile returns a tr_pathbuf

* refactor: tr_torrent_metainfo.makeFilename returns a tr_pathbuf

* refactor: use tr_urlbuf in announcer-http
2022-03-28 17:13:32 -05:00

73 lines
1.4 KiB
C++

// This file Copyright 2021-2022 Mnemosyne LLC.
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#pragma once
#include <string>
#include <string_view>
#include <vector>
#include "transmission.h"
#include "announce-list.h"
#include "tr-strbuf.h" // tr_urlbuf
struct tr_error;
struct tr_variant;
class tr_magnet_metainfo
{
public:
bool parseMagnet(std::string_view magnet_link, tr_error** error = nullptr);
[[nodiscard]] tr_urlbuf magnet() const;
auto const& infoHash() const
{
return info_hash_;
}
auto const& name() const
{
return name_;
}
auto webseedCount() const
{
return std::size(webseed_urls_);
}
auto const& webseed(size_t i) const
{
return webseed_urls_[i];
}
auto& announceList()
{
return announce_list_;
}
auto const& announceList() const
{
return announce_list_;
}
std::string const& infoHashString() const
{
return info_hash_str_;
}
void setName(std::string_view name)
{
name_ = name;
}
protected:
tr_announce_list announce_list_;
std::vector<std::string> webseed_urls_;
tr_sha1_digest_t info_hash_;
std::string info_hash_str_;
std::string name_;
};