Skip to content
Petr Stefan edited this page May 16, 2016 · 5 revisions

INICPP wiki

inicpp is a C++ parser of INI files with schema validation.

Main features

With inicpp library you can do following:

  • Specify format of configuration file (schema)
    • For every section should be defined:
      • identifier
      • mandatory/optional
      • comment with short description of this section
    • For every option in a section should be defined:
      • identifier
      • mandatory/optional
      • one element or list of elements
      • type ofthe elementu and restriction of valid values
      • default value when the option is optional
      • comment (describing valid values)
  • Load configuration file in two modes:
    • strict – content must be valid according to given schema, exeption is thrown otherwise
    • relaxed – unknown section and options are read as strings, known section have full validity check
  • Access to loaded configuration with possibily to modify values
  • Write configuration to file (try as similar as loaded configuration, eq. not write default values which wasn't present)
  • Write default configuration (schema) to file including comments
  • Read/write from/to stream

Getting started

If you want to use this library, you should first read INI format specification and make sure it fits your needs. It not, feel free to fork this project, improve it and alternatively send us a pull request.

Building

Building of the library itself is described in README in root of project source tree. You can choose if you need dynamic linked library, static linked library or both.

For extra assurance you can also run our unit tests, but there shouldn't be any problem.

Getting know the API

For basic high-level knowledge of library's features, please read Design overview page. Then you should look at our examples, compile, run and understand them. After that, you will have pretty good overview of the API and you should be able to use the library in your own projects. Specific information then can be found in programmer's documentation online.

Including into other projects

Inicpp library is easy to include into other projects. All code is in inicpp namespace, so you won't have any naming issues. All needed header files are located in include/inicpp/ directory in source tree. There is also inicpp.h header, which includes all dependencies, so this is only include you need to use in your sources.

Cmake project

Building inicpp inside other cmake project is super easy. In your CMakeLists.txt file you need to add these files (assume this library sources are located in vendor/inicpp/ directory and your project's name is foo):

include_directories(vendor/inicpp/include)
target_link_libraries(foo inicpp)
add_subdirectory(vendor/inicpp)

Then in your sources you need just to include headers like this and start coding:

#include "inicpp/inicpp.h"

Other

For other projects, build the library as in README and link it with your executable as any other library.