diff options
| author | 2018-08-15 05:38:37 -0400 | |
|---|---|---|
| committer | 2018-08-15 05:52:37 -0400 | |
| commit | 87d8a9c98626be491e87e4b9fad84b862d8aa0c9 (patch) | |
| tree | d242adb55cd5998b6f5ee20462717d6a916bb552 /src/core/loader/loader.cpp | |
| parent | Merge pull request #1067 from lioncash/init (diff) | |
| download | yuzu-87d8a9c98626be491e87e4b9fad84b862d8aa0c9.tar.gz yuzu-87d8a9c98626be491e87e4b9fad84b862d8aa0c9.tar.xz yuzu-87d8a9c98626be491e87e4b9fad84b862d8aa0c9.zip | |
loader: Make ResultStatus directly compatible with fmt
We can make the enum class type compatible with fmt by providing an
overload of operator<<.
While we're at it, perform proper bounds checking. If something exceeds
the array, it should be a hard fail, because it's, without a doubt, a
programmer error in this case.
Diffstat (limited to 'src/core/loader/loader.cpp')
| -rw-r--r-- | src/core/loader/loader.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index b143f043c..5e07a3f10 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | #include <ostream> | ||
| 6 | #include <string> | 7 | #include <string> |
| 7 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 8 | #include "common/string_util.h" | 9 | #include "common/string_util.h" |
| @@ -119,14 +120,9 @@ constexpr std::array<const char*, 36> RESULT_MESSAGES{ | |||
| 119 | "There is no control data available.", | 120 | "There is no control data available.", |
| 120 | }; | 121 | }; |
| 121 | 122 | ||
| 122 | std::string GetMessageForResultStatus(ResultStatus status) { | 123 | std::ostream& operator<<(std::ostream& os, ResultStatus status) { |
| 123 | return GetMessageForResultStatus(static_cast<u16>(status)); | 124 | os << RESULT_MESSAGES.at(static_cast<size_t>(status)); |
| 124 | } | 125 | return os; |
| 125 | |||
| 126 | std::string GetMessageForResultStatus(u16 status) { | ||
| 127 | if (status >= 36) | ||
| 128 | return ""; | ||
| 129 | return RESULT_MESSAGES[status]; | ||
| 130 | } | 126 | } |
| 131 | 127 | ||
| 132 | /** | 128 | /** |