forked from sonic-net/sonic-swss-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathportmap.cpp
More file actions
39 lines (27 loc) · 728 Bytes
/
portmap.cpp
File metadata and controls
39 lines (27 loc) · 728 Bytes
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
#include "portmap.h"
using namespace std;
namespace swss {
map<set<int>, string> handlePortMap(string file)
{
map<set<int>, string> port_map;
ifstream infile(file);
if (!infile.is_open())
throw "Cannot open port map configuration file!";
string line;
while (getline(infile, line))
{
if (line.at(0) == '#')
continue;
istringstream iss_line(line);
string alias, lanes, lane;
set<int> lane_set;
iss_line >> alias >> lanes;
istringstream iss_lane(lanes);
while (getline(iss_lane, lane, ','))
lane_set.insert(stoi(lane));
port_map[lane_set] = alias;
}
infile.close();
return port_map;
}
}