| 279 | } |
| 280 | |
| 281 | void CommandLineParser::printParams() |
| 282 | { |
| 283 | int col_p = 30; |
| 284 | int col_d = 50; |
| 285 | |
| 286 | std::map<std::string, std::vector<std::string> >::iterator it; |
| 287 | std::vector<string> keysVector; |
| 288 | std::string buf; |
| 289 | for(it = data.begin(); it != data.end(); it++) |
| 290 | { |
| 291 | keysVector = split_string(it->first, "|"); |
| 292 | for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]); |
| 293 | |
| 294 | cout << " "; |
| 295 | buf = ""; |
| 296 | if (keysVector[0] != "") |
| 297 | { |
| 298 | buf = "-" + keysVector[0]; |
| 299 | if (keysVector[1] != "") buf += ", --" + keysVector[1]; |
| 300 | } |
| 301 | else if (keysVector[1] != "") buf += "--" + keysVector[1]; |
| 302 | if (del_space(it->second[0]) != "") buf += "=[" + del_space(it->second[0]) + "]"; |
| 303 | |
| 304 | cout << setw(col_p-2) << left << buf; |
| 305 | |
| 306 | if ((int)buf.length() > col_p-2) |
| 307 | { |
| 308 | cout << endl << " "; |
| 309 | cout << setw(col_p-2) << left << " "; |
| 310 | } |
| 311 | |
| 312 | buf = ""; |
| 313 | if (del_space(it->second[1]) != "") buf += del_space(it->second[1]); |
| 314 | |
| 315 | for(;;) |
| 316 | { |
| 317 | bool tr = ((int)buf.length() > col_d-2) ? true: false; |
| 318 | std::string::size_type pos = 0; |
| 319 | |
| 320 | if (tr) |
| 321 | { |
| 322 | pos = buf.find_first_of(' '); |
| 323 | for(;;) |
| 324 | { |
| 325 | if (buf.find_first_of(' ', pos + 1 ) < (std::string::size_type)(col_d-2) && |
| 326 | buf.find_first_of(' ', pos + 1 ) != std::string::npos) |
| 327 | pos = buf.find_first_of(' ', pos + 1); |
| 328 | else |
| 329 | break; |
| 330 | } |
| 331 | pos++; |
| 332 | cout << setw(col_d-2) << left << buf.substr(0, pos) << endl; |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | cout << setw(col_d-2) << left << buf<< endl; |
| 337 | break; |
| 338 | } |