Merge pull request #4304 from B3n30/std_optional
Replace boost::optional with std::optional where possible
This commit is contained in:
commit
9adc407112
30 changed files with 115 additions and 109 deletions
|
@ -147,7 +147,9 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
|
|||
|
||||
if (base_address == 0 && target_address == 0) {
|
||||
// Calculate the address at which to map the memory block.
|
||||
target_address = Memory::PhysicalToVirtualAddress(linear_heap_phys_address).value();
|
||||
auto maybe_vaddr = Memory::PhysicalToVirtualAddress(linear_heap_phys_address);
|
||||
ASSERT(maybe_vaddr);
|
||||
target_address = *maybe_vaddr;
|
||||
}
|
||||
|
||||
// Map the memory block into the target process
|
||||
|
|
|
@ -132,8 +132,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
|
|||
auto content_count = container.GetTitleMetadata().GetContentCount();
|
||||
content_written.resize(content_count);
|
||||
|
||||
auto title_key = container.GetTicket().GetTitleKey();
|
||||
if (title_key) {
|
||||
if (auto title_key = container.GetTicket().GetTitleKey()) {
|
||||
decryption_state->content.resize(content_count);
|
||||
for (std::size_t i = 0; i < content_count; ++i) {
|
||||
auto ctr = tmd.GetContentCTRByIndex(i);
|
||||
|
@ -340,7 +339,7 @@ InstallStatus InstallCIA(const std::string& path,
|
|||
Service::AM::CIAFile installFile(
|
||||
Service::AM::GetTitleMediaType(container.GetTitleMetadata().GetTitleID()));
|
||||
|
||||
bool title_key_available = container.GetTicket().GetTitleKey().is_initialized();
|
||||
bool title_key_available = container.GetTicket().GetTitleKey().has_value();
|
||||
|
||||
for (std::size_t i = 0; i < container.GetTitleMetadata().GetContentCount(); i++) {
|
||||
if ((container.GetTitleMetadata().GetContentTypeByIndex(static_cast<u16>(i)) &
|
||||
|
|
|
@ -208,7 +208,7 @@ ResultVal<MessageParameter> AppletManager::GlanceParameter(AppletId app_id) {
|
|||
// Note: The NS module always clears the DSPSleep and DSPWakeup signals even in GlanceParameter.
|
||||
if (next_parameter->signal == SignalType::DspSleep ||
|
||||
next_parameter->signal == SignalType::DspWakeup)
|
||||
next_parameter = boost::none;
|
||||
next_parameter = {};
|
||||
|
||||
return MakeResult<MessageParameter>(parameter);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ ResultVal<MessageParameter> AppletManager::ReceiveParameter(AppletId app_id) {
|
|||
auto result = GlanceParameter(app_id);
|
||||
if (result.Succeeded()) {
|
||||
// Clear the parameter
|
||||
next_parameter = boost::none;
|
||||
next_parameter = {};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ bool AppletManager::CancelParameter(bool check_sender, AppletId sender_appid, bo
|
|||
}
|
||||
|
||||
if (cancellation_success)
|
||||
next_parameter = boost::none;
|
||||
next_parameter = {};
|
||||
|
||||
return cancellation_success;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/fs/archive.h"
|
||||
|
@ -168,8 +168,7 @@ public:
|
|||
|
||||
private:
|
||||
/// Parameter data to be returned in the next call to Glance/ReceiveParameter.
|
||||
/// TODO(Subv): Use std::optional once we migrate to C++17.
|
||||
boost::optional<MessageParameter> next_parameter;
|
||||
std::optional<MessageParameter> next_parameter;
|
||||
|
||||
static constexpr std::size_t NumAppletSlot = 4;
|
||||
|
||||
|
|
|
@ -205,8 +205,10 @@ void Module::Interface::GetSharedFont(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
// The shared font has to be relocated to the new address before being passed to the
|
||||
// application.
|
||||
VAddr target_address =
|
||||
Memory::PhysicalToVirtualAddress(apt->shared_font_mem->linear_heap_phys_address).value();
|
||||
auto maybe_vaddr =
|
||||
Memory::PhysicalToVirtualAddress(apt->shared_font_mem->linear_heap_phys_address);
|
||||
ASSERT(maybe_vaddr);
|
||||
VAddr target_address = *maybe_vaddr;
|
||||
if (!apt->shared_font_relocated) {
|
||||
BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address);
|
||||
apt->shared_font_relocated = true;
|
||||
|
|
|
@ -133,7 +133,7 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
|
|||
}
|
||||
|
||||
// This command can only be called without a bound session.
|
||||
if (session_data->current_http_context != boost::none) {
|
||||
if (session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
|
@ -199,7 +199,7 @@ void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) {
|
|||
return;
|
||||
}
|
||||
|
||||
ASSERT_MSG(session_data->current_http_context == boost::none,
|
||||
ASSERT_MSG(!session_data->current_http_context,
|
||||
"Unimplemented CloseContext on context-bound session");
|
||||
|
||||
auto itr = contexts.find(context_handle);
|
||||
|
@ -250,7 +250,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
|
|||
}
|
||||
|
||||
// This command can only be called with a bound context
|
||||
if (session_data->current_http_context == boost::none) {
|
||||
if (!session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called without a bound context");
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
|
@ -264,7 +264,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
|
|||
LOG_ERROR(Service_HTTP,
|
||||
"Tried to add a request header on a mismatched session input context={} session "
|
||||
"context={}",
|
||||
context_handle, session_data->current_http_context.get());
|
||||
context_handle, *session_data->current_http_context);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(ERROR_STATE_ERROR);
|
||||
rb.PushMappedBuffer(value_buffer);
|
||||
|
@ -314,7 +314,7 @@ void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||
if (!session_data->initialized) {
|
||||
LOG_ERROR(Service_HTTP, "Command called without Initialize");
|
||||
result = ERROR_STATE_ERROR;
|
||||
} else if (session_data->current_http_context != boost::none) {
|
||||
} else if (session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||
result = ERROR_NOT_IMPLEMENTED;
|
||||
} else if (session_data->num_client_certs >= 2) {
|
||||
|
@ -353,7 +353,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (session_data->current_http_context != boost::none) {
|
||||
if (session_data->current_http_context) {
|
||||
LOG_ERROR(Service_HTTP, "Command called with a bound context");
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(ERROR_NOT_IMPLEMENTED);
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
|
@ -116,8 +116,8 @@ public:
|
|||
std::string url;
|
||||
RequestMethod method;
|
||||
RequestState state = RequestState::NotStarted;
|
||||
boost::optional<Proxy> proxy;
|
||||
boost::optional<BasicAuth> basic_auth;
|
||||
std::optional<Proxy> proxy;
|
||||
std::optional<BasicAuth> basic_auth;
|
||||
SSLConfig ssl_config{};
|
||||
u32 socket_buffer_size;
|
||||
std::vector<RequestHeader> headers;
|
||||
|
@ -127,7 +127,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.
|
||||
boost::optional<Context::Handle> current_http_context;
|
||||
std::optional<Context::Handle> current_http_context;
|
||||
|
||||
u32 session_id;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue