hunting/utils/Config/include/Config.h

49 lines
1.8 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 CONFIG_H
#define CONFIG_H
#include "StatusCode.h"
#ifdef __cplusplus
extern "C"
{
#endif
enum CONFIG_CODE
{
CONFIG_CODE_PARAM_NOT_EXIST = STATUS_CODE_END,
CONFIG_CODE_END
};
typedef struct v_config VConfig;
typedef struct v_config
{
const StatusCode (*get_int)(VConfig *, const char *, int *);
const StatusCode (*set_int)(VConfig *, const char *, const int);
const StatusCode (*get_string)(VConfig *, const char *, const char**);
const StatusCode (*set_string)(VConfig *, const char *, const char*);
const StatusCode (*save)(VConfig *);
} VConfig;
const StatusCode ConfigInit(void);
const StatusCode ConfigUnInit(void);
VConfig *OpenConfigFile(const char *fileName);
const StatusCode ConfigSaveFile(VConfig *cfg);
void CloseConfigFile(VConfig *cfg);
const StatusCode ConfigGetInt(VConfig *cfg, const char *name, int *value);
const StatusCode ConfigSetInt(VConfig *cfg, const char *name, const int value);
const StatusCode ConfigGetString(VConfig *cfg, const char *name, const char** value);
const StatusCode ConfigSetString(VConfig *cfg, const char *name, const char* value);
#ifdef __cplusplus
}
#endif
#endif