Skip to content

Commit

Permalink
Fix header file type id definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Sep 29, 2024
1 parent c2d3c98 commit a415088
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/serialization/include/serialization/SerializationBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ namespace l::serialization {
while (src >> tmp) dst.push_back(tmp);
}

extern const int32_t kHeaderIdentifier;

struct HeaderValidity {
static const int32_t kIdentifier = 0x00defa00; // storage base file identifier

friend zpp::serializer::access;
template <typename Archive, typename Self>
Expand All @@ -51,10 +52,10 @@ namespace l::serialization {
}

bool IsIdentifierValid() {
return mIdentifier == kIdentifier;
return mIdentifier == kHeaderIdentifier;
}
bool IsVersionValid(int32_t latestVersion) {
if (mIdentifier != kIdentifier) {
if (mIdentifier != kHeaderIdentifier) {
mVersion = mIdentifier; // we might have loaded data without identifier but with version, so check
}
return mVersion >= 0 && mVersion <= latestVersion;
Expand Down Expand Up @@ -151,7 +152,7 @@ namespace l::serialization {
*p = self.mLatestVersion;

if (self.mUseIdentifier) {
archive(HeaderValidity::kIdentifier);
archive(kHeaderIdentifier);
}
if (self.mUseVersion) {
archive(self.mVersion);
Expand All @@ -165,7 +166,7 @@ namespace l::serialization {
if (self.mUseIdentifier) {
int32_t fileIdentifier;
archive(fileIdentifier);
ASSERT(fileIdentifier == HeaderValidity::kIdentifier);
ASSERT(fileIdentifier == kHeaderIdentifier);
}
if (self.mUseVersion) {
archive(self.mVersion);
Expand Down
1 change: 1 addition & 0 deletions packages/serialization/source/common/SerializationBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
#include <ctime>

namespace l::serialization {
const int32_t kIdentifier = 0x00defa00; // storage base file identifier

}

0 comments on commit a415088

Please sign in to comment.