-
Notifications
You must be signed in to change notification settings - Fork 0
/
LXIni.h
79 lines (62 loc) · 1.68 KB
/
LXIni.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// Ini.hpp
// FileUtil
//
// Created by duoyi on 2017/6/29.
// Copyright © 2017年 lixu. All rights reserved.
//
#ifndef Ini_hpp
#define Ini_hpp
#include <map>
#include <string>
namespace LX_FU {
/**
* INI files handlers.
*
* Name space LX_FU::INI
* getIniConfigMap & saveIniConfigFile
*
* @warning One line's size should not be greater than 32
*/
namespace INI {
class IniConfig
{
public:
IniConfig();
IniConfig(const std::string& configName);
~IniConfig();
/**
* Save the current config map to file.
* If the file do not exists, this will create the file.
*
* @warning this will overwrite the file in existance.
*/
bool saveToFile(const std::string& configName);
/**
* Load configs from a file.
*
*/
bool loadFromFile(const std::string& configName);
/**
* Judge whether current configs contains key of confName or not.
*
*/
bool hasConf(const std::string& confName);
/**
* Get the value of confName, return "" if do not have this config.
*
*/
std::string getConf(const std::string& confName);
/**
* Set key->value to this ini config.
*
*/
void setConf(const std::string& key, const std::string& value);
private:
std::map<std::string, std::string> m_mapIni;
};
IniConfig readIniConfigFromFile(const std::string& configName);
bool saveIniConfigToFile(IniConfig& iniConfig, const std::string& configName);
}
}
#endif /* Ini_hpp */