Add read/write specializations for bool
This commit is contained in:
parent
2b06f0c149
commit
e71ae319a2
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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]; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue