sector_parser.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SuperTux
  2. // Copyright (C) 2015 Ingo Ruhnke <grumbel@gmail.com>
  3. // 2023 Vankata453
  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. #ifndef HEADER_SUPERTUX_SUPERTUX_SECTOR_PARSER_HPP
  18. #define HEADER_SUPERTUX_SUPERTUX_SECTOR_PARSER_HPP
  19. #include <memory>
  20. #include <string>
  21. class GameObject;
  22. class Level;
  23. class ReaderMapping;
  24. class Sector;
  25. namespace Base {
  26. class Sector;
  27. }
  28. class SectorParser
  29. {
  30. public:
  31. static std::unique_ptr<Sector> from_reader(Level& level, const ReaderMapping& sector, bool editable);
  32. static std::unique_ptr<Sector> from_reader_old_format(Level& level, const ReaderMapping& sector, bool editable);
  33. static std::unique_ptr<Sector> from_nothing(Level& level);
  34. protected:
  35. SectorParser(Base::Sector& sector, bool editable);
  36. virtual ~SectorParser() {}
  37. void parse_old_format(const ReaderMapping& reader);
  38. void parse(const ReaderMapping& reader);
  39. void create_sector();
  40. std::unique_ptr<GameObject> parse_object(const std::string& name, const ReaderMapping& reader);
  41. /** Allows setting additional rules for parsing objects.
  42. Return value indicates whether the regular object parsing process should be skipped. **/
  43. virtual bool parse_object_additional(const std::string& name, const ReaderMapping& reader);
  44. protected:
  45. Base::Sector& m_sector;
  46. bool m_editable;
  47. private:
  48. SectorParser(const SectorParser&) = delete;
  49. SectorParser& operator=(const SectorParser&) = delete;
  50. };
  51. #endif
  52. /* EOF */