Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

YAML configuration wrapper for C++

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 include
Octocat-spinner-32 src
Octocat-spinner-32 tests
Octocat-spinner-32 CMakeLists.txt
Octocat-spinner-32 FindYamlCpp.cmake
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
README.md

yconfig

A simple YAML configuration wrapper for C++.

yconfig is a configuration wrapper built around the yaml-cpp library and is distributed under the MIT license.
It is a companion project to the chapter "YAML for C++: Applied Data-Driven Design" of the book Game Development Tools.

Building yconfig

yconfig requires CMake and the yaml-cpp library (auto-detected by CMake) to be built.

$ cd yconfig
$ mkdir build
$ cd build
$ cmake ..
$ make

You should now have the yconfig headers and library files, directly integrable into your C++ project.
To run the test examples described in the book chapter, you can type the following:

$ cd ..
$ build/configtest

Using yconfig

#include "Config.h"

std::ifstream file("configfile.yaml");
Config cfg(file); // throws an exception if the stream is unreadable

unsigned int width = cfg["screen/width"];
unsigned int width = cfg["screen/height"];
// use width and height to initialize the screen...

std::vector<Player> players = cfg["players"];
// iterate over the players list here...
Something went wrong with that request. Please try again.