How can I read this YAML file with yaml-cpp:
sensors:
- id: 5
hardwareId: 28-000005a32133
type: 1
- id: 6
hardwareId: 28-000005a32132
typ
It looks like your code works, but if you want to rewrite it with iterators, you can:
YAML::Node config = YAML::LoadFile(config_path);
const YAML::Node& sensors = config["sensors"];
for (YAML::iterator it = sensors.begin(); it != sensors.end(); ++it) {
const YAML::Node& sensor = *it;
std::cout << "Id: " << sensor["id"].as<std::string>() << "\n";
std::cout << "hardwareId: " << sensor["hardwareId"].as<std::string>() << "\n\n";
}