hunting/utils/ConfigBase/src/ConfigBaseImpl.h
2024-04-07 19:26:15 +08:00

50 lines
2.3 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_IMPL_H
#define CONFIG_BASE_IMPL_H
#include "IConfigBase.h"
#include <libconfig.h>
class ConfigBaseImpl : public IConfigBase
{
public:
ConfigBaseImpl(const std::string &fileName);
virtual ~ConfigBaseImpl() = default;
void OpenConfigFile(void) override;
void CloseConfigFile(void) override;
StatusCode ConfigSaveFile(void) override;
StatusCode ConfigGetInt(const char *name, int *value) override;
StatusCode ConfigSetInt(const char *name, const int value) override;
StatusCode ConfigGetShort(const char *name, short *value) override;
StatusCode ConfigSetShort(const char *name, const short value) override;
StatusCode ConfigGetLong(const char *name, long *value) override;
StatusCode ConfigSetLong(const char *name, const long value) override;
StatusCode ConfigGetLLong(const char *name, long long *value) override;
StatusCode ConfigSetLLong(const char *name, const long long value) override;
StatusCode ConfigGetChar(const char *name, char *value) override;
StatusCode ConfigSetChar(const char *name, const char value) override;
StatusCode ConfigGetBool(const char *name, bool *value) override;
StatusCode ConfigSetBool(const char *name, const bool value) override;
StatusCode ConfigGetFloat(const char *name, float *value) override;
StatusCode ConfigSetFloat(const char *name, const float value) override;
StatusCode ConfigGetDouble(const char *name, double *value) override;
StatusCode ConfigSetDouble(const char *name, const double value) override;
StatusCode ConfigGetString(const char *name, const char **value) override;
StatusCode ConfigSetString(const char *name, const char *value) override;
private:
const std::string mFileName;
config_t cfg;
};
#endif