提供跨平台的与平台相关函数,包括文件操作、环境检测、动态库加载、界面操作等。
|
| EEndian | ast::aGetEndian () |
| |
| bool | ast::aIsCI () |
| |
| bool | ast::aIsGithubCI () |
| |
| bool | ast::aIsGitlabCI () |
| |
| bool | ast::aTerminalSupportColor () |
| |
| int | ast::aTerminalWidth () |
| |
| StringView | ast::aProjectName () |
| |
| bool | ast::aIsTerminal (FILE *file) |
| |
| bool | ast::aIsFile (FILE *file) |
| |
| bool | ast::aStdInIsTerminal () |
| |
| bool | ast::aStdInIsFile () |
| |
| bool | ast::aStdOutIsTerminal () |
| |
| bool | ast::aStdOutIsFile () |
| |
| bool | ast::aStdErrIsTerminal () |
| |
| bool | ast::aStdErrIsFile () |
| |
| std::string | ast::aGetModulePathFromAddress (void *addr) |
| |
| std::string | ast::aLibDir () |
| |
| std::string | ast::aExeDir () |
| |
| std::string | ast::aLibPath () |
| |
| std::string | ast::aExePath () |
| |
| bool | ast::aCanDisplayGUI () |
| |
| errc_t | ast::aUriFetch (StringView uri, std::string &filepath) |
| |
| std::FILE * | ast::uriopen (const char *uri, const char *mode) |
| |
|
A_ALWAYS_INLINE std::FILE * | ast::ast_fopen (const char *filepath, const char *mode) |
| |
|
A_ALWAYS_INLINE FILE * | ast::ast_freopen (const char *filepath, const char *mode, FILE *stream) |
| |
|
A_ALWAYS_INLINE int | ast::ast_vprintf (const char *format, va_list args) |
| |
|
int | ast::ast_printf (const char *format,...) |
| |
| int | ast::aPrintLink (StringView text, StringView link) |
| |
| int | ast::aCurrentLineNumber (std::FILE *file) |
| |
| errc_t | ast::aGetFilePath (std::FILE *file, std::string &filepath) |
| |
| A_ALWAYS_INLINE std::string | ast::aGetFilePath (std::FILE *file) |
| |
| void * | ast::aLoadLibrary (const char *filepath) |
| |
| void * | ast::aLoadLibrary (StringView filepath) |
| |
| void * | ast::aGetProcAddress (void *lib, const char *funcName) |
| |
| void * | ast::aResolveProcAddress (const char *filepath, const char *funcName) |
| |
| errc_t | ast::aFreeLibrary (void *lib) |
| |
| const char * | ast::aGetLoadError () |
| |
| bool | ast::aIsLibrary (StringView fileName) |
| |
|
A_ALWAYS_INLINE void | ast::swap (Thread &lhs, Thread &rhs) noexcept |
| |
| errc_t | ast::aEditObject (Object *object) |
| |
| Object * | ast::aSelectObject (StringView typeName) |
| |
◆ EEndian
| 枚举值 |
|---|
| eLittleEndian | 小端字节序
|
| eBigEndian | 大端字节序
|
◆ aCanDisplayGUI()
| AST_UTIL_CAPI bool ast::aCanDisplayGUI |
( |
| ) |
|
◆ aCurrentLineNumber()
| AST_UTIL_CAPI int ast::aCurrentLineNumber |
( |
std::FILE * | file | ) |
|
获取文件当前行号
- 参数
-
- 返回
- 当前行号,从1开始计数
◆ aEditObject()
| AST_UTIL_CAPI errc_t ast::aEditObject |
( |
Object * | object | ) |
|
◆ aExeDir()
| AST_UTIL_API std::string ast::aExeDir |
( |
| ) |
|
◆ aExePath()
| AST_UTIL_API std::string ast::aExePath |
( |
| ) |
|
◆ aFreeLibrary()
| AST_UTIL_CAPI errc_t ast::aFreeLibrary |
( |
void * | lib | ) |
|
◆ aGetEndian()
| AST_UTIL_CAPI EEndian ast::aGetEndian |
( |
| ) |
|
获取当前系统的字节序
- 返回
- EEndian 当前系统的字节序
◆ aGetFilePath() [1/2]
| A_ALWAYS_INLINE std::string ast::aGetFilePath |
( |
std::FILE * | file | ) |
|
◆ aGetFilePath() [2/2]
| AST_UTIL_CAPI errc_t ast::aGetFilePath |
( |
std::FILE * | file, |
|
|
std::string & | filepath ) |
获取文件路径
- 参数
-
| file | 文件指针 |
| filepath | 输出文件路径,utf-8编码 |
- 返回
- 错误码
◆ aGetLoadError()
| AST_UTIL_CAPI const char * ast::aGetLoadError |
( |
| ) |
|
◆ aGetModulePathFromAddress()
| AST_UTIL_API std::string ast::aGetModulePathFromAddress |
( |
void * | addr | ) |
|
获取函数、变量所在模块的路径
- 参数
-
- 返回
- std::string 模块路径
◆ aGetProcAddress()
| AST_UTIL_CAPI void * ast::aGetProcAddress |
( |
void * | lib, |
|
|
const char * | funcName ) |
◆ aIsCI()
| AST_UTIL_CAPI bool ast::aIsCI |
( |
| ) |
|
检查是否在持续集成环境中运行
- 返回
- 如果在CI环境中运行,返回true;否则返回false
◆ aIsFile()
| AST_UTIL_CAPI bool ast::aIsFile |
( |
FILE * | file | ) |
|
检查文件是否为普通文件
- 参数
-
- 返回
- 如果文件为普通文件,返回true;否则返回false
◆ aIsGithubCI()
| AST_UTIL_CAPI bool ast::aIsGithubCI |
( |
| ) |
|
检查是否在Github action CI环境中运行
- 返回
- 如果在Github action CI环境中运行,返回true;否则返回false
◆ aIsGitlabCI()
| AST_UTIL_API bool ast::aIsGitlabCI |
( |
| ) |
|
检查是否在Gitlab runner CI环境中运行
- 返回
- 如果在Gitlab runner CI环境中运行,返回true;否则返回false
◆ aIsLibrary()
| AST_UTIL_CAPI bool ast::aIsLibrary |
( |
StringView | fileName | ) |
|
判断文件名是否具有有效的动态库后缀
- 参数
-
- 返回
- 是否为有效的库后缀
◆ aIsTerminal()
| AST_UTIL_CAPI bool ast::aIsTerminal |
( |
FILE * | file | ) |
|
检查文件是否为终端
- 参数
-
- 返回
- 如果文件为终端,返回true;否则返回false
◆ aLibDir()
| AST_UTIL_API std::string ast::aLibDir |
( |
| ) |
|
◆ aLibPath()
| AST_UTIL_API std::string ast::aLibPath |
( |
| ) |
|
◆ aLoadLibrary() [1/2]
| AST_UTIL_API void * ast::aLoadLibrary |
( |
const char * | filepath | ) |
|
加载动态库
- 参数
-
- 返回
- 库句柄,失败返回 nullptr
◆ aLoadLibrary() [2/2]
| AST_UTIL_API void * ast::aLoadLibrary |
( |
StringView | filepath | ) |
|
加载动态库(StringView 重载)
- 返回
- 库句柄,失败返回 nullptr
◆ aPrintLink()
◆ aProjectName()
◆ aResolveProcAddress()
| AST_UTIL_CAPI void * ast::aResolveProcAddress |
( |
const char * | filepath, |
|
|
const char * | funcName ) |
从动态库中获取函数指针
- 参数
-
| filepath | 动态库路径 |
| funcName | 函数名称 |
- 返回
◆ aSelectObject()
选择对象
~
- 参数
-
- 返回
- Object* 选择的对象指针
◆ aStdErrIsFile()
| AST_UTIL_CAPI bool ast::aStdErrIsFile |
( |
| ) |
|
检查标准错误是否为文件
- 返回
- 如果标准错误为文件,返回true;否则返回false
◆ aStdErrIsTerminal()
| AST_UTIL_CAPI bool ast::aStdErrIsTerminal |
( |
| ) |
|
检查标准错误是否为终端
- 返回
- 如果标准错误为终端,返回true;否则返回false
◆ aStdInIsFile()
| AST_UTIL_CAPI bool ast::aStdInIsFile |
( |
| ) |
|
检查标准输入是否为文件
- 返回
- 如果标准输入为文件,返回true;否则返回false
◆ aStdInIsTerminal()
| AST_UTIL_CAPI bool ast::aStdInIsTerminal |
( |
| ) |
|
检查标准输入是否为终端
- 返回
- 如果标准输入为终端,返回true;否则返回false
◆ aStdOutIsFile()
| AST_UTIL_CAPI bool ast::aStdOutIsFile |
( |
| ) |
|
检查标准输出是否为文件
- 返回
- 如果标准输出为文件,返回true;否则返回false
◆ aStdOutIsTerminal()
| AST_UTIL_CAPI bool ast::aStdOutIsTerminal |
( |
| ) |
|
检查标准输出是否为终端
- 返回
- 如果标准输出为终端,返回true;否则返回false
◆ aTerminalSupportColor()
| AST_UTIL_API bool ast::aTerminalSupportColor |
( |
| ) |
|
检查终端是否支持颜色
- 返回
- 如果终端支持颜色,返回true;否则返回false
◆ aTerminalWidth()
| AST_UTIL_API int ast::aTerminalWidth |
( |
| ) |
|
获取终端窗口宽度(列数)
- 返回
- 终端宽度(列),若无法获取则返回默认值 80
◆ aUriFetch()
| AST_UTIL_CAPI errc_t ast::aUriFetch |
( |
StringView | uri, |
|
|
std::string & | filepath ) |
解析URI(统一资源标识符)并返回其对应的本地文件路径
支持三种输入:
- 普通文件路径:原样返回,不检查文件是否存在, 例如 "C:\\Users\\axel\\Desktop\\file.txt";
file:// 本地文件URI:支持 percent 解码(%20 等)与 localhost 主机名, 例如 file:///path/to/file.txt ;
http://、https:// 远程资源:下载并缓存在缓存文件夹(见 aCacheDir)中, 同一URI只下载一次,多个进程间用文件锁协调。 - 参数
-
| [in] | uri | 文件URI,utf-8编码 |
| [out] | filepath | 本地文件路径,utf-8编码; |
- 返回
- 错误码
◆ uriopen()
| AST_UTIL_CAPI std::FILE * ast::uriopen |
( |
const char * | uri, |
|
|
const char * | mode ) |
打开URI(统一资源标识符)对应的文件 例如 https://example.com/file.txt 、file:///path/to/file.txt 等 也支持传入普通文件路径,即与 fopen 函数相同, 例如 "C:\\Users\\axel\\Desktop\\file.txt" 等
内部先调用 aUriFetch 得到本地路径,再以 mode 打开。 远程资源会被下载并缓存,因此同一URI的第二次打开不会再联网。 打开远程二进制资源时建议使用 "rb"。
- 参数
-
| [in] | uri | 文件URI,utf-8编码 |
| [in] | mode | 文件打开模式,网络文件只支持 "r"、"rb" |
- 返回
- 文件指针,失败时返回空指针并设置 errno