2
0

parse.cpp 528 B

1234567891011121314151617181920212223242526
  1. #include "cpptoml.h"
  2. #include <iostream>
  3. #include <cassert>
  4. int main(int argc, char** argv)
  5. {
  6. if (argc < 2)
  7. {
  8. std::cout << "Usage: " << argv[0] << " filename" << std::endl;
  9. return 1;
  10. }
  11. try
  12. {
  13. std::shared_ptr<cpptoml::table> g = cpptoml::parse_file(argv[1]);
  14. std::cout << (*g) << std::endl;
  15. }
  16. catch (const cpptoml::parse_exception& e)
  17. {
  18. std::cerr << "Failed to parse " << argv[1] << ": " << e.what() << std::endl;
  19. return 1;
  20. }
  21. return 0;
  22. }