INI#

A simple INI parser and emitter.

Info

To use declarations from this page, include the <essence/ini.hpp> header.

class ini::exception : public std::exception#

Exception type for INI parsing.

class ini::field#

Represents a single key-value pair.

std::string key#

The key part of the key-value pair.

std::string value#

The value part of the key-value pair.

field::field(std::string k, std::string v)#

Default constructor, accepting two strings.

field::field(std::pair<std::string, std::string>)#

Alternative constructor, accepting a std::pair of strings.

std::string field::string() const#

Get a string representation of the field.

std::string field::pretty() const#

Get a colorized string representation of the field.

template<typename T>                requires anyof<T, i64, f64, bool, null>
std::optional<T> as()#

Attempt to parse the field’s value as T.

class ini::section : public std::vector<ini::field>#

Represents a named list of key-value pairs.

std::string name#

The section’s name.

section::section(std::string pname)#

Default constructor, accepting the section name as a string.

std::string string() const#

Get a string representation of the section.

std::string pretty() const#

Get a colorized string representation of the section.

class ini::document : public std::vector<ini::section>#

Represents the entirety of an INI file.

ini::section top = ini::section("__TOP_LEVEL__")#

The outer, pseudo-unnamed section of the INI file.

ini::section &operator[](std::string_view name)#

Get a section by name.

std::string string() const#

Get a string representation of the document.

std::string pretty() const#

Get a colorized string representation of the document.

class ini::parser#

A proxy object for parsing an input file.

ini::document parse(const fs::path &path)#

Parse the file at path

ini::document parse(std::istream &is)#

Parse input from stream is.

class ini::writer#

A proxy object for emitting INI documents.

writer::writer(const document &doc)#
ini::writer &write(const fs::path &path)#

Write the INI document to file path.

ini::writer &write(std::ostream &os)#

Write the INI document to stream os.