Merge pull request #1079 from lioncash/fmt

loader: Make ResultStatus directly compatible with fmt
This commit is contained in:
bunnei 2018-08-15 18:25:57 -04:00 committed by GitHub
commit 69236e5aff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 14 deletions

View file

@ -4,11 +4,14 @@
#include <array>
#include <string>
#include <core/loader/loader.h>
#include <fmt/ostream.h>
#include "common/logging/log.h"
#include "core/file_sys/card_image.h"
#include "core/file_sys/partition_filesystem.h"
#include "core/file_sys/vfs_offset.h"
#include "core/loader/loader.h"
namespace FileSys {
@ -142,7 +145,7 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
const u16 error_id = static_cast<u16>(nca->GetStatus());
LOG_CRITICAL(Loader, "Could not load NCA {}/{}, failed with error code {:04X} ({})",
partition_names[static_cast<size_t>(part)], nca->GetName(), error_id,
Loader::GetMessageForResultStatus(nca->GetStatus()));
nca->GetStatus());
}
}

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <memory>
#include <ostream>
#include <string>
#include "common/logging/log.h"
#include "common/string_util.h"
@ -119,14 +120,9 @@ constexpr std::array<const char*, 36> RESULT_MESSAGES{
"There is no control data available.",
};
std::string GetMessageForResultStatus(ResultStatus status) {
return GetMessageForResultStatus(static_cast<u16>(status));
}
std::string GetMessageForResultStatus(u16 status) {
if (status >= 36)
return "";
return RESULT_MESSAGES[status];
std::ostream& operator<<(std::ostream& os, ResultStatus status) {
os << RESULT_MESSAGES.at(static_cast<size_t>(status));
return os;
}
/**

View file

@ -5,6 +5,7 @@
#pragma once
#include <algorithm>
#include <iosfwd>
#include <memory>
#include <string>
#include <utility>
@ -94,8 +95,7 @@ enum class ResultStatus : u16 {
ErrorNoControl,
};
std::string GetMessageForResultStatus(ResultStatus status);
std::string GetMessageForResultStatus(u16 status);
std::ostream& operator<<(std::ostream& os, ResultStatus status);
/// Interface for loading an application
class AppLoader : NonCopyable {