30 #ifndef TCLAP_STDCMDLINEOUTPUT_H
31 #define TCLAP_STDCMDLINEOUTPUT_H
50 class StdOutput :
public CmdLineOutput
61 StdOutput( std::ostream &desired_out = std::cout ) :
118 const std::string& s,
121 int secondLineOffset )
const;
131 m_my_output << std::endl << progName <<
" version: "
132 <<
version << std::endl << std::endl;
137 m_my_output << std::endl <<
"USAGE: " << std::endl << std::endl;
141 m_my_output << std::endl << std::endl <<
"Where: " << std::endl << std::endl;
154 std::cerr <<
"PARSE ERROR: " << e.
argId() << std::endl
155 <<
" " << e.
error() << std::endl << std::endl;
159 std::cerr <<
"Brief USAGE: " << std::endl;
163 std::cerr << std::endl <<
"For complete USAGE and HELP type: "
164 << std::endl <<
" " << progName <<
" --help"
165 << std::endl << std::endl;
173 std::ostream& )
const
175 std::list<Arg*> argList = _cmd.getArgList();
176 std::string progName = _cmd.getProgramName();
177 XorHandler xorHandler = _cmd.getXorHandler();
178 std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList();
180 std::string s = progName +
" ";
183 for (
int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ )
187 it != xorList[i].end(); it++ )
188 s += (*it)->shortID() +
"|";
190 s[s.length()-1] =
'}';
195 if ( !xorHandler.contains( (*it) ) )
196 s +=
" " + (*it)->shortID();
199 int secondLineOffset = static_cast<int>(progName.length()) + 2;
200 if ( secondLineOffset > 75/2 )
201 secondLineOffset = static_cast<int>(75/2);
207 std::ostream& os )
const
209 std::list<Arg*> argList = _cmd.getArgList();
210 std::string message = _cmd.getMessage();
211 XorHandler xorHandler = _cmd.getXorHandler();
212 std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList();
215 for (
int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ )
218 it != xorList[i].end();
224 if ( it+1 != xorList[i].
end() )
227 os << std::endl << std::endl;
232 if ( !xorHandler.contains( (*it) ) )
235 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
245 const std::string& s,
248 int secondLineOffset )
const
250 int len = static_cast<int>(s.length());
252 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
254 int allowedLen = maxWidth - indentSpaces;
256 while ( start < len )
259 int stringLen = std::min( len - start, allowedLen );
262 if ( stringLen == allowedLen )
263 while ( stringLen >= 0 &&
264 s[stringLen+start] !=
' ' &&
265 s[stringLen+start] !=
',' &&
266 s[stringLen+start] !=
'|'
272 if ( stringLen <= 0 )
273 stringLen = allowedLen;
276 for (
int i = 0; i < stringLen; i++ )
277 if ( s[start+i] ==
'\n' )
281 for (
int i = 0; i < indentSpaces; i++ )
287 indentSpaces += secondLineOffset;
290 allowedLen -= secondLineOffset;
293 os << s.substr(start,stringLen) << std::endl;
296 while ( s[stringLen+start] ==
' ' && start < len )
304 for (
int i = 0; i < indentSpaces; i++ )
306 os << s << std::endl;