ERBSLAND CONFIG FOR C++

A dependency-free, modern configuration parser for C++20 and newer

Language C++
License Apache 2.0

The Erbsland Configuration Language Parser is the official reference implementation of the Erbsland Configuration Language (ELCL), built for C++20 and newer.
It delivers a secure, lightweight, and dependency-free solution for handling configuration files in your applications.

Integration is straightforward: all you need is a C++20-compliant compiler and the standard library—nothing else.

#include <erbsland/all_conf.hpp>

#include <filesystem>
#include <iostream>
#include <format>

using namespace el::conf;

int main(int argc, char **argv) {
    if (argc < 2) {
        std::cout << "Usage: " << argv[0] << " <config-file>\n";
        return 1;
    }

    const auto configFile = std::filesystem::path{argv[1]};
    try {
        Parser parser;
        const auto source = Source::fromFile(configFile);
        const auto doc = parser.parseOrThrow(source);

        auto width = doc->getIntegerOrThrow(u8"field.width");
        auto height = doc->getIntegerOrThrow(u8"field.height");

        std::cout << std::format("Field width = {}, height = {}\n", width, height);
        return 0;
    } catch (const Error &error) {
        std::cerr << error.toText().toCharString() << "\n";
        return 1;
    }
}

Why Use this Erbsland Configuration Parser?

This parser was built to be more than just another config reader.
It is the official reference implementation of the Erbsland Configuration Language (ELCL), designed with these goals in mind:

  • Minimal dependencies – Requires only C++20 and the standard library.
  • Expressive interface – Reduces boilerplate and keeps integration clean.
  • Security and robustness – Safe, production-ready error handling at its core.
  • Full feature coverage – Implements the entire ELCL specification, including:
    • Core features: names, values, sections
    • Standard features: multiline values, byte counts, lists
    • Advanced features: regular expressions, code blocks, time deltas
  • Reference design – Serves as both a ready-to-use library and a clear guide for implementing other ELCL parsers.

In short: if you want a configuration system that is modern, complete, and built for C++ from the ground up, this parser is made for you.

Ready to Start?

Jump right in and see how easy it is to integrate the parser into your project. The Getting Started Guide walks you through setup, compilation, and your first working example in just a few minutes.

Catch-all Error Handling

Error handling can easily become complex and inconsistent, but this implementation simplifies it by providing a catch-all error handler. It covers:

  • Parsing errors
  • IO errors
  • Runtime errors while interpreting the parsed document

With this approach, you only need one try...catch block around the entire configuration parsing process.

try {
    Parser parser;
    const auto doc = parser.parseOrThrow(Source::fromFile(configFile));
    // ...
    const auto port = doc->getTypeOrThrow<uint16_t>(u8"server.port");
    const auto tags = doc->getListOrThrow<String>(u8"client.tags");
    // ...
    return 0;
} catch (const Error &error) {
    std::cerr << error.toText().toCharString() << "\n";
    return 1;
}

If an operation fails or a value doesn’t match the expected type, the parser generates a clear and user-friendly error message:

TypeMismatch: Expected all values in the list to be of type 'Integer',
but found an element of type 'Float'.
name path = server[0].filter[0].ports[3] at
location = file:/dir/config/example.elcl:6:32

This message provides both semantic context and technical detail:

  • The logical name path shows which configuration key caused the issue.
  • The file path, line, and column pinpoint the exact location in the source document.

This makes errors quick to understand and easy to fix, even in larger configuration files.

Requirements

The parser is designed to be lightweight in setup, requiring only modern C++ and a recent build system.

Code Requirements

  • A C++20 (or newer) compliant compiler
  • A standard library with C++20 support

Build Requirements

  • CMake 3.25 or newer

Test Requirements

  • Python 3.12+ (used for generating metadata during test builds)

That’s all you need to get started—no external libraries or heavy dependencies.

Design Goals

This parser was built with a clear set of design goals in mind:

  • Minimal Dependencies
    Requires only C++20 and the standard library—no third-party libraries.

  • Expressive Interface
    Reduces boilerplate and makes integration straightforward.

  • Security & Robustness
    Strong error handling and predictable behavior in all cases.

  • Full Feature Coverage
    Implements the entire Erbsland Configuration Language (ELCL) specification, from core elements (names, values, sections) to advanced types (regex, code blocks, time deltas).

  • Reference Implementation
    Serves as both a production-ready library and a guide for developers implementing their own ELCL parsers.

These principles ensure the parser is not just functional, but also reliable, maintainable, and future-proof.

Get Started Today

Start using the parser in your own projects right away.
The Getting Started Guide gives you everything you need—from setup to your first working example.

Sources and License

The complete source code of Erbsland Configuration Parser for C++ is available on GitHub. The project is licensed under the Apache License 2.0.

This permissive license allows you to use the library in both open-source and proprietary projects, giving you maximum flexibility in how you integrate it into your software.