C++ library for parsing and writing YAML 1.2 configuration files
C++ YAML parser and emitter for YAML 1.2 spec
$ // Include yaml-cpp header
#include <yaml-cpp/yaml.h>
NYAML::Node config = YAML::LoadFile("config.yaml");$ // Access YAML node values
std::string name = config["name"].as<std::string>();
int port = config["port"].as<int>();$ // Create and emit YAML
NYAML::Node output;
output["key"] = "value";
std::ofstream fout("output.yaml");
fout << output;$ // Deserialize YAML into custom struct
struct Config { std::string host; int port; };
Config cfg = config.as<Config>();$ # In CMakeLists.txt
find_package(yaml-cpp REQUIRED)
target_link_libraries(myapp yaml-cpp)