Garmin Fleet Management Controller  2.19.0
LogParser.h
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * HEADER NAME:
4 * LogParser.h
5 *
6 * Copyright 2008-2009 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #ifndef LogParser_H
11 #define LogParser_H
12 
13 #include "stdafx.h"
14 #include <string>
15 #include <map>
16 #include "garmin_types.h"
17 
18 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 class LogParser
24 {
25 public:
26  LogParser();
27  virtual ~LogParser();
28 
29  void init
30  (
31  const CString& aFilename
32  );
33 
34  CString getFilename();
35 
38  virtual void resendPacket
39  (
40  int aLineNumber
41  ) = 0;
42 
45  virtual CString getPacketDetail
46  (
47  int aLineNumber
48  ) = 0;
49 
52  virtual CString getPacketTitle
53  (
54  int aLineNumber
55  ) = 0;
56 
57  BOOL readLog();
58  void reset();
59 
60  int getLineCount() const;
61  void setRenderWidth
62  (
63  int aWidth
64  );
65 
66 protected:
67  CString formatMultiLineHex
68  (
69  int aSize,
70  uint8 * aData
71  );
72 
74  CString mLogFilename;
75 
78 
81 
84 
87 
89  BOOL mIsMorning;
90 
92  std::streamoff mParseEndOffset;
93 
95  std::map<int, std::streamoff> mLineOffset;
96 
99 
102 };
103 
104 #endif
CString formatMultiLineHex(int aSize, uint8 *aData)
Format bytes into a multi logLine hex dump format.
Definition: LogParser.cpp:165
int mLogStartMillis
Milliseconds of the time when the log file was created (from log header)
Definition: LogParser.h:86
int mRenderWidth
Available width in pixels to render the packet detail.
Definition: LogParser.h:101
Abstract base class for log item parsers.
Definition: LogParser.h:23
virtual void resendPacket(int aLineNumber)=0
Resend the packet at this line number.
int mLogStartSec
Seconds of the time when the log file was created (from log header)
Definition: LogParser.h:83
LogParser()
Constructor.
Definition: LogParser.cpp:23
BOOL mIsMorning
If TRUE, the log was started in the mIsMorning (computed from log header)
Definition: LogParser.h:89
virtual CString getPacketDetail(int aLineNumber)=0
Return the packet detail as a formatted string.
void reset()
Reset the log parser to initial state.
Definition: LogParser.cpp:130
virtual CString getPacketTitle(int aLineNumber)=0
Return the packet title as a formatted string.
BOOL readLog()
Reads from the log file starting from the end of the last read position and adds it to the display...
Definition: LogParser.cpp:44
void setRenderWidth(int aWidth)
Set the number of pixels available for rendering text.
Definition: LogParser.cpp:151
int mLogStartHr
Hour of the time when the log file was created (from log header)
Definition: LogParser.h:77
int getLineCount() const
Return the number of lines parsed so far.
Definition: LogParser.cpp:141
std::streamoff mParseEndOffset
Offset of the log file where parsing stopped.
Definition: LogParser.h:92
unsigned char uint8
8-bit unsigned integer
Definition: garmin_types.h:62
int mLineCount
Number of lines that have been parsed so far.
Definition: LogParser.h:98
CString getFilename()
Get the path of the log file being parsed.
Definition: LogParser.cpp:204
CString mLogFilename
File name of the currently open log file.
Definition: LogParser.h:74
std::map< int, std::streamoff > mLineOffset
Map of log items to the offset in the log file where the text line starts.
Definition: LogParser.h:95
void init(const CString &aFilename)
Initialize the LogParser to read a particular file.
Definition: LogParser.cpp:193
virtual ~LogParser()
Destructor.
Definition: LogParser.cpp:31
int mLogStartMin
Minutes of the time when the log file was created (from log header)
Definition: LogParser.h:80