mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
56 lines
4.0 KiB
C
56 lines
4.0 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_BASE_H
|
|
#define CONFIG_BASE_H
|
|
#include "StatusCode.h"
|
|
#ifdef __cplusplus
|
|
extern "C" //The declaration is to allow the C++compiler to process code surrounded by extern "C" in the same way as the C language. This is necessary
|
|
{
|
|
#endif
|
|
//#The three preprocessing instructions ifndef VNet BASE.H, # define VNet BASE.H, and # endif work together to ensure that the header file VNet BASE.H is only included once in any compilation unit. This is achieved by defining a unique macro (VNet BASE_H), skipping the file content if the macro has already been defined.
|
|
enum CONFIG_CODE//Defined an enumeration type VNet CODE for possible configuration error codes. It starts with VNet CODE-IND (assuming VNet CODE-IND is a status code defined in Status Code. h, indicating the end of a set of status codes), and defines a VNet CODE-IND as the end flag for enumeration.
|
|
{
|
|
CONFIG_CODE_PARAM_NOT_EXIST = STATUS_CODE_END,
|
|
CONFIG_CODE_END
|
|
};
|
|
// StatusCode ConfigInit(void);
|
|
// StatusCode ConfigUnInit(void);
|
|
void *OpenConfigFile(const char *fileName);
|
|
StatusCode ConfigSaveFile(void *object);
|
|
void CloseConfigFile(void *object);
|
|
StatusCode ConfigGetInt(void *object, const char *name, int *value);
|
|
StatusCode ConfigSetInt(void *object, const char *name, const int value);
|
|
StatusCode ConfigGetShort(void *object, const char *name, short *value);
|
|
StatusCode ConfigSetShort(void *object, const char *name, const short value);
|
|
StatusCode ConfigGetLong(void *object, const char *name, long *value);
|
|
StatusCode ConfigSetLong(void *object, const char *name, const long value);
|
|
StatusCode ConfigGetLLong(void *object, const char *name, long long *value);
|
|
StatusCode ConfigSetLLong(void *object, const char *name, const long long value);
|
|
StatusCode ConfigGetChar(void *object, const char *name, char *value);
|
|
StatusCode ConfigSetChar(void *object, const char *name, const char value);
|
|
StatusCode ConfigGetBool(void *object, const char *name, bool *value);
|
|
StatusCode ConfigSetBool(void *object, const char *name, const bool value);
|
|
StatusCode ConfigGetFloat(void *object, const char *name, float *value);
|
|
StatusCode ConfigSetFloat(void *object, const char *name, const float value);
|
|
StatusCode ConfigGetDouble(void *object, const char *name, double *value);
|
|
StatusCode ConfigSetDouble(void *object, const char *name, const double value);
|
|
StatusCode ConfigGetString(void *object, const char *name, const char **value);
|
|
StatusCode ConfigSetString(void *object, const char *name, const char *value);
|
|
//Provides a series of functions for opening, saving, closing configuration files, as well as obtaining and setting values for different data types (such as integer, short integer, long integer, long integer, character, boolean, floating-point, double precision floating-point, and string) in the configuration file. Most of these functions accept a void * object as the first parameter, which is typically a pointer to the configuration file context or object used to access and manipulate the configuration file. Other parameters include the name of the configuration item (const char * name) and a pointer to the variable used to store the retrieved value (such as int * value).
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|
|
//Overall, this header file defines a configuration management interface that allows developers to read and write configuration file values in a type safe manner, while considering interoperability between C and C++.
|