diff --git a/include/PacketBuffer/Serializer/TinyUTF8String.h b/include/PacketBuffer/Serializer/TinyUTF8String.h new file mode 100644 index 0000000..2bc5988 --- /dev/null +++ b/include/PacketBuffer/Serializer/TinyUTF8String.h @@ -0,0 +1,34 @@ +// +// Created by Rogiel on 8/28/2018. +// + +#ifndef PACKETBUFFER_SERIALIZER_TINYUTF8STRING_H +#define PACKETBUFFER_SERIALIZER_TINYUTF8STRING_H + +#include "PacketBuffer/ObjectSerializer.h" +#include + +namespace PacketBuffer { + + /** + * A ObjectSerializer for utf8_string from tinyutf8. + */ + template<> + class ObjectSerializer { + public: + template + static inline void pack(Packer& packer, const utf8_string& string) { + packer(string.cpp_str()); + } + + template + static inline void unpack(Unpacker& unpacker, utf8_string& string) { + std::string rawString; + unpacker(rawString); + string = rawString; + } + }; + +} + +#endif //PACKETBUFFER_SERIALIZER_TINYUTF8STRING_H