Class Status
#include <status.h>
构造函数
Status()
inline Status(enum StatusCode status_code, const std::string &status_msg = "")
inline Status(const StatusCode code, int line_of_code, const char *file_name, const std::string &extra = "")
析构函数
~Status() = default
公有成员函数
函数 |
云侧推理是否支持 |
端侧推理是否支持 |
|---|---|---|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
inline std::string SetErrDescription(const std::string &err_description) |
√ |
√ |
√ |
√ |
|
friend std::ostream &operator<<(std::ostream &os, const Status &s) |
√ |
√ |
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
StatusCode
enum StatusCode StatusCode() const
获取状态码。
返回值
状态码。
ToString
inline std::string ToString() const
状态码转成字符串。
返回值
状态码的字符串。
GetLineOfCode
int GetLineOfCode() const
获取代码行数。
返回值
代码行数。
GetFileName
inline std::string GetFileName() const
获取文件名。
返回值
文件名。
GetErrDescription
inline std::string GetErrDescription() const
获取错误描述字符串。
返回值
错误描述字符串。
SetErrDescription
inline std::string SetErrDescription(const std::string &err_description)
配置错误描述字符串。
参数
err_description: 错误描述字符串。
返回值
状态信息字符串。
SetStatusMsg
inline void SetStatusMsg(const std::string &status_msg)
配置状态描述字符串。
参数
status_msg: 状态描述字符串。
operator<<(std::ostream &os, const Status &s)
friend std::ostream &operator<<(std::ostream &os, const Status &s)
状态信息写到输出流。
参数
os: 输出流。s: 状态类。
返回值
输出流。
operator==(const Status &other)
bool operator==(const Status &other) const
判断是否与另一个Status相等。
参数
other: 另一个Status。
返回值
是否与另一个Status相等。
operator==(enum StatusCode other_code)
bool operator==(enum StatusCode other_code) const
判断是否与一个StatusCode相等。
参数
other_code: 一个StatusCode。
返回值
是否与一个StatusCode相等。
operator!=(const Status &other)
bool operator!=(const Status &other) const
判断是否与另一个Status不相等。
参数
other: 另一个Status。
返回值
是否与另一个Status不相等。
operator!=(enum StatusCode other_code)
bool operator!=(enum StatusCode other_code) const
判断是否与一个StatusCode不等。
参数
other_code: 一个StatusCode。
返回值
是否与一个StatusCode不等。
operator bool()
explicit operator bool() const
重载bool操作,判断是否当前状态为kSuccess。
返回值
是否当前状态为kSuccess。
explicit operator int() const
explicit operator int() const
重载int操作。当Status对象被作为整型表达式使用时,返回整型表示的当前状态值。
返回值
当前状态值。
OK
static Status OK()
获取kSuccess的状态码。
返回值
StatusCode::kSuccess。
IsOk
bool IsOk() const
判断是否是kSuccess的状态码。
返回值
是否是kSuccess。
IsError
bool IsError() const
判断是否不是kSuccess的状态码。
返回值
是否不是kSuccess。
CodeAsString
static inline std::string CodeAsString(enum StatusCode c)
获取StatusCode对应的字符串。
参数
c: 状态码枚举值。
返回值
状态码对应的字符串。