1
0
mirror of https://github.com/Rogiel/PacketBuffer synced 2025-12-06 08:23:05 +00:00

Add support for TinyUTF8

This commit is contained in:
2018-08-29 10:50:43 -03:00
parent 592c4c8ee0
commit c4dc5ffc8a

View File

@@ -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 <tinyutf8.h>
namespace PacketBuffer {
/**
* A ObjectSerializer for utf8_string from tinyutf8.
*/
template<>
class ObjectSerializer<utf8_string> {
public:
template<typename Packer>
static inline void pack(Packer& packer, const utf8_string& string) {
packer(string.cpp_str());
}
template<typename Unpacker>
static inline void unpack(Unpacker& unpacker, utf8_string& string) {
std::string rawString;
unpacker(rawString);
string = rawString;
}
};
}
#endif //PACKETBUFFER_SERIALIZER_TINYUTF8STRING_H