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 <<
" --help"
147 << std::endl << std::endl;
157 std::ostream& os )
const
162 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
164 std::string s = progName +
" ";
167 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
171 it != xorList[i].end(); it++ )
172 s += (*it)->shortID() +
"|";
174 s[s.length()-1] =
'}';
179 if ( !xorHandler.
contains( (*it) ) )
180 s +=
" " + (*it)->shortID();
183 int secondLineOffset =
static_cast<int>(progName.length()) + 2;
184 if ( secondLineOffset > 75/2 )
185 secondLineOffset =
static_cast<int>(75/2);
192 std::ostream& os )
const
197 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
200 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
203 it != xorList[i].end();
207 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
209 if ( it+1 != xorList[i].end() )
212 os << std::endl << std::endl;
217 if ( !xorHandler.
contains( (*it) ) )
220 spacePrint( os, (*it)->getDescription(), 75, 5, 0 );
230 const std::string& s,
233 int secondLineOffset )
const
235 int len =
static_cast<int>(s.length());
237 if ( (len + indentSpaces > maxWidth) && maxWidth > 0 )
239 int allowedLen = maxWidth - indentSpaces;
241 while ( start < len )
247 int stringLen = min<int>( len - start, allowedLen );
250 if ( stringLen == allowedLen )
251 while ( stringLen >= 0 &&
252 s[stringLen+start] !=
' ' &&
253 s[stringLen+start] !=
',' &&
254 s[stringLen+start] !=
'|' )
259 if ( stringLen <= 0 )
260 stringLen = allowedLen;
263 for (
int i = 0; i < stringLen; i++ )
264 if ( s[start+i] ==
'\n' )
268 for (
int i = 0; i < indentSpaces; i++ )
274 indentSpaces += secondLineOffset;
277 allowedLen -= secondLineOffset;
280 os << s.substr(start,stringLen) << std::endl;
283 while ( s[stringLen+start] ==
' ' && start < len )
291 for (
int i = 0; i < indentSpaces; i++ )
293 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.
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...
void _shortUsage(CmdLineInterface &c, std::ostream &os) const
Writes a brief usage message with short args.
virtual std::string & getVersion()=0
Returns the version string.
virtual XorHandler & getXorHandler()=0
Returns the XorHandler.
std::string error() const
Returns the error text.
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.
std::string argId() const
Returns the argument id.
virtual void failure(CmdLineInterface &c, ArgException &e)
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior...
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.
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.