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;
61 currentFields.clear();
62 }
else if (
key ==
"TableEnd") {
63 std::ostringstream ostr;
64 ostr <<
"TableSize:" << currentTable;
65 add(ostr.str(), currentIndex);
69 currentFields.clear();
70 }
else if (
key ==
"Section") {
79 }
else if (
key ==
"EndSection") {
90 std::istringstream istr2(
line);
92 if (currentIndex < 0) {
94 while (!istr2.eof()) {
97 if (!
value.empty()) currentFields.push_back(
value);
101 for (
unsigned int i=0;
i < currentFields.size();
i++) {
105 std::ostringstream ostr;
106 ostr << currentTable <<
"#" << currentIndex <<
":" << currentFields[
i];
126 std::string tableName;
128 std::string rowNumber;
129 bool foundRowNumber =
false;
130 std::string::size_type
pos =
key.find(
':');
131 if (
pos != std::string::npos) {
132 tableName =
key.substr(0,
pos);
138 std::string tmpRowNumber;
140 if (foundRowNumber) {
142 std::cout <<
"ERROR in format:" <<
key << std::endl;
144 rowNumber = tmpRowNumber;
148 std::string newKey =
key;
149 if ((tableName.empty() && !rowNumber.empty()) ||
fieldName.empty()) {
150 std::cout <<
"ERROR in format: " <<
key << std::endl;
152 if (rowNumber.empty()) rowNumber =
"0";
153 if (tableName.empty()) {
155 }
else if (tableName ==
"TableSize") {
158 newKey = tableName+
"#"+rowNumber+
":"+
fieldName;
168 std::string::size_type
pos =
key.find(
'#');
169 if (
pos != std::string::npos) {
170 rowNumber =
key.substr(
pos+1);
181 std::ostringstream ostr;
191 std::cout <<
"WARNING! Overwriting exist entry with key: " <<
key << std::endl;
199 std::unordered_map<std::string,Data>::const_iterator iter =
m_table.find(
key);
201 result = iter->second.value;
202 (iter->second).
flag=
true;
213 std::ios::fmtflags iosflags = std::cout.flags();
214 std::cout << std::left;
217 std::unordered_map<std::string,int>::const_iterator iterSect =
m_sections.find(
section);
218 if (iterSect !=
m_sections.end()) sectionNum = iterSect->second;
221 for (std::unordered_map<std::string,Data>::const_iterator iter =
m_table.begin();
224 if (
section.empty() || iter->second.section == sectionNum) {
225 std::cout << std::setw(35) << iter->first <<
" " << iter->second.value << std::endl;
229 std::cout.flags(iosflags);
236 std::ios::fmtflags iosflags = std::cout.flags();
237 std::cout << std::left;
241 std::unordered_map<std::string,int>::const_iterator iterSect =
m_sections.find(
section);
242 if (iterSect !=
m_sections.end()) sectionNum = iterSect->second;
245 for (std::unordered_map<std::string,Data>::const_iterator iter =
m_table.begin();
248 if ((
section.empty() || iter->second.section == sectionNum) && (!(iter->second.flag))) {
249 std::cout << std::setw(35) << iter->first <<
" " << iter->second.value << std::endl;
254 std::cout <<
"All parameters used" << std::endl;
257 std::cout.flags(iosflags);