From: Andrey Morozov Date: Mon, 3 Oct 2011 11:17:36 +0000 (+0000) Subject: improved print help in CommandLineParser X-Git-Tag: accepted/2.0/20130307.220821~1766 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf636e40bfef8134fe881ce688a22e0272b82509;p=profile%2Fivi%2Fopencv.git improved print help in CommandLineParser --- diff --git a/modules/core/src/cmdparser.cpp b/modules/core/src/cmdparser.cpp index 4e7da03..7957344 100644 --- a/modules/core/src/cmdparser.cpp +++ b/modules/core/src/cmdparser.cpp @@ -261,6 +261,9 @@ template void CommandLineParser::printParams() { + int col_p = 30; + int col_d = 50; + std::map >::iterator it; std::vector keysVector; std::string buf; @@ -278,12 +281,39 @@ template else if (keysVector[1] != "") buf += "--" + keysVector[1]; if (del_space(it->second[0]) != "") buf += "=[" + del_space(it->second[0]) + "]"; - cout << setw(28) << left << buf; + cout << setw(col_p-2) << left << buf; + + if (buf.length() > col_p-2) + { + cout << endl << " "; + cout << setw(col_p-2) << left << " "; + } buf = ""; if (del_space(it->second[1]) != "") buf += del_space(it->second[1]); - - cout << setw(50) << left << buf << endl; + + while (true) + { + bool tr = (buf.length() >= col_d-2) ? true: false; + int pos; + + if (tr) + { + pos = buf.find_first_of(' '); + while (buf.find_first_of(' ', pos + 1 ) > 0 && pos < col_d-2) pos = buf.find_first_of(' ', pos + 1); + pos++; + cout << setw(col_d-2) << left << buf.substr(0, pos) << endl; + } + else + { + cout << setw(col_d-2) << left << buf<< endl; + break; + } + + buf.erase(0, pos); + cout << " "; + cout << setw(col_p-2) << left << " "; + } } }