22 #ifndef DtCmdLine_STDCMDLINEOUTPUT_H
23 #define DtCmdLine_STDCMDLINEOUTPUT_H
42 #ifdef DtUSE_UTILITIES_NAMESPACE
43 namespace DtUSE_UTILITIES_NAMESPACE
112 void spacePrint( std::ostream& os,
113 const std::string& s,
116 int secondLineOffset )
const;
129 <<
'\n' << progName <<
" version: "
130 << version <<
"\n\n";
138 DtInfo <<
'\n' <<
"USAGE: " <<
'\n' <<
'\n';
140 _shortUsage( _cmd,
DtInfo );
142 DtInfo <<
'\n' <<
"Where: " <<
'\n';
144 _longUsage( _cmd,
DtInfo );
159 <<
"PARSE ERROR: " << e.
argId() <<
'\n'
160 <<
" " << e.
error() <<
"\n\n"
161 <<
"Brief USAGE: " <<
'\n';
163 _shortUsage( _cmd,
DtWarn );
166 <<
'\n' <<
"For complete USAGE and HELP type: "
167 <<
'\n' <<
" " << progName <<
" --help"
168 <<
'\n' << std::endl;
174 std::ostream& os )
const
179 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
181 std::string s = progName +
" ";
184 for (
int i = 0; (
unsigned int)i < xorList.size(); i++ )
188 it != xorList[i].end(); it++ )
189 s += (*it)->shortID() +
"|";
191 s[s.length()-1] =
'}';
196 if ( !xorHandler.
contains( (*it) ) )
197 s +=
" " + (*it)->shortID();
200 int secondLineOffset = (int)(progName.length()) + 2;
201 if ( secondLineOffset > 80/2 )
202 secondLineOffset = (int)(80/2);
204 spacePrint( os, s, 80, 3, secondLineOffset );
208 std::ostream& os )
const
213 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
216 for (
int i = 0; (
unsigned int)i < xorList.size(); i++ )
219 it != xorList[i].end();
222 spacePrint( os, (*it)->longID(), 80, 3, 3 );
223 spacePrint( os, (*it)->getDescription(), 80, 12, 0 );
225 if ( it+1 != xorList[i].end() )
226 spacePrint(os,
"-- OR --", 80, 25, 0);
233 if ( !xorHandler.
contains( (*it) ) )
235 spacePrint( os, (*it)->longID(), 80, 3, 3 );
236 spacePrint( os, (*it)->getDescription(), 80, 12, 0 );
240 spacePrint( os, message, 80, 3, 0 );
243 inline void StdOutput::spacePrint( std::ostream& os,
244 const std::string& s,
247 int secondLineOffset )
const
249 int len = (int)(s.length());
251 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
253 int allowedLen = maxWidth - indentSpaces;
255 while ( start < len )
259 int stringLen = ( len - start < allowedLen ? len - start : allowedLen);
261 int stringLen = std::min( len - start, allowedLen );
265 if ( stringLen == allowedLen )
266 while ( stringLen >= 0 &&
267 s[stringLen+start] !=
' ' &&
268 s[stringLen+start] !=
',' &&
269 s[stringLen+start] !=
'|')
274 if ( stringLen <= 0 )
275 stringLen = allowedLen;
279 for (i = 0; i < stringLen; i++ )
280 if ( s[start+i] ==
'\n' )
284 for (i = 0; i < indentSpaces; i++ )
290 indentSpaces += secondLineOffset;
293 allowedLen -= secondLineOffset;
296 os << s.substr(start,stringLen) << std::endl;
299 while ( s[stringLen+start] ==
' ' && start < len )
307 for (
int i = 0; i < indentSpaces; i++ )
309 os << s << std::endl;
315 #ifdef DtUSE_UTILITIES_NAMESPACE