The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

46 lines
1.2 KiB

2 months ago
  1. #include <fstream>
  2. #include <iostream>
  3. #include <vector>
  4. #include "yaml-cpp/eventhandler.h"
  5. #include "yaml-cpp/yaml.h" // IWYU pragma: keep
  6. class NullEventHandler : public YAML::EventHandler {
  7. public:
  8. void OnDocumentStart(const YAML::Mark&) override {}
  9. void OnDocumentEnd() override {}
  10. void OnNull(const YAML::Mark&, YAML::anchor_t) override {}
  11. void OnAlias(const YAML::Mark&, YAML::anchor_t) override {}
  12. void OnScalar(const YAML::Mark&, const std::string&, YAML::anchor_t,
  13. const std::string&) override {}
  14. void OnSequenceStart(const YAML::Mark&, const std::string&, YAML::anchor_t,
  15. YAML::EmitterStyle::value) override {}
  16. void OnSequenceEnd() override {}
  17. void OnMapStart(const YAML::Mark&, const std::string&, YAML::anchor_t,
  18. YAML::EmitterStyle::value) override {}
  19. void OnMapEnd() override {}
  20. };
  21. void parse(std::istream& input) {
  22. try {
  23. YAML::Node doc = YAML::Load(input);
  24. std::cout << doc << "\n";
  25. } catch (const YAML::Exception& e) {
  26. std::cerr << e.what() << "\n";
  27. }
  28. }
  29. int main(int argc, char** argv) {
  30. if (argc > 1) {
  31. std::ifstream fin;
  32. fin.open(argv[1]);
  33. parse(fin);
  34. } else {
  35. parse(std::cin);
  36. }
  37. return 0;
  38. }