summaryrefslogtreecommitdiff
path: root/utils/tfstats/logevent.h
blob: 02fb18749a15008486326ed977426379635687de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:  Interface of CLogEvent
//
// $Workfile:     $
// $Date:         $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#ifndef LOGEVENT_H
#define LOGEVENT_H
#ifdef WIN32
#pragma once
#endif
#pragma warning(disable :4786)


#include "Argument.h"

#ifdef WIN32
//#include <strstrea.h>
#else
//#include <strstream.h>
#endif
#include <time.h>
//#include <iostream.h>

#include <stdio.h>



//------------------------------------------------------------------------------------------------------
// Purpose: CLogEvent represents an event in the log file.  e.g. one line.
// It can have one of several types (enumerated below) and a list of arguments
// is attached as well.
//------------------------------------------------------------------------------------------------------
class CLogEvent
{
public:
	enum Type
	{
		NOTYPE =0,
		INVALID = 0,
		LOG_FILE_INIT,
		SERVER_SPAWN,
		SERVER_SHUTDOWN,
		LOG_CLOSED,
		SERVER_MISC,
		SERVER_NAME,
		TEAM_RENAME,
		LEVEL_CHANGE,
		CVAR_ASSIGN,
		MAP_CRC,
		TEAM_JOIN,
		CONNECT,
		ENTER_GAME,
		DISCONNECT,
		NAME_CHANGE,
		FRAG,
		TEAM_FRAG,
		SUICIDE,
		KILLED_BY_WORLD,
		BUILD,
		MATCH_RESULTS_MARKER,
		MATCH_DRAW,
		MATCH_VICTOR,
		MATCH_TEAM_RESULTS,
		SAY,
		SAY_TEAM,
		CURE,
		NAMED_GOAL_ACTIVATE,
		ANON_GOAL_ACTIVATE,
		NAMED_BROADCAST,
		ANON_BROADCAST,
		CLASS_CHANGE,
		NUM_TYPES
	};
	
	char* m_StrippedText;	
private:
	ArgVector m_args;

	char m_EventCode;
	
	time_t m_EventTime;
	
	bool m_Valid;
	char* m_EventMessage;
	Type m_EventType;


	bool keywordsOccur(char* s1,char* s2=NULL,char* s3=NULL);
	void parseArgs();
//	void readEventTime(istream& is);
//	void readEventCode(istream& is);
//	void readEventMessage(istream& is);
	void parseArgument(const char*& raw); //ref to pointer to constant char, gotta love it.
	void determineType();

public:
	CLogEvent* m_Next;

	CLogEvent();
	~CLogEvent();
	bool isValid(){return m_Valid;}
	
//	explicit CLogEvent(istream& is);
//	virtual void readEvent(istream& is);
//	virtual void print(ostream& os);
	
	
	

	CLogEvent::Type getType() const {return m_EventType;}
	time_t getTime() const {return m_EventTime;}
	const CLogEventArgument* getArgument(int i) const;

	const char* getFullMessage() const {return m_EventMessage;}




	static const char* TypeNames[];	

	
	//unused stuff 
protected:	
	void readEventTime(FILE* f);
	void readEventCode(FILE* f);
	void readEventMessage(FILE* f);

public:
	explicit CLogEvent(FILE* f);
	virtual void readEvent(FILE* f);
	virtual void print(FILE* f=stdout);
	
};



#endif // LOGEVENT_H