53 lines
1.5 KiB
C
53 lines
1.5 KiB
C
/*
|
|
* Copyright (c) 2023 Fancy Code.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#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_MAKE_SHARED_PTR_FAILED,
|
|
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 |