QGearsRSDFileSerializer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears 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. #pragma once
  16. #include "QGearsRSDFile.h"
  17. #include "QGearsSerializer.h"
  18. #include "common/TypeDefine.h"
  19. namespace QGears{
  20. /**
  21. * Handles the serialization of RDS files.
  22. */
  23. class RSDFileSerializer : public Serializer{
  24. public:
  25. /**
  26. * Constructor.
  27. */
  28. RSDFileSerializer();
  29. /**
  30. * Destructor.
  31. */
  32. virtual ~RSDFileSerializer();
  33. /**
  34. * Imports a RSD file.
  35. *
  36. * @param stream[in] The contents of the RSD file.
  37. * @param dest[out] The formed RSD file.
  38. */
  39. virtual void ImportRSDFile(
  40. Ogre::DataStreamPtr &stream, RSDFile* dest
  41. );
  42. protected:
  43. /**
  44. * Reads a file header and sets the instance data.
  45. *
  46. * @param stream[in] The contents of the RSD file.
  47. */
  48. virtual void ReadFileHeader(Ogre::DataStreamPtr &stream);
  49. /**
  50. * Parses a line of the RSD file.
  51. *
  52. * @param line[in] The line to parse.
  53. */
  54. virtual void ParseLine(const String &line, RSDFile* dest);
  55. /**
  56. * The file header tag.
  57. */
  58. static const String TAG_HEADER;
  59. /**
  60. * The polygon tag.
  61. */
  62. static const String TAG_POLYGON;
  63. /**
  64. * The material tag.
  65. */
  66. static const String TAG_MATERIAL;
  67. /**
  68. * The group tag.
  69. */
  70. static const String TAG_GROUP;
  71. /**
  72. * The texture count tag.
  73. */
  74. static const String TAG_TEXTURE_COUNT;
  75. /**
  76. * The texture name tag.
  77. */
  78. static const String TAG_TEXTURE_NAME;
  79. /**
  80. * Delimiter for line parsing.
  81. */
  82. static const String PARSE_DELIMITER;
  83. private:
  84. /**
  85. * Indicates if the file has a texture count.
  86. */
  87. bool has_texture_count_;
  88. /**
  89. * The texture count (if any).
  90. */
  91. size_t texture_count_;
  92. };
  93. }