Guest User

Untitled

a guest
Jan 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. sensors:
  2. - id: 5
  3. hardwareId: 28-000005a32133
  4. type: 1
  5. - id: 6
  6. hardwareId: 28-000005a32132
  7. type: 4
  8.  
  9. YAML::Node config = YAML::LoadFile(config_path);
  10. const YAML::Node& node_test1 = confg["sensors"];
  11.  
  12. for (std::size_t i = 0; i < node_test1.size(); i++) {
  13. const YAML::Node& node_test2 = node_test1[i];
  14. std::cout << "Id: " << node_test2["id"].as<std::string>() << std::endl;
  15. std::cout << "hardwareId: " << node_test2["hardwareId"].as<std::string>() << std::endl << std::endl;
  16. }
  17.  
  18. YAML::Node config = YAML::LoadFile(config_path);
  19. const YAML::Node& sensors = config["sensors"];
  20. for (YAML::iterator it = sensors.begin(); it != sensors.end(); ++it) {
  21. const YAML::Node& sensor = *it;
  22. std::cout << "Id: " << sensor["id"].as<std::string>() << "n";
  23. std::cout << "hardwareId: " << sensor["hardwareId"].as<std::string>() << "nn";
  24. }
  25.  
  26. YAML::Node config = YAML::LoadFile(config_path);
  27. const YAML::Node& sensors = config["sensors"];
  28. for (YAML::const_iterator it = sensors.begin(); it != sensors.end(); ++it) {
  29. const YAML::Node& sensor = *it;
  30. std::cout << "Id: " << sensor["id"].as<std::string>() << "n";
  31. std::cout << "hardwareId: " << sensor["hardwareId"].as<std::string>() << "nn";
  32. }
Add Comment
Please, Sign In to add comment