hunting/utils/StatusCode/include/StatusCode.h
xiaojiazhu a80a8f7cee 1.Add clang-tidy in CMakeList.txt.
2.Add clang-tidy tools.
2023-09-02 04:26:30 -07:00

39 lines
1.0 KiB
C

#ifndef STATUSCODE_H
#define STATUSCODE_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
enum STATUS_CODE
{
STATUS_CODE_OK = 0,
STATUS_CODE_NOT_OK,
STATUS_CODE_VIRTUAL_FUNCTION,
STATUS_CODE_INVALID_PARAMENTER,
STATUS_CODE_END
};
typedef struct status_code StatusCode;
typedef struct status_code
{
const char *(*mPrintStringCode)(const StatusCode);
const bool (*mCodeEqual)(const StatusCode, const char *);
const long int mStatusCode;
} StatusCode;
const StatusCode CreateStatusCode(const long int code);
static inline const char *PrintStringCode(const StatusCode code)
{
return code.mPrintStringCode(code);
}
static inline bool IsCodeOK(const StatusCode code)
{
return STATUS_CODE_OK == code.mStatusCode ? true : false;
}
static inline bool StatusCodeEqual(const StatusCode code, const char *value)
{
return code.mCodeEqual(code, value);
}
#ifdef __cplusplus
}
#endif
#endif