nbt_visitor.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * libnbt++ - A library for the Minecraft Named Binary Tag format.
  3. * Copyright (C) 2013, 2015 ljfa-ag
  4. *
  5. * This file is part of libnbt++.
  6. *
  7. * libnbt++ is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * libnbt++ is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with libnbt++. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef NBT_VISITOR_H_INCLUDED
  21. #define NBT_VISITOR_H_INCLUDED
  22. #include "tagfwd.h"
  23. namespace nbt
  24. {
  25. /**
  26. * @brief Base class for visitors of tags
  27. *
  28. * Implementing the Visitor pattern
  29. */
  30. class nbt_visitor
  31. {
  32. public:
  33. virtual ~nbt_visitor() noexcept = 0; //Abstract class
  34. virtual void visit(tag_byte&) {}
  35. virtual void visit(tag_short&) {}
  36. virtual void visit(tag_int&) {}
  37. virtual void visit(tag_long&) {}
  38. virtual void visit(tag_float&) {}
  39. virtual void visit(tag_double&) {}
  40. virtual void visit(tag_byte_array&) {}
  41. virtual void visit(tag_string&) {}
  42. virtual void visit(tag_list&) {}
  43. virtual void visit(tag_compound&) {}
  44. virtual void visit(tag_int_array&) {}
  45. virtual void visit(tag_long_array&) {}
  46. };
  47. /**
  48. * @brief Base class for visitors of constant tags
  49. *
  50. * Implementing the Visitor pattern
  51. */
  52. class const_nbt_visitor
  53. {
  54. public:
  55. virtual ~const_nbt_visitor() noexcept = 0; //Abstract class
  56. virtual void visit(const tag_byte&) {}
  57. virtual void visit(const tag_short&) {}
  58. virtual void visit(const tag_int&) {}
  59. virtual void visit(const tag_long&) {}
  60. virtual void visit(const tag_float&) {}
  61. virtual void visit(const tag_double&) {}
  62. virtual void visit(const tag_byte_array&) {}
  63. virtual void visit(const tag_string&) {}
  64. virtual void visit(const tag_list&) {}
  65. virtual void visit(const tag_compound&) {}
  66. virtual void visit(const tag_int_array&) {}
  67. virtual void visit(const tag_long_array&) {}
  68. };
  69. inline nbt_visitor::~nbt_visitor() noexcept {}
  70. inline const_nbt_visitor::~const_nbt_visitor() noexcept {}
  71. }
  72. #endif // NBT_VISITOR_H_INCLUDED