forked from vchukanov/cppimagefilterbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseconfig.cpp
More file actions
40 lines (37 loc) · 753 Bytes
/
parseconfig.cpp
File metadata and controls
40 lines (37 loc) · 753 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
40
#include "parseconfig.h"
#include <cstring>
#include <string>
#include <vector>
vector<configData> ParseConfig::readConfig(string configFile) {
vector<configData> data;
char* str = new char[256];
ifstream file(configFile);
while (!file.eof())
{
file.getline(str, 256);
char* pch = strtok(str, " ");
int flag = 0, maxFlag = 5;
configData cnf;
while (pch != NULL)
{
if (flag == 0) {
string s = string(pch);
cnf.nameFilter = s;
}
if (flag != 0) {
int ch = (*pch) - '0';
cnf.coordinates.push_back(ch);
}
flag++;
if (flag == maxFlag) {
flag = 0;
data.push_back(cnf);
//cnf.nameFilter = NULL;
cnf.coordinates.clear();
}
pch = strtok(NULL, " ");
}
}
file.close();
return data;
}