added usage stuff

This commit is contained in:
mes5k 2004-08-11 02:45:27 +00:00
parent f951dccd84
commit e1d1339530
5 changed files with 75 additions and 4 deletions

View File

@ -31,5 +31,6 @@
#include <tclap/Visitor.h> #include <tclap/Visitor.h>
#include <tclap/XorHandler.h> #include <tclap/XorHandler.h>
#include <tclap/CommandLine.h> #include <tclap/CommandLine.h>
#include <tclap/PrintSensibly.h>
#endif #endif

View File

@ -33,10 +33,12 @@
#include <tclap/SwitchArg.h> #include <tclap/SwitchArg.h>
#include <tclap/Visitor.h> #include <tclap/Visitor.h>
#include <tclap/XorHandler.h> #include <tclap/XorHandler.h>
#include <tclap/PrintSensibly.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <list> #include <list>
#include <iostream> #include <iostream>
#include <ostream>
#include <cstdio> #include <cstdio>
#include <cstdarg> #include <cstdarg>
#include <iomanip> #include <iomanip>
@ -101,6 +103,19 @@ class CmdLine
*/ */
bool _emptyCombined(const string& s); bool _emptyCombined(const string& s);
/**
* Writes a brief usage message with short args.
* \param os - The stream to write the message to.
*/
void _shortUsage( ostream& os );
/**
* Writes a longer usage message with long and short args,
* provides descriptions and prints message.
* \param os - The stream to write the message to.
*/
void _longUsage( ostream& os );
private: private:
/** /**

View File

@ -13,5 +13,6 @@ libtclapinclude_HEADERS = ArgException.h \
HelpVisitor.h \ HelpVisitor.h \
SwitchArg.h \ SwitchArg.h \
VersionVisitor.h \ VersionVisitor.h \
IgnoreRestVisitor.h IgnoreRestVisitor.h \
PrintSensibly.h

View File

@ -0,0 +1,51 @@
/******************************************************************************
*
* file: PrintSensibly.h
*
* Copyright (c) 2004, Michael E. Smoot .
* All rights reverved.
*
* See the file COPYING in the top directory of this distribution for
* more information.
*
* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#ifndef __PRINTSENSIBLY_HH__
#define __PRINTSENSIBLY_HH__
#include <ostream>
#include <algorithm>
#include <string>
using namespace std;
namespace TCLAP {
/**
* This function inserts line breaks and indents long strings according the
* params input. It will only break lines at spaces, commas and pipes.
* \param os - The stream to be printed to.
* \param s - The string to be printed.
* \param maxWidth - The maxWidth allowed for the output line.
* \param indentSpaces - The number of spaces to indent the first line.
* \param secondLineOffset - The number of spaces to indent the second
* and all subsequent lines in addition to indentSpaces.
*/
void spacePrint( ostream& os,
const string& s,
int maxWidth,
int indentSpaces=0,
int secondLineOffset=0 );
}
#endif

View File

@ -23,9 +23,11 @@
#define __ORHANDLER_HH__ #define __ORHANDLER_HH__
#include <tclap/Arg.h> #include <tclap/Arg.h>
#include <tclap/PrintSensibly.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <ostream>
using namespace std; using namespace std;
@ -67,14 +69,15 @@ class XorHandler
int check( const Arg* a ); int check( const Arg* a );
/** /**
* Prints the XOR specific short usage. * Returns the XOR specific short usage.
*/ */
void shortUsage(); string shortUsage();
/** /**
* Prints the XOR specific long usage. * Prints the XOR specific long usage.
* \param os - Stream to print to.
*/ */
void longUsage(); void printLongUsage(ostream& os);
/** /**
* Simply checks whether the Arg is contained in one of the arg * Simply checks whether the Arg is contained in one of the arg