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

基于RapidJSON的JSON配置文件读取器和类型安全的值访问器。 More...

#include "rapidjson/stringbuffer.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "tools/tools.h"
#include <functional>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <map>
#include <set>

Classes

class  ngl::ncjson
 RapidJSON Document的RAII封装类。 More...
struct  ngl::json_format< T >
 JSON序列化/反序列化模板。 More...
struct  ngl::json_format< T * >
struct  ngl::json_format< std::shared_ptr< T > >
class  ngl::tool_rapidjson_value
 RapidJSON值查找辅助工具类。 More...
struct  ngl::json_format< int64_t >
struct  ngl::json_format< uint64_t >
struct  ngl::json_format< int32_t >
struct  ngl::json_format< uint32_t >
struct  ngl::json_format< int16_t >
struct  ngl::json_format< uint16_t >
struct  ngl::json_format< int8_t >
struct  ngl::json_format< uint8_t >
struct  ngl::json_format< const char * >
struct  ngl::json_format< std::string >
struct  ngl::json_format< double >
struct  ngl::json_format< float >
struct  ngl::json_format< bool >
struct  ngl::json_format< std::vector< T > >
struct  ngl::json_format< std::list< T > >
struct  ngl::json_format< std::set< T > >
struct  ngl::json_format< std::map< TKEY, TVALUE > >
struct  ngl::json_format< std::unordered_map< TKEY, TVALUE > >
class  ngl::njson
 可变参数JSON批量读写前端。 More...

Functions

bool ngl::njson_detail::add_member (rapidjson::Value *ajson, rapidjson::Document::AllocatorType *aallocator, const char *akey, rapidjson::Value &avalue)
bool ngl::njson_detail::push_back (rapidjson::Value *ajson, rapidjson::Document::AllocatorType *aallocator, rapidjson::Value &avalue)
template<typename T>
bool ngl::njson_detail::assign_signed_integral (int64_t avalue, T &adata)
template<typename T>
bool ngl::njson_detail::assign_unsigned_integral (uint64_t avalue, T &adata)

Detailed Description

基于RapidJSON的JSON配置文件读取器和类型安全的值访问器。

本文件提供了JSON序列化/反序列化框架,包括:

  • ncjson:RapidJSON Document的RAII封装,支持解析和格式化输出
  • json_format<T>:类型特化的JSON读写模板,支持基本类型、容器、指针等
  • njson:可变参数前端,批量读写多个JSON字段
  • tool_rapidjson_value:JSON值查找辅助工具

支持的基本类型:整数(int8~int64/uint8~uint64)、浮点(float/double)、 字符串(string/const char*)、布尔(bool)、枚举、Protobuf消息、自定义类型。 支持的容器:vector、list、set、map、unordered_map。