docs: 重构 API 文档结构并修正源码准确性

- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
  - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
  - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
  - core: 修复 types 链接错误
  - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
  - memory: 修复头文件路径, malloc vs operator new, 新增方法文档
  - resources: 修复 Shader/Texture 链接错误
  - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
This commit is contained in:
2026-03-19 00:22:30 +08:00
parent d0e16962c8
commit dc850d7739
1012 changed files with 26673 additions and 9222 deletions

View File

@@ -0,0 +1,38 @@
# FileWriter::Close
```cpp
void Close();
```
关闭文件。
**描述**
关闭当前打开的文件。如果文件未打开,则什么都不做。析构函数会自动调用此方法。
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/FileWriter.h>
FileWriter writer;
if (writer.Open("data.txt")) {
writer.Write("Some data\n");
writer.Flush();
writer.Close();
}
// 文件已关闭,可再次打开其他文件
if (writer.Open("other.txt")) {
writer.Write("New content\n");
}
// 析构时自动关闭
```
## 相关文档
- [FileWriter 总览](filewriter.md) - 返回类总览
- [Open](Open.md) - 打开文件

View File

@@ -0,0 +1,42 @@
# FileWriter::Flush
```cpp
bool Flush();
```
刷新缓冲区。
**描述**
将缓冲区中的数据强制写入磁盘,确保数据持久化。在写入大量数据后应调用此方法以确保数据已保存。
**返回:** `bool` - 是否刷新成功
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/FileWriter.h>
FileWriter writer("output.txt");
if (writer.IsOpen()) {
// 写入大量数据
for (int i = 0; i < 1000; i++) {
writer.Write("Line ");
writer.Write(std::to_string(i).c_str());
writer.Write("\n");
}
// 刷新确保数据写入磁盘
writer.Flush();
// 数据已安全保存
writer.Close();
}
```
## 相关文档
- [FileWriter 总览](filewriter.md) - 返回类总览
- [Write](Write.md) - 写入数据

View File

@@ -0,0 +1,41 @@
# FileWriter::IsOpen
```cpp
bool IsOpen() const;
```
检查文件是否已打开。
**描述**
返回文件是否已成功打开并可用于写入。
**返回:** `bool` - 文件是否已打开
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/FileWriter.h>
FileWriter writer1;
if (writer1.IsOpen()) {
// 不会执行
writer1.Write("test");
}
// 打开文件
FileWriter writer2("output.txt");
if (writer2.IsOpen()) {
printf("File opened successfully\n");
writer2.Write("Content");
} else {
printf("Failed to open file\n");
}
```
## 相关文档
- [FileWriter 总览](filewriter.md) - 返回类总览
- [Open](Open.md) - 打开文件

View File

@@ -0,0 +1,51 @@
# FileWriter::Open
```cpp
bool Open(const char* filePath, bool append = false);
```
打开文件。
**描述**
打开指定路径的文件,准备写入。如果之前已打开文件,会先关闭。返回是否成功打开文件。
**参数:**
- `filePath` - 要打开的文件路径
- `append` - 是否以追加模式打开,默认为覆盖模式
**返回:** `bool` - 是否成功打开
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/FileWriter.h>
FileWriter writer;
// 打开文件(覆盖模式)
if (writer.Open("output.txt")) {
writer.Write("Hello\n");
writer.Close();
}
// 打开文件(追加模式)
if (writer.Open("log.txt", true)) {
writer.Write("Another line\n");
writer.Flush();
}
// 检查是否成功
FileWriter writer2;
if (!writer2.Open("/invalid/path/file.txt")) {
printf("Failed to open file\n");
}
```
## 相关文档
- [FileWriter 总览](filewriter.md) - 返回类总览
- [Close](Close.md) - 关闭文件
- [IsOpen](IsOpen.md) - 检查文件状态

View File

@@ -0,0 +1,46 @@
# FileWriter::Write
```cpp
bool Write(const char* data, size_t length);
bool Write(const Containers::String& str);
```
写入数据到文件。
**描述**
将数据写入文件。如果文件未打开,操作会失败。
**参数:**
- `data` - 要写入的字符数据
- `length` - 要写入的字节数
- `str` - 要写入的 String 对象
**返回:** `bool` - 是否写入成功
**复杂度:** O(n) 其中 n 为写入的字节数
**示例:**
```cpp
#include <XCEngine/Core/FileWriter.h>
#include <XCEngine/Containers/String.h>
FileWriter writer("output.txt");
if (writer.IsOpen()) {
// 写入原始字符数组
writer.Write("Hello, World!", 13);
writer.Write("\n", 1);
// 写入 String
Containers::String message = "This is a test string";
writer.Write(message);
writer.Flush();
}
```
## 相关文档
- [FileWriter 总览](filewriter.md) - 返回类总览
- [Flush](Flush.md) - 刷新缓冲区

View File

@@ -0,0 +1,87 @@
# FileWriter
**命名空间**: `XCEngine::Core`
**类型**: `class`
**描述**: 文件写入工具类,提供简单的文件写入操作封装。
## 概述
`FileWriter` 是一个轻量级的文件写入工具,封装了 `FILE*` 接口提供便捷的字符串和二进制数据写入功能。它支持追加模式和自动资源管理RAII
## 公共方法
### 构造/析构
| 方法 | 描述 |
|------|------|
| `FileWriter()` | 默认构造(不打开文件) |
| `FileWriter(const char* filePath, bool append = false)` | 构造并打开文件 |
| `~FileWriter()` | 析构函数,自动关闭文件 |
### 文件操作
| 方法 | 描述 |
|------|------|
| `bool Open(const char* filePath, bool append = false)` | 打开文件append=true 时为追加模式 |
| `void Close()` | 关闭文件 |
| `bool IsOpen() const` | 检查文件是否已打开 |
### 数据写入
| 方法 | 描述 |
|------|------|
| `bool Write(const char* data, size_t length)` | 写入指定长度的字符串 |
| `bool Write(const Containers::String& str)` | 写入 String 内容 |
| `bool Flush()` | 刷新缓冲区,确保数据写入磁盘 |
## 方法列表
| 方法 | 描述 |
|------|------|
| [FileWriter](FileWriter.md) | 构造函数 |
| [Open](Open.md) | 打开文件 |
| [Close](Close.md) | 关闭文件 |
| [IsOpen](IsOpen.md) | 检查文件是否已打开 |
| [Write](Write.md) | 写入数据 |
| [Flush](Flush.md) | 刷新缓冲区 |
## 使用示例
```cpp
#include <XCEngine/Core/FileWriter.h>
// 方式1构造时打开
FileWriter writer("output.txt", false);
if (writer.IsOpen()) {
writer.Write("Hello, World!\n");
writer.Write("Line 2\n");
writer.Flush();
}
// 方式2先构造再打开
FileWriter writer2;
if (writer2.Open("log.txt")) {
writer2.Write("Application started\n");
writer2.Close();
}
// 追加模式
FileWriter appendWriter("log.txt", true);
if (appendWriter.IsOpen()) {
appendWriter.Write("Another log entry\n");
appendWriter.Flush();
}
// 使用 String 写入
Containers::String content = "Content written from String";
FileWriter writer3("data.txt");
writer3.Write(content);
```
## 相关文档
- [Core 模块总览](../core.md) - 返回模块总览
- [Logger](../../debug/logger/logger.md) - 日志系统
- [FileLogSink](../../debug/filelogsink/filelogsink.md) - 文件日志输出