27{
30 if (!ifile) {
31
32 return false;
33 }
34
35 bool tableMode = false;
36 std::string currentTable;
37 int currentIndex = -1;
38 std::vector<std::string> currentFields;
40
41 while (ifile) {
43 std::getline(ifile,line);
44 if (!ifile) break;
45
46 if (
line.empty() || line[0] ==
'#' ||
line.substr(0,2) ==
"//" )
continue;
47 std::istringstream istr(line);
48
50
52
53 if (
key.empty())
continue;
54
55 if (key == "Table") {
56 istr >> currentTable;
57 tableMode = true;
58 currentIndex = -1;
59 currentFields.clear();
60 } else if (key == "TableEnd") {
61 std::ostringstream ostr;
62 ostr << "TableSize:" << currentTable;
63 add(ostr.str(), currentIndex);
64 tableMode = false;
65 currentTable = "";
66 currentIndex = -1;
67 currentFields.clear();
68 } else if (key == "Section") {
73
76 }
77 } else if (key == "EndSection") {
79 } else {
80 if (!tableMode) {
83
86 } else {
87
88 std::istringstream istr2(line);
89
90 if (currentIndex < 0) {
91
92 while (!istr2.eof()) {
95 if (!
value.empty()) currentFields.push_back(std::move(value));
96 }
97 } else {
98
99 for (
unsigned int i=0;
i < currentFields.size();
i++) {
102 if (istr2) {
103 std::ostringstream ostr;
104 ostr << currentTable <<
"#" << currentIndex <<
":" << currentFields[
i];
105 add(ostr.str(), value);
106 }
107 }
108 }
109 currentIndex++;
110 }
111 }
112 }
114
115 return true;
116}
std::string formatKey(const std::string &key) const