Skip to content

snoury/yconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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...

About

YAML configuration wrapper for C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published