Go to the documentation of this file.
21 #ifndef THUNDEREGG_BUFFERWRITER_H
22 #define THUNDEREGG_BUFFERWRITER_H
32 #include <type_traits>
44 char* buffer =
nullptr;
58 static constexpr
bool isSerializable()
60 return std::is_base_of<Serializable, T>::value;
90 pos += obj.
serialize(buffer ==
nullptr ?
nullptr : (buffer + pos));
104 if (buffer !=
nullptr) {
105 for (
size_t i = 0; i <
sizeof(T); i++) {
106 buffer[pos] =
reinterpret_cast<const char*
>(&obj)[i];
virtual int serialize(char *buffer) const =0
Serialize object into buffer.
BufferWriter(char *buffer)
Create a new BufferWriter with given buffer.
Definition: BufferWriter.h:74
Class that is used to help serialize objects into a buffer.
Definition: BufferWriter.h:38
Interface for serializing objects.
Definition: Serializable.h:34
The ThunderEgg namespace.
Definition: BiLinearGhostFiller.h:31
std::enable_if<!isSerializable< T >), BufferWriter >::type & operator<<(const T &obj)
Add an object to the buffer.
Definition: BufferWriter.h:102
BufferWriter & operator<<(const Serializable &obj)
Add object to the buffer.
Definition: BufferWriter.h:88
int getPos()
get the current position in the buffer
Definition: BufferWriter.h:80
BufferWriter()=default
Create a new BufferWriter with the buffer set to nullptr. This is helpful for determining the size ne...