Serialize ArchiveManager and other code review actions
This commit is contained in:
parent
04aa351c40
commit
6760ea18b6
43 changed files with 102 additions and 67 deletions
|
@ -65,7 +65,7 @@ private:
|
|||
LowPathType type;
|
||||
std::vector<u8> binary;
|
||||
std::string string;
|
||||
std::u16string u16str{};
|
||||
std::u16string u16str;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
|
@ -77,18 +77,16 @@ private:
|
|||
case LowPathType::Char:
|
||||
ar& string;
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
case LowPathType::Wchar:
|
||||
static_assert(sizeof(wchar_t) == sizeof(char16_t));
|
||||
{
|
||||
std::wstring wstring(reinterpret_cast<wchar_t*>(u16str.data()));
|
||||
ar& wstring;
|
||||
if (!Archive::is_saving::value) {
|
||||
u16str = std::u16string(reinterpret_cast<char16_t*>(wstring.data()));
|
||||
}
|
||||
case LowPathType::Wchar: {
|
||||
std::vector<char16_t> data;
|
||||
if (Archive::is_saving::value) {
|
||||
std::copy(u16str.begin(), u16str.end(), std::back_inserter(data));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
ar& data;
|
||||
if (Archive::is_loading::value) {
|
||||
u16str = std::u16string(data.data(), data.size());
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -167,6 +167,14 @@ public:
|
|||
}
|
||||
return SaveDataArchive::CreateFile(path, size);
|
||||
}
|
||||
|
||||
private:
|
||||
ExtSaveDataArchive() = default;
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<SaveDataArchive>(*this);
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
struct ExtSaveDataArchivePath {
|
||||
|
@ -304,3 +312,4 @@ void ArchiveFactory_ExtSaveData::WriteIcon(const Path& path, const u8* icon_data
|
|||
} // namespace FileSys
|
||||
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::ExtSaveDataDelayGenerator)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::ExtSaveDataArchive)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include "core/file_sys/archive_source_sd_savedata.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include "core/file_sys/archive_source_sd_savedata.h"
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <vector>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include <boost/serialization/unordered_map.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/file_sys/archive_backend.h"
|
||||
|
@ -63,7 +64,7 @@ private:
|
|||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<ArchiveFactory>(*this);
|
||||
// NOTE: ncch_data is never written to, so we don't serialize it here
|
||||
ar& ncch_data;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/unique_ptr.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/result.h"
|
||||
|
|
|
@ -23,14 +23,6 @@ struct RomFSHeader {
|
|||
struct Descriptor {
|
||||
u32_le offset;
|
||||
u32_le length;
|
||||
|
||||
private:
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& offset;
|
||||
ar& length;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
u32_le header_length;
|
||||
Descriptor directory_hash_table;
|
||||
|
@ -146,6 +138,7 @@ private:
|
|||
if (Archive::is_loading::value) {
|
||||
Load();
|
||||
}
|
||||
// NOTE: Everything else is essentially cached, updated when we call Load
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
|
|
@ -38,10 +38,9 @@ public:
|
|||
|
||||
protected:
|
||||
std::string mount_point;
|
||||
|
||||
private:
|
||||
SaveDataArchive() = default;
|
||||
|
||||
private:
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<ArchiveBackend>(*this);
|
||||
|
@ -51,8 +50,10 @@ private:
|
|||
};
|
||||
|
||||
class SaveDataDelayGenerator;
|
||||
class ExtSaveDataArchive;
|
||||
|
||||
} // namespace FileSys
|
||||
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::SaveDataArchive)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::SaveDataDelayGenerator)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::ExtSaveDataArchive)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue