mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-21 03:12:41 +01:00
Codechange: Allow using EnumBitSet over network commands.
This commit is contained in:
committed by
Peter Nelson
parent
fdb3555147
commit
6d1f56ce6b
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <string_view>
|
||||
#include "../core/bitmath_func.hpp"
|
||||
#include "../core/enum_type.hpp"
|
||||
#include "../core/overflowsafe_type.hpp"
|
||||
|
||||
struct StrongTypedefBase;
|
||||
@@ -36,6 +37,9 @@ public:
|
||||
EndianBufferWriter &operator <<(std::string_view data) { this->Write(data); return *this; }
|
||||
EndianBufferWriter &operator <<(bool data) { return *this << static_cast<uint8_t>(data ? 1 : 0); }
|
||||
|
||||
template <typename Tenum, typename Tstorage>
|
||||
EndianBufferWriter &operator <<(const EnumBitSet<Tenum, Tstorage> &data) { return *this << data.base(); }
|
||||
|
||||
template <typename T>
|
||||
EndianBufferWriter &operator <<(const OverflowSafeInt<T> &data) { return *this << static_cast<T>(data); };
|
||||
|
||||
@@ -130,6 +134,9 @@ public:
|
||||
EndianBufferReader &operator >>(std::string &data) { data = this->ReadStr(); return *this; }
|
||||
EndianBufferReader &operator >>(bool &data) { data = this->Read<uint8_t>() != 0; return *this; }
|
||||
|
||||
template <typename Tenum, typename Tstorage>
|
||||
EndianBufferReader &operator >>(EnumBitSet<Tenum, Tstorage> &data) { data = Tenum{this->Read<Tstorage>()}; return *this; }
|
||||
|
||||
template <typename T>
|
||||
EndianBufferReader &operator >>(OverflowSafeInt<T> &data) { data = this->Read<T>(); return *this; };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user