Core/Serializer: Add FlushBits method
Former-commit-id: 64b8d4277001ab763dc92c0a157ebce72a8bfef8
This commit is contained in:
parent
bbe8a776e8
commit
b5fb11b5c2
|
|
@ -25,6 +25,8 @@ namespace Nz
|
|||
inline Endianness GetDataEndianness() const;
|
||||
inline Stream& GetStream() const;
|
||||
|
||||
inline bool FlushBits();
|
||||
|
||||
inline void SetDataEndianness(Endianness endiannes);
|
||||
inline void SetStream(Stream& stream);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,8 @@ namespace Nz
|
|||
|
||||
inline Serializer::~Serializer()
|
||||
{
|
||||
if (m_serializationContext.currentBitPos != 8)
|
||||
{
|
||||
m_serializationContext.currentBitPos = 8; //< To prevent Serialize to flush bits itself
|
||||
|
||||
if (!Serialize<UInt8>(m_serializationContext, m_serializationContext.currentByte))
|
||||
NazaraWarning("Failed to flush bits at serializer destruction");
|
||||
}
|
||||
if (!FlushBits())
|
||||
NazaraWarning("Failed to flush bits at serializer destruction");
|
||||
}
|
||||
|
||||
inline Endianness Serializer::GetDataEndianness() const
|
||||
|
|
@ -35,6 +30,19 @@ namespace Nz
|
|||
return *m_serializationContext.stream;
|
||||
}
|
||||
|
||||
inline bool Serializer::FlushBits()
|
||||
{
|
||||
if (m_serializationContext.currentBitPos != 8)
|
||||
{
|
||||
m_serializationContext.currentBitPos = 8; //< To prevent Serialize to flush bits itself
|
||||
|
||||
if (!Serialize<UInt8>(m_serializationContext, m_serializationContext.currentByte))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void Serializer::SetDataEndianness(Endianness endiannes)
|
||||
{
|
||||
m_serializationContext.endianness = endiannes;
|
||||
|
|
|
|||
Loading…
Reference in New Issue