15 #ifndef TCLAP_STDCMDLINEOUTPUT_H
16 #define TCLAP_STDCMDLINEOUTPUT_H
38 class StdOutput :
public CmdLineOutput
98 int secondLineOffset )
const;
106 std::string interface_version = _cmd.
getVersion();
108 std::cout << std::endl << progName <<
" version: "
109 << interface_version << std::endl << std::endl;
114 std::cout << std::endl <<
"USAGE: " << std::endl << std::endl;
118 std::cout << std::endl << std::endl <<
"Where: " << std::endl << std::endl;
122 std::cout << std::endl;
131 std::cerr <<
"PARSE ERROR: " << e.
argId() << std::endl
132 <<
" " << e.
error() << std::endl << std::endl;
136 std::cerr <<
"Brief USAGE: " << std::endl;
140 std::cerr << std::endl <<
"For complete USAGE and HELP type: "
141 << std::endl <<
" " << progName <<
" --help"
142 << std::endl << std::endl;
150 std::ostream& os )
const
155 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
157 std::string s = progName +
" ";
160 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
164 it != xorList[i].end(); it++ )
165 s += (*it)->shortID() +
"|";
167 s[s.length()-1] =
'}';
172 if ( !xorHandler.
contains( (*it) ) )
173 s +=
" " + (*it)->shortID();
176 int secondLineOffset =
static_cast<int>(progName.length()) + 2;
177 if ( secondLineOffset > 75/2 )
178 secondLineOffset =
static_cast<int>(75/2);
185 std::ostream& os )
const
190 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
193 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
196 it != xorList[i].end();
200 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
202 if ( it+1 != xorList[i].end() )
205 os << std::endl << std::endl;
210 if ( !xorHandler.
contains( (*it) ) )
213 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
223 const std::string& s,
226 int secondLineOffset )
const
228 int len =
static_cast<int>(s.length());
230 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
232 int allowedLen = maxWidth - indentSpaces;
234 while ( start < len )
237 int stringLen = std::min<int>( len - start, allowedLen );
240 if ( stringLen == allowedLen )
241 while ( s[stringLen+start] !=
' ' &&
242 s[stringLen+start] !=
',' &&
243 s[stringLen+start] !=
'|' &&
249 if ( stringLen <= 0 )
250 stringLen = allowedLen;
253 for (
int i = 0; i < stringLen; i++ )
254 if ( s[start+i] ==
'\n' )
258 for (
int i = 0; i < indentSpaces; i++ )
264 indentSpaces += secondLineOffset;
267 allowedLen -= secondLineOffset;
270 os << s.substr(start,stringLen) << std::endl;
273 while ( s[stringLen+start] ==
' ' && start < len )
281 for (
int i = 0; i < indentSpaces; i++ )
283 os << s << std::endl;