Skip to content

OliverEvans96/cpp-libyaml-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Maps from YAML

  • Uses libyaml instead of yaml-cpp for the sake of C++98 compliance. I'm stuck with a compiler that doesn't support C++11.
  • Creates a C++ map of vectors of strings out of the contents of the YAML file.
  • Uses libyaml's document-based parsing syntax.
  • Does not support nested YAML mappings. This is intended only for very simple YAML files.
  • Mapping keys are stored as vectors whether they are written as sequences or scalars in the YAML.
  • Since all values are strings, they must be manually converted to the correct types.

e.g.

Input YAML (yaml.config)

opt1: true
opt2: false
atoms: [4,3,5]
num: 3.5 
name: "myname"

Output map in C++

atoms: ["4", "3", "5", ]
name: ["myname", ]
num: ["3.5", ]
opt1: ["true", ]
opt2: ["false", ]

You'll probably need to modify the Makefile to point to the PREFIX where libyaml is installed.

Based on advice from:

About

Simple YAML parser example for C++98 using libyaml

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published