Use more std::span arguments

This commit is contained in:
Sintendo 2026-02-01 09:20:46 +01:00
parent c05b231015
commit f6a67aa6e7
79 changed files with 164 additions and 146 deletions

View File

@ -486,7 +486,7 @@ void Lexer::EatAndReset()
SetIdentifierMatchRule(IdentifierMatchRule::Typical);
}
std::optional<std::string_view> Lexer::RunDfa(const std::vector<DfaNode>& dfa) const
std::optional<std::string_view> Lexer::RunDfa(std::span<const DfaNode> dfa) const
{
size_t dfa_index = 0;
bool transition_found;

View File

@ -7,6 +7,7 @@
#include <array>
#include <deque>
#include <optional>
#include <span>
#include <string_view>
#include <vector>
@ -166,7 +167,7 @@ public:
}
private:
std::optional<std::string_view> RunDfa(const std::vector<DfaNode>& dfa) const;
std::optional<std::string_view> RunDfa(std::span<const DfaNode> dfa) const;
void SkipWs() const;
void FeedbackTokens() const;
bool IdentifierHeadExtra(char h) const;

View File

@ -89,7 +89,7 @@ void Watches::RemoveWatch(std::size_t index)
m_watches.erase(m_watches.begin() + index);
}
void Watches::LoadFromStrings(const std::vector<std::string>& watches)
void Watches::LoadFromStrings(std::span<const std::string> watches)
{
for (const std::string& watch : watches)
{

View File

@ -4,6 +4,7 @@
#pragma once
#include <cstddef>
#include <span>
#include <string>
#include <vector>
@ -42,7 +43,7 @@ public:
void DisableWatch(std::size_t index);
bool HasEnabledWatch(u32 address) const;
void RemoveWatch(std::size_t index);
void LoadFromStrings(const std::vector<std::string>& watches);
void LoadFromStrings(std::span<const std::string> watches);
std::vector<std::string> SaveToStrings() const;
void Clear();

View File

@ -96,13 +96,13 @@ HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& he
return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0, codes);
}
HttpRequest::Response HttpRequest::Post(const std::string& url, const std::vector<u8>& payload,
HttpRequest::Response HttpRequest::Post(const std::string& url, std::span<const u8> payload,
const Headers& headers, AllowedReturnCodes codes)
{
return m_impl->Fetch(url, Impl::Method::POST, headers, payload.data(), payload.size(), codes);
}
HttpRequest::Response HttpRequest::Post(const std::string& url, const std::string& payload,
HttpRequest::Response HttpRequest::Post(const std::string& url, std::string_view payload,
const Headers& headers, AllowedReturnCodes codes)
{
return m_impl->Fetch(url, Impl::Method::POST, headers,

View File

@ -10,6 +10,7 @@
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include "Common/CommonTypes.h"
@ -50,9 +51,9 @@ public:
std::string GetHeaderValue(std::string_view name) const;
Response Get(const std::string& url, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response Post(const std::string& url, const std::vector<u8>& payload, const Headers& headers = {},
Response Post(const std::string& url, std::span<const u8> payload, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response Post(const std::string& url, const std::string& payload, const Headers& headers = {},
Response Post(const std::string& url, std::string_view payload, const Headers& headers = {},
AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
Response PostMultiform(const std::string& url, std::span<Multiform> multiform,

View File

@ -462,7 +462,7 @@ DHCPBody::DHCPBody(u32 transaction, const MACAddress& client_address, u32 new_ip
DHCPPacket::DHCPPacket() = default;
DHCPPacket::DHCPPacket(const std::vector<u8>& data)
DHCPPacket::DHCPPacket(std::span<const u8> data)
{
if (data.size() < DHCPBody::SIZE)
return;
@ -489,7 +489,7 @@ DHCPPacket::DHCPPacket(const std::vector<u8>& data)
}
}
void DHCPPacket::AddOption(u8 fnc, const std::vector<u8>& params)
void DHCPPacket::AddOption(u8 fnc, std::span<const u8> params)
{
if (params.size() > 255)
return;
@ -507,7 +507,7 @@ std::vector<u8> DHCPPacket::Build() const
{
result.insert(result.end(), opt.begin(), opt.end());
}
const std::vector<u8> no_option = {255, 0, 0, 0};
constexpr auto no_option = std::to_array<u8>({255, 0, 0, 0});
result.insert(result.end(), no_option.begin(), no_option.end());
return result;

View File

@ -4,7 +4,9 @@
#pragma once
#include <array>
#include <initializer_list>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <type_traits>
@ -183,8 +185,12 @@ static_assert(sizeof(DHCPBody) == DHCPBody::SIZE);
struct DHCPPacket
{
DHCPPacket();
DHCPPacket(const std::vector<u8>& data);
void AddOption(u8 fnc, const std::vector<u8>& params);
DHCPPacket(std::span<const u8> data);
void AddOption(u8 fnc, std::span<const u8> params);
void AddOption(u8 fnc, std::initializer_list<u8> params)
{
AddOption(fnc, {params.begin(), params.end()});
}
std::vector<u8> Build() const;
DHCPBody body;

View File

@ -31,7 +31,7 @@ DolReader::DolReader(const std::string& filename) : BootExecutableReader(filenam
DolReader::~DolReader() = default;
bool DolReader::Initialize(const std::vector<u8>& buffer)
bool DolReader::Initialize(std::span<const u8> buffer)
{
if (buffer.size() < sizeof(SDolHeader) || buffer.size() > UINT32_MAX)
return false;

View File

@ -65,7 +65,7 @@ private:
bool m_is_ancast;
// Copy sections to internal buffers
bool Initialize(const std::vector<u8>& buffer);
bool Initialize(std::span<const u8> buffer);
bool LoadAncastIntoMemory(Core::System& system) const;
};

View File

@ -111,7 +111,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
template <typename T>
auto Cheats::NewSearch(const Core::CPUThreadGuard& guard,
const std::vector<Cheats::MemoryRange>& memory_ranges,
std::span<const Cheats::MemoryRange> memory_ranges,
PowerPC::RequestedAddressSpace address_space, bool aligned,
const std::function<bool(const T& value)>& validator)
-> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
@ -164,7 +164,7 @@ auto Cheats::NewSearch(const Core::CPUThreadGuard& guard,
template <typename T>
auto Cheats::NextSearch(
const Core::CPUThreadGuard& guard, const std::vector<Cheats::SearchResult<T>>& previous_results,
const Core::CPUThreadGuard& guard, std::span<const Cheats::SearchResult<T>> previous_results,
PowerPC::RequestedAddressSpace address_space,
const std::function<bool(const T& new_value, const T& old_value)>& validator)
-> std::expected<std::vector<SearchResult<T>>, SearchErrorCode>

View File

@ -117,7 +117,7 @@ std::vector<u8> GetValueAsByteVector(const SearchValue& value);
// for which the given validator returns true.
template <typename T>
std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
NewSearch(const Core::CPUThreadGuard& guard, const std::vector<MemoryRange>& memory_ranges,
NewSearch(const Core::CPUThreadGuard& guard, std::span<const MemoryRange> memory_ranges,
PowerPC::RequestedAddressSpace address_space, bool aligned,
const std::function<bool(const T& value)>& validator);
@ -125,7 +125,7 @@ NewSearch(const Core::CPUThreadGuard& guard, const std::vector<MemoryRange>& mem
// which the given validator returns true.
template <typename T>
std::expected<std::vector<SearchResult<T>>, SearchErrorCode>
NextSearch(const Core::CPUThreadGuard& guard, const std::vector<SearchResult<T>>& previous_results,
NextSearch(const Core::CPUThreadGuard& guard, std::span<const SearchResult<T>> previous_results,
PowerPC::RequestedAddressSpace address_space,
const std::function<bool(const T& new_value, const T& old_value)>& validator);

View File

@ -367,7 +367,7 @@ std::vector<std::string> GetIsoPaths()
return paths;
}
void SetIsoPaths(const std::vector<std::string>& paths)
void SetIsoPaths(std::span<const std::string> paths)
{
size_t old_size = MathUtil::SaturatingCast<size_t>(Config::Get(Config::MAIN_ISO_PATH_COUNT));
size_t new_size = paths.size();

View File

@ -218,7 +218,7 @@ extern const Info<int> MAIN_GDB_PORT;
extern const Info<int> MAIN_ISO_PATH_COUNT;
extern const Info<std::string> MAIN_SKYLANDERS_PATH;
std::vector<std::string> GetIsoPaths();
void SetIsoPaths(const std::vector<std::string>& paths);
void SetIsoPaths(std::span<const std::string> paths);
// Main.GBA

View File

@ -4,6 +4,7 @@
#include "Core/DSP/DSPCodeUtil.h"
#include <algorithm>
#include <span>
#include <string>
#include <vector>
@ -35,7 +36,7 @@ bool Assemble(const std::string& text, std::vector<u16>& code, bool force)
return assembler.Assemble(text, code);
}
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text)
bool Disassemble(std::span<const u16> code, bool line_numbers, std::string& text)
{
if (code.empty())
return false;
@ -56,7 +57,7 @@ bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& t
// NOTE: This code is called from DSPTool and UnitTests, which do not use the logging system.
// Thus, fmt::print is used instead of the log system.
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
bool Compare(std::span<const u16> code1, std::span<const u16> code2)
{
if (code1.size() != code2.size())
fmt::print("Size difference! 1={} 2={}\n", code1.size(), code2.size());
@ -106,7 +107,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
if (code2.size() != code1.size())
{
fmt::print("Extra code words:\n");
const std::vector<u16>& longest = code1.size() > code2.size() ? code1 : code2;
const auto longest = code1.size() > code2.size() ? code1 : code2;
for (u16 i = min_size; i < longest.size(); i++)
{
u16 pc = i;
@ -119,7 +120,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
return code1.size() == code2.size() && code1.size() == count_equal;
}
std::string CodeToBinaryStringBE(const std::vector<u16>& code)
std::string CodeToBinaryStringBE(std::span<const u16> code)
{
std::string str(code.size() * 2, '\0');
@ -153,7 +154,7 @@ std::optional<std::vector<u16>> LoadBinary(const std::string& filename)
return std::make_optional(BinaryStringBEToCode(buffer));
}
bool SaveBinary(const std::vector<u16>& code, const std::string& filename)
bool SaveBinary(std::span<const u16> code, const std::string& filename)
{
const std::string buffer = CodeToBinaryStringBE(code);

View File

@ -4,6 +4,7 @@
#pragma once
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -12,16 +13,16 @@
namespace DSP
{
bool Assemble(const std::string& text, std::vector<u16>& code, bool force = false);
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text);
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2);
bool Disassemble(std::span<const u16> code, bool line_numbers, std::string& text);
bool Compare(std::span<const u16> code1, std::span<const u16> code2);
// Big-endian, for writing straight to file using File::WriteStringToFile.
std::string CodeToBinaryStringBE(const std::vector<u16>& code);
std::string CodeToBinaryStringBE(std::span<const u16> code);
std::vector<u16> BinaryStringBEToCode(const std::string& str);
// Load code (big endian binary).
std::optional<std::vector<u16>> LoadBinary(const std::string& filename);
bool SaveBinary(const std::vector<u16>& code, const std::string& filename);
bool SaveBinary(std::span<const u16> code, const std::string& filename);
bool DumpDSPCode(const u8* code_be, size_t size_in_bytes, u32 crc);
} // namespace DSP

View File

@ -7,7 +7,6 @@
#include <limits>
#include <string>
#include <utility>
#include <vector>
#include <fmt/format.h>
@ -23,7 +22,7 @@ DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(
{
}
bool DSPDisassembler::Disassemble(const std::vector<u16>& code, std::string& text)
bool DSPDisassembler::Disassemble(std::span<const u16> code, std::string& text)
{
if (code.size() > std::numeric_limits<u16>::max())
{
@ -140,7 +139,7 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
return buf;
}
bool DSPDisassembler::DisassembleOpcode(const std::vector<u16>& code, u16* pc, std::string& dest)
bool DSPDisassembler::DisassembleOpcode(std::span<const u16> code, u16* pc, std::string& dest)
{
return DisassembleOpcode(code.data(), code.size(), pc, dest);
}

View File

@ -4,8 +4,8 @@
#pragma once
#include <span>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
@ -32,11 +32,11 @@ class DSPDisassembler
public:
explicit DSPDisassembler(const AssemblerSettings& settings);
bool Disassemble(const std::vector<u16>& code, std::string& text);
bool Disassemble(std::span<const u16> code, std::string& text);
// Disassembles the given opcode at pc and increases pc by the opcode's size.
// The PC is wrapped such that 0x0000 and 0x8000 both point to the start of the buffer.
bool DisassembleOpcode(const std::vector<u16>& code, u16* pc, std::string& dest);
bool DisassembleOpcode(std::span<const u16> code, u16* pc, std::string& dest);
bool DisassembleOpcode(const u16* binbuf, size_t binbuf_size, u16* pc, std::string& dest);
private:

View File

@ -5,6 +5,7 @@
#include <cstddef>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -40,7 +41,7 @@ public:
virtual void DisableWatch(std::size_t index) = 0;
virtual bool HasEnabledWatch(u32 address) const = 0;
virtual void RemoveWatch(std::size_t index) = 0;
virtual void LoadWatchesFromStrings(const std::vector<std::string>& watches) = 0;
virtual void LoadWatchesFromStrings(std::span<const std::string> watches) = 0;
virtual std::vector<std::string> SaveWatchesToStrings() const = 0;
virtual void ClearWatches() = 0;

View File

@ -158,7 +158,7 @@ void PPCDebugInterface::RemoveWatch(std::size_t index)
return m_watches.RemoveWatch(index);
}
void PPCDebugInterface::LoadWatchesFromStrings(const std::vector<std::string>& watches)
void PPCDebugInterface::LoadWatchesFromStrings(std::span<const std::string> watches)
{
m_watches.LoadFromStrings(watches);
}

View File

@ -65,7 +65,7 @@ public:
void DisableWatch(std::size_t index) override;
bool HasEnabledWatch(u32 address) const override;
void RemoveWatch(std::size_t index) override;
void LoadWatchesFromStrings(const std::vector<std::string>& watches) override;
void LoadWatchesFromStrings(std::span<const std::string> watches) override;
std::vector<std::string> SaveWatchesToStrings() const override;
void ClearWatches() override;

View File

@ -389,8 +389,7 @@ bool FifoDataFile::GetFlag(u32 flag) const
return !!(m_Flags & flag);
}
u64 FifoDataFile::WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates,
File::IOFile& file)
u64 FifoDataFile::WriteMemoryUpdates(std::span<const MemoryUpdate> memUpdates, File::IOFile& file)
{
// Add space for memory update list
u64 updateListOffset = file.Tell();

View File

@ -5,6 +5,7 @@
#include <array>
#include <memory>
#include <span>
#include <string>
#include <vector>
@ -92,7 +93,7 @@ private:
void SetFlag(u32 flag, bool set);
bool GetFlag(u32 flag) const;
u64 WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);
u64 WriteMemoryUpdates(std::span<const MemoryUpdate> memUpdates, File::IOFile& file);
static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates,
std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);

View File

@ -231,7 +231,7 @@ static void SaveGeckoCode(std::vector<std::string>& lines, const GeckoCode& gcod
lines.push_back('*' + note);
}
void SaveCodes(Common::IniFile& inifile, const std::vector<GeckoCode>& gcodes)
void SaveCodes(Common::IniFile& inifile, std::span<const GeckoCode> gcodes)
{
std::vector<std::string> lines;
std::vector<std::string> enabled_lines;

View File

@ -5,6 +5,7 @@
#include <expected>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -19,7 +20,7 @@ namespace Gecko
{
std::vector<GeckoCode> LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni);
std::expected<std::vector<GeckoCode>, int> DownloadCodes(std::string gametdb_id);
void SaveCodes(Common::IniFile& inifile, const std::vector<GeckoCode>& gcodes);
void SaveCodes(Common::IniFile& inifile, std::span<const GeckoCode> gcodes);
std::optional<GeckoCode::Code> DeserializeLine(const std::string& line);
} // namespace Gecko

View File

@ -133,7 +133,7 @@ void DVDInterface::DoState(PointerWrap& p)
}
size_t DVDInterface::ProcessDTKSamples(s16* target_samples, size_t target_block_count,
const std::vector<u8>& audio_data)
std::span<const u8> audio_data)
{
const size_t block_count_to_process =
std::min(target_block_count, audio_data.size() / StreamADPCM::ONE_BLOCK_SIZE);
@ -192,7 +192,7 @@ u32 DVDInterface::AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process)
}
void DVDInterface::DTKStreamingCallback(DIInterruptType interrupt_type,
const std::vector<u8>& audio_data, s64 cycles_late)
std::span<const u8> audio_data, s64 cycles_late)
{
auto& ai = m_system.GetAudioInterface();
@ -1305,7 +1305,7 @@ void DVDInterface::SetDriveError(DriveError error)
}
void DVDInterface::FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type,
s64 cycles_late, const std::vector<u8>& data)
s64 cycles_late, std::span<const u8> data)
{
// The data parameter contains the requested data iff this was called from DVDThread, and is
// empty otherwise. DVDThread is the only source of ReplyType::NoReply and ReplyType::DTK.

View File

@ -6,6 +6,7 @@
#include <array>
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -170,17 +171,17 @@ public:
// Used by DVDThread
void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late,
const std::vector<u8>& data = std::vector<u8>());
std::span<const u8> data = {});
// Used by IOS HLE
void SetInterruptEnabled(DIInterruptType interrupt, bool enabled);
void ClearInterrupt(DIInterruptType interrupt);
private:
void DTKStreamingCallback(DIInterruptType interrupt_type, const std::vector<u8>& audio_data,
void DTKStreamingCallback(DIInterruptType interrupt_type, std::span<const u8> audio_data,
s64 cycles_late);
size_t ProcessDTKSamples(s16* target_samples, size_t target_block_count,
const std::vector<u8>& audio_data);
const std::span<const u8> audio_data);
u32 AdvanceDTK(u32 maximum_blocks, u32* blocks_to_process);
void SetLidOpen();

View File

@ -124,9 +124,9 @@ bool CEXIETHERNET::BuiltInBBAInterface::IsActivated()
return m_active;
}
void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector<u8>& data)
void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(std::vector<u8> data)
{
m_queue_data[m_queue_write] = data;
m_queue_data[m_queue_write] = std::move(data);
const u8 next_write_index = (m_queue_write + 1) & 15;
if (next_write_index != m_queue_read)
m_queue_write = next_write_index;
@ -178,7 +178,7 @@ void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
// Otherwise, enqueue it
const auto socket_data = TryGetDataFromSocket(&net_ref);
if (socket_data.has_value())
WriteToQueue(*socket_data);
WriteToQueue(std::move(*socket_data));
}
else
{
@ -220,7 +220,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleDHCP(const Common::UDPPacket& pack
const u8* router_ip_ptr = reinterpret_cast<const u8*>(&m_router_ip);
const std::vector<u8> ip_part(router_ip_ptr, router_ip_ptr + sizeof(m_router_ip));
const std::vector<u8> timeout_24h = {0, 1, 0x51, 0x80};
constexpr auto timeout_24h = std::to_array<u8>({0, 1, 0x51, 0x80});
Common::DHCPPacket reply;
reply.body = Common::DHCPBody(request.transaction_id, m_current_mac, m_current_ip, m_router_ip);
@ -666,8 +666,7 @@ bool CEXIETHERNET::BuiltInBBAInterface::SendFrame(const u8* frame, u32 size)
case IPPROTO_IGMP:
{
// Acknowledge IGMP packet
const std::vector<u8> data(frame, frame + size);
WriteToQueue(data);
WriteToQueue({frame, frame + size});
break;
}

View File

@ -463,7 +463,7 @@ private:
Common::Flag m_read_thread_shutdown;
static void ReadThreadHandler(BuiltInBBAInterface* self);
#endif
void WriteToQueue(const std::vector<u8>& data);
void WriteToQueue(std::vector<u8> data);
bool WillQueueOverrun() const;
void PollData(std::size_t* datasize);
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);

View File

@ -369,7 +369,7 @@ bool MemoryManager::TryAddLargePageTableMapping(u32 logical_address, u32 transla
return CanCreateHostMappingForGuestPages(entries);
}
bool MemoryManager::CanCreateHostMappingForGuestPages(const std::vector<u32>& entries) const
bool MemoryManager::CanCreateHostMappingForGuestPages(std::span<const u32> entries) const
{
const u32 translated_address = entries[0];
if ((translated_address & (m_page_size - 1)) != 0)

View File

@ -289,7 +289,7 @@ private:
void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable);
bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address,
std::map<u32, std::vector<u32>>& map);
bool CanCreateHostMappingForGuestPages(const std::vector<u32>& entries) const;
bool CanCreateHostMappingForGuestPages(std::span<const u32> entries) const;
void AddHostPageTableMapping(u32 logical_address, u32 translated_address, bool writeable,
u32 logical_size);
void RemoveLargePageTableMapping(u32 logical_address);

View File

@ -158,7 +158,7 @@ public:
bool WriteBkHeader(const BkHeader& bk_header) override { return true; }
bool WriteFiles(const std::vector<SaveFile>& files) override
bool WriteFiles(std::span<const SaveFile> files) override
{
if (!m_uid || !m_gid)
return false;
@ -390,7 +390,7 @@ public:
return m_file.Seek(sizeof(Header), File::SeekOrigin::Begin) && m_file.WriteArray(&bk_header, 1);
}
bool WriteFiles(const std::vector<SaveFile>& files) override
bool WriteFiles(std::span<const SaveFile> files) override
{
if (!m_file.Seek(sizeof(Header) + sizeof(BkHeader), File::SeekOrigin::Begin))
return false;

View File

@ -10,6 +10,7 @@
#include <array>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -108,6 +109,6 @@ public:
virtual std::optional<std::vector<SaveFile>> ReadFiles() = 0;
virtual bool WriteHeader(const Header& header) = 0;
virtual bool WriteBkHeader(const BkHeader& bk_header) = 0;
virtual bool WriteFiles(const std::vector<SaveFile>& files) = 0;
virtual bool WriteFiles(std::span<const SaveFile> files) = 0;
};
} // namespace WiiSave

View File

@ -4,6 +4,7 @@
#pragma once
#include <memory>
#include <span>
#include <string>
#include <vector>
@ -36,7 +37,7 @@ class GBAHostInterface
public:
virtual ~GBAHostInterface() = default;
virtual void GameChanged() = 0;
virtual void FrameEnded(const std::vector<u32>& video_buffer) = 0;
virtual void FrameEnded(std::span<const u32> video_buffer) = 0;
};
enum class HostMessageID

View File

@ -4,7 +4,7 @@
#pragma once
#include <array>
#include <map>
#include <span>
#include <string>
#include <vector>
@ -376,8 +376,8 @@ private:
IPCReply SeekContent(u32 uid, const IOCtlVRequest& request);
// Title information
IPCReply GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request);
IPCReply GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request);
IPCReply GetTitleCount(std::span<const u64> titles, const IOCtlVRequest& request);
IPCReply GetTitles(std::span<const u64> titles, const IOCtlVRequest& request);
IPCReply GetOwnedTitleCount(const IOCtlVRequest& request);
IPCReply GetOwnedTitles(const IOCtlVRequest& request);
IPCReply GetTitleCount(const IOCtlVRequest& request);
@ -416,7 +416,7 @@ private:
void FinishInit();
s32 WriteSystemFile(const std::string& path, const std::vector<u8>& data, Ticks ticks = {});
s32 WriteSystemFile(const std::string& path, std::span<const u8> data, Ticks ticks = {});
s32 WriteLaunchFile(const ES::TMDReader& tmd, Ticks ticks = {});
bool BootstrapPPC();

View File

@ -399,7 +399,7 @@ std::string ESCore::GetContentPath(const u64 title_id, const ES::Content& conten
return fmt::format("{}/{:08x}.app", Common::GetTitleContentPath(title_id), content.id);
}
s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& data, Ticks ticks)
s32 ESDevice::WriteSystemFile(const std::string& path, std::span<const u8> data, Ticks ticks)
{
auto& fs = GetEmulationKernel().GetFSCore();
const std::string tmp_path = "/tmp/" + PathToFileName(path);

View File

@ -120,7 +120,7 @@ IPCReply ESDevice::GetTMDStoredContents(const IOCtlVRequest& request)
return GetStoredContents(tmd, request);
}
IPCReply ESDevice::GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request)
IPCReply ESDevice::GetTitleCount(std::span<const u64> titles, const IOCtlVRequest& request)
{
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4)
return IPCReply(ES_EINVAL);
@ -132,7 +132,7 @@ IPCReply ESDevice::GetTitleCount(const std::vector<u64>& titles, const IOCtlVReq
return IPCReply(IPC_SUCCESS);
}
IPCReply ESDevice::GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request)
IPCReply ESDevice::GetTitles(std::span<const u64> titles, const IOCtlVRequest& request)
{
if (!request.HasNumberOfValidVectors(1, 1))
return IPCReply(ES_EINVAL);

View File

@ -372,7 +372,7 @@ IPCReply ESDevice::ImportContentData(Context& context, const IOCtlVRequest& requ
return IPCReply(m_core.ImportContentData(context, content_fd, data_start, data_size));
}
static bool CheckIfContentHashMatches(const std::vector<u8>& content, const ES::Content& info)
static bool CheckIfContentHashMatches(std::span<const u8> content, const ES::Content& info)
{
return Common::SHA1::CalculateDigest(content.data(), info.size) == info.sha1;
}

View File

@ -43,7 +43,7 @@ void ARCUnpacker::Reset()
m_whole_file.clear();
}
void ARCUnpacker::AddBytes(const std::vector<u8>& bytes)
void ARCUnpacker::AddBytes(std::span<const u8> bytes)
{
m_whole_file.insert(m_whole_file.end(), bytes.begin(), bytes.end());
}
@ -244,7 +244,7 @@ std::optional<IPCReply> WFSIDevice::IOCtl(const IOCtlRequest& request)
"IOCTL_WFSI_IMPORT_CONTENT_END";
INFO_LOG_FMT(IOS_WFS, "{}", ioctl_name);
const auto callback = [this](const std::string& filename, const std::vector<u8>& bytes) {
const auto callback = [this](const std::string& filename, std::span<const u8> bytes) {
INFO_LOG_FMT(IOS_WFS, "Extract: {} ({} bytes)", filename, bytes.size());
const std::string path = WFS::NativePath(m_base_extract_path + '/' + filename);

View File

@ -5,6 +5,7 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <vector>
@ -22,9 +23,9 @@ public:
ARCUnpacker() { Reset(); }
void Reset();
void AddBytes(const std::vector<u8>& bytes);
void AddBytes(std::span<const u8> bytes);
using WriteCallback = std::function<void(const std::string&, const std::vector<u8>&)>;
using WriteCallback = std::function<void(const std::string&, std::span<const u8>)>;
void Extract(const WriteCallback& callback);
private:

View File

@ -13,7 +13,6 @@
#include <string>
#include <thread>
#include <unordered_map>
#include <utility>
#include <vector>
#include "Common/CommonTypes.h"
@ -89,7 +88,7 @@ public:
virtual void OnIndexRefreshFailed(std::string error) = 0;
virtual void ShowChunkedProgressDialog(const std::string& title, u64 data_size,
const std::vector<int>& players) = 0;
std::span<const int> players) = 0;
virtual void HideChunkedProgressDialog() = 0;
virtual void SetChunkedProgress(int pid, u64 progress) = 0;

View File

@ -116,7 +116,7 @@ bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet
return CompressFolderIntoPacketInternal(File::ScanDirectoryTree(folder_path, true), packet);
}
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet)
bool CompressBufferIntoPacket(std::span<const u8> in_buffer, sf::Packet& packet)
{
const u64 size = in_buffer.size();
packet << size;

View File

@ -5,9 +5,9 @@
#include <SFML/Network/Packet.hpp>
#include <array>
#include <chrono>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -22,7 +22,7 @@ constexpr std::chrono::milliseconds PEER_TIMEOUT = 30s;
bool CompressFileIntoPacket(const std::string& file_path, sf::Packet& packet);
bool CompressFolderIntoPacket(const std::string& folder_path, sf::Packet& packet);
bool CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet);
bool CompressBufferIntoPacket(std::span<const u8> in_buffer, sf::Packet& packet);
bool DecompressPacketIntoFile(sf::Packet& packet, const std::string& file_path);
bool DecompressPacketIntoFolder(sf::Packet& packet, const std::string& folder_path);
std::optional<std::vector<u8>> DecompressPacketIntoBuffer(sf::Packet& packet);

View File

@ -149,7 +149,7 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>* patches,
}
}
void SavePatchSection(Common::IniFile* local_ini, const std::vector<Patch>& patches)
void SavePatchSection(Common::IniFile* local_ini, std::span<const Patch> patches)
{
std::vector<std::string> lines;
std::vector<std::string> lines_enabled;

View File

@ -4,6 +4,7 @@
#pragma once
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -53,7 +54,7 @@ std::optional<PatchEntry> DeserializeLine(std::string line);
std::string SerializeLine(const PatchEntry& entry);
void LoadPatchSection(const std::string& section, std::vector<Patch>* patches,
const Common::IniFile& globalIni, const Common::IniFile& localIni);
void SavePatchSection(Common::IniFile* local_ini, const std::vector<Patch>& patches);
void SavePatchSection(Common::IniFile* local_ini, std::span<const Patch> patches);
void LoadPatches();
void AddMemoryPatch(std::size_t index);

View File

@ -267,7 +267,7 @@ struct SlotWithTimestamp
} // namespace
// Returns first slot number (1-based indexing) not in the vector.
static std::optional<int> GetEmptySlot(const std::vector<SlotWithTimestamp>& used_slots)
static std::optional<int> GetEmptySlot(std::span<const SlotWithTimestamp> used_slots)
{
for (int i = 1; i <= int(NUM_STATES); ++i)
{

View File

@ -346,7 +346,7 @@ private:
};
Response GetSystemTitles();
Response ParseTitlesResponse(const std::vector<u8>& response) const;
Response ParseTitlesResponse(std::span<const u8> response) const;
bool ShouldInstallTitle(const TitleInfo& title);
UpdateResult InstallTitleFromNUS(const std::string& prefix_url, const TitleInfo& title,
@ -371,7 +371,7 @@ OnlineSystemUpdater::OnlineSystemUpdater(UpdateCallback update_callback, const s
}
OnlineSystemUpdater::Response
OnlineSystemUpdater::ParseTitlesResponse(const std::vector<u8>& response) const
OnlineSystemUpdater::ParseTitlesResponse(std::span<const u8> response) const
{
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_buffer(response.data(), response.size());

View File

@ -575,7 +575,7 @@ u64 DirectoryBlobReader::GetDataSize() const
return m_data_size;
}
void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(const std::vector<u8>& partition_header,
void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(std::span<const u8> partition_header,
const std::string& game_partition_root)
{
std::vector<u8> header_bin(WII_NONPARTITION_DISCHEADER_SIZE);
@ -585,7 +585,7 @@ void DirectoryBlobReader::SetNonpartitionDiscHeaderFromFile(const std::vector<u8
SetNonpartitionDiscHeader(partition_header, std::move(header_bin));
}
void DirectoryBlobReader::SetNonpartitionDiscHeader(const std::vector<u8>& partition_header,
void DirectoryBlobReader::SetNonpartitionDiscHeader(std::span<const u8> partition_header,
std::vector<u8> header_bin)
{
const size_t header_bin_size = header_bin.size();
@ -619,7 +619,7 @@ void DirectoryBlobReader::SetWiiRegionDataFromFile(const std::string& game_parti
SetWiiRegionData(wii_region_data, region_bin_path);
}
void DirectoryBlobReader::SetWiiRegionData(const std::vector<u8>& wii_region_data,
void DirectoryBlobReader::SetWiiRegionData(std::span<const u8> wii_region_data,
const std::string& log_path)
{
std::vector<u8> region_data(0x10, 0x00);
@ -961,7 +961,7 @@ DirectoryBlobPartition::DirectoryBlobPartition(
}
void DirectoryBlobPartition::SetDiscType(std::optional<bool> is_wii,
const std::vector<u8>& disc_header)
std::span<const u8> disc_header)
{
if (is_wii.has_value())
{
@ -1108,7 +1108,7 @@ static void ConvertUTF8NamesToSHIFTJIS(std::vector<FSTBuilderNode>* fst)
}
}
static u32 ComputeNameSize(const std::vector<FSTBuilderNode>& files)
static u32 ComputeNameSize(std::span<const FSTBuilderNode> files)
{
u32 name_size = 0;
for (const FSTBuilderNode& entry : files)

View File

@ -200,7 +200,7 @@ public:
void SetKey(std::array<u8, VolumeWii::AES_KEY_SIZE> key) { m_key = key; }
private:
void SetDiscType(std::optional<bool> is_wii, const std::vector<u8>& disc_header);
void SetDiscType(std::optional<bool> is_wii, std::span<const u8> disc_header);
void SetBI2FromFile(const std::string& bi2_path);
void SetBI2(std::vector<u8> bi2);
@ -296,12 +296,11 @@ private:
bool EncryptPartitionData(u64 offset, u64 size, u8* buffer, u64 partition_data_offset,
u64 partition_data_decrypted_size);
void SetNonpartitionDiscHeaderFromFile(const std::vector<u8>& partition_header,
void SetNonpartitionDiscHeaderFromFile(std::span<const u8> partition_header,
const std::string& game_partition_root);
void SetNonpartitionDiscHeader(const std::vector<u8>& partition_header,
std::vector<u8> header_bin);
void SetNonpartitionDiscHeader(std::span<const u8> partition_header, std::vector<u8> header_bin);
void SetWiiRegionDataFromFile(const std::string& game_partition_root);
void SetWiiRegionData(const std::vector<u8>& wii_region_data, const std::string& log_path);
void SetWiiRegionData(std::span<const u8> wii_region_data, const std::string& log_path);
void SetPartitions(std::vector<PartitionWithType>&& partitions);
void SetPartitionHeader(DirectoryBlobPartition* partition, u64 partition_address);

View File

@ -5,6 +5,7 @@
#include <algorithm>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -155,7 +156,7 @@ static u64 GetBiggestReferencedOffset(const Volume& volume, const FileInfo& file
}
}
u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition>& partitions)
u64 GetBiggestReferencedOffset(const Volume& volume, std::span<const Partition> partitions)
{
const u64 disc_header_size = volume.GetVolumeType() == Platform::GameCubeDisc ? 0x460 : 0x50000;
u64 biggest_offset = disc_header_size;

View File

@ -4,8 +4,8 @@
#pragma once
#include <optional>
#include <span>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "DiscIO/Blob.h"
@ -84,7 +84,7 @@ std::optional<u64> GetFSTOffset(const Volume& volume, const Partition& partition
std::optional<u64> GetFSTSize(const Volume& volume, const Partition& partition);
u64 GetBiggestReferencedOffset(const Volume& volume);
u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition>& partitions);
u64 GetBiggestReferencedOffset(const Volume& volume, std::span<const Partition> partitions);
bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size);
bool IsDiscImageBlockSizeValid(int block_size, BlobType format);

View File

@ -105,7 +105,7 @@ std::vector<File::DirectIOFile> NFSFileReader::OpenFiles(const std::string& dire
return files;
}
u64 NFSFileReader::CalculateExpectedRawSize(const std::vector<NFSLBARange>& lba_ranges)
u64 NFSFileReader::CalculateExpectedRawSize(std::span<const NFSLBARange> lba_ranges)
{
u64 total_blocks = 0;
for (const NFSLBARange& range : lba_ranges)
@ -114,7 +114,7 @@ u64 NFSFileReader::CalculateExpectedRawSize(const std::vector<NFSLBARange>& lba_
return sizeof(NFSHeader) + total_blocks * BLOCK_SIZE;
}
u64 NFSFileReader::CalculateExpectedDataSize(const std::vector<NFSLBARange>& lba_ranges)
u64 NFSFileReader::CalculateExpectedDataSize(std::span<const NFSLBARange> lba_ranges)
{
u32 greatest_block_index = 0;
for (const NFSLBARange& range : lba_ranges)

View File

@ -6,6 +6,7 @@
#include <array>
#include <limits>
#include <memory>
#include <span>
#include <string>
#include <vector>
@ -68,8 +69,8 @@ private:
static std::vector<File::DirectIOFile> OpenFiles(const std::string& directory,
File::DirectIOFile first_file,
u64 expected_raw_size, u64* raw_size_out);
static u64 CalculateExpectedRawSize(const std::vector<NFSLBARange>& lba_ranges);
static u64 CalculateExpectedDataSize(const std::vector<NFSLBARange>& lba_ranges);
static u64 CalculateExpectedRawSize(std::span<const NFSLBARange> lba_ranges);
static u64 CalculateExpectedDataSize(std::span<const NFSLBARange> lba_ranges);
NFSFileReader(std::vector<NFSLBARange> lba_ranges, std::vector<File::DirectIOFile> files, Key key,
u64 raw_size);

View File

@ -218,9 +218,9 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
return disc;
}
static bool CheckRegion(const std::vector<std::string>& xml_regions, std::string_view game_region)
static bool CheckRegion(std::span<const std::string> xml_regions, std::string_view game_region)
{
if (xml_regions.begin() == xml_regions.end())
if (xml_regions.empty())
return true;
for (const auto& region : xml_regions)

View File

@ -8,7 +8,6 @@
#include <map>
#include <memory>
#include <optional>
#include <ranges>
#include <span>
#include <string>
#include <type_traits>
@ -93,7 +92,7 @@ void Volume::AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& p
AddToSyncHash(context, content);
}
std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<char16_t>& data)
std::map<Language, std::string> Volume::ReadWiiNames(std::span<const char16_t> data)
{
std::map<Language, std::string> names;
for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i)

View File

@ -81,7 +81,7 @@ public:
virtual std::vector<u8> GetContent(u16 index) const { return {}; }
virtual std::vector<u64> GetContentOffsets() const { return {}; }
virtual bool CheckContentIntegrity(const IOS::ES::Content& content,
const std::vector<u8>& encrypted_data,
std::span<const u8> encrypted_data,
const IOS::ES::TicketReader& ticket) const
{
return false;
@ -150,7 +150,7 @@ protected:
void AddTMDToSyncHash(Common::SHA1::Context* context, const Partition& partition) const;
virtual u32 GetOffsetShift() const { return 0; }
static std::map<Language, std::string> ReadWiiNames(const std::vector<char16_t>& data);
static std::map<Language, std::string> ReadWiiNames(std::span<const char16_t> data);
static constexpr size_t NUMBER_OF_LANGUAGES = 10;
static constexpr size_t NAME_CHARS_LENGTH = 42;

View File

@ -213,7 +213,7 @@ static std::vector<u8> ParseHash(const char* str)
return hash;
}
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const std::vector<u8>& data,
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(std::span<const u8> data,
const std::string& system)
{
pugi::xml_document doc;

View File

@ -85,7 +85,7 @@ private:
static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status);
static std::vector<u8> ReadDatfile(const std::string& system);
std::vector<PotentialMatch> ScanDatfile(const std::vector<u8>& data, const std::string& system);
std::vector<PotentialMatch> ScanDatfile(std::span<const u8> data, const std::string& system);
std::string m_game_id;
u16 m_revision = 0;

View File

@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <utility>
#include <vector>
@ -149,7 +150,7 @@ std::vector<u64> VolumeWAD::GetContentOffsets() const
}
bool VolumeWAD::CheckContentIntegrity(const IOS::ES::Content& content,
const std::vector<u8>& encrypted_data,
std::span<const u8> encrypted_data,
const IOS::ES::TicketReader& ticket) const
{
if (encrypted_data.size() != Common::AlignUp(content.size, 0x40))

View File

@ -6,6 +6,7 @@
#include <map>
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <vector>
@ -38,7 +39,7 @@ public:
GetCertificateChain(const Partition& partition = PARTITION_NONE) const override;
std::vector<u8> GetContent(u16 index) const override;
std::vector<u64> GetContentOffsets() const override;
bool CheckContentIntegrity(const IOS::ES::Content& content, const std::vector<u8>& encrypted_data,
bool CheckContentIntegrity(const IOS::ES::Content& content, std::span<const u8> encrypted_data,
const IOS::ES::TicketReader& ticket) const override;
IOS::ES::TicketReader GetTicketWithFixedCommonKey() const override;
std::string GetGameID(const Partition& partition = PARTITION_NONE) const override;

View File

@ -860,7 +860,7 @@ size_t WIARVZFileReader<RVZ>::Chunk::GetOutBytesWrittenExcludingExceptions() con
template <bool RVZ>
bool WIARVZFileReader<RVZ>::ApplyHashExceptions(
const std::vector<HashExceptionEntry>& exception_list,
std::span<const HashExceptionEntry> exception_list,
VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP])
{
for (const HashExceptionEntry& exception : exception_list)

View File

@ -242,7 +242,7 @@ private:
WIARVZCompressionType compression_type, u32 exception_lists = 0,
u32 rvz_packed_size = 0, u64 data_offset = 0);
static bool ApplyHashExceptions(const std::vector<HashExceptionEntry>& exception_list,
static bool ApplyHashExceptions(std::span<const HashExceptionEntry> exception_list,
VolumeWii::HashBlock hash_blocks[VolumeWii::BLOCKS_PER_GROUP]);
static std::string VersionToString(u32 version);

View File

@ -45,7 +45,7 @@ void ConfigChoiceU32::OnConfigChanged()
setCurrentIndex(ReadValue(m_setting));
}
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
ConfigStringChoice::ConfigStringChoice(std::span<const std::string> options,
const Config::Info<std::string>& setting,
Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true)
@ -57,7 +57,7 @@ ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update);
}
ConfigStringChoice::ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
ConfigStringChoice::ConfigStringChoice(std::span<const std::pair<QString, QString>> options,
const Config::Info<std::string>& setting,
Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false)

View File

@ -85,9 +85,9 @@ class ConfigStringChoice final : public ConfigControl<ToolTipComboBox>
{
Q_OBJECT
public:
ConfigStringChoice(const std::vector<std::string>& options,
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
ConfigStringChoice(std::span<const std::string> options, const Config::Info<std::string>& setting,
Config::Layer* layer = nullptr);
ConfigStringChoice(std::span<const std::pair<QString, QString>> options,
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
void Load();

View File

@ -6,8 +6,8 @@
#include <future>
#include <memory>
#include <optional>
#include <span>
#include <tuple>
#include <vector>
#include <QByteArray>
#include <QHBoxLayout>
@ -129,7 +129,7 @@ void VerifyWidget::ConnectWidgets()
#endif
}
static void SetHash(QLineEdit* line_edit, const std::vector<u8>& hash)
static void SetHash(QLineEdit* line_edit, std::span<const u8> hash)
{
const QByteArray byte_array = QByteArray::fromRawData(reinterpret_cast<const char*>(hash.data()),
static_cast<int>(hash.size()));

View File

@ -4,7 +4,6 @@
#pragma once
#include <memory>
#include <string>
#include <utility>
#include <QCheckBox>

View File

@ -98,7 +98,7 @@ void WiimoteControllersWidget::StartBluetoothAdapterRefresh()
}
void WiimoteControllersWidget::OnBluetoothAdapterRefreshComplete(
const std::vector<USBUtils::DeviceInfo>& devices)
std::span<const USBUtils::DeviceInfo> devices)
{
const int configured_vid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_VID);
const int configured_pid = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_PID);

View File

@ -4,6 +4,7 @@
#pragma once
#include <array>
#include <span>
#include <QWidget>
@ -40,7 +41,7 @@ private:
void OnBluetoothPassthroughDeviceChanged(int index);
void OnBluetoothPassthroughSyncPressed();
void OnBluetoothPassthroughResetPressed();
void OnBluetoothAdapterRefreshComplete(const std::vector<USBUtils::DeviceInfo>& devices);
void OnBluetoothAdapterRefreshComplete(std::span<const USBUtils::DeviceInfo> devices);
void OnWiimoteRefreshPressed();
void OnWiimoteConfigure(size_t index);
void StartBluetoothAdapterRefresh();

View File

@ -38,7 +38,7 @@ void GBAHost::GameChanged()
});
}
void GBAHost::FrameEnded(const std::vector<u32>& video_buffer)
void GBAHost::FrameEnded(std::span<const u32> video_buffer)
{
QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, video_buffer] {
widget_controller->FrameEnded(video_buffer);

View File

@ -5,7 +5,7 @@
#ifdef HAS_LIBMGBA
#include <vector>
#include <span>
#include "Core/Host.h"
@ -22,7 +22,7 @@ public:
explicit GBAHost(std::weak_ptr<HW::GBA::Core> core);
~GBAHost() override;
void GameChanged() override;
void FrameEnded(const std::vector<u32>& video_buffer) override;
void FrameEnded(std::span<const u32> video_buffer) override;
private:
GBAWidgetController* m_widget_controller{};

View File

@ -65,7 +65,7 @@ void ChunkedProgressDialog::ConnectWidgets()
}
void ChunkedProgressDialog::show(const QString& title, const u64 data_size,
const std::vector<int>& players)
std::span<const int> players)
{
m_progress_box->setTitle(title);
m_data_size = data_size;

View File

@ -4,7 +4,7 @@
#pragma once
#include <map>
#include <vector>
#include <span>
#include <QDialog>
@ -23,7 +23,7 @@ class ChunkedProgressDialog : public QDialog
public:
explicit ChunkedProgressDialog(QWidget* parent);
void show(const QString& title, u64 data_size, const std::vector<int>& players);
void show(const QString& title, u64 data_size, std::span<const int> players);
void SetProgress(int pid, u64 progress);
void reject() override;

View File

@ -1248,7 +1248,7 @@ void NetPlayDialog::AbortGameDigest()
}
void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u64 data_size,
const std::vector<int>& players)
std::span<const int> players)
{
QueueOnObject(this, [this, title, data_size, players] {
if (m_chunked_progress_dialog->isVisible())

View File

@ -93,7 +93,7 @@ public:
void AbortGameDigest() override;
void ShowChunkedProgressDialog(const std::string& title, u64 data_size,
const std::vector<int>& players) override;
std::span<const int> players) override;
void HideChunkedProgressDialog() override;
void SetChunkedProgress(int pid, u64 progress) override;

View File

@ -5,6 +5,7 @@
#include <chrono>
#include <numeric>
#include <span>
#include <string>
#include <picojson.h>
@ -23,14 +24,13 @@ NetPlayIndex::~NetPlayIndex()
Remove();
}
static std::optional<picojson::value> ParseResponse(const std::vector<u8>& response)
static std::optional<picojson::value> ParseResponse(std::span<const u8> response)
{
const std::string response_string(reinterpret_cast<const char*>(response.data()),
response.size());
const char* data = reinterpret_cast<const char*>(response.data());
picojson::value json;
const auto error = picojson::parse(json, response_string);
const auto error = picojson::parse(json, data, data + response.size());
if (!error.empty())
return {};

View File

@ -14,7 +14,9 @@
#include <mbedtls/sha256.h>
#include <zlib.h>
#ifdef _WIN32
#include "Common/CommonFuncs.h"
#endif
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/HttpRequest.h"
@ -204,7 +206,7 @@ void TodoList::Log() const
}
}
static bool DownloadContent(const std::vector<TodoList::DownloadOp>& to_download,
static bool DownloadContent(std::span<const TodoList::DownloadOp> to_download,
const std::string& content_base_url, const std::string& temp_path)
{
Common::HttpRequest req(std::chrono::seconds(30), ProgressCallback);
@ -337,7 +339,7 @@ static bool BackupFile(const std::string& path)
return true;
}
static bool DeleteObsoleteFiles(const std::vector<TodoList::DeleteOp>& to_delete,
static bool DeleteObsoleteFiles(std::span<const TodoList::DeleteOp> to_delete,
const std::string& install_base_path)
{
for (const auto& op : to_delete)
@ -370,7 +372,7 @@ static bool DeleteObsoleteFiles(const std::vector<TodoList::DeleteOp>& to_delete
return true;
}
static bool UpdateFiles(const std::vector<TodoList::UpdateOp>& to_update,
static bool UpdateFiles(std::span<const TodoList::UpdateOp> to_update,
const std::string& install_base_path, const std::string& temp_path)
{
#ifdef _WIN32

View File

@ -161,7 +161,7 @@ bool VertexShaderManager::UseVertexDepthRange()
// Syncs the shader constant buffers with xfmem
// TODO: A cleaner way to control the matrices without making a mess in the parameters field
void VertexShaderManager::SetConstants(const std::vector<std::string>& textures,
void VertexShaderManager::SetConstants(std::span<const std::string> textures,
XFStateManager& xf_state_manager)
{
if (constants.missing_color_hex != g_ActiveConfig.iMissingColorValue)

View File

@ -4,10 +4,9 @@
#pragma once
#include <array>
#include <span>
#include <string>
#include <vector>
#include "Common/BitSet.h"
#include "Common/CommonTypes.h"
#include "Common/Matrix.h"
#include "VideoCommon/ConstantManager.h"
@ -26,7 +25,7 @@ public:
// constant management
void SetProjectionMatrix(XFStateManager& xf_state_manager);
void SetConstants(const std::vector<std::string>& textures, XFStateManager& xf_state_manager);
void SetConstants(std::span<const std::string> textures, XFStateManager& xf_state_manager);
// data: 3 floats representing the X, Y and Z vertex model coordinates and the posmatrix index.
// out: 4 floats which will be initialized with the corresponding clip space coordinates

View File

@ -13,7 +13,7 @@
#include <gtest/gtest.h>
static bool RoundTrippableDisassemble(const std::vector<u16>& code, std::string& text)
static bool RoundTrippableDisassemble(std::span<const u16> code, std::string& text)
{
DSP::AssemblerSettings settings;
settings.ext_separator = '\'';
@ -29,7 +29,7 @@ static bool RoundTrippableDisassemble(const std::vector<u16>& code, std::string&
// This test goes from text ASM to binary to text ASM and once again back to binary.
// Then the two binaries are compared.
static bool RoundTrip(const std::vector<u16>& code1)
static bool RoundTrip(std::span<const u16> code1)
{
std::vector<u16> code2;
std::string text;
@ -90,7 +90,7 @@ static bool SuperTrip(const char* asm_code)
}
// Assembles asm_code, and verifies that it matches code1.
static bool AssembleAndCompare(const char* asm_code, const std::vector<u16>& code1)
static bool AssembleAndCompare(const char* asm_code, std::span<const u16> code1)
{
std::vector<u16> code2;
if (!DSP::Assemble(asm_code, code2))