https://github.com/devvoid/vini
A single-header INI parser capable of both reading and writing files.
https://github.com/devvoid/vini
c-plus-plus cpp cpp-library cpp98 ini ini-parser no-dependencies single-file single-header single-header-lib
Last synced: 6 months ago
JSON representation
A single-header INI parser capable of both reading and writing files.
- Host: GitHub
- URL: https://github.com/devvoid/vini
- Owner: devvoid
- License: other
- Created: 2018-04-19T05:04:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-21T22:39:50.000Z (over 7 years ago)
- Last Synced: 2025-04-10T00:51:09.980Z (9 months ago)
- Topics: c-plus-plus, cpp, cpp-library, cpp98, ini, ini-parser, no-dependencies, single-file, single-header, single-header-lib
- Language: C++
- Size: 48.8 KB
- Stars: 8
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# VINI (Void's INI Parsing Library)
A small, single-header library for reading/writing INI files.
## Usage
```c++
#include
#include "vini.hpp"
int main() {
//Load INI file from existing file.
Vini file_one("test.ini");
//Create a blank file; use this to create an INI from scratch
Vini file_two;
//Get a value from the INI file.
//The first argument is the section to search from.
//The second argument is the key to get content from.
//The third argument is a default value.
//If the section or key does not exist, that value will be created in that section or key.
//In addition, the function will return that default value.
std::string returned_string = file_two.get("main", "key", "default_value");
//Sets a value in the INI file.
//The arguments are all the same as the get function.
//This function returns nothing.
//It will also overwrite any existing values in that section/key if one already exists.
file_two.set("main", "otherkey", "Hello, world!");
//Write file to disk.
file_two.save("output.ini");
}
```
Output:
```ini
[main]
key="default_value"
otherkey="Hello, world!"
```
Note that Vini does not provide any functions for getting any data types from an INI file other than a std::string. This was intentional; Vini is designed to have a simple API, small filesize, and simple implimentation. The C++ standard library has plenty of functions for converting strings into other datatypes anyway.
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.