重构:存储引擎(二进制/CRC/原子写)+ 业务层 + C++26 反射集成 - #2
Open
chenjintang-shrimp wants to merge 14 commits into
Open
Conversation
- 新增 xmake.lua:nlohmann_json/libcurl 包管理、APP_VERSION 宏、/utf-8 - version.rc 由 set_version 自动生成(VERSION/VERSION_MAJOR/VERSION_MINOR/VERSION_ALTER) - 删除 CMakeLists.txt,.vscode 构建任务和调试配置改用 xmake - .gitignore 忽略 .xmake 缓存
- 删除 include/(json.hpp、curl/*),main.cpp 改用 <nlohmann/json.hpp> - xmake.lua 移除 add_includedirs,头文件由 nlohmann_json/libcurl 包提供 - .gitignore 忽略 compile_commands.json 与 .vscode/(含硬编码路径的编辑器配置) - .vscode/launch.json、tasks.json 移出版本控制
- 未来等到C++26 反射正式上线我们可以大幅简化代码
- 旧目标随 master 改名 points_main_old -> points_main - 保留 gcc 工具链条件化 requires(规避 MSVC libcurl 包串台)与 points_modernize 反射目标
- FileInstance 完整实现:load/save/switch_to/find/add/remove/mark_dirty + CRC32 校验 + tmp+rename 原子写 + 空闲链表重建与恒等式校验 - 补上 FileInstance 构造函数实现(此前只有声明) - data_storage.h 命名统一 point->score - 新增 src/data_storage.cpp:read/write 业务层,class_name 映射文件路径, rules/gifts 独立文本表(待迁二进制引擎),config.ini 解析 - 消费 TU include 先于 import(规避 MSVC C2572)
- FileInstance 重构为模板 FileStore<T>(header+定长记录+空闲链+CRC+原子写), 每记录类型独立单例;using FileInstance = FileStore<Record> 保持兼容 - 新增 RuleRecord(desc[64]+delta,77B),GiftRecord 继承之(独立单例) - rules/gifts 从管道文本表迁移到二进制引擎(data_storage.cpp 重写) - crc32 内联进模块接口(模板在消费 TU 实例化时需要) - 反射分支扩展到 RuleRecord;GCC 16.1 -freflection 编译验证通过 - 往返测试:学生 161B + 规则 77B 双表读写/重载/CRC 损坏检测全过
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
基于 master(xmake 迁移 + 接口头文件)继续重构。本分支与 master 已合并过一次(ff957dd),无冲突。
变更
存储引擎(src/storage_management.ixx/.cpp)
FileStore<T>:学生(Record 161B)/规则(RuleRecord 77B)/礼物(GiftRecord)三表共用引擎,每类型独立单例file_format_error__cpp_impl_reflection检测,GCC 16.1+-freflection下字段尺寸由members_of推导,clang-cl/MSVC 走数组+断言回退;xmake 自动检测 gcc 工具链启用业务层(src/data_storage.cpp)
data_storage.h接口:read/write 命名空间,class_name → 文件路径映射杂项
验证
-std=c++26 -freflection反射路径编译通过