ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
nserialize.h File Reference

基于模板的序列化引擎,将C++类型映射到二进制线路格式。 More...

#include "actor/generated/pb/net.pb.h"
#include "tools/tools.h"
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/descriptor.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <cstdint>
#include <cstring>
#include <utility>
#include <memory>
#include <cstdio>
#include <limits>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <map>

Classes

class  ngl::ser::serialize< TBUFF >
 序列化缓冲区基类,提供基本的缓冲区操作。 More...
class  ngl::ser::serialize_byte
class  ngl::ser::serialize_push
 序列化(写入)实现类。 More...
class  ngl::ser::serialize_pop
 反序列化(读取)实现类。 More...
struct  ngl::ser::serialize_format< T >
struct  ngl::ser::serialize_format< T * >
struct  ngl::ser::serialize_format< std::shared_ptr< T > >
struct  ngl::ser::serialize_format< int8_t >
struct  ngl::ser::serialize_format< int16_t >
struct  ngl::ser::serialize_format< int32_t >
struct  ngl::ser::serialize_format< int64_t >
struct  ngl::ser::serialize_format< uint8_t >
struct  ngl::ser::serialize_format< uint16_t >
struct  ngl::ser::serialize_format< uint32_t >
struct  ngl::ser::serialize_format< uint64_t >
struct  ngl::ser::serialize_format< bool >
struct  ngl::ser::serialize_format< float >
struct  ngl::ser::serialize_format< double >
struct  ngl::ser::serialize_format< std::string >
struct  ngl::ser::serialize_format< std::vector< T > >
struct  ngl::ser::serialize_format< std::set< T > >
struct  ngl::ser::serialize_format< std::list< T > >
struct  ngl::ser::serialize_format< std::map< TKEY, TVAL > >
struct  ngl::ser::serialize_format< std::unordered_map< TKEY, TVAL > >
struct  ngl::ser::nserialize
 序列化工具结构体,提供统一的序列化接口。 More...

Detailed Description

基于模板的序列化引擎,将C++类型映射到二进制线路格式。

实现了一个高效的二进制序列化引擎,支持:

  • 基本数据类型(int8_t, int16_t, int32_t, int64_t, float, double, bool)
  • 标准容器(string, vector, set, list, map, unordered_map)
  • 指针和智能指针(T*, shared_ptr<T>)
  • 枚举类型
  • Protobuf消息
  • 自定义结构体(通过push_format/pop_format/bytes_format方法) 支持字节序转换和错误回滚。
    Author
    NingLeixueR
    Date
    2020-2025