diff --git a/externals/vcpkg b/externals/vcpkg index 8b14e7e87..d293ac220 160000 --- a/externals/vcpkg +++ b/externals/vcpkg @@ -1 +1 @@ -Subproject commit 8b14e7e8729c532b7c2be9e603b7ee886b62db6b +Subproject commit d293ac220dd126165d24907b6f07e6b658b3329f diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0b1509fed..5aa411df6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -104,7 +104,6 @@ add_library(common STATIC serialization/boost_flat_set.h serialization/boost_small_vector.hpp serialization/boost_vector.hpp - serialization/optional.h string_util.cpp string_util.h swap.h diff --git a/src/common/serialization/optional.h b/src/common/serialization/optional.h deleted file mode 100644 index 52c601220..000000000 --- a/src/common/serialization/optional.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace serialization { - -// Allow serialization of std::optional -template -void save(Archive& ar, const std::optional& t, const unsigned int /*version*/) { - const bool tflag = t.has_value(); - ar << boost::serialization::make_nvp("initialized", tflag); - if (tflag) { - ar << boost::serialization::make_nvp("value", *t); - } -} - -template -void load(Archive& ar, std::optional& t, const unsigned int version) { - bool tflag; - ar >> boost::serialization::make_nvp("initialized", tflag); - if (!tflag) { - t.reset(); - return; - } - - if (version == 0) { - boost::serialization::item_version_type item_version(0); - boost::serialization::library_version_type library_version( - ar.get_library_version() - ); - - if (boost::serialization::library_version_type(3) < library_version) { - ar >> BOOST_SERIALIZATION_NVP(item_version); - } - } - - if (!t.has_value()) { - t = T(); - } - - ar >> boost::serialization::make_nvp("value", *t); -} - -template -void serialize(Archive& ar, std::optional& t, const unsigned int version) { - boost::serialization::split_free(ar, t, version); -} - -template -struct version> { - BOOST_STATIC_CONSTANT(int, value = 1); -}; - -} // serialization -} // boost \ No newline at end of file diff --git a/src/core/core.cpp b/src/core/core.cpp index 5d2280459..dee891192 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -568,7 +568,7 @@ void System::Reset() { // TODO: Properly implement the reset // Since the system is completely reinitialized, we'll have to store the deliver arg manually. - std::optional deliver_arg; + boost::optional deliver_arg; if (auto apt = Service::APT::GetModule(*this)) { deliver_arg = apt->GetAppletManager()->ReceiveDeliverArg(); } diff --git a/src/core/hle/service/apt/applet_manager.h b/src/core/hle/service/apt/applet_manager.h index 3318e4d3e..830efa20f 100644 --- a/src/core/hle/service/apt/applet_manager.h +++ b/src/core/hle/service/apt/applet_manager.h @@ -9,11 +9,10 @@ #include #include #include -#include #include +#include #include #include -#include "common/serialization/optional.h" #include "core/global.h" #include "core/hle/kernel/event.h" #include "core/hle/result.h" @@ -179,10 +178,10 @@ public: ResultCode DoApplicationJump(DeliverArg arg); - std::optional ReceiveDeliverArg() const { + boost::optional ReceiveDeliverArg() const { return deliver_arg; } - void SetDeliverArg(std::optional arg) { + void SetDeliverArg(boost::optional arg) { deliver_arg = std::move(arg); } @@ -225,7 +224,7 @@ public: private: /// Parameter data to be returned in the next call to Glance/ReceiveParameter. // NOTE: A bug in gcc prevents serializing std::optional - std::optional next_parameter; + boost::optional next_parameter; static constexpr std::size_t NumAppletSlot = 4; @@ -272,7 +271,7 @@ private: }; ApplicationJumpParameters app_jump_parameters{}; - std::optional deliver_arg{}; + boost::optional deliver_arg{}; // Holds data about the concurrently running applets in the system. std::array applet_slots = {}; diff --git a/src/core/hle/service/http_c.h b/src/core/hle/service/http_c.h index 37935b786..490e06648 100644 --- a/src/core/hle/service/http_c.h +++ b/src/core/hle/service/http_c.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -221,7 +221,7 @@ public: struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase { /// The HTTP context that is currently bound to this session, this can be empty if no context /// has been bound. Certain commands can only be called on a session with a bound context. - std::optional current_http_context; + boost::optional current_http_context; u32 session_id; diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 15ab34488..05bff9455 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -544,7 +544,7 @@ void NWM_UDS::OnWifiPacketReceived(const Network::WifiPacket& packet) { } } -std::optional NWM_UDS::GetNodeMacAddress(u16 dest_node_id, u8 flags) { +boost::optional NWM_UDS::GetNodeMacAddress(u16 dest_node_id, u8 flags) { constexpr u8 BroadcastFlag = 0x2; if ((flags & BroadcastFlag) || dest_node_id == BroadcastNetworkNodeId) { // Broadcast @@ -559,7 +559,7 @@ std::optional NWM_UDS::GetNodeMacAddress(u16 dest_node_id, return node.second.node_id == dest_node_id && node.second.connected; }); if (destination == node_map.end()) { - return std::nullopt; + return {}; } return destination->first; } diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index c1a7fc6b4..c5bff31ac 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include "common/common_types.h" #include "common/swap.h" @@ -506,7 +506,7 @@ private: /// Callback to parse and handle a received wifi packet. void OnWifiPacketReceived(const Network::WifiPacket& packet); - std::optional GetNodeMacAddress(u16 dest_node_id, u8 flags); + boost::optional GetNodeMacAddress(u16 dest_node_id, u8 flags); // Event that is signaled every time the connection status changes. std::shared_ptr connection_status_event; diff --git a/src/core/movie.cpp b/src/core/movie.cpp index 59a5c5a4b..68bcf2237 100644 --- a/src/core/movie.cpp +++ b/src/core/movie.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include "common/bit_field.h" @@ -574,28 +574,30 @@ void Movie::SetReadOnly(bool read_only_) { read_only = read_only_; } -static std::optional ReadHeader(const std::string& movie_file) { +static boost::optional ReadHeader(const std::string& movie_file) { FileUtil::IOFile save_record(movie_file, "rb"); const u64 size = save_record.GetSize(); if (!save_record || size <= sizeof(CTMHeader)) { - return std::nullopt; + return boost::none; } CTMHeader header; save_record.ReadArray(&header, 1); if (header_magic_bytes != header.filetype) { - return std::nullopt; + return boost::none; } return header; } void Movie::PrepareForPlayback(const std::string& movie_file) { - if (auto header = ReadHeader(movie_file); header) { - init_time = header.value().clock_init_time; - } + auto header = ReadHeader(movie_file); + if (header == boost::none) + return; + + init_time = header.value().clock_init_time; } void Movie::PrepareForRecording() { @@ -636,15 +638,15 @@ Movie::ValidationResult Movie::ValidateMovie(const std::string& movie_file) cons } Movie::MovieMetadata Movie::GetMovieMetadata(const std::string& movie_file) const { - if (auto header = ReadHeader(movie_file); header) { - std::array author{}; // Add a null terminator - std::memcpy(author.data(), header->author.data(), header->author.size()); + auto header = ReadHeader(movie_file); + if (header == boost::none) + return {}; - return {header->program_id, std::string{author.data()}, header->rerecord_count, - header->input_count}; - } + std::array author{}; // Add a null terminator + std::memcpy(author.data(), header->author.data(), header->author.size()); - return {}; + return {header->program_id, std::string{author.data()}, header->rerecord_count, + header->input_count}; } void Movie::Shutdown() { diff --git a/vcpkg.json b/vcpkg.json index abef623ba..253059f48 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -6,6 +6,7 @@ "boost-serialization", "boost-system", "boost-range", + "boost-optional", "boost-icl", "boost-date-time", "boost-crc",