1
0
mirror of https://github.com/Rogiel/PacketBuffer synced 2025-12-06 00:13:04 +00:00
Files
PacketBuffer/include/PacketBuffer/Serializer/TinyUTF8String.h

35 lines
819 B
C++

//
// 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