Single header YAML C++ >= 11 sax/dom reader.
scalar: hello world
list:
- "foo bar"
- boolean: true
integer: 123
floating point: 2.75Error checking is omitted, see examples/quickstart_full.cpp for a real use case example.
#include "yaml/yaml.hpp"
auto result = yaml::dom::read_document_from_file<char>("file.yml");
if(!result) {
return print_result(result);
}
auto& root = result.root_node;
std::cout << root["scalar"].as<std::string>() << "\n";
std::cout << root["list"][0].as<std::string>() << "\n";
std::cout << root["list"][1]["boolean"].as<bool>() << "\n";
std::cout << root["list"][1]["integer"].as<int>() << "\n";
std::cout << root["list"][1]["floating point"].as<float>() << "\n";
hello world
foo bar
true
123
2.75
Place /yaml in your project's include directory and simply #include "yaml/yaml.hpp".
git clone https://github.com/jimmiebergmann/mini-yaml.git
Builds pass if all tests are successful and no memory leaks are found.
| Branch | Linux | Windows | Fuzzing |
|---|---|---|---|
| master | |||
| dev |
✅ Supported
| Feature | Support | Note |
|---|---|---|
| sax reader | ✅ | |
| dom reader | ✅ | |
| dom_view reader | ❌ | |
| dom writer | ❌ | |
| unicode | No escape character support. | |
| scalars | ✅ | |
| block scalars | ✅ | |
| flow scalars | ✅ | |
| maps | ✅ | |
| ordered maps | Supported, but no ordered map container is included. | |
| flow maps | ❌ | |
| sequences | ✅ | |
| flow sequences | ❌ | |
| scalar type conversions | ✅ | |
| tags | ✅ | |
| indentation indicator | ❌ | |
| sets | ❌ | |
| anchors | ❌ | |
| complex keys | ❌ | |
| reader result printing | ❌ |
One does not simply write a yaml parser from scratch.