[nx] AciHeader updated to inherit from ISerialisableBinary.

This commit is contained in:
jakcron 2017-07-06 20:56:52 +10:00
parent e7172949da
commit 844a46c83a
2 changed files with 42 additions and 3 deletions

View file

@ -19,6 +19,37 @@ void AciHeader::calculateSectionOffsets()
mKc.offset = mSac.offset + align(mSac.size, kAciAlignSize);
}
bool AciHeader::isEqual(const AciHeader & other) const
{
return (mType == other.mType) \
&& (mProgramId == other.mProgramId) \
&& (mFac.offset == other.mFac.offset) \
&& (mFac.size == other.mFac.size) \
&& (mSac.offset == other.mSac.offset) \
&& (mSac.size == other.mSac.size) \
&& (mKc.offset == other.mKc.offset) \
&& (mKc.size == other.mKc.size);
}
void AciHeader::copyFrom(const AciHeader & other)
{
if (other.getSize())
{
importBinary(other.getBytes(), other.getSize());
}
else
{
mType = other.mType;
mProgramId = other.mProgramId;
mFac.offset = other.mFac.offset;
mFac.size = other.mFac.size;
mSac.offset = other.mSac.offset;
mSac.size = other.mSac.size;
mKc.offset = other.mKc.offset;
mKc.size = other.mKc.size;
}
}
AciHeader::AciHeader()
{
clearVariables();
@ -34,9 +65,14 @@ AciHeader::AciHeader(const u8 * bytes)
importBinary(bytes);
}
bool AciHeader::operator==(const AciHeader & other)
bool AciHeader::operator==(const AciHeader & other) const
{
return memcmp(this->getBytes(), other.getBytes(), this->getSize());
return isEqual(other);
}
bool AciHeader::operator!=(const AciHeader & other) const
{
return !isEqual(other);
}
void AciHeader::operator=(const AciHeader & other)

View file

@ -23,7 +23,8 @@ public:
AciHeader(const AciHeader& other);
AciHeader(const u8* bytes);
bool operator==(const AciHeader& other);
bool operator==(const AciHeader& other) const;
bool operator!=(const AciHeader& other) const;
void operator=(const AciHeader& other);
// to be used after export
@ -102,5 +103,7 @@ private:
void clearVariables();
void calculateSectionOffsets();
bool isEqual(const AciHeader& other) const;
void copyFrom(const AciHeader& other);
};