Skip to content

C++ parser library for an INI-inspired configuration syntax

License

Notifications You must be signed in to change notification settings

wolmibo/iconfigp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iconfigp

C++ parser library for an INI-inspired configuration syntax with verbose error messages.

Example

#include <iconfigp/parser.hpp>
#include <iconfigp/value-parser.hpp>

#include <cassert>

static constexpr std::string_view config = R"(
# This is a comment

global-option = true

[section]
key = value
)";



int main() {
  auto root = iconfigp::parser::parse(config);

  assert(iconfigp::parse<bool>(root.unique_key("global-option")).value() == true);

  if (auto sec = root.subsection("section")) {
    assert(sec->unique_key("key"));
    assert(sec->unique_key("key")->value() == "value");
  } else {
    throw std::runtime_error{"config has no [section]!"};
  }
}

About

C++ parser library for an INI-inspired configuration syntax

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published