docs: update core and debug API docs
This commit is contained in:
@@ -10,6 +10,10 @@ void Close();
|
||||
|
||||
关闭当前打开的文件。如果文件未打开,则什么都不做。析构函数会自动调用此方法。
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
@@ -12,6 +12,8 @@ bool Flush();
|
||||
|
||||
**返回:** `bool` - 是否刷新成功
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
@@ -12,6 +12,8 @@ bool IsOpen() const;
|
||||
|
||||
**返回:** `bool` - 文件是否已打开
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
@@ -16,6 +16,8 @@ bool Open(const char* filePath, bool append = false);
|
||||
|
||||
**返回:** `bool` - 是否成功打开
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
@@ -18,6 +18,8 @@ bool Write(const Containers::String& str);
|
||||
|
||||
**返回:** `bool` - 是否写入成功
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(n) 其中 n 为写入的字节数
|
||||
|
||||
**示例:**
|
||||
|
||||
36
docs/api/core/filewriter/ctor-default.md
Normal file
36
docs/api/core/filewriter/ctor-default.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# FileWriter::FileWriter (默认构造)
|
||||
|
||||
```cpp
|
||||
FileWriter();
|
||||
```
|
||||
|
||||
默认构造 FileWriter 对象,不打开任何文件。
|
||||
|
||||
**描述**
|
||||
|
||||
创建 FileWriter 实例,m_file 初始化为 nullptr。可后续通过 Open 方法打开文件。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/FileWriter.h>
|
||||
|
||||
using namespace XCEngine::Core;
|
||||
|
||||
FileWriter writer;
|
||||
if (!writer.IsOpen()) {
|
||||
writer.Open("output.txt");
|
||||
writer.Write("Hello\n");
|
||||
writer.Close();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [FileWriter 总览](filewriter.md) - 返回类总览
|
||||
- [Open](Open.md) - 打开文件
|
||||
- [FileWriter(filePath, append)](ctor-file.md) - 构造并打开文件
|
||||
45
docs/api/core/filewriter/ctor-file.md
Normal file
45
docs/api/core/filewriter/ctor-file.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# FileWriter::FileWriter (文件路径构造)
|
||||
|
||||
```cpp
|
||||
FileWriter(const char* filePath, bool append = false);
|
||||
```
|
||||
|
||||
构造 FileWriter 对象并打开文件。
|
||||
|
||||
**描述**
|
||||
|
||||
创建 FileWriter 实例并尝试打开指定路径的文件。如果 append 为 true,则以追加模式打开;否则以覆盖模式打开。
|
||||
|
||||
**参数:**
|
||||
- `filePath` - 要打开的文件路径
|
||||
- `append` - 是否以追加模式打开,默认 false(覆盖模式)
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/FileWriter.h>
|
||||
|
||||
using namespace XCEngine::Core;
|
||||
|
||||
// 覆盖模式打开
|
||||
FileWriter writer1("output.txt");
|
||||
if (writer1.IsOpen()) {
|
||||
writer1.Write("Content\n");
|
||||
}
|
||||
|
||||
// 追加模式打开
|
||||
FileWriter writer2("log.txt", true);
|
||||
if (writer2.IsOpen()) {
|
||||
writer2.Write("New log entry\n");
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [FileWriter 总览](filewriter.md) - 返回类总览
|
||||
- [Open](Open.md) - 打开文件
|
||||
- [FileWriter()](ctor-default.md) - 默认构造
|
||||
33
docs/api/core/filewriter/dtor.md
Normal file
33
docs/api/core/filewriter/dtor.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# FileWriter::~FileWriter
|
||||
|
||||
```cpp
|
||||
~FileWriter();
|
||||
```
|
||||
|
||||
析构函数,自动关闭文件。
|
||||
|
||||
**描述**
|
||||
|
||||
销毁 FileWriter 实例,如果文件处于打开状态则自动调用 Close 关闭文件,释放 FILE* 资源。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/FileWriter.h>
|
||||
|
||||
using namespace XCEngine::Core;
|
||||
|
||||
{
|
||||
FileWriter writer("output.txt");
|
||||
writer.Write("Content inside scope\n");
|
||||
} // 析构时自动关闭文件
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [FileWriter 总览](filewriter.md) - 返回类总览
|
||||
- [Close](Close.md) - 关闭文件
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**头文件**: `XCEngine/Core/FileWriter.h`
|
||||
|
||||
**描述**: 文件写入工具类,提供简单的文件写入操作封装。
|
||||
|
||||
## 概述
|
||||
@@ -14,9 +16,9 @@
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `FileWriter()` | 默认构造(不打开文件) |
|
||||
| `FileWriter(const char* filePath, bool append = false)` | 构造并打开文件 |
|
||||
| `~FileWriter()` | 析构函数,自动关闭文件 |
|
||||
| [`FileWriter()`](ctor-default.md) | 默认构造(不打开文件) |
|
||||
| [`FileWriter(filePath, append)`](ctor-file.md) | 构造并打开文件 |
|
||||
| [`~FileWriter()`](dtor.md) | 析构函数,自动关闭文件 |
|
||||
| [`Open`](Open.md) | 打开文件,append=true 时为追加模式 |
|
||||
| [`Close`](Close.md) | 关闭文件 |
|
||||
| [`IsOpen`](IsOpen.md) | 检查文件是否已打开 |
|
||||
|
||||
Reference in New Issue
Block a user