NYAML


Interchange formats are many, JSON, BSON, XML, YAML and it goes on. A lot of these formats are very much at home in certain languages and/or task. YAML is very comfortable in Ruby, but to get it into C++ requires a fairly hefty library for what it is. XML parsers are easier to get into C++ but XML lacks the readability of YAML.

I don’t need yaml for what I need in C++, I really just need (want?) a better .INI file for config type things.

NYAML (Not YAML!)

Taking the main syntax style of YAML, but dropping a lot of the specs, we can strip yaml right back to a key value tree.

window:
  width: 800
  height: 600
  title: window title
  fullscreen: false

This is nice and readable, no special syntax highlighting required, and we can boil this straight down to a C++ lookup.

set_title(node["title"].get_value());

Final

I’ve wrapped this up as a single header library that can be found on github here. This isn’t meant to be a fully fledge interchange format, its just meant to have a yaml like key/value config file.

Related Posts

Life Without STL

Constraints for the hell of it.

The Component Entity Pattern

Organizing code.

Quick SDL2 Context

SDL2 context in 30 seconds on a Mac.

Simplistic Variant

Simple C++ union solution.

Draw Text In One Draw Call

One technique at batching text.

Wrapping OpenGL

Object Orientated OpenGL.

Prototypes

Some little prototypes I made.

Mega Textures

Texturing the MEGA

Working With Maps

7 months in maps.

Caffeine Math

Small hobby math engine.