Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
4.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #if !defined( CLASS_H )
  8. #define CLASS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. class CTypeDescriptionField
  13. {
  14. public:
  15. CTypeDescriptionField()
  16. {
  17. m_szVariableName[ 0 ] = 0;
  18. m_szType[ 0 ] = 0;
  19. m_szDefineType[ 0 ] = 0;
  20. m_bCommentedOut = false;
  21. m_bRepresentedInRecvTable = false;
  22. }
  23. char m_szVariableName[ 128 ];
  24. char m_szType[ 128 ];
  25. char m_szDefineType[ 128 ];
  26. bool m_bCommentedOut;
  27. bool m_bRepresentedInRecvTable;
  28. };
  29. class CClassVariable
  30. {
  31. public:
  32. CClassVariable()
  33. {
  34. m_szName[ 0 ] = 0;
  35. m_szType[ 0 ] = 0;
  36. m_Type = TPUBLIC;
  37. m_bKnownType = false;
  38. m_nTypeSize = 0;
  39. m_bIsArray = false;
  40. m_szArraySize[ 0 ] = 0;
  41. m_bInRecvTable = false;
  42. m_TypeSize = 0;
  43. }
  44. typedef enum
  45. {
  46. TPUBLIC = 0,
  47. TPROTECTED,
  48. TPRIVATE
  49. } VARTYPE;
  50. char m_szName[ 128 ];
  51. char m_szType[ 128 ];
  52. VARTYPE m_Type;
  53. bool m_bKnownType;
  54. int m_nTypeSize;
  55. bool m_bIsArray;
  56. char m_szArraySize[ 128 ];
  57. bool m_bInRecvTable;
  58. int m_TypeSize;
  59. };
  60. class CClassMemberFunction
  61. {
  62. public:
  63. typedef enum
  64. {
  65. TPUBLIC = 0,
  66. TPROTECTED,
  67. TPRIVATE
  68. } MEMBERTYPE;
  69. char m_szName[ 128 ];
  70. // Return type
  71. char m_szType[ 128 ];
  72. MEMBERTYPE m_Type;
  73. };
  74. class CClassTypedef
  75. {
  76. public:
  77. char m_szTypeName[ 128 ];
  78. char m_szAlias[ 128 ];
  79. // bool m_bIsTypedefForBaseClass;
  80. };
  81. class CClass
  82. {
  83. public:
  84. enum
  85. {
  86. MAX_VARIABLES = 1024,
  87. MAX_MEMBERS = 1024,
  88. MAX_TDFIELDS = 1024,
  89. };
  90. CClass( const char *name );
  91. ~CClass( void );
  92. char *ParseClassDeclaration( char *input );
  93. void SetBaseClass( const char *name );
  94. void CheckChildOfBaseEntity( const char *baseentityclass );
  95. bool CheckForMissingTypeDescriptionFields( int& missingcount, bool createtds = false );
  96. bool CheckForMissingPredictionFields( int& missingcount, bool createtds = false );
  97. bool CheckForPredictionFieldsInRecvTableNotMarkedAsSuchCorrectly( int& missingcount );
  98. void AddVariable( int protection, char *type, char *name, bool array, char *arraysize = 0 );
  99. // Parsing helper methods
  100. bool ParseProtection( char *&input, int &protection );
  101. bool ParseNestedClass( char *&input );
  102. bool ParseBaseClass( char *&input );
  103. bool ParseClassMember( char *&input, int protection );
  104. bool ParseNetworkVar( char *&input, int protection );
  105. void ReportTypeMismatches( CClassVariable *var, CTypeDescriptionField *td );
  106. void CheckForHungarianErrors( int& warnings );
  107. char m_szName[ 128 ];
  108. char m_szBaseClass[ 128 ];
  109. char m_szTypedefBaseClass[ 128 ];
  110. CClassVariable *FindVar( const char *name, bool checkbaseclasses = false );
  111. CClassVariable *AddVar( const char *name );
  112. int m_nVarCount;
  113. CClassVariable *m_Variables[ MAX_VARIABLES ];
  114. CClassMemberFunction *FindMember( const char *name );
  115. CClassMemberFunction *AddMember( const char *name );
  116. int m_nMemberCount;
  117. CClassMemberFunction *m_Members[ MAX_MEMBERS ];
  118. CTypeDescriptionField *FindTD( const char *name );
  119. CTypeDescriptionField *AddTD( const char *name, const char *type, const char *definetype, bool incomments );
  120. int m_nTDCount;
  121. CTypeDescriptionField *m_TDFields[ MAX_TDFIELDS ];
  122. CTypeDescriptionField *FindPredTD( const char *name );
  123. CTypeDescriptionField *AddPredTD( const char *name, const char *type, const char *definetype, bool incomments, bool inrecvtable );
  124. int m_nPredTDCount;
  125. CTypeDescriptionField *m_PredTDFields[ MAX_TDFIELDS ];
  126. CClass *m_pBaseClass;
  127. CClass *m_pNext;
  128. bool m_bDerivedFromCBaseEntity;
  129. bool m_bHasSaveRestoreData;
  130. bool m_bHasPredictionData;
  131. bool m_bHasRecvTableData;
  132. bool m_bConstructPredictableCalled;
  133. int m_nClassDataSize;
  134. private:
  135. struct MemberVarParse_t
  136. {
  137. char m_pType[256];
  138. char m_pTypeModifier[256];
  139. char m_pName[256];
  140. char m_pArraySize[ 128 ];
  141. bool m_bArray;
  142. MemberVarParse_t() { Reset(); }
  143. void Reset()
  144. {
  145. m_pType[0] = 0;
  146. m_pTypeModifier[0] = 0;
  147. m_pName[0] = 0;
  148. m_pArraySize[0] = 0;
  149. m_bArray = false;
  150. }
  151. };
  152. };
  153. #endif // CLASS_H