23 #ifndef TCLAP_STDCMDLINEOUTPUT_H
24 #define TCLAP_STDCMDLINEOUTPUT_H
43 class StdOutput :
public CmdLineOutput
53 virtual void usage(CmdLineInterface& c);
60 virtual void version(CmdLineInterface& c);
100 const std::string& s,
103 int secondLineOffset )
const;
113 std::cout << std::endl << progName <<
" version: "
114 << xversion << std::endl << std::endl;
119 std::cout << std::endl <<
"USAGE: " << std::endl << std::endl;
123 std::cout << std::endl << std::endl <<
"Where: " << std::endl << std::endl;
127 std::cout << std::endl;
136 std::cerr <<
"PARSE ERROR: " << e.
argId() << std::endl
137 <<
" " << e.
error() << std::endl << std::endl;
141 std::cerr <<
"Brief USAGE: " << std::endl;
145 std::cerr << std::endl <<
"For complete USAGE and HELP type: "
146 << std::endl <<
" " << progName <<
" "
148 << std::endl << std::endl;
158 std::ostream& os )
const
160 std::list<Arg*> argList = _cmd.getArgList();
161 std::string progName = _cmd.getProgramName();
162 XorHandler xorHandler = _cmd.getXorHandler();
163 std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList();
165 std::string s = progName +
" ";
168 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
172 it != xorList[i].end(); it++ )
173 s += (*it)->shortID() +
"|";
175 s[s.length()-1] =
'}';
180 if ( !xorHandler.contains( (*it) ) )
181 s +=
" " + (*it)->shortID();
184 int secondLineOffset =
static_cast<int>(progName.length()) + 2;
185 if ( secondLineOffset > 75/2 )
186 secondLineOffset =
static_cast<int>(75/2);
193 std::ostream& os )
const
195 std::list<Arg*> argList = _cmd.getArgList();
196 std::string message = _cmd.getMessage();
197 XorHandler xorHandler = _cmd.getXorHandler();
198 std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList();
201 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
204 it != xorList[i].end();
208 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
210 if ( it+1 != xorList[i].end() )
213 os << std::endl << std::endl;
218 if ( !xorHandler.contains( (*it) ) )
221 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
231 const std::string& s,
234 int secondLineOffset )
const
236 int len =
static_cast<int>(s.length());
238 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
240 int allowedLen = maxWidth - indentSpaces;
242 while ( start < len )
248 int stringLen = min<int>( len - start, allowedLen );
251 if ( stringLen == allowedLen )
252 while ( stringLen >= 0 &&
253 s[stringLen+start] !=
' ' &&
254 s[stringLen+start] !=
',' &&
255 s[stringLen+start] !=
'|' )
260 if ( stringLen <= 0 )
261 stringLen = allowedLen;
264 for (
int i = 0; i < stringLen; i++ )
265 if ( s[start+i] ==
'\n' )
269 for (
int i = 0; i < indentSpaces; i++ )
275 indentSpaces += secondLineOffset;
278 allowedLen -= secondLineOffset;
281 os << s.substr(start,stringLen) << std::endl;
284 while ( s[stringLen+start] ==
' ' && start < len )
292 for (
int i = 0; i < indentSpaces; i++ )
294 os << s << std::endl;