mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-27 04:36:18 +00:00
DiscIO: Use std::optional in Volume and Blob
This commit is contained in:
parent
e23cfc2965
commit
c3fa0d6edf
23 changed files with 232 additions and 237 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -46,13 +47,12 @@ public:
|
|||
// NOT thread-safe - can't call this from multiple threads.
|
||||
virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0;
|
||||
template <typename T>
|
||||
bool ReadSwapped(u64 offset, T* buffer)
|
||||
std::optional<T> ReadSwapped(u64 offset)
|
||||
{
|
||||
T temp;
|
||||
if (!Read(offset, sizeof(T), reinterpret_cast<u8*>(&temp)))
|
||||
return false;
|
||||
*buffer = Common::FromBigEndian(temp);
|
||||
return true;
|
||||
return {};
|
||||
return Common::FromBigEndian(temp);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue