main.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * main.cpp - console tool main
  3. * Copyright (C) 2017 caryoscelus
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <iostream>
  19. #include <fstream>
  20. #include <fmt/ostream.h>
  21. #include <core/document.h>
  22. #include <core/filters/svg_path_reader.h>
  23. #include <core/renderers/svg_renderer.h>
  24. void render_file(std::string const& fname) {
  25. auto reader = core::filters::SvgPathReader();
  26. std::ifstream in(fname);
  27. std::shared_ptr<core::Document> document = reader.read_document(in);
  28. in.close();
  29. auto renderer = core::renderers::SvgRenderer();
  30. renderer.render(*document->get_default_context());
  31. }
  32. int main(int argc, char** argv) {
  33. std::string fname;
  34. if (argc < 2) {
  35. fmt::print(std::cerr, "Usage: {} [<file-name>]\n", argv[0]);
  36. return 1;
  37. } else {
  38. fname = argv[1];
  39. }
  40. render_file(fname);
  41. return 0;
  42. }