GameMessageParser.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. #pragma once
  24. #include "Common/MessageStream.h"
  25. #include "Common/GameMemory.h"
  26. //----------------------------------------------------------------------------
  27. class GameMessageParserArgumentType : public MemoryPoolObject
  28. {
  29. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(GameMessageParserArgumentType, "GameMessageParserArgumentType")
  30. public:
  31. GameMessageParserArgumentType(GameMessageArgumentDataType type, Int argCount);
  32. //virtual ~GameMessageParserArgumentType();
  33. GameMessageParserArgumentType *getNext();
  34. void setNext(GameMessageParserArgumentType *next);
  35. Int getArgCount();
  36. GameMessageArgumentDataType getType();
  37. protected:
  38. GameMessageParserArgumentType* m_next;
  39. GameMessageArgumentDataType m_type;
  40. Int m_argCount;
  41. };
  42. //----------------------------------------------------------------------------
  43. inline GameMessageParserArgumentType * GameMessageParserArgumentType::getNext()
  44. {
  45. return m_next;
  46. }
  47. //----------------------------------------------------------------------------
  48. inline void GameMessageParserArgumentType::setNext(GameMessageParserArgumentType *next)
  49. {
  50. m_next = next;
  51. }
  52. //----------------------------------------------------------------------------
  53. inline GameMessageArgumentDataType GameMessageParserArgumentType::getType()
  54. {
  55. return m_type;
  56. }
  57. //----------------------------------------------------------------------------
  58. inline Int GameMessageParserArgumentType::getArgCount()
  59. {
  60. return m_argCount;
  61. }
  62. //----------------------------------------------------------------------------
  63. //----------------------------------------------------------------------------
  64. //----------------------------------------------------------------------------
  65. class GameMessageParser : public MemoryPoolObject
  66. {
  67. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(GameMessageParser, "GameMessageParser")
  68. public:
  69. GameMessageParser();
  70. GameMessageParser(GameMessage *msg);
  71. //virtual ~GameMessageParser();
  72. GameMessageParserArgumentType *getFirstArgumentType();
  73. void addArgType(GameMessageArgumentDataType type, Int argCount);
  74. Int getNumTypes();
  75. protected:
  76. GameMessageParserArgumentType *m_first, *m_last;
  77. Int m_argTypeCount;
  78. };
  79. //----------------------------------------------------------------------------
  80. inline GameMessageParserArgumentType * GameMessageParser::getFirstArgumentType()
  81. {
  82. return m_first;
  83. }
  84. //----------------------------------------------------------------------------
  85. inline Int GameMessageParser::getNumTypes()
  86. {
  87. return m_argTypeCount;
  88. }