mirror of
https://github.com/Rogiel/PacketBuffer
synced 2025-12-06 00:13:04 +00:00
Add support for TinyUTF8
This commit is contained in:
34
include/PacketBuffer/Serializer/TinyUTF8String.h
Normal file
34
include/PacketBuffer/Serializer/TinyUTF8String.h
Normal 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
|
||||||
Reference in New Issue
Block a user