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

CSV表加载器和解析器 More...

#include "tools/tools.h"
#include <type_traits>
#include <system_error>
#include <string_view>
#include <functional>
#include <iostream>
#include <charconv>
#include <cstdint>
#include <fstream>
#include <cctype>
#include <string>
#include <limits>
#include <vector>
#include <tuple>
#include <list>
#include <map>
#include <set>
#include <utility>

Classes

struct  ngl::csvpair
 CSV解析器状态 More...
struct  ngl::csv_read< T >
 CSV读取器模板 More...
struct  ngl::csv_helper
 CSV辅助工具 More...
struct  ngl::csv_read< int8_t >
struct  ngl::csv_read< int16_t >
struct  ngl::csv_read< int32_t >
struct  ngl::csv_read< int64_t >
struct  ngl::csv_read< uint8_t >
struct  ngl::csv_read< uint16_t >
struct  ngl::csv_read< uint32_t >
struct  ngl::csv_read< uint64_t >
struct  ngl::csv_read< float >
struct  ngl::csv_read< double >
struct  ngl::csv_read< bool >
struct  ngl::csv_read< std::string >
struct  ngl::csv_read< std::vector< T > >
struct  ngl::csv_read< std::list< T > >
struct  ngl::csv_read< std::set< T > >
class  ngl::rcsv
 CSV读取器 More...
struct  ngl::csvwpair
 CSV写入器状态 More...
struct  ngl::csv_write< T >
 CSV写入器模板 More...
struct  ngl::csv_whelper
 CSV写入辅助工具 More...
struct  ngl::csv_write< int8_t >
struct  ngl::csv_write< int16_t >
struct  ngl::csv_write< int32_t >
struct  ngl::csv_write< int64_t >
struct  ngl::csv_write< uint8_t >
struct  ngl::csv_write< uint16_t >
struct  ngl::csv_write< uint32_t >
struct  ngl::csv_write< uint64_t >
struct  ngl::csv_write< float >
struct  ngl::csv_write< double >
struct  ngl::csv_write< bool >
struct  ngl::csv_write< std::string >
struct  ngl::csv_write< std::vector< T > >
struct  ngl::csv_write< std::list< T > >
struct  ngl::csv_write< std::set< T > >
struct  ngl::csv_write< std::map< K, V > >
class  ngl::wcsv

Detailed Description

CSV表加载器和解析器

将CSV配置表解析为带类型的C++结构体,支持:

  • 基础数据类型(整数、浮点数、布尔值、字符串)
  • 容器类型(vector、list、set、map)
  • 嵌套结构体和枚举类型
  • 引号字段和特殊字符处理
  • 热加载支持
    Note
    所有类和函数均位于 ngl 命名空间下。
    // 定义CSV表结构
    struct MyTable {
    int m_id;
    std::string m_name;
    std::vector<int> m_items;
    bool rcsv(ngl::csvpair& apair) {
    return ngl::rcsv::readcsv(apair, m_id, m_name, m_items);
    }
    };
    // 读取CSV文件
    ngl::rcsv reader;
    std::map<int, MyTable> data;
    if (reader.read("config.csv", verify_hash)) {
    reader.readcsv(data);
    }