forked from ljtum/logalyzer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
74 lines (56 loc) · 1.38 KB
/
main.cpp
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
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include "Logalyzer.h"
int main( int argc, char* argv[] )
{
if( argc < 2 )
return -1;
std::ifstream log_file( argv[1] );
if( !log_file.is_open() )
return -1;
const std::string event_prefix( "cap_cr|" );
const char delimiter = '|';
std::string line;
std::vector<std::string> events;
std::vector<unsigned int> stage_indices;
while( std::getline( log_file, line ) )
{
auto pos = line.find( event_prefix );
if( pos == std::string::npos )
continue;
line = line.substr( pos + event_prefix.size(), line.find_last_of( delimiter ) );
/* std::istringstream ss( line );
std::string token;
std::vector<std::string> tokens;
while( std::getline( ss, token, delimiter ) )
{
tokens.push_back( token );
}
if( tokens[0] == "STAGE" )
stage_indices.push_back( events.size() );
*/
events.push_back( line );
}
log_file.close();
/* unsigned int index1, index2;
for( size_t i = 0, j = 1; i != stage_indices.size(); ++i, ++j)
{
index1 = stage_indices[i];
if( j != stage_indices.size() )
index2 = stage_indices[j];
else
index2 = events.size();
std::cout << ">>> NEW STAGE" << std::endl;
for( ; index1 < index2; ++index1)
{
std::cout << events[index1] << std::endl;
}
std::cout << std::endl;
}
*/
Logalyzer logalyzer( events );
logalyzer.print_summary();
return 0;
}