48 int filenameLength = WideCharToMultiByte( CP_ACP, 0, mLogFilename, -1, NULL, 0, NULL, NULL );
49 char *filenameAnsi =
new char[filenameLength];
50 WideCharToMultiByte( CP_ACP, 0, mLogFilename, -1, filenameAnsi, filenameLength, NULL, NULL );
51 ifstream logFile( filenameAnsi, ios_base::in );
52 delete[] filenameAnsi;
57 std::string logLineString;
58 logFile.seekg( mParseEndOffset, ios_base::beg );
59 if( mParseEndOffset == 0 )
64 memset( timeString, 0,
sizeof( timeString ) );
65 getline( logFile, logLineString );
66 logLine = logLineString.c_str();
67 strncpy( timeString, logLine,
cnt_of_array( timeString ) - 1 );
68 mParseEndOffset = logFile.tellg();
71 number = strtok_s( timeString,
",", &context );
72 if( number != NULL ) mLogStartHr = atoi( number );
74 number = strtok_s( NULL,
",", &context );
75 if( number != NULL ) mLogStartMin = atoi( number );
77 number = strtok_s( NULL,
",", &context );
78 if( number != NULL ) mLogStartSec = atoi( number );
80 number = strtok_s( NULL,
",", &context );
81 if( number != NULL ) mLogStartMillis = atoi( number );
83 if( mLogStartHr < 12 )
86 if( mLogStartHr == 0 )
94 if( mLogStartHr != 12 )
102 while( !logFile.eof() )
104 std::streamoff packetStartOffset;
106 packetStartOffset = logFile.tellg();
107 getline( logFile, logLineString );
108 logLine = logLineString.c_str();
109 mParseEndOffset = logFile.tellg();
110 if( logLine[0] !=
'\0' && mParseEndOffset != -1 )
113 mLineOffset[ mLineCount ] = packetStartOffset;
118 mParseEndOffset = packetStartOffset;
155 mRenderWidth = aWidth;
171 int charsPerLine = ( ( mRenderWidth - 86 ) / 15 );
172 for(
int i = 0; i < aSize; i++ )
175 if( i != 0 && i % charsPerLine == 0 )
176 hexString.AppendFormat( _T(
"\r\n+ x%03x\t\t"), i );
179 hexString.AppendFormat
185 hexString.Append( _T(
"\r\n") );
195 mLogFilename = aFilename;
CString formatMultiLineHex(int aSize, uint8 *aData)
Format bytes into a multi logLine hex dump format.
#define cnt_of_array(_a)
The number of elements in _a.
void reset()
Reset the log parser to initial state.
BOOL readLog()
Reads from the log file starting from the end of the last read position and adds it to the display...
void setRenderWidth(int aWidth)
Set the number of pixels available for rendering text.
int getLineCount() const
Return the number of lines parsed so far.
unsigned char uint8
8-bit unsigned integer
CString getFilename()
Get the path of the log file being parsed.
void init(const CString &aFilename)
Initialize the LogParser to read a particular file.
virtual ~LogParser()
Destructor.