mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-09-07 19:29:07 -04:00
xor stuff
This commit is contained in:
parent
e47dc310a0
commit
59b98dd182
@ -87,6 +87,12 @@ class Arg
|
||||
*/
|
||||
bool _required;
|
||||
|
||||
/**
|
||||
* Label to be used in usage description. Normally set to
|
||||
* "required", but can be changed when necessary.
|
||||
*/
|
||||
string _requireLabel;
|
||||
|
||||
/**
|
||||
* Indicates whether a value is required for the argument.
|
||||
* Note that the value may be required but the argument/value
|
||||
@ -114,6 +120,12 @@ class Arg
|
||||
*/
|
||||
bool _ignoreable;
|
||||
|
||||
/**
|
||||
* Indicates that the arg was set as part of an XOR and not on the
|
||||
* command line.
|
||||
*/
|
||||
bool _xorSet;
|
||||
|
||||
/**
|
||||
* Performs the special handling described by the Vistitor.
|
||||
*/
|
||||
@ -242,15 +254,28 @@ class Arg
|
||||
*/
|
||||
bool isRequired() const;
|
||||
|
||||
/**
|
||||
* Sets _required to true. This is used by the XorHandler.
|
||||
* You really have no reason to ever use it.
|
||||
*/
|
||||
void forceRequired();
|
||||
|
||||
/**
|
||||
* Sets the _alreadySet value to true. This is used by the XorHandler.
|
||||
* You really have no reason to ever use it.
|
||||
*/
|
||||
void xorSet();
|
||||
|
||||
/**
|
||||
* Indicates whether a value must be specified for argument.
|
||||
*/
|
||||
bool isValueRequired() const;
|
||||
|
||||
/**
|
||||
* Indicates whether the argument has already been set.
|
||||
* Indicates whether the argument has already been set. Only true
|
||||
* if the arg has been matched on the command line.
|
||||
*/
|
||||
bool isAlreadySet() const;
|
||||
bool isSet() const;
|
||||
|
||||
/**
|
||||
* Indicates whether the argument can be ignored, if desired.
|
||||
@ -298,9 +323,16 @@ class Arg
|
||||
* Checks whether a given string has blank chars, indicating that
|
||||
* it is a combined SwitchArg. If so, return true, otherwise return
|
||||
* false.
|
||||
* \param s - string to be checked.
|
||||
*/
|
||||
bool _hasBlanks( const string& s ) const;
|
||||
|
||||
/**
|
||||
* Sets the requireLabel. Used by XorHandler. You shouldn't ever
|
||||
* use this.
|
||||
* \param s - Set the requireLabel to this value.
|
||||
*/
|
||||
void setRequireLabel( const string& s );
|
||||
|
||||
};
|
||||
|
||||
@ -308,6 +340,7 @@ class Arg
|
||||
* Typedef of a list iterator.
|
||||
*/
|
||||
typedef list<Arg*>::iterator ArgIterator;
|
||||
typedef vector<Arg*>::iterator ArgVectorIterator;
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <tclap/ValueArg.h>
|
||||
#include <tclap/UnlabeledValueArg.h>
|
||||
#include <tclap/Visitor.h>
|
||||
#include <tclap/OrHandler.h>
|
||||
#include <tclap/XorHandler.h>
|
||||
#include <tclap/CommandLine.h>
|
||||
|
||||
#endif
|
||||
|
@ -22,14 +22,17 @@
|
||||
#ifndef __COMMANDLINE_HH__
|
||||
#define __COMMANDLINE_HH__
|
||||
|
||||
//
|
||||
// Explanation of dumb naming. Originally this file was used as the generic
|
||||
// include to use the tclap library. However, this introduced a few weird
|
||||
// bugs related to g++. Thus, this file has been renamed, and CmdLine.h
|
||||
// just contains the files needed to use the lib.
|
||||
//
|
||||
|
||||
#include <tclap/Arg.h>
|
||||
#include <tclap/SwitchArg.h>
|
||||
//#include <tclap/MultiArg.h>
|
||||
//#include <tclap/UnlabeledMultiArg.h>
|
||||
//#include <tclap/ValueArg.h>
|
||||
//#include <tclap/UnlabeledValueArg.h>
|
||||
#include <tclap/Visitor.h>
|
||||
#include <tclap/OrHandler.h>
|
||||
#include <tclap/XorHandler.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@ -43,6 +46,10 @@ using namespace std;
|
||||
|
||||
namespace TCLAP {
|
||||
|
||||
/**
|
||||
* The base class that manages the command line definition and passes
|
||||
* along the parsing to the appropriate Arg classes.
|
||||
*/
|
||||
class CmdLine
|
||||
{
|
||||
protected:
|
||||
@ -81,7 +88,10 @@ class CmdLine
|
||||
*/
|
||||
char _delimiter;
|
||||
|
||||
OrHandler _xorHandler;
|
||||
/**
|
||||
* The handler that manages xoring lists of args.
|
||||
*/
|
||||
XorHandler _xorHandler;
|
||||
|
||||
/**
|
||||
* Checks whether a name/flag string matches entirely matches
|
||||
@ -134,9 +144,27 @@ class CmdLine
|
||||
* \param a - Argument to be added.
|
||||
*/
|
||||
void add( Arg& a );
|
||||
|
||||
/**
|
||||
* An alternative add. Functionally identical.
|
||||
* \param a - Argument to be added.
|
||||
*/
|
||||
void add( Arg* a );
|
||||
|
||||
/**
|
||||
* Add two Args that will be xor'd. If this method is used, add does
|
||||
* not need to be called.
|
||||
* \param a - Argument to be added and xor'd.
|
||||
* \param b - Argument to be added and xor'd.
|
||||
*/
|
||||
void xorAdd( Arg& a, Arg& b );
|
||||
void xorAdd( vector<Arg*>& ors );
|
||||
|
||||
/**
|
||||
* Add a list of Args that will be xor'd. If this method is used,
|
||||
* add does not need to be called.
|
||||
* \param xors - List of Args to be added and xor'd.
|
||||
*/
|
||||
void xorAdd( vector<Arg*>& xors );
|
||||
|
||||
/**
|
||||
* Prints the usage to stdout and exits.
|
||||
|
Loading…
x
Reference in New Issue
Block a user