• Stars
    star
    270
  • Rank 152,189 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created over 7 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple C++ ini parser.

IniPP

Simple header-only C++ ini parser and generator.

Build Status Build status

Features

  • Header-only.
  • Both parsing and generating.
  • Wide character support for native unicode on Windows.
  • Default section support (similar to Python's ConfigParser).
  • Interpolation support (i.e. variable substitution, similar to Python's ConfigParser).
  • Trailing comments support.
  • Simple design and implementation.
  • Permissive MIT license.

Example

#include <fstream>
#include "inipp.h"

int main() {
	inipp::Ini<char> ini;
	std::ifstream is("example.ini");
	ini.parse(is);
	std::cout << "raw ini file:" << std::endl;
	ini.generate(std::cout);
	ini.strip_trailing_comments();
	ini.default_section(ini.sections["DEFAULT"]);
	ini.interpolate();
	std::cout << "ini file after default section and interpolation:" << std::endl;
	ini.generate(std::cout);
	int compression_level = -1;
	inipp::get_value(ini.sections["bitbucket.org"], "CompressionLevel", compression_level);
	std::cout << "bitbucket.org compression level: " << compression_level << std::endl;
	return 0;
}

To include in a cmake project:

FetchContent_Declare(inipp GIT_REPOSITORY https://github.com/mcmtroffaes/inipp.git)
FetchContent_MakeAvailable(inipp)
target_link_libraries(MyTarget PRIVATE inipp::inipp)

Parsing algorithm

  • The section is set to the empty string.

  • Every line is read from the file and trimmed from whitespace.

    • If line is empty or starts with ; then nothing happens.

    • Otherwise, if line starts with [ then section is changed to the string between [ and ]. If line does not end with ] then an error is reported.

    • Otherwise, if line contains an = sign, then all characters before = are treated as variable and all characters following = are treated as value. Both are trimmed. If the variable was already assigned earlier, an error is reported. Otherwise, the corresponding assigment is added to the section.

    • Otherwise, the line is reported as an error.

Default section algorithm

Insert every variable from the default section into every other section, without overwriting existing variables.

Interpolation algorithm

  1. Locally within each section, every occurrence "${variable}" is replaced by "${section:variable}".
  2. Every occurrence of "${section:variable}" is replaced by its value.
  3. The previous step is repeated until no more replacements are possible, or until the recursion depth (by default, 10) is reached.

More Repositories

1

sphinxcontrib-bibtex

Sphinx extension for bibtex style references.
Python
176
star
2

ffmpeg-msvc-build

Script for building ffmpeg with msvc.
CMake
73
star
3

pycddlib

A Python wrapper for Komei Fukuda's cddlib.
Python
58
star
4

latexcodec

Lexer and codec to work with LaTeX code in Python. Instead of using latexcodec, I encourage you to consider pylatexenc instead, which is far superior: https://github.com/phfaist/pylatexenc
Python
27
star
5

cddlib_old

Please refer to the official version of cddlib on github instead.
Mathematica
13
star
6

improb

A Python module for working with imprecise probabilities.
Python
10
star
7

ffmpeg-nuget

As of October 1st 2020, this repository will no longer receive any updates, since zeranoe is closing and will no longer be providing any builds. Visual Studio has nowadays excellent integration with vcpkg. Pre-built vcpkg archives are available from ffmpeg-msvc-build, or simply build ffmpeg yourself using vcpkg.
PowerShell
8
star
8

agda-proofs

Agda
4
star
9

AgdaTutorial

Git fork of http://hub.darcs.net/divip/AgdaTutorial
Agda
4
star
10

gta5-simple-video-export

For quick experimentation only.
C++
3
star
11

bibliography

My bibtex bibliography.
TeX
3
star
12

quickrest

Quick restructured text creator.
Python
2
star
13

x264-msvc-build

Visual Studio builds of x264. This repository is no longer maintained. If you are looking to build x264, you may look into vcpkg instead.
Shell
2
star
14

sphinx-citation-invalid-html

1
star
15

kbtune

Keyboard tuning calculator.
Python
1
star
16

homepage

My homepage.
Haskell
1
star
17

config-openbox

My openbox configuration.
Shell
1
star
18

xresources

My .Xresources file.
Emacs Lisp
1
star
19

ffmpeg-msvc-nuget

As of October 1st 2020 onward, this repository will no longer receive any updates, since Visual Studio has nowadays excellent integration with vcpkg. Pre-built vcpkg archives are available from ffmpeg-msvc-build, or simply build ffmpeg yourself using vcpkg.
PowerShell
1
star
20

pybtex-docutils

A docutils backend for pybtex.
Python
1
star
21

sipta-school-2024-decision-notebooks

Jupyter notebooks for the SIPTA school 2024 lectures on decision making.
Jupyter Notebook
1
star