So yeah, while TorrentRead is not compulsory to use, right now it'd be pretty inconvenient to not use it as the hash grouping function is fidgety to get right. I think group_torrent_hashes() eventually should be moved elsewhere.
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
/* Copyright 2025, Michele "King_DuckZ" Santullo
|
|
* This file is part of ducktorrent.
|
|
*
|
|
* Ducktorrent 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 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Ducktorrent 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 ducktorrent. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string_view>
|
|
#include <boost/spirit/home/x3/support/ast/variant.hpp>
|
|
#include <map>
|
|
#include <vector>
|
|
#include <stdexcept>
|
|
|
|
namespace duck {
|
|
typedef std::string_view TorrentStringType;
|
|
typedef signed long long int TorrentIntType;
|
|
|
|
class ParseError : public std::runtime_error {
|
|
public:
|
|
ParseError (const std::string& desc);
|
|
~ParseError() noexcept = default;
|
|
};
|
|
|
|
struct TorrentValue : public boost::spirit::x3::variant<
|
|
TorrentIntType,
|
|
TorrentStringType,
|
|
boost::spirit::x3::forward_ast< std::vector<TorrentValue> >,
|
|
boost::spirit::x3::forward_ast< std::map<TorrentStringType, TorrentValue> >
|
|
> {
|
|
using base_type::base_type;
|
|
using base_type::operator=;
|
|
};
|
|
|
|
std::vector<TorrentValue> parse_torrent (std::string_view binary_data);
|
|
} //namespace duck
|