23 #ifndef TCLAP_STDCMDLINEOUTPUT_H 24 #define TCLAP_STDCMDLINEOUTPUT_H 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 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 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;
virtual bool hasHelpAndVersion()=0
Indicates whether or not the help and version switches were created automatically.
std::vector< std::vector< Arg * > > & getXorList()
A simple class that defines and argument exception.
virtual std::string & getProgramName()=0
Returns the program name string.
std::string argId() const
Returns the argument id.
virtual void usage(CmdLineInterface &c)
Prints the usage to stdout.
virtual std::list< Arg * > & getArgList()=0
Returns the argList.
virtual void version(CmdLineInterface &c)
Prints the version to stdout.
void _longUsage(CmdLineInterface &c, std::ostream &os) const
Writes a longer usage message with long and short args, provides descriptions and prints message.
virtual std::string & getVersion()=0
Returns the version string.
virtual XorHandler & getXorHandler()=0
Returns the XorHandler.
static const std::string nameStartString()
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.
The base class that manages the command line definition and passes along the parsing to the appropria...
bool contains(const Arg *a)
Simply checks whether the Arg is contained in one of the arg lists.
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
A class that isolates any output from the CmdLine object so that it may be easily modified.
virtual std::string & getMessage()=0
Returns the message string.
void _shortUsage(CmdLineInterface &c, std::ostream &os) const
Writes a brief usage message with short args.
void spacePrint(std::ostream &os, const std::string &s, int maxWidth, int indentSpaces, int secondLineOffset) const
This function inserts line breaks and indents long strings according the params input.
virtual void failure(CmdLineInterface &c, ArgException &e)
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior.
std::string error() const
Returns the error text.
This class handles lists of Arg's that are to be XOR'd on the command line.
The interface that any output object must implement.