mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 08:15:37 +00:00
Use fixed size types for serialization
This commit is contained in:
parent
1b3acc85f7
commit
9584cb7ac2
2 changed files with 7 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
|
||||
namespace SerializationTesting
|
||||
{
|
||||
|
@ -20,7 +21,7 @@ namespace SerializationTesting
|
|||
}
|
||||
};
|
||||
|
||||
enum Enum
|
||||
enum Enum : std::int32_t
|
||||
{
|
||||
A,
|
||||
B,
|
||||
|
@ -30,7 +31,7 @@ namespace SerializationTesting
|
|||
struct Composite
|
||||
{
|
||||
short mFloatArray[3] = {0};
|
||||
std::vector<int> mIntVector;
|
||||
std::vector<std::int32_t> mIntVector;
|
||||
std::vector<Enum> mEnumVector;
|
||||
std::vector<Pod> mPodVector;
|
||||
std::size_t mPodDataSize = 0;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Serialization
|
||||
{
|
||||
|
@ -51,13 +52,13 @@ namespace Serialization
|
|||
-> std::enable_if_t<isContiguousContainer<T>>
|
||||
{
|
||||
if constexpr (mode == Mode::Write)
|
||||
visitor(self(), value.size());
|
||||
visitor(self(), static_cast<std::uint64_t>(value.size()));
|
||||
else
|
||||
{
|
||||
static_assert(mode == Mode::Read);
|
||||
std::size_t size = 0;
|
||||
std::uint64_t size = 0;
|
||||
visitor(self(), size);
|
||||
value.resize(size);
|
||||
value.resize(static_cast<std::size_t>(size));
|
||||
}
|
||||
self()(std::forward<Visitor>(visitor), value.data(), value.size());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue