ams: std::optional -> util::optional

This commit is contained in:
Michael Scire 2021-07-08 02:37:26 -07:00
parent 9df13781c2
commit a7c14e03b9
59 changed files with 950 additions and 147 deletions

View file

@ -38,8 +38,8 @@ namespace ams::capsrv::server {
/* Destroy the server. */
os::FinalizeEvent(std::addressof(this->idle_event));
this->server_manager_holder = std::nullopt;
this->service_holder = std::nullopt;
this->server_manager_holder = util::nullopt;
this->service_holder = util::nullopt;
}
void DecoderControlServerManager::StartServer() {

View file

@ -31,8 +31,8 @@ namespace ams::capsrv::server {
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
private:
std::optional<ServiceHolderType> service_holder;
std::optional<ServerManager> server_manager_holder;
util::optional<ServiceHolderType> service_holder;
util::optional<ServerManager> server_manager_holder;
os::EventType idle_event;
public:
constexpr DecoderControlServerManager() : service_holder(), server_manager_holder(), idle_event{} { /* ... */ }

View file

@ -26,10 +26,10 @@ namespace ams::erpt::srv {
constinit char Reporter::s_serial_number[24] = "Unknown";
constinit char Reporter::s_os_version[24] = "Unknown";
constinit char Reporter::s_private_os_version[96] = "Unknown";
constinit std::optional<os::Tick> Reporter::s_application_launch_time;
constinit std::optional<os::Tick> Reporter::s_awake_time;
constinit std::optional<os::Tick> Reporter::s_power_on_time;
constinit std::optional<time::SteadyClockTimePoint> Reporter::s_initial_launch_settings_completion_time;
constinit util::optional<os::Tick> Reporter::s_application_launch_time;
constinit util::optional<os::Tick> Reporter::s_awake_time;
constinit util::optional<os::Tick> Reporter::s_power_on_time;
constinit util::optional<time::SteadyClockTimePoint> Reporter::s_initial_launch_settings_completion_time;
namespace {
@ -78,13 +78,13 @@ namespace ams::erpt::srv {
entry->suspended_duration = suspended_duration;
}
std::optional<TimeSpan> GetActiveDuration(ncm::ProgramId program_id) const {
util::optional<TimeSpan> GetActiveDuration(ncm::ProgramId program_id) const {
/* Try to find a matching entry. */
const auto entry = util::range::find_if(m_list, [&](const AppletActiveTimeInfo &info) { return info.program_id == program_id; });
if (entry != m_list.end()) {
return (os::GetSystemTick() - entry->register_tick).ToTimeSpan() - entry->suspended_duration;
} else {
return std::nullopt;
return util::nullopt;
}
}
};

View file

@ -25,13 +25,13 @@ namespace ams::erpt::srv {
static char s_serial_number[24];
static char s_os_version[24];
static char s_private_os_version[96];
static std::optional<os::Tick> s_application_launch_time;
static std::optional<os::Tick> s_awake_time;
static std::optional<os::Tick> s_power_on_time;
static std::optional<time::SteadyClockTimePoint> s_initial_launch_settings_completion_time;
static util::optional<os::Tick> s_application_launch_time;
static util::optional<os::Tick> s_awake_time;
static util::optional<os::Tick> s_power_on_time;
static util::optional<time::SteadyClockTimePoint> s_initial_launch_settings_completion_time;
public:
static void ClearApplicationLaunchTime() { s_application_launch_time = std::nullopt; }
static void ClearInitialLaunchSettingsCompletionTime() { s_initial_launch_settings_completion_time = std::nullopt; }
static void ClearApplicationLaunchTime() { s_application_launch_time = util::nullopt; }
static void ClearInitialLaunchSettingsCompletionTime() { s_initial_launch_settings_completion_time = util::nullopt; }
static void SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time) { s_initial_launch_settings_completion_time = time; }

View file

@ -238,7 +238,7 @@ namespace ams::fs {
class SdCardRedirectionCodeFileSystem : public OpenFileOnlyFileSystem {
private:
std::optional<ReadOnlyFileSystem> sd_content_fs;
util::optional<ReadOnlyFileSystem> sd_content_fs;
ReadOnlyFileSystem code_fs;
bool is_redirect;
public:
@ -303,8 +303,8 @@ namespace ams::fs {
class AtmosphereCodeFileSystem : public OpenFileOnlyFileSystem {
private:
std::optional<SdCardRedirectionCodeFileSystem> code_fs;
std::optional<ReadOnlyFileSystem> hbl_fs;
util::optional<SdCardRedirectionCodeFileSystem> code_fs;
util::optional<ReadOnlyFileSystem> hbl_fs;
ncm::ProgramId program_id;
bool initialized;
public:

View file

@ -154,8 +154,8 @@ namespace ams::fssrv::impl {
AMS_ABORT_UNLESS(false);
}
std::optional<std::shared_lock<os::ReadWriteLock>> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() {
std::optional<std::shared_lock<os::ReadWriteLock>> lock;
util::optional<std::shared_lock<os::ReadWriteLock>> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() {
util::optional<std::shared_lock<os::ReadWriteLock>> lock;
if (this->deep_retry_enabled) {
lock.emplace(this->invalidation_lock);
}

View file

@ -34,8 +34,8 @@ namespace ams::fssrv::impl {
/* ... */
}
std::optional<std::shared_lock<os::ReadWriteLock>> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() {
std::optional<std::shared_lock<os::ReadWriteLock>> lock;
util::optional<std::shared_lock<os::ReadWriteLock>> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() {
util::optional<std::shared_lock<os::ReadWriteLock>> lock;
if (this->deep_retry_enabled) {
lock.emplace(this->invalidation_lock);
}

View file

@ -113,7 +113,7 @@ namespace ams::fssystem {
constexpr inline s32 KeySlotCacheEntryCount = 3;
KeySlotCache g_key_slot_cache;
std::optional<KeySlotCacheEntry> g_key_slot_cache_entry[KeySlotCacheEntryCount];
util::optional<KeySlotCacheEntry> g_key_slot_cache_entry[KeySlotCacheEntryCount];
spl::AccessKey &GetNcaKekAccessKey(s32 key_type) {
static spl::AccessKey s_nca_kek_access_key_array[KeyAreaEncryptionKeyCount] = {};

View file

@ -162,7 +162,7 @@ namespace ams::fssystem {
template class PartitionFileSystemMetaCore<impl::PartitionFileSystemFormat>;
template class PartitionFileSystemMetaCore<impl::Sha256PartitionFileSystemFormat>;
Result Sha256PartitionFileSystemMeta::Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, std::optional<u8> suffix) {
Result Sha256PartitionFileSystemMeta::Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, util::optional<u8> suffix) {
/* Ensure preconditions. */
R_UNLESS(hash_size == crypto::Sha256Generator::HashSize, fs::ResultPreconditionViolation());

View file

@ -59,7 +59,7 @@ namespace ams::htclow::driver {
std::scoped_lock lk(m_mutex);
/* Clear our driver type. */
m_driver_type = std::nullopt;
m_driver_type = util::nullopt;
/* Close our driver. */
if (m_open_driver != nullptr) {

View file

@ -23,7 +23,7 @@ namespace ams::htclow::driver {
class DriverManager {
private:
std::optional<htclow::impl::DriverType> m_driver_type{};
util::optional<htclow::impl::DriverType> m_driver_type{};
IDriver *m_debug_driver{};
SocketDriver m_socket_driver;
UsbDriver m_usb_driver{};

View file

@ -47,7 +47,7 @@ namespace ams::htclow::mux {
u64 m_total_send_size;
u64 m_cur_max_data;
u64 m_prev_max_data;
std::optional<u64> m_share;
util::optional<u64> m_share;
os::Event m_state_change_event;
ChannelState m_state;
public:

View file

@ -55,9 +55,9 @@ namespace ams::kvdb {
AMS_ABORT_UNLESS(this->entries != nullptr);
}
std::optional<size_t> FileKeyValueStore::Cache::TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size) {
util::optional<size_t> FileKeyValueStore::Cache::TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size) {
if (!this->HasEntries()) {
return std::nullopt;
return util::nullopt;
}
/* Try to find the entry. */
@ -66,7 +66,7 @@ namespace ams::kvdb {
if (entry.key_size == key_size && std::memcmp(entry.key, key, key_size) == 0) {
/* If we don't have enough space, fail to read from cache. */
if (max_out_size < entry.value_size) {
return std::nullopt;
return util::nullopt;
}
std::memcpy(out_value, entry.value, entry.value_size);
@ -74,12 +74,12 @@ namespace ams::kvdb {
}
}
return std::nullopt;
return util::nullopt;
}
std::optional<size_t> FileKeyValueStore::Cache::TryGetSize(const void *key, size_t key_size) {
util::optional<size_t> FileKeyValueStore::Cache::TryGetSize(const void *key, size_t key_size) {
if (!this->HasEntries()) {
return std::nullopt;
return util::nullopt;
}
/* Try to find the entry. */
@ -90,7 +90,7 @@ namespace ams::kvdb {
}
}
return std::nullopt;
return util::nullopt;
}
void FileKeyValueStore::Cache::Set(const void *key, size_t key_size, const void *value, size_t value_size) {

View file

@ -78,13 +78,13 @@ namespace ams::ncm {
util::SNPrintf(dst, dst_size, "%s.cert", str.data);
}
std::optional<ContentId> GetContentIdFromString(const char *str, size_t len) {
util::optional<ContentId> GetContentIdFromString(const char *str, size_t len) {
if (len < ContentIdStringLength) {
return std::nullopt;
return util::nullopt;
}
ContentId content_id;
return GetBytesFromString(std::addressof(content_id), sizeof(content_id), str, ContentIdStringLength) ? std::optional<ContentId>(content_id) : std::nullopt;
return GetBytesFromString(std::addressof(content_id), sizeof(content_id), str, ContentIdStringLength) ? util::optional<ContentId>(content_id) : util::nullopt;
}
}

View file

@ -225,7 +225,7 @@ namespace ams::ncm {
out->max_content_metas = max_content_metas;
out->memory_resource = memory_resource;
out->content_meta_database = nullptr;
out->kvs = std::nullopt;
out->kvs = util::nullopt;
/* Create a new mount name and copy it to out. */
std::strcpy(out->mount_name, impl::CreateUniqueMountName().str);
@ -240,7 +240,7 @@ namespace ams::ncm {
out->max_content_metas = max_content_metas;
out->memory_resource = memory_resource;
out->content_meta_database = nullptr;
out->kvs = std::nullopt;
out->kvs = util::nullopt;
return ResultSuccess();
}
@ -649,7 +649,7 @@ namespace ams::ncm {
/* N doesn't bother checking the result of this */
root->content_meta_database->DisableForcibly();
root->content_meta_database = nullptr;
root->kvs = std::nullopt;
root->kvs = util::nullopt;
/* Also unmount, except in the case of game cards. */
if (storage_id != StorageId::GameCard) {

View file

@ -18,7 +18,7 @@
namespace ams::ncm {
Result ContentMetaDatabaseImpl::GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, std::optional<u8> id_offset) const {
Result ContentMetaDatabaseImpl::GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const {
R_TRY(this->EnsureEnabled());
/* Find the meta key. */
@ -78,7 +78,7 @@ namespace ams::ncm {
}
Result ContentMetaDatabaseImpl::GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) {
return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, std::nullopt);
return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::nullopt);
}
Result ContentMetaDatabaseImpl::ListContentInfo(sf::Out<s32> out_count, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) {
@ -149,7 +149,7 @@ namespace ams::ncm {
Result ContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
R_TRY(this->EnsureEnabled());
std::optional<ContentMetaKey> found_key = std::nullopt;
util::optional<ContentMetaKey> found_key = util::nullopt;
/* Find the last key with the desired program id. */
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
@ -308,15 +308,15 @@ namespace ams::ncm {
out_orphaned[i] = true;
}
auto IsOrphanedContent = [] ALWAYS_INLINE_LAMBDA (const sf::InArray<ContentId> &list, const ncm::ContentId &id) -> std::optional<size_t> {
auto IsOrphanedContent = [] ALWAYS_INLINE_LAMBDA (const sf::InArray<ContentId> &list, const ncm::ContentId &id) -> util::optional<size_t> {
/* Check if any input content ids match our found content id. */
for (size_t i = 0; i < list.GetSize(); i++) {
if (list[i] == id) {
return std::make_optional(i);
return util::make_optional(i);
}
}
return std::nullopt;
return util::nullopt;
};
/* Iterate over all entries. */
@ -435,7 +435,7 @@ namespace ams::ncm {
}
Result ContentMetaDatabaseImpl::GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, std::make_optional(id_offset));
return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::make_optional(id_offset));
}
Result ContentMetaDatabaseImpl::GetCount(sf::Out<u32> out_count) {

View file

@ -25,7 +25,7 @@ namespace ams::ncm {
ContentMetaDatabaseImpl(ContentMetaKeyValueStore *kvs) : ContentMetaDatabaseImplBase(kvs) { /* ... */ }
private:
/* Helpers. */
Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, std::optional<u8> id_offset) const;
Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional<u8> id_offset) const;
public:
/* Actual commands. */
virtual Result Set(const ContentMetaKey &key, const sf::InBuffer &value) override;

View file

@ -116,7 +116,7 @@ namespace ams::ncm {
R_UNLESS(reader.GetExtendedDataSize() != 0, ReadMetaInfoListFromBase());
SystemUpdateMetaExtendedDataReader extended_data_reader(reader.GetExtendedData(), reader.GetExtendedDataSize());
std::optional<s32> firmware_variation_index = std::nullopt;
util::optional<s32> firmware_variation_index = util::nullopt;
/* NOTE: Atmosphere extension to support downgrading. */
/* If all firmware variations refer to base, don't require the current variation be present. */

View file

@ -208,7 +208,7 @@ namespace ams::ncm {
return this->OpenCurrentDirectory();
}
Result ContentStorageImpl::ContentIterator::GetNext(std::optional<fs::DirectoryEntry> *out) {
Result ContentStorageImpl::ContentIterator::GetNext(util::optional<fs::DirectoryEntry> *out) {
/* Iterate until we get the next entry. */
while (true) {
/* Ensure that we have entries loaded. */
@ -216,7 +216,7 @@ namespace ams::ncm {
/* If we failed to load any entries, there's nothing to get. */
if (this->entry_count <= 0) {
*out = std::nullopt;
*out = util::nullopt;
return ResultSuccess();
}
@ -353,7 +353,7 @@ namespace ams::ncm {
fs::CloseFile(this->cached_file_handle);
this->cached_content_id = InvalidContentId;
}
this->content_iterator = std::nullopt;
this->content_iterator = util::nullopt;
}
Result ContentStorageImpl::OpenContentIdFile(ContentId content_id) {
@ -586,7 +586,7 @@ namespace ams::ncm {
/* Advance to the desired offset. */
for (auto current_offset = 0; current_offset < offset; /* ... */) {
/* Get the next directory entry. */
std::optional<fs::DirectoryEntry> dir_entry;
util::optional<fs::DirectoryEntry> dir_entry;
R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry)));
/* If we run out of entries before reaching the desired offset, we're done. */
@ -606,7 +606,7 @@ namespace ams::ncm {
s32 count = 0;
while (count < static_cast<s32>(out.GetSize())) {
/* Get the next directory entry. */
std::optional<fs::DirectoryEntry> dir_entry;
util::optional<fs::DirectoryEntry> dir_entry;
R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry)));
/* Don't continue if the directory entry is absent. */

View file

@ -42,7 +42,7 @@ namespace ams::ncm {
~ContentIterator();
Result Initialize(const char *root_path, size_t max_depth);
Result GetNext(std::optional<fs::DirectoryEntry> *out);
Result GetNext(util::optional<fs::DirectoryEntry> *out);
private:
Result OpenCurrentDirectory();
Result OpenDirectory(const char *dir);
@ -53,14 +53,14 @@ namespace ams::ncm {
ContentId cached_content_id;
fs::FileHandle cached_file_handle;
RightsIdCache *rights_id_cache;
std::optional<ContentIterator> content_iterator;
std::optional<s32> last_content_offset;
util::optional<ContentIterator> content_iterator;
util::optional<s32> last_content_offset;
public:
static Result InitializeBase(const char *root_path);
static Result CleanupBase(const char *root_path);
static Result VerifyBase(const char *root_path);
public:
ContentStorageImpl() : placeholder_accessor(), cached_content_id(InvalidContentId), cached_file_handle(), rights_id_cache(nullptr), content_iterator(std::nullopt), last_content_offset(std::nullopt) { /* ... */ }
ContentStorageImpl() : placeholder_accessor(), cached_content_id(InvalidContentId), cached_file_handle(), rights_id_cache(nullptr), content_iterator(util::nullopt), last_content_offset(util::nullopt) { /* ... */ }
~ContentStorageImpl();
Result Initialize(const char *root_path, MakeContentPathFunction content_path_func, MakePlaceHolderPathFunction placeholder_path_func, bool delay_flush, RightsIdCache *rights_id_cache);

View file

@ -87,8 +87,8 @@ namespace ams::ncm {
R_TRY(this->CountInstallContentMetaData(std::addressof(count)));
/* Iterate over content meta. */
std::optional<PlaceHolderId> placeholder_id;
std::optional<StorageId> storage_id;
util::optional<PlaceHolderId> placeholder_id;
util::optional<StorageId> storage_id;
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
@ -716,7 +716,7 @@ namespace ams::ncm {
return ResultSuccess();
}
Result InstallTaskBase::WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, std::optional<bool> is_temporary) {
Result InstallTaskBase::WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional<bool> is_temporary) {
/* Generate a placeholder id. */
auto placeholder_id = storage->GeneratePlaceHolderId();
@ -736,14 +736,14 @@ namespace ams::ncm {
return ResultSuccess();
}
Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, std::optional<ContentMetaKey> expected_key, std::optional<u32> source_version) {
Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional<ContentMetaKey> expected_key, util::optional<u32> source_version) {
/* Open the BuiltInSystem content storage. */
ContentStorage content_storage;
R_TRY(OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
/* Write content meta to a placeholder. */
InstallContentInfo content_info;
R_TRY(this->WriteContentMetaToPlaceHolder(std::addressof(content_info), std::addressof(content_storage), meta_info, std::nullopt));
R_TRY(this->WriteContentMetaToPlaceHolder(std::addressof(content_info), std::addressof(content_storage), meta_info, util::nullopt));
/* Get the path of the placeholder. */
Path path;
@ -929,7 +929,7 @@ namespace ams::ncm {
/* Get and prepare install content meta info. */
InstallContentMetaInfo install_content_meta_info;
R_TRY(this->GetInstallContentMetaInfo(std::addressof(install_content_meta_info), key));
R_TRY(this->PrepareContentMeta(install_content_meta_info, key, std::nullopt));
R_TRY(this->PrepareContentMeta(install_content_meta_info, key, util::nullopt));
}
return ResultSuccess();
@ -997,7 +997,7 @@ namespace ams::ncm {
return this->data->Delete(keys, num_keys);
}
Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, std::optional<u32> source_version) {
Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional<u32> source_version) {
AutoBuffer meta;
{
fs::ScopedAutoAbortDisabler aad;
@ -1027,7 +1027,7 @@ namespace ams::ncm {
return ResultSuccess();
}
InstallContentInfo InstallTaskBase::MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, std::optional<bool> is_tmp) {
InstallContentInfo InstallTaskBase::MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, util::optional<bool> is_tmp) {
return {
.digest = info.digest,
.info = ContentInfo::Make(info.content_id, info.content_size, ContentType::Meta, 0),

View file

@ -67,7 +67,7 @@ namespace ams::ncm {
Result OnMemoryContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
R_TRY(this->EnsureEnabled());
std::optional<ContentMetaKey> found_key = std::nullopt;
util::optional<ContentMetaKey> found_key = util::nullopt;
/* Find the last key with the desired program id. */
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {

View file

@ -50,9 +50,9 @@ namespace ams::ncm {
/* Check if this entry is content meta. */
if (this->IsContentMetaContentName(entry.name)) {
/* Prepare content meta if id is valid. */
std::optional<ContentId> id = GetContentIdFromString(entry.name, strnlen(entry.name, fs::EntryNameLengthMax + 1));
util::optional<ContentId> id = GetContentIdFromString(entry.name, strnlen(entry.name, fs::EntryNameLengthMax + 1));
R_UNLESS(id, ncm::ResultInvalidPackageFormat());
R_TRY(this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(*id, entry.file_size), std::nullopt, std::nullopt));
R_TRY(this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(*id, entry.file_size), util::nullopt, util::nullopt));
}
}

View file

@ -70,7 +70,7 @@ namespace ams::ncm {
/* Get and prepare install content meta info. We aren't concerned if our key is older. */
InstallContentMetaInfo install_content_meta_info;
R_TRY(this->GetInstallContentMetaInfo(std::addressof(install_content_meta_info), key));
return this->PrepareContentMeta(install_content_meta_info, key, std::nullopt);
return this->PrepareContentMeta(install_content_meta_info, key, util::nullopt);
}
}

View file

@ -70,7 +70,7 @@ namespace ams::ncm {
return ResultSuccess();
}
std::optional<ContentMetaKey> PackageSystemUpdateTask::GetSystemUpdateMetaKey() {
util::optional<ContentMetaKey> PackageSystemUpdateTask::GetSystemUpdateMetaKey() {
StorageContentMetaKey storage_keys[0x10];
s32 ofs = 0;
@ -93,7 +93,7 @@ namespace ams::ncm {
}
} while (count > 0);
return std::nullopt;
return util::nullopt;
}
Result PackageSystemUpdateTask::GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) {
@ -117,7 +117,7 @@ namespace ams::ncm {
R_TRY(this->GetContentInfoOfContentMeta(std::addressof(info), key));
/* Prepare the content meta. */
return this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(info.GetId(), info.GetSize(), key), key, std::nullopt);
return this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(info.GetId(), info.GetSize(), key), key, util::nullopt);
}
Result PackageSystemUpdateTask::PrepareDependency() {

View file

@ -21,9 +21,9 @@ namespace ams::ncm {
class SubmissionPackageInstallTask::Impl {
private:
fs::FileHandleStorage storage;
std::optional<impl::MountName> mount_name;
util::optional<impl::MountName> mount_name;
public:
explicit Impl(fs::FileHandle file) : storage(file), mount_name(std::nullopt) { /* ... */ }
explicit Impl(fs::FileHandle file) : storage(file), mount_name(util::nullopt) { /* ... */ }
~Impl() {
if (this->mount_name) {

View file

@ -85,12 +85,12 @@ namespace ams::pgl::srv {
}
}
std::optional<os::ProcessId> GetRunningApplicationProcessId() {
util::optional<os::ProcessId> GetRunningApplicationProcessId() {
os::ProcessId process_id;
if (R_SUCCEEDED(pm::shell::GetApplicationProcessIdForShell(std::addressof(process_id)))) {
return process_id;
} else {
return std::nullopt;
return util::nullopt;
}
}

View file

@ -131,7 +131,7 @@ namespace ams::pgl::srv {
return ResultSuccess();
}
Result GetContentPath(lr::Path *out, ncm::ContentType type, std::optional<u8> index) const {
Result GetContentPath(lr::Path *out, ncm::ContentType type, util::optional<u8> index) const {
switch (this->extension_type) {
case ExtensionType::Nsp: return this->GetContentPathInNsp(out, type, index);
case ExtensionType::Nspd: return this->GetContentPathInNspd(out, type, index);
@ -155,7 +155,7 @@ namespace ams::pgl::srv {
return this->program_index;
}
private:
Result GetContentPathInNsp(lr::Path *out, ncm::ContentType type, std::optional<u8> index) const {
Result GetContentPathInNsp(lr::Path *out, ncm::ContentType type, util::optional<u8> index) const {
/* Create a reader. */
auto reader = ncm::PackagedContentMetaReader(this->content_meta_buffer.Get(), this->content_meta_buffer.GetSize());
@ -185,7 +185,7 @@ namespace ams::pgl::srv {
return ResultSuccess();
}
Result GetContentPathInNspd(lr::Path *out, ncm::ContentType type, std::optional<u8> index) const {
Result GetContentPathInNspd(lr::Path *out, ncm::ContentType type, util::optional<u8> index) const {
/* Get the content name. */
const char *content_name = nullptr;
switch (type) {

View file

@ -23,7 +23,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
namespace {
constinit std::optional<BatteryDevice> g_battery_device;
constinit util::optional<BatteryDevice> g_battery_device;
Max17050Driver &GetMax17050Driver() {
static Max17050Driver s_max17050_driver;
@ -91,7 +91,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
GetMax17050Driver().Finalize();
/* Destroy the charger device. */
g_battery_device = std::nullopt;
g_battery_device = util::nullopt;
/* Finalize gpio library. */
gpio::Finalize();

View file

@ -26,7 +26,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::BatteryDevice, ::ams::powctl::impl::IDevice);
private:
bool use_event_handler;
std::optional<BatteryInterruptEventHandler> event_handler;
util::optional<BatteryInterruptEventHandler> event_handler;
os::SystemEventType system_event;
public:
BatteryDevice(bool ev);

View file

@ -23,8 +23,8 @@ namespace ams::powctl::impl::board::nintendo::nx {
namespace {
constinit std::optional<ChargerDriver> g_charger_driver;
constinit std::optional<BatteryDriver> g_battery_driver;
constinit util::optional<ChargerDriver> g_charger_driver;
constinit util::optional<BatteryDriver> g_battery_driver;
void InitializeChargerDriver(bool use_event_handlers) {
/* Create the charger driver. */
@ -47,7 +47,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
powctl::impl::UnregisterDriver(std::addressof(*g_charger_driver));
/* Destroy the battery driver. */
g_charger_driver = std::nullopt;
g_charger_driver = util::nullopt;
}
void FinalizeBatteryDriver() {
@ -55,7 +55,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
powctl::impl::UnregisterDriver(std::addressof(*g_battery_driver));
/* Destroy the battery driver. */
g_battery_driver = std::nullopt;
g_battery_driver = util::nullopt;
}
}

View file

@ -23,7 +23,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
namespace {
constinit std::optional<ChargerDevice> g_charger_device;
constinit util::optional<ChargerDevice> g_charger_device;
Bq24193Driver &GetBq24193Driver() {
static Bq24193Driver s_bq24193_driver;
@ -80,7 +80,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
gpio::CloseSession(g_charger_device->GetPadSession());
/* Destroy the charger device. */
g_charger_device = std::nullopt;
g_charger_device = util::nullopt;
/* Finalize gpio library. */
gpio::Finalize();

View file

@ -29,7 +29,7 @@ namespace ams::powctl::impl::board::nintendo::nx {
bool watchdog_timer_enabled;
TimeSpan watchdog_timer_timeout;
bool use_event_handler;
std::optional<ChargerInterruptEventHandler> event_handler;
util::optional<ChargerInterruptEventHandler> event_handler;
os::SystemEventType system_event;
public:
ChargerDevice(bool ev);