24 #ifndef TCLAP_STDCMDLINEOUTPUT_H
25 #define TCLAP_STDCMDLINEOUTPUT_H
44 class StdOutput :
public CmdLineOutput
54 virtual void usage(CmdLineInterface& c);
61 virtual void version(CmdLineInterface& c);
69 virtual void failure(CmdLineInterface& c,
79 void _shortUsage( CmdLineInterface& c, std::ostream& os )
const;
87 void _longUsage( CmdLineInterface& c, std::ostream& os )
const;
101 const std::string& s,
104 int secondLineOffset )
const;
111 std::string progName = _cmd.getProgramName();
112 std::string xversion = _cmd.getVersion();
114 std::cout << std::endl << progName <<
" version: "
115 << xversion << std::endl << std::endl;
120 std::cout << std::endl <<
"USAGE: " << std::endl << std::endl;
124 std::cout << std::endl << std::endl <<
"Where: " << std::endl << std::endl;
128 std::cout << std::endl;
137 std::cerr <<
"PARSE ERROR: " << e.
argId() << std::endl
138 <<
" " << e.
error() << std::endl << std::endl;
142 std::cerr <<
"Brief USAGE: " << std::endl;
146 std::cerr << std::endl <<
"For complete USAGE and HELP type: "
147 << std::endl <<
" " << progName <<
" "
149 << std::endl << std::endl;
159 std::ostream& os )
const
164 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
166 std::string s = progName +
" ";
169 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
173 it != xorList[i].end(); it++ )
174 s += (*it)->shortID() +
"|";
176 s[s.length()-1] =
'}';
181 if ( !xorHandler.
contains( (*it) ) )
182 s +=
" " + (*it)->shortID();
185 int secondLineOffset =
static_cast<int>(progName.length()) + 2;
186 if ( secondLineOffset > 75/2 )
187 secondLineOffset =
static_cast<int>(75/2);
194 std::ostream& os )
const
196 std::list<Arg*> argList = _cmd.getArgList();
197 std::string message = _cmd.getMessage();
198 XorHandler xorHandler = _cmd.getXorHandler();
199 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
202 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
205 it != xorList[i].end();
209 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
211 if ( it+1 != xorList[i].end() )
214 os << std::endl << std::endl;
219 if ( !xorHandler.contains( (*it) ) )
222 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
232 const std::string& s,
235 int secondLineOffset )
const
237 int len =
static_cast<int>(s.length());
239 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
241 int allowedLen = maxWidth - indentSpaces;
243 while ( start < len )
249 int stringLen = min<int>( len - start, allowedLen );
252 if ( stringLen == allowedLen )
253 while ( stringLen >= 0 &&
254 s[stringLen+start] !=
' ' &&
255 s[stringLen+start] !=
',' &&
256 s[stringLen+start] !=
'|' )
261 if ( stringLen <= 0 )
262 stringLen = allowedLen;
265 for (
int i = 0; i < stringLen; i++ )
266 if ( s[start+i] ==
'\n' )
270 for (
int i = 0; i < indentSpaces; i++ )
276 indentSpaces += secondLineOffset;
279 allowedLen -= secondLineOffset;
282 os << s.substr(start,stringLen) << std::endl;
285 while ( s[stringLen+start] ==
' ' && start < len )
293 for (
int i = 0; i < indentSpaces; i++ )
295 os << s << std::endl;