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.

144 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Interface of CLogEvent
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef LOGEVENT_H
  14. #define LOGEVENT_H
  15. #ifdef WIN32
  16. #pragma once
  17. #endif
  18. #pragma warning(disable :4786)
  19. #include "Argument.h"
  20. #ifdef WIN32
  21. //#include <strstrea.h>
  22. #else
  23. //#include <strstream.h>
  24. #endif
  25. #include <time.h>
  26. //#include <iostream.h>
  27. #include <stdio.h>
  28. //------------------------------------------------------------------------------------------------------
  29. // Purpose: CLogEvent represents an event in the log file. e.g. one line.
  30. // It can have one of several types (enumerated below) and a list of arguments
  31. // is attached as well.
  32. //------------------------------------------------------------------------------------------------------
  33. class CLogEvent
  34. {
  35. public:
  36. enum Type
  37. {
  38. NOTYPE =0,
  39. INVALID = 0,
  40. LOG_FILE_INIT,
  41. SERVER_SPAWN,
  42. SERVER_SHUTDOWN,
  43. LOG_CLOSED,
  44. SERVER_MISC,
  45. SERVER_NAME,
  46. TEAM_RENAME,
  47. LEVEL_CHANGE,
  48. CVAR_ASSIGN,
  49. MAP_CRC,
  50. TEAM_JOIN,
  51. CONNECT,
  52. ENTER_GAME,
  53. DISCONNECT,
  54. NAME_CHANGE,
  55. FRAG,
  56. TEAM_FRAG,
  57. SUICIDE,
  58. KILLED_BY_WORLD,
  59. BUILD,
  60. MATCH_RESULTS_MARKER,
  61. MATCH_DRAW,
  62. MATCH_VICTOR,
  63. MATCH_TEAM_RESULTS,
  64. SAY,
  65. SAY_TEAM,
  66. CURE,
  67. NAMED_GOAL_ACTIVATE,
  68. ANON_GOAL_ACTIVATE,
  69. NAMED_BROADCAST,
  70. ANON_BROADCAST,
  71. CLASS_CHANGE,
  72. NUM_TYPES
  73. };
  74. char* m_StrippedText;
  75. private:
  76. ArgVector m_args;
  77. char m_EventCode;
  78. time_t m_EventTime;
  79. bool m_Valid;
  80. char* m_EventMessage;
  81. Type m_EventType;
  82. bool keywordsOccur(char* s1,char* s2=NULL,char* s3=NULL);
  83. void parseArgs();
  84. // void readEventTime(istream& is);
  85. // void readEventCode(istream& is);
  86. // void readEventMessage(istream& is);
  87. void parseArgument(const char*& raw); //ref to pointer to constant char, gotta love it.
  88. void determineType();
  89. public:
  90. CLogEvent* m_Next;
  91. CLogEvent();
  92. ~CLogEvent();
  93. bool isValid(){return m_Valid;}
  94. // explicit CLogEvent(istream& is);
  95. // virtual void readEvent(istream& is);
  96. // virtual void print(ostream& os);
  97. CLogEvent::Type getType() const {return m_EventType;}
  98. time_t getTime() const {return m_EventTime;}
  99. const CLogEventArgument* getArgument(int i) const;
  100. const char* getFullMessage() const {return m_EventMessage;}
  101. static const char* TypeNames[];
  102. //unused stuff
  103. protected:
  104. void readEventTime(FILE* f);
  105. void readEventCode(FILE* f);
  106. void readEventMessage(FILE* f);
  107. public:
  108. explicit CLogEvent(FILE* f);
  109. virtual void readEvent(FILE* f);
  110. virtual void print(FILE* f=stdout);
  111. };
  112. #endif // LOGEVENT_H