22 #ifndef DtCmdLine_STDCMDLINEOUTPUT_H
23 #define DtCmdLine_STDCMDLINEOUTPUT_H
42 #ifdef DtUSE_UTILITIES_NAMESPACE
43 namespace DtUSE_UTILITIES_NAMESPACE
53 class StdOutput :
public CmdLineOutput
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
This file declares the class DtCmdLine::CmdLineOutput.
std::vector< std::vector< Arg * > > & getXorList()
Definition: cmdXorHandler.h:185
This file declares classes for VR-Link command line parsing utility.
This file declares the class DtCmdLine::CmdLineInterface.
Functions in vlPrint.h provide an error and print facility for vrlink.
This class handles lists of Arg's that are to be XOR'd on the command line.
Definition: cmdXorHandler.h:48
std::string argId() const
Returns the argument id.
Definition: cmdArgException.h:76
virtual std::list< Arg * > & getArgList()=0
Returns the argList.
A simple class that defines and argument exception.
Definition: cmdArgException.h:43
virtual XorHandler & getXorHandler()=0
Returns the XorHandler.
int DtNotifyLevel
DtNotifyLevel is used to control the level of diagnostics output by VR-Link.
virtual std::string & getProgramName()=0
Returns the program name string.
This file declares the class DtCmdLine::XorHandler.
virtual std::string & getMessage()=0
Returns the message string.
DtOutputStream DtWarn
These DtOutputStream instances are used for all print messaging in VR-Link.
std::string error() const
Returns the error text.
Definition: cmdArgException.h:70
bool contains(const Arg *a)
Simply checks whether the Arg is contained in one of the arg lists.
Definition: cmdXorHandler.h:173
DtOutputStream DtInfo
DtInfo is an global instance of a DtOutputStream.
virtual std::string & getVersion()=0
Returns the version string.
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.
Definition: cmdArg.h:342
The base class that manages the command line definition and passes along the parsing to the appropria...
Definition: cmdLineInterface.h:52
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
Definition: cmdArg.h:347
virtual ~StdOutput()
Definition: cmdStdOutput.h:59
ProcControl.h provides operating system independent methods to control processes. ...