This is a header only C++ version of inih.

Related tags

Configuration inih
Overview

inih

Build Status

This is a header only C++ version of inih.

inih (INI Not Invented Here) is a simple .INI file parser written in C. It's only a couple of pages of code, and it was designed to be small and simple, so it's good for embedded systems. It's also more or less compatible with Python's ConfigParser style of .INI files, including RFC 822-style multi-line syntax and name: value entries.

Usage

All you need to do is to include INIReader.h. Consider the following example (INIReaderTest.cpp):

#include <iostream>
#include "INIReader.h"

int main() {

    INIReader reader("test.ini");

    if (reader.ParseError() != 0) {
        std::cout << "Can't load 'test.ini'\n";
        return 1;
    }
    std::cout << "Config loaded from 'test.ini': version="
              << reader.GetInteger("protocol", "version", -1) << ", name="
              << reader.Get("user", "name", "UNKNOWN") << ", email="
              << reader.Get("user", "email", "UNKNOWN") << ", pi="
              << reader.GetReal("user", "pi", -1) << ", active="
              << reader.GetBoolean("user", "active", true) << "\n";
    return 0;

}

To compile and run:

g++ INIReaderTest.cpp -o INIReaderTest.out
./INIReaderTest.out
# Config loaded from 'test.ini': version=6, name=Bob Smith, [email protected], pi=3.14159, active=1
Issues
  • Add Sections() method

    Add Sections() method

    It may be useful in case if you dont know which sections present in configuration and want to iterate over all available sections.

    We are going to store section names in memory because there are no obvious ways to parse all stored keys and get sections from them.

    opened by arcan1s 4
  • How implementing custom or string-based I/O

    How implementing custom or string-based I/O

        /* Same as ini_parse(), but takes an ini_reader function pointer instead of
       filename. Used for implementing custom or string-based I/O. */
        int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
                             void *user);
    

    How I use ini_parse_stream , implementing custom or string-based I/O

    opened by fananchong 2
  • Quoting values containing '/' leads to misinterpretation, missing quotation support

    Quoting values containing '/' leads to misinterpretation, missing quotation support

    Take this .ini file as reference:

    [database-mysql]
    hostA = "tcp://127.0.0.1:3306"
    hostB = tcp://127.0.0.1:3306
    

    When trying to retrieve hostA, it will evaluate to "tcp while hostB evaluates correctly. As shown in INI file, quoting of values should be perfectly fine. The closing " is missing too.

    By looking at the code, it seems to me that quoting wasn't considered at all. Is this on purpose?

    opened by choopm 2
  • Passing objects by referrence instead by value.

    Passing objects by referrence instead by value.

    Hello,

    I see all over the places that objects are passed by value instead by reference:

    INIReader(std::string filename);
    

    You probably know that it is a bad idea to pass objects by value due to its performance impact.

    Correct is:

    INIReader(const std::string& filename);
    
    opened by silviucpp 1
  • Mark the getter functions as const.

    Mark the getter functions as const.

    The current version of inih has marked the GetX() methods as const, and they should be updated here as well. Since they don't modify any state of the class, this should be a fairly simple fix.

    opened by ghost 1
  • add const to ParseError

    add const to ParseError

    ParseError does not modify the object and should a priori be usable from const methods of objects encapsulating a INIReader object. Therefore ParseError should be const.

    opened by nicolasaunai 1
  • Fix usage example of README

    Fix usage example of README

    There is an error in the usage example. The method ParseError() returns -1 if file can't be loaded or line number where parsing error occured. So the right checking that no error occured is ParseError() != 0.

    opened by kuznetsss 0
  • Falls back to section

    Falls back to section "main" if a give key is not found in a given section

    Hey.

    I saw this header and because I needed a fallback feature, I implemented and thought to send back a PR with it.

    The code change was minor, but has been working for me! Hope you enjoy.

    Best.

    opened by cmaruan 0
  • C4996 Warnings Are Not Suppressed

    C4996 Warnings Are Not Suppressed

    Hi, there are C4996 warnings when I try to compile my code with #include "INIReader.h" in multiple files. I didn't add _CRT_SECURE_NO_WARNINGS for my project but it should be fine as INIReader.h attempts to suppress this particular warning for its codes using codes below.

    #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
    #define _CRT_SECURE_NO_WARNINGS
    #endif
    

    Is there anything missing in code or I need to define _CRT_SECURE_NO_WARNINGS explicitly?


    Information about the IDE I am using:

    • IDE: Visual Studio 2017
    • Windows SDK Version: 10.0.17134.0
    • Platform Toolset: Visual Studio 2017 (v141)
    opened by WongZeHao 2
  • Add compilers to .travis.yml

    Add compilers to .travis.yml

    This is a PR to allow testing with multiple compilers:

    • g++ 5
    • g++ 6
    • g++ 7
    • g++ 8
    • g++ 9

    Currently the test application was only compiled with g++ version 5.4.0 on Travis CI.

    opened by Crayon2000 0
  • Support for ExtendedInterpolation Environment variables.

    Support for ExtendedInterpolation Environment variables.

    Would be nice to have, but should be an opt-in define or maybe a separate method... As you would have to find all the ${.*} patterns and call a GetEnvironmentVariable for each then place it in.

    opened by LiamKarlMitchell 0
C++20 single-header library for embedding INI configs

ini-config A single-header library that converts INI-formatted string literals to a key-value pair list at compile-time. Requires C++20; tested on gcc

clyne 54 Jun 21, 2022
A header-only version of Instagram Private API in C++

C++ Instagram API A header-only version of Instagram Private API in C++ Getting started. Writing your first bot General API Documentation Usage Error

Denis Beqiraj 35 Jun 4, 2022
gsl-lite – A single-file header-only version of ISO C++ Guidelines Support Library (GSL) for C++98, C++11, and later

gsl-lite: Guidelines Support Library for C++98, C++11 up metadata build packages try online gsl-lite is an implementation of the C++ Core Guidelines S

gsl-lite 750 Aug 10, 2022
gsl-lite – A single-file header-only version of ISO C++ Guidelines Support Library (GSL) for C++98, C++11, and later

gsl-lite: Guidelines Support Library for C++98, C++11 up metadata build packages try online gsl-lite is an implementation of the C++ Core Guidelines S

gsl-lite 750 Aug 10, 2022
Low dependency(C++11 STL only), good portability, header-only, deep neural networks for embedded

LKYDeepNN LKYDeepNN 可訓練的深度類神經網路 (Deep Neural Network) 函式庫。 輕量,核心部份只依賴 C++11 標準函式庫,低相依性、好移植,方便在嵌入式系統上使用。 Class diagram 附有訓練視覺化 demo 程式 訓練視覺化程式以 OpenCV

Lin Kao-Yuan 42 Aug 6, 2022
Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.

Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags. Quick start #include <bitflags/bitf

Marin Peko 71 Jul 30, 2022
Internet Key Exchange version 2 (IKEv2) daemon - portable version of OpenBSD iked

Portable OpenIKED This is a port of OpenBSD's OpenIKED to different Unix-like operating systems, including Linux, macOS and FreeBSD.

OpenIKED 26 May 23, 2022
Make CVE-2020-0668 exploit work for version < win10 v1903 and version >= win10 v1903

CVE-2020-0668 Made CVE-2020-0668 exploit work for version < win10 v1903 and version >= win10 v1903 Diaghub Exploit (< v1903) powershell exploit works

null 13 Dec 15, 2021
Modified version of srlua for MSVC using version 5.4 of Lua

Modified version of srlua for MSVC using version 5.4 of Lua. Quote from the original README: This is a self-running Lua interpreter. It is meant to be

Augusto Goulart 2 Feb 24, 2022
A special version of Packet Batch that utilizes AF_XDP Linux sockets (this should be faster than the standard version, but not as fast as the DPDK).

Packet Batch (AF_XDP) Description This is a special version of Packet Batch that utilizes AF_XDP sockets instead of AF_PACKETv3 (which is what the sta

Packet Batch 10 Jul 25, 2022
A special version of Packet Batch that utilizes the DPDK (this should be faster than the standard version).

Packet Batch (DPDK) Description This is a special version of Packet Batch that utilizes the DPDK, a kernel-bypass library. This does not use any form

Packet Batch 6 Feb 24, 2022
A simple API to parse long URL to a shorter version, and retrieve the longer version from the latter.

URLShortener Overview A simple API to parse long URL to a shorter version, and retrieve the longer version from the latter. URLShortener builds upon l

Mikayel Egibyan 2 Dec 7, 2021
We implemented our own sequential version of GA, PSO, SA and ACA using C++ and the parallelized version with CUDA support

We implemented our own sequential version of GA, PSO, SA and ACA using C++ (some using Eigen3 as matrix operation backend) and the parallelized version with CUDA support. All of them are much faster than the popular lib scikit-opt.

Aron751 4 May 7, 2022
Stripped down version of BIGTREETECH-TouchScreenFirmware which only supports ST7920 emulation (Marlin Mode)

Stripped down version of BIGTREETECH-TouchScreenFirmware which only supports ST7920 emulation (Marlin Mode). This project only uses peripheral drivers supplied by the screen manufacturer and uses it's own library to parse the ST7920 commands.

null 92 Aug 9, 2022
Enables Permanent UART output across boots. Supports PS4 version 6.72 only for now

Enables Permanent UART for PS4. Requires a 5.05/6.72/7.02 Jailbroken PS4. To build, you require ps4-sdk from Scene-Collective/ps4-payload-sdk In the t

Alexander Boulton 15 May 12, 2022
this is very basic version for our dataset validation, only change the path, and align the frame of vio and Groundtruth

VINS-Fusion for UrbanNavDataset Evaluation 1. Prerequisites please refer to VINS-Fusion Github 2. Build mkdir catkin/src cd catkin/src mkdir result cd

baaixw 12 May 26, 2022
My old heavily modified version of bigbase v1, it has an impulse-like scrollbar, ytd header loader, Vector3 fix + gamestate fix and some other misc changes!

Old Bigbase V1 UI This is my old ui for bigbase v1 but i dont need it anymore because the dev of solar mod menu stole it, and the new paragon menu (Fr

null 11 Jun 19, 2022
Simple one file header for hijacking windows version.dll for desired executable to do 3rd party modifying without dll injection.

Version-Hijack Simple one file header for hijacking windows version.dll for desired executable to do 3rd party modifying without dll injection. Usage

sneakyevil 5 Mar 31, 2022
BladeBit - Fast Chia (XCH) RAM-only k32-only Plotter

BladeBit Chia Plotter A fast RAM-only, k32-only, Chia plotter. Requirements 416 GiB of RAM are required to run it, plus a few more megabytes for stack

Harold Brenes 218 Aug 7, 2022
BladeBit - Fast Chia (XCH) RAM-only k32-only Plotter

BladeBit Chia Plotter A fast RAM-only, k32-only, Chia plotter. Requirements 416 GiB of RAM are required to run it, plus a few more megabytes for stack

Chia Network 220 Aug 11, 2022
Grassroots DICOM read-only mirror. Only for Pull Request.

This is the source code of GDCM. It is available from sf.net website. Official GIT repository is at: https://sourceforge.net/p/gdcm/gdcm/ For a genera

Mathieu Malaterre 287 Jul 28, 2022
Header-only library for using Keras models in C++.

frugally-deep Use Keras models in C++ with ease Table of contents Introduction Usage Performance Requirements and Installation FAQ Introduction Would

Tobias Hermann 882 Aug 7, 2022
header only, dependency-free deep learning framework in C++14

The project may be abandoned since the maintainer(s) are just looking to move on. In the case anyone is interested in continuing the project, let us k

tiny-dnn 5.6k Aug 11, 2022
Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!

Do you have a question that doesn't require you to open an issue? Join the gitter channel. If you use uvw and you want to say thanks or support the pr

Michele Caini 1.5k Aug 10, 2022
A simple header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).

args Note that this library is essentially in maintenance mode. I haven't had the time to work on it or give it the love that it deserves. I'm not add

Taylor C. Richberger 992 Aug 5, 2022
Small header only C++ library for writing multiplatform terminal applications

Terminal Terminal is small header only library for writing terminal applications. It works on Linux, macOS and Windows (in the native cmd.exe console)

Jupyter Xeus 218 Aug 8, 2022
A header-only C++ library for task concurrency

transwarp Doxygen documentation transwarp is a header-only C++ library for task concurrency. It allows you to easily create a graph of tasks where eve

Christian Blume 590 Aug 6, 2022
Header-only TOML config file parser and serializer for C++17 (and later!).

toml++ homepage ✨ This README is fine, but the toml++ homepage is better. ✨ Library features Header-only Supports the latest TOML release (v1.0.0), pl

Mark Gillard 846 Aug 8, 2022
Simple Useful Libraries: The C++17 header-only dynamic bitset

dynamic_bitset Simple Useful Libraries: The C++17 header-only dynamic bitset Requirements To use this dynamic bitset, you will need a C++17 compliant

Maxime Pinard 112 Aug 5, 2022