docs: Add missing resources module documentation
Added documentation for undocumented classes: - ResourcePath: Path manipulation and GUID conversion utilities - FileArchive: Archive file reading support - ResourcePackage/ResourcePackageBuilder: Resource packaging system Updated resources.md overview to include new documentation modules and added ImportSettings and ResourceFileSystem to core components.
This commit is contained in:
87
docs/api/resources/resourcepath/resourcepath.md
Normal file
87
docs/api/resources/resourcepath/resourcepath.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# ResourcePath
|
||||
|
||||
**命名空间**: `XCEngine::Resources`
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**描述**: 资源路径封装类,提供路径解析、转换和 GUID 生成功能。
|
||||
|
||||
## 概述
|
||||
|
||||
`ResourcePath` 封装了资源路径字符串,提供了一系列便捷方法进行路径解析、扩展名检查和 GUID 转换。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Resources/ResourcePath.h>
|
||||
```
|
||||
|
||||
## 公共方法
|
||||
|
||||
### 构造
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `ResourcePath() = default` | 默认构造空路径 |
|
||||
| `ResourcePath(const char* path)` | 从 C 字符串构造 |
|
||||
| `ResourcePath(const Containers::String& path)` | 从 String 构造 |
|
||||
|
||||
### 路径解析
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `Containers::String GetExtension() const` | 获取文件扩展名 |
|
||||
| `Containers::String GetStem() const` | 获取文件名(不含扩展名) |
|
||||
| `Containers::String GetFullPath() const` | 获取完整路径 |
|
||||
| `Containers::String GetFileName() const` | 获取文件名(含扩展名) |
|
||||
| `Containers::String GetDirectory() const` | 获取目录部分 |
|
||||
| `Containers::String GetRelativePath() const` | 获取相对路径 |
|
||||
|
||||
### GUID 转换
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `ResourceGUID ToGUID() const` | 将路径转换为 GUID |
|
||||
|
||||
### 扩展名检查
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `bool HasExtension(const char* ext) const` | 检查是否具有指定扩展名 |
|
||||
| `bool HasAnyExtension(const char* const* extensions, Core::uint32 count) const` | 检查是否具有任意指定扩展名 |
|
||||
|
||||
### 状态
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `bool IsValid() const` | 检查路径是否有效(非空) |
|
||||
| `const Containers::String& GetPath() const` | 获取原始路径字符串 |
|
||||
| `void SetPath(const Containers::String& path)` | 设置路径字符串 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
|
||||
// 路径解析
|
||||
Containers::String ext = path.GetExtension(); // ".png"
|
||||
Containers::String name = path.GetFileName(); // "player.png"
|
||||
Containers::String dir = path.GetDirectory(); // "textures"
|
||||
|
||||
// 扩展名检查
|
||||
if (path.HasExtension(".png") || path.HasExtension(".jpg")) {
|
||||
// 是图像文件
|
||||
}
|
||||
|
||||
// 转换为 GUID
|
||||
ResourceGUID guid = path.ToGUID();
|
||||
|
||||
// 在 HashMap 中作为键使用
|
||||
Containers::HashMap<ResourcePath, ResourceHandle<Texture>> textures;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourceTypes](../resourcetypes/resourcetypes.md) - 资源类型定义
|
||||
- [ResourceManager](../resourcemanager/resourcemanager.md) - 资源管理器
|
||||
- [Resources 总览](../resources.md) - 返回模块总览
|
||||
Reference in New Issue
Block a user