docs: update resources API docs
This commit is contained in:
32
docs/api/resources/resourcepath/getdirectory.md
Normal file
32
docs/api/resources/resourcepath/getdirectory.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# ResourcePath::GetDirectory
|
||||
|
||||
```cpp
|
||||
Containers::String GetDirectory() const
|
||||
```
|
||||
|
||||
获取目录部分。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回路径中最后一个路径分隔符之前的所有内容,即目录路径。兼容 Windows (`\`) 和 Unix (`/`) 路径分隔符。
|
||||
|
||||
**返回:** `Containers::String`,目录路径
|
||||
|
||||
**复杂度:** O(n),n 为路径长度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
Containers::String dir = path.GetDirectory(); // "textures"
|
||||
|
||||
ResourcePath path2("textures/subfolder/player.png");
|
||||
Containers::String dir2 = path2.GetDirectory(); // "textures/subfolder"
|
||||
|
||||
ResourcePath path3("player.png");
|
||||
Containers::String dir3 = path3.GetDirectory(); // ""
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
32
docs/api/resources/resourcepath/getextension.md
Normal file
32
docs/api/resources/resourcepath/getextension.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# ResourcePath::GetExtension
|
||||
|
||||
```cpp
|
||||
Containers::String GetExtension() const
|
||||
```
|
||||
|
||||
获取文件扩展名。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回路径字符串的文件扩展名部分,包括前缀点(`.`)。如果路径为空或不包含扩展名,返回空字符串。
|
||||
|
||||
**返回:** `Containers::String`,包含扩展名(如 `".png"`),如果无扩展名则返回空字符串
|
||||
|
||||
**复杂度:** O(n),n 为路径长度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
Containers::String ext = path.GetExtension(); // ".png"
|
||||
|
||||
ResourcePath path2("textures/player");
|
||||
Containers::String ext2 = path2.GetExtension(); // ""
|
||||
|
||||
ResourcePath path3("");
|
||||
Containers::String ext3 = path3.GetExtension(); // ""
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
32
docs/api/resources/resourcepath/getfilename.md
Normal file
32
docs/api/resources/resourcepath/getfilename.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# ResourcePath::GetFileName
|
||||
|
||||
```cpp
|
||||
Containers::String GetFileName() const
|
||||
```
|
||||
|
||||
获取文件名(含扩展名)。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回路径中最后一个路径分隔符后的部分,包括文件名和扩展名。兼容 Windows (`\`) 和 Unix (`/`) 路径分隔符。
|
||||
|
||||
**返回:** `Containers::String`,文件名(含扩展名)
|
||||
|
||||
**复杂度:** O(n),n 为路径长度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
Containers::String name = path.GetFileName(); // "player.png"
|
||||
|
||||
ResourcePath path2("player.png");
|
||||
Containers::String name2 = path2.GetFileName(); // "player.png"
|
||||
|
||||
ResourcePath path3("textures\\windows\\file.txt");
|
||||
Containers::String name3 = path3.GetFileName(); // "file.txt"
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
26
docs/api/resources/resourcepath/getfullpath.md
Normal file
26
docs/api/resources/resourcepath/getfullpath.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# ResourcePath::GetFullPath
|
||||
|
||||
```cpp
|
||||
Containers::String GetFullPath() const
|
||||
```
|
||||
|
||||
获取完整路径。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回存储的完整路径字符串。
|
||||
|
||||
**返回:** `Containers::String`,完整路径
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
Containers::String fullPath = path.GetFullPath(); // "textures/player.png"
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
27
docs/api/resources/resourcepath/getpath.md
Normal file
27
docs/api/resources/resourcepath/getpath.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# ResourcePath::GetPath
|
||||
|
||||
```cpp
|
||||
const Containers::String& GetPath() const
|
||||
```
|
||||
|
||||
获取原始路径字符串。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回内部存储的路径字符串的常量引用。
|
||||
|
||||
**返回:** `const Containers::String&`,路径字符串的常量引用
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
const Containers::String& rawPath = path.GetPath(); // "textures/player.png"
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
- [SetPath](setpath.md) - 设置路径
|
||||
26
docs/api/resources/resourcepath/getrelativepath.md
Normal file
26
docs/api/resources/resourcepath/getrelativepath.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# ResourcePath::GetRelativePath
|
||||
|
||||
```cpp
|
||||
Containers::String GetRelativePath() const
|
||||
```
|
||||
|
||||
获取相对路径。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回存储的相对路径字符串。当前实现直接返回完整路径。
|
||||
|
||||
**返回:** `Containers::String`,相对路径
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
Containers::String relPath = path.GetRelativePath(); // "textures/player.png"
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
32
docs/api/resources/resourcepath/getstem.md
Normal file
32
docs/api/resources/resourcepath/getstem.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# ResourcePath::GetStem
|
||||
|
||||
```cpp
|
||||
Containers::String GetStem() const
|
||||
```
|
||||
|
||||
获取文件名(不含扩展名)。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
返回路径中文件名部分,不包含扩展名。兼容 Windows (`\`) 和 Unix (`/`) 路径分隔符。
|
||||
|
||||
**返回:** `Containers::String`,文件名(不含扩展名)
|
||||
|
||||
**复杂度:** O(n),n 为路径长度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
Containers::String stem = path.GetStem(); // "player"
|
||||
|
||||
ResourcePath path2("textures/player.backup.png");
|
||||
Containers::String stem2 = path2.GetStem(); // "player.backup"
|
||||
|
||||
ResourcePath path3("textures");
|
||||
Containers::String stem3 = path3.GetStem(); // "textures"
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
36
docs/api/resources/resourcepath/hasanyextension.md
Normal file
36
docs/api/resources/resourcepath/hasanyextension.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# ResourcePath::HasAnyExtension
|
||||
|
||||
```cpp
|
||||
bool HasAnyExtension(const char* const* extensions, Core::uint32 count) const
|
||||
```
|
||||
|
||||
检查是否具有任意指定扩展名。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
遍历扩展名数组,检查路径是否匹配其中任意一个扩展名。扩展名应包含前缀点(`.`)。
|
||||
|
||||
**参数:**
|
||||
- `extensions` - 扩展名数组指针
|
||||
- `count` - 扩展名数组长度
|
||||
|
||||
**返回:** `bool`,匹配任意扩展名返回 `true`,否则返回 `false`
|
||||
|
||||
**复杂度:** O(n * m),n 为路径长度,m 为扩展名数量
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
|
||||
const char* imageExts[] = {".png", ".jpg", ".jpeg", ".bmp", ".tga"};
|
||||
bool isImage = path.HasAnyExtension(imageExts, 5); // true
|
||||
|
||||
const char* videoExts[] = {".mp4", ".avi", ".mkv"};
|
||||
bool isVideo = path.HasAnyExtension(videoExts, 3); // false
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
- [HasExtension](hasextension.md) - 检查单个扩展名
|
||||
33
docs/api/resources/resourcepath/hasextension.md
Normal file
33
docs/api/resources/resourcepath/hasextension.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# ResourcePath::HasExtension
|
||||
|
||||
```cpp
|
||||
bool HasExtension(const char* ext) const
|
||||
```
|
||||
|
||||
检查是否具有指定扩展名。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
比较路径的扩展名与指定的扩展名。扩展名应包含前缀点(`.`)。
|
||||
|
||||
**参数:**
|
||||
- `ext` - 要检查的扩展名(应包含 `.`,如 `".png"`)
|
||||
|
||||
**返回:** `bool`,扩展名匹配返回 `true`,否则返回 `false`
|
||||
|
||||
**复杂度:** O(n),n 为路径长度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
|
||||
bool isPng = path.HasExtension(".png"); // true
|
||||
bool isJpg = path.HasExtension(".jpg"); // false
|
||||
bool isInvalid = path.HasExtension("png"); // false (缺少前缀点)
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
- [HasAnyExtension](hasanyextension.md) - 检查多个扩展名
|
||||
33
docs/api/resources/resourcepath/isvalid.md
Normal file
33
docs/api/resources/resourcepath/isvalid.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# ResourcePath::IsValid
|
||||
|
||||
```cpp
|
||||
bool IsValid() const
|
||||
```
|
||||
|
||||
检查路径是否有效(非空)。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
判断路径是否有效,即路径字符串是否非空。
|
||||
|
||||
**返回:** `bool`,路径非空返回 `true`,否则返回 `false`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath validPath("textures/player.png");
|
||||
if (validPath.IsValid()) {
|
||||
// 处理有效路径
|
||||
}
|
||||
|
||||
ResourcePath emptyPath("");
|
||||
if (!emptyPath.IsValid()) {
|
||||
// 处理空路径
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**头文件**: `XCEngine/Resources/ResourcePath.h`
|
||||
|
||||
**描述**: 资源路径封装类,提供路径解析、转换和 GUID 生成功能。
|
||||
|
||||
## 概述
|
||||
|
||||
29
docs/api/resources/resourcepath/setpath.md
Normal file
29
docs/api/resources/resourcepath/setpath.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# ResourcePath::SetPath
|
||||
|
||||
```cpp
|
||||
void SetPath(const Containers::String& path)
|
||||
```
|
||||
|
||||
设置路径字符串。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
更新内部存储的路径字符串。
|
||||
|
||||
**参数:**
|
||||
- `path` - 新的路径字符串
|
||||
|
||||
**复杂度:** O(n),n 为路径长度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path;
|
||||
path.SetPath("textures/player.png");
|
||||
Containers::String name = path.GetFileName(); // "player.png"
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
- [GetPath](getpath.md) - 获取路径
|
||||
30
docs/api/resources/resourcepath/toguid.md
Normal file
30
docs/api/resources/resourcepath/toguid.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# ResourcePath::ToGUID
|
||||
|
||||
```cpp
|
||||
ResourceGUID ToGUID() const
|
||||
```
|
||||
|
||||
将路径转换为 GUID。
|
||||
|
||||
**详细描述:**
|
||||
|
||||
通过 `ResourceGUID::Generate` 方法根据路径字符串生成唯一的资源标识符。
|
||||
|
||||
**返回:** `ResourceGUID`,基于路径生成的全局唯一标识符
|
||||
|
||||
**复杂度:** O(n),取决于 `ResourceGUID::Generate` 实现
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourcePath path("textures/player.png");
|
||||
ResourceGUID guid = path.ToGUID();
|
||||
|
||||
// GUID 可用于资源查找、缓存键等
|
||||
ResourceHandle<Texture> tex = ResourceManager::Get().Find(guid);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ResourcePath 总览](resourcepath.md) - 返回类总览
|
||||
- [ResourceTypes](../resourcetypes/resourcetypes.md) - 资源类型定义
|
||||
Reference in New Issue
Block a user