mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
227 lines
9.6 KiB
C
227 lines
9.6 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.
|
|
*/
|
|
/*!
|
|
* This file contains the base configuration interface for managing configuration files.
|
|
* It provides functions to open, read, write, and close configuration files,
|
|
* as well as to get and set various data types stored within these files.
|
|
*/
|
|
/**
|
|
* @file ConfigBase.h
|
|
* @brief Configuration management definitions and interfaces.
|
|
*
|
|
* This header file provides the necessary declarations for configuration management.
|
|
* It includes the definition of the configuration codes, as well as the function
|
|
* prototypes for interacting with the configuration system.
|
|
*/
|
|
#ifndef CONFIG_BASE_H
|
|
#define CONFIG_BASE_H
|
|
#include "StatusCode.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
/**
|
|
* @brief Enumeration for configuration codes.
|
|
*
|
|
* Defines specific codes for configuration-related status messages.
|
|
*/
|
|
enum CONFIG_CODE
|
|
{
|
|
CONFIG_CODE_PARAM_NOT_EXIST = STATUS_CODE_END,
|
|
/**< Parameter does not exist in the configuration. */
|
|
CONFIG_CODE_END
|
|
/**< End of configuration codes. */
|
|
};
|
|
|
|
// StatusCode ConfigInit(void);
|
|
// StatusCode ConfigUnInit(void);
|
|
/**
|
|
* @brief Opens a configuration file.
|
|
* @param fileName The name of the configuration file to open.
|
|
* @return A pointer to the opened configuration file object.
|
|
*/
|
|
void *OpenConfigFile(const char *fileName);
|
|
/**
|
|
* @brief Saves the current configuration to a file.
|
|
* @param object The configuration object to save.
|
|
* @return A StatusCode indicating the result of the operation.
|
|
*/
|
|
StatusCode ConfigSaveFile(void *object);
|
|
/**
|
|
* @brief Closes a configuration file.
|
|
* @param object The configuration file object to close.
|
|
*/
|
|
void CloseConfigFile(void *object);
|
|
/**
|
|
* @brief Retrieves an integer value from the configuration.
|
|
* @param object The configuration object.
|
|
* @param name The name of the configuration parameter.
|
|
* @param value A pointer to store the retrieved integer value.
|
|
* @return A StatusCode indicating the result of the operation.
|
|
*/
|
|
StatusCode ConfigGetInt(void *object, const char *name, int *value);
|
|
/**
|
|
* @brief Sets an integer value in the configuration.
|
|
* @param object The configuration object.
|
|
* @param name The name of the configuration parameter.
|
|
* @param value The integer value to set.
|
|
* @return A StatusCode indicating the result of the operation.
|
|
*/
|
|
StatusCode ConfigSetInt(void *object, const char *name, const int value);
|
|
/**
|
|
* @brief Retrieves a short configuration value.
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to retrieve.
|
|
* @param value A pointer to store the retrieved short value.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetShort(void *object, const char *name, short *value);
|
|
/**
|
|
* @brief Sets a short configuration value.
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The short value to set for the configuration parameter.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetShort(void *object, const char *name, const short value);
|
|
/**
|
|
* @brief Retrieves a long integer value from the configuration.
|
|
* @param object Pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value Pointer to store the retrieved long integer value.
|
|
* @return StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetLong(void *object, const char *name, long *value);
|
|
/**
|
|
* @brief Sets a long integer value in the configuration.
|
|
* @param object Pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The long integer value to set.
|
|
* @return StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetLong(void *object, const char *name, const long value);
|
|
/**
|
|
* @brief Retrieves a long long integer value from the configuration.
|
|
* @param object Pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value Pointer to store the retrieved long long integer value.
|
|
* @return StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetLLong(void *object, const char *name, long long *value);
|
|
/**
|
|
* @brief Sets a long long integer value in the configuration.
|
|
* @param object Pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The long long integer value to set.
|
|
* @return StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetLLong(void *object, const char *name, const long long value);
|
|
/**
|
|
* @brief Retrieves a string value from the configuration.
|
|
* @param object Pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value Pointer to store the retrieved string value.
|
|
* @return StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetChar(void *object, const char *name, char *value);
|
|
/**
|
|
* @brief Sets a string value in the configuration.
|
|
* @param object Pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The string value to set.
|
|
* @return StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetChar(void *object, const char *name, const char value);
|
|
/**
|
|
* @brief Retrieves a boolean configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value A pointer to store the retrieved boolean value.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetBool(void *object, const char *name, bool *value);
|
|
/**
|
|
* @brief Sets a boolean configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The boolean value to set.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetBool(void *object, const char *name, const bool value);
|
|
/**
|
|
* @brief Retrieves a floating-point configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value A pointer to store the retrieved floating-point value.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetFloat(void *object, const char *name, float *value);
|
|
/**
|
|
* @brief Sets a floating-point configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The floating-point value to set.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetFloat(void *object, const char *name, const float value);
|
|
/**
|
|
* @brief Retrieves a double-precision floating-point configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value A pointer to store the retrieved double-precision floating-point value.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigGetDouble(void *object, const char *name, double *value);
|
|
|
|
/**
|
|
* @brief Sets a double-precision floating-point configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The double-precision floating-point value to set.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetDouble(void *object, const char *name, const double value);
|
|
/**
|
|
* @brief Retrieves a string configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to read.
|
|
* @param value A reference to a pointer where the string value will be stored.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
* If the operation is successful, the pointed-to pointer will hold
|
|
* the address of the string value. The caller should not attempt to
|
|
* free this memory if the string is managed internally by the
|
|
* configuration system.
|
|
*/
|
|
StatusCode ConfigGetString(void *object, const char *name, const char **value);
|
|
/**
|
|
* @brief Sets a string configuration value.
|
|
*
|
|
* @param object A pointer to the configuration object.
|
|
* @param name The name of the configuration parameter to set.
|
|
* @param value The string value to set for the configuration parameter.
|
|
* @return A StatusCode indicating the success or failure of the operation.
|
|
*/
|
|
StatusCode ConfigSetString(void *object, const char *name, const char *value);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|