35 bool tableMode =
false;
36 std::string currentTable;
37 int currentIndex = -1;
38 std::vector<std::string> currentFields;
43 std::getline(ifile,line);
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];
105 add(ostr.str(), value);
124 std::string tableName;
125 std::string fieldName;
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);
132 fieldName = key.substr(++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()) {
152 newKey = std::move(fieldName);
153 }
else if (tableName ==
"TableSize") {
154 newKey =
"TableSize:"+fieldName;
156 newKey = tableName+
"#"+rowNumber+
":"+fieldName;
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);
void printNotUsed(const std::string §ion="") const
void add(const std::string &key, const std::string &value)
std::string formatKey(const std::string &key) const
bool getRowNumber(std::string &key, std::string &rowNumber) const
void printParameters(const std::string §ion="") const
bool find(const std::string &key, std::string &result) const
std::unordered_map< std::string, int > m_sections
bool readFile(const std::string &filename)
bool sectionPresent(const std::string §ion) const
std::unordered_map< std::string, Data > m_table