22 #ifndef TCLAP_STDCMDLINEOUTPUT_H
23 #define TCLAP_STDCMDLINEOUTPUT_H
53 StdOutput( std::ostream &desired_out = std::cout ) :
110 const std::string& s,
113 int secondLineOffset )
const;
123 m_my_output << std::endl << progName <<
" version: "
124 << version << std::endl << std::endl;
129 m_my_output << std::endl <<
"USAGE: " << std::endl << std::endl;
133 m_my_output << std::endl << std::endl <<
"Where: " << std::endl << std::endl;
146 std::cerr <<
"PARSE ERROR: " << e.
argId() << std::endl
147 <<
" " << e.
error() << std::endl << std::endl;
151 std::cerr <<
"Brief USAGE: " << std::endl;
155 std::cerr << std::endl <<
"For complete USAGE and HELP type: "
156 << std::endl <<
" " << progName <<
" --help"
157 << std::endl << std::endl;
165 std::ostream& os )
const
170 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
172 std::string s = progName +
" ";
175 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
179 it != xorList[i].end(); it++ )
180 s += (*it)->shortID() +
"|";
182 s[s.length()-1] =
'}';
187 if ( !xorHandler.
contains( (*it) ) )
188 s +=
" " + (*it)->shortID();
191 int secondLineOffset =
static_cast<int>(progName.length()) + 2;
192 if ( secondLineOffset > 75/2 )
193 secondLineOffset =
static_cast<int>(75/2);
199 std::ostream& os )
const
204 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
207 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
210 it != xorList[i].end();
214 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
216 if ( it+1 != xorList[i].
end() )
219 os << std::endl << std::endl;
224 if ( !xorHandler.
contains( (*it) ) )
227 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
237 const std::string& s,
240 int secondLineOffset )
const
242 int len =
static_cast<int>(s.length());
244 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
246 int allowedLen = maxWidth - indentSpaces;
248 while ( start < len )
251 int stringLen = std::min( len - start, allowedLen );
254 if ( stringLen == allowedLen )
255 while ( s[stringLen+start] !=
' ' &&
256 s[stringLen+start] !=
',' &&
257 s[stringLen+start] !=
'|' &&
263 if ( stringLen <= 0 )
264 stringLen = allowedLen;
267 for (
int i = 0; i < stringLen; i++ )
268 if ( s[start+i] ==
'\n' )
272 for (
int i = 0; i < indentSpaces; i++ )
278 indentSpaces += secondLineOffset;
281 allowedLen -= secondLineOffset;
284 os << s.substr(start,stringLen) << std::endl;
287 while ( s[stringLen+start] ==
' ' && start < len )
295 for (
int i = 0; i < indentSpaces; i++ )
297 os << s << std::endl;