35 bool tableMode =
false;
36 std::string currentTable;
37 int currentIndex = -1;
38 std::vector<std::string> currentFields;
46 if (
line.empty() ||
line[0] ==
'#' ||
line.substr(0,2) ==
"//" )
continue;
47 std::istringstream istr(
line);
53 if (
key.empty())
continue;
59 currentFields.clear();
60 }
else if (
key ==
"TableEnd") {
61 std::ostringstream ostr;
62 ostr <<
"TableSize:" << currentTable;
63 add(ostr.str(), currentIndex);
67 currentFields.clear();
68 }
else if (
key ==
"Section") {
77 }
else if (
key ==
"EndSection") {
88 std::istringstream istr2(
line);
90 if (currentIndex < 0) {
92 while (!istr2.eof()) {
95 if (!
value.empty()) currentFields.push_back(std::move(
value));
99 for (
unsigned int i=0;
i < currentFields.size();
i++) {
103 std::ostringstream ostr;
104 ostr << currentTable <<
"#" << currentIndex <<
":" << currentFields[
i];
124 std::string tableName;
126 std::string rowNumber;
127 bool foundRowNumber =
false;
128 std::string::size_type
pos =
key.find(
':');
129 if (
pos != std::string::npos) {
130 tableName =
key.substr(0,
pos);
136 std::string tmpRowNumber;
138 if (foundRowNumber) {
140 std::cout <<
"ERROR in format:" <<
key << std::endl;
142 rowNumber = std::move(tmpRowNumber);
146 std::string newKey =
key;
147 if ((tableName.empty() && !rowNumber.empty()) ||
fieldName.empty()) {
148 std::cout <<
"ERROR in format: " <<
key << std::endl;
150 if (rowNumber.empty()) rowNumber =
"0";
151 if (tableName.empty()) {
153 }
else if (tableName ==
"TableSize") {
156 newKey = tableName+
"#"+rowNumber+
":"+
fieldName;
166 std::string::size_type
pos =
key.find(
'#');
167 if (
pos != std::string::npos) {
168 rowNumber =
key.substr(
pos+1);
179 std::ostringstream ostr;
189 std::cout <<
"WARNING! Overwriting exist entry with key: " <<
key << std::endl;
197 std::unordered_map<std::string,Data>::const_iterator
iter =
m_table.find(
key);
211 std::ios::fmtflags iosflags = std::cout.flags();
212 std::cout << std::left;
215 std::unordered_map<std::string,int>::const_iterator iterSect =
m_sections.find(
section);
216 if (iterSect !=
m_sections.end()) sectionNum = iterSect->second;
219 for (std::unordered_map<std::string,Data>::const_iterator
iter =
m_table.begin();
222 if (
section.empty() ||
iter->second.section == sectionNum) {
223 std::cout << std::setw(35) <<
iter->first <<
" " <<
iter->second.value << std::endl;
227 std::cout.flags(iosflags);
234 std::ios::fmtflags iosflags = std::cout.flags();
235 std::cout << std::left;
239 std::unordered_map<std::string,int>::const_iterator iterSect =
m_sections.find(
section);
240 if (iterSect !=
m_sections.end()) sectionNum = iterSect->second;
243 for (std::unordered_map<std::string,Data>::const_iterator
iter =
m_table.begin();
246 if ((
section.empty() ||
iter->second.section == sectionNum) && (!(
iter->second.flag))) {
247 std::cout << std::setw(35) <<
iter->first <<
" " <<
iter->second.value << std::endl;
252 std::cout <<
"All parameters used" << std::endl;
255 std::cout.flags(iosflags);