mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-05 20:24:01 +01:00
SaveState: Rename ChunkFile files to Serialize.
Makes more sense and less weird than ChunkFileDoMap, etc.
This commit is contained in:
1 parent
d0f3cfeb9b
commit
b8342fb8ec
112 files changed
+268
-231
No files matched your search
@@ -0,0 +1,69 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Templates for save state serialization. See Serializer.h.
|
||||
#include <set>
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
|
||||
template <class T>
|
||||
void DoSet(PointerWrap &p, std::set<T> &x) {
|
||||
unsigned int number = (unsigned int)x.size();
|
||||
Do(p, number);
|
||||
|
||||
switch (p.mode) {
|
||||
case PointerWrap::MODE_READ:
|
||||
{
|
||||
x.clear();
|
||||
while (number-- > 0) {
|
||||
T it = T();
|
||||
Do(p, it);
|
||||
x.insert(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PointerWrap::MODE_WRITE:
|
||||
case PointerWrap::MODE_MEASURE:
|
||||
case PointerWrap::MODE_VERIFY:
|
||||
{
|
||||
typename std::set<T>::iterator itr = x.begin();
|
||||
while (number-- > 0)
|
||||
Do(p, *itr++);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(SAVESTATE, "Savestate error: invalid mode %d.", p.mode);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Do(PointerWrap &p, std::set<T *> &x) {
|
||||
if (p.mode == PointerWrap::MODE_READ) {
|
||||
for (auto it = x.begin(), end = x.end(); it != end; ++it) {
|
||||
if (*it != nullptr)
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
DoSet(p, x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Do(PointerWrap &p, std::set<T> &x) {
|
||||
DoSet(p, x);
|
||||
}
|
||||
Reference in new issue
Block a user