LibCfg++ is a convenient C++ library for working with configuration files.
- Manipulate strings (Read and change string values).
- Create and read sections.
- Format the file in its own style.
- Scan the file for errors.
- G++ (GCC >= 4.8.1) -
sudo apt-get install g++
- MinGW or Visual C++
- Clone this repository to any folder you like, using this command
git clone https://github.com/DRHandyman/LibCfgPP
. If you do not have GIT installed, then here is a link to the documentation for installing it. - Drag and drop files LibCfgPP.cpp and LibCfgPP.hpp to the folder with your project.
- Compile the source file LibCfgPP.cpp along with the rest of the source files.
// main.cpp
#include <iostream>
#include "LibCfgPP.hpp"
using namespace std;
LibCfgPP::CfgFile cfg_file;
int main() {
try {
cfg_file.open("cfg_file.cfg");
cout << cfg_file.read("string") << endl
<< cfg_file.read("section", "string") << endl;
} catch (const LibCfgPP::LCPPException &ex) {
cout << ex.what() << endl;
}
cfg_file.close();
return EXIT_SUCCESS;
}
# cfg_file.cfg
string = "value" # Test comment
[section]
string = "value" # Test comment
- You can run the sample code on the Replit website.
- Added the ability to read string values and read sections.
- Added the ability to change the string value.
- You can view code examples in the examples folder.
- You can view the function descriptions in LibCfgPP.hpp file or view the documentation by opening the file docs/html/index.html in your browser.