Add read/write specializations for bool

This commit is contained in:
DankParrot 2020-08-18 18:26:01 -07:00
parent 2b06f0c149
commit e71ae319a2
2 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,13 @@ namespace Feather
}
}
// Write bool as 1 byte
template <>
inline void Write<bool>(const bool& value)
{
Write<uint8_t>(value ? 0x01 : 0x00);
}
template <typename Int = int32_t>
inline void WriteVarInt(Int val)
{

View File

@ -40,6 +40,14 @@ namespace Feather
return value;
}
// Read bool as 1 byte
template <>
inline bool Read<bool>()
{
// TODO: Could warn on non-bool value
return (ReadByte() != 0x00);
}
// Fast way to peek the next byte
inline uint8_t PeekByte() { return m_data[m_offset]; }