-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.cpp
More file actions
41 lines (37 loc) · 1.13 KB
/
parser.cpp
File metadata and controls
41 lines (37 loc) · 1.13 KB
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
#include "parser.h"
#include <ctime>
bool AlgParser::read(char *inputFileName)
{
ifstream infile( inputFileName );
if (!infile) {
cout << "Incorrect [input_file_name]: " << inputFileName << endl;
cout << "Usage: ./parser [input_file_name]" << endl;
return false;
}
string s, buf;
while( infile >> s ){
if( s == "grid" ){ infile >> numHTilesm >> numVTilesm; }
else if( s == "capacity" ){ infile >> capacity; }
else if( s == "num" ){ infile >> buf >> numNets; break; }
else { cout << s << " does not follow the rule" << endl; break; }
}
netsPos.resize( numNets );
for( size_t i = 0; i < numNets; ++i ){
int id, sx, sy, ex, ey;
infile >> id >> sx >> sy >> ex >> ey;
Pos sPos = pair<int,int>(sx,sy);
Pos ePos = pair<int,int>(ex,ey);
netsPos[ id ] = pair<Pos,Pos>(sPos,ePos);
}
infile.close();
cout << "file parsed completely." << endl;
return true;
}
void AlgTimer::Begin(void)
{
begin_clock = clock();
}
double AlgTimer::End(void)
{
return ( (double)( clock() - begin_clock ) / (double)CLOCKS_PER_SEC );
}