Skip to content

Commit

Permalink
[portsyncd] allow port syncd to parse port_config.ini in random colum…
Browse files Browse the repository at this point in the history
…n order (sonic-net#445)

- Parse the column header to decide column ordering.
- Extra column(s) will be ignored.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
  • Loading branch information
yxieca committed Feb 25, 2018
1 parent 6dd0870 commit 6e274fb
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions portsyncd/portsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,15 @@ void handlePortConfigFile(ProducerStateTable &p, string file)
{
if (line.at(0) == '#')
{
/* Find out what info is specified in the configuration file */
for (auto it = header.begin(); it != header.end();)
{
if (line.find(*it) == string::npos)
{
it = header.erase(it);
}
else
{
++it;
}
// Take this line as column header line
istringstream iss_hdr(line.substr(1));
string hdr;

header.clear();
while (! iss_hdr.eof()) {
iss_hdr >> hdr;
cout << "Adding column header '" << hdr << "'" << endl;
header.push_back(hdr);
}

continue;
Expand Down

0 comments on commit 6e274fb

Please sign in to comment.