mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-08-04 02:06:29 -04:00
cleaned up a bunch of things
This commit is contained in:
parent
6cc1ce8463
commit
67c8ff84e1
@ -151,6 +151,11 @@ class Arg
|
||||
bool valreq,
|
||||
Visitor* v = NULL );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Arg();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -204,30 +209,6 @@ class Arg
|
||||
*/
|
||||
static void setDelimiter( char c ) { Arg::_delimiter = c; }
|
||||
|
||||
/**
|
||||
* Null constructor.
|
||||
* Everything set to null/blank/0 values.
|
||||
*/
|
||||
Arg();
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* \param a - The Arg to be copied.
|
||||
*/
|
||||
Arg(const Arg& a);
|
||||
|
||||
/**
|
||||
* Operator =.
|
||||
* Assignment operator.
|
||||
* \param a - The Arg to be assigned to this.
|
||||
*/
|
||||
Arg& operator=(const Arg& a);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Arg();
|
||||
|
||||
/**
|
||||
* Processes the argument.
|
||||
* This is the method that handles the parsing and value assignment
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define __ARG_EXCEPTION_H__
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
namespace TCLAP {
|
||||
|
||||
@ -31,7 +32,7 @@ namespace TCLAP {
|
||||
* A simple class that defines and argument exception. Should be caught
|
||||
* whenever a CmdLine is created and parsed.
|
||||
*/
|
||||
class ArgException
|
||||
class ArgException : std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
@ -43,19 +44,19 @@ class ArgException
|
||||
*/
|
||||
ArgException( const std::string& text = "undefined exception",
|
||||
const std::string& id = "undefined" )
|
||||
: _errorText(text), _argId( id ) {};
|
||||
: std::exception(), _errorText(text), _argId( id ) { }
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* \param e - The ArgException that will be copied.
|
||||
*/
|
||||
ArgException(const ArgException& e)
|
||||
: _errorText(e._errorText), _argId(e._argId) {};
|
||||
: _errorText(e._errorText), _argId(e._argId) { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~ArgException() {};
|
||||
virtual ~ArgException() throw() { }
|
||||
|
||||
|
||||
/**
|
||||
@ -71,23 +72,28 @@ class ArgException
|
||||
_argId = e._argId;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error text.
|
||||
*/
|
||||
std::string error() { return ( _errorText ); };
|
||||
std::string error() const { return ( _errorText ); }
|
||||
|
||||
/**
|
||||
* Returns the argument id.
|
||||
*/
|
||||
std::string argId()
|
||||
std::string argId() const
|
||||
{
|
||||
if ( _argId == "undefined" )
|
||||
return " ";
|
||||
else
|
||||
return ( "Argument: " + _argId );
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error text.
|
||||
*/
|
||||
const char* what() throw() { return _errorText.c_str(); }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -44,7 +44,7 @@ class HelpVisitor: public Visitor
|
||||
* Constructor.
|
||||
* \param cmd - The CmdLine that will called for usage method.
|
||||
*/
|
||||
HelpVisitor(CmdLine* cmd) : Visitor(), _cmd( cmd ) {};
|
||||
HelpVisitor(CmdLine* cmd) : Visitor(), _cmd( cmd ) { }
|
||||
|
||||
/**
|
||||
* Calls the usage method of the CmdLine.
|
||||
|
@ -39,7 +39,7 @@ class IgnoreRestVisitor: public Visitor
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
IgnoreRestVisitor() : Visitor() {};
|
||||
IgnoreRestVisitor() : Visitor() {}
|
||||
|
||||
/**
|
||||
* Sets Arg::_ignoreRest.
|
||||
|
@ -171,11 +171,6 @@ class MultiArg : public Arg
|
||||
CmdLine& parser,
|
||||
Visitor* v = NULL );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~MultiArg();
|
||||
|
||||
/**
|
||||
* Handles the processing of the argument.
|
||||
* This re-implements the Arg version of this method to set the
|
||||
@ -190,7 +185,7 @@ class MultiArg : public Arg
|
||||
* Returns a vector of type T containing the values parsed from
|
||||
* the command line.
|
||||
*/
|
||||
const std::vector<T>& getValue() ;
|
||||
const std::vector<T>& getValue();
|
||||
|
||||
/**
|
||||
* Returns the a short id string. Used in the usage.
|
||||
@ -218,6 +213,9 @@ class MultiArg : public Arg
|
||||
void allowedInit();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
void MultiArg<T>::allowedInit()
|
||||
{
|
||||
@ -297,13 +295,7 @@ MultiArg<T>::MultiArg(const std::string& flag,
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
MultiArg<T>::~MultiArg() { };
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
const std::vector<T>& MultiArg<T>::getValue() { return _values; };
|
||||
const std::vector<T>& MultiArg<T>::getValue() { return _values; }
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -88,11 +88,6 @@ class SwitchArg : public Arg
|
||||
Visitor* v = NULL);
|
||||
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~SwitchArg();
|
||||
|
||||
/**
|
||||
* Handles the processing of the argument.
|
||||
* This re-implements the Arg version of this method to set the
|
||||
@ -112,7 +107,7 @@ class SwitchArg : public Arg
|
||||
/**
|
||||
* Returns bool, whether or not the switch has been set.
|
||||
*/
|
||||
bool getValue() ;
|
||||
bool getValue();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
|
||||
: MultiArg<T>("", name, desc, false, typeDesc, v)
|
||||
{
|
||||
_ignoreable = ignoreable;
|
||||
};
|
||||
}
|
||||
|
||||
template<class T>
|
||||
UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
|
||||
|
@ -209,11 +209,6 @@ class ValueArg : public Arg
|
||||
const std::vector<T>& allowed,
|
||||
Visitor* v = NULL );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~ValueArg();
|
||||
|
||||
/**
|
||||
* Handles the processing of the argument.
|
||||
* This re-implements the Arg version of this method to set the
|
||||
@ -336,17 +331,11 @@ ValueArg<T>::ValueArg(const std::string& flag,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destructor implementation.
|
||||
*/
|
||||
template<class T>
|
||||
ValueArg<T>::~ValueArg() { };
|
||||
|
||||
/**
|
||||
* Implementation of getValue().
|
||||
*/
|
||||
template<class T>
|
||||
T& ValueArg<T>::getValue() { return _value; };
|
||||
T& ValueArg<T>::getValue() { return _value; }
|
||||
|
||||
/**
|
||||
* Implementation of processArg().
|
||||
|
@ -46,7 +46,7 @@ class VersionVisitor: public Visitor
|
||||
* Constructor.
|
||||
* \param cmd - The CmdLine whose version method will be called.
|
||||
*/
|
||||
VersionVisitor(CmdLine* cmd) : Visitor(), _cmd( cmd ) {};
|
||||
VersionVisitor(CmdLine* cmd) : Visitor(), _cmd( cmd ) { }
|
||||
|
||||
/**
|
||||
* Prints the version to stdout.
|
||||
|
@ -35,12 +35,12 @@ class Visitor
|
||||
/**
|
||||
* Constructor. Does nothing.
|
||||
*/
|
||||
Visitor() {};
|
||||
Visitor() { }
|
||||
|
||||
/**
|
||||
* Does nothing. Should be overridden by child.
|
||||
*/
|
||||
virtual void visit() {};
|
||||
virtual void visit() { }
|
||||
};
|
||||
|
||||
}
|
||||
|
54
src/Arg.cpp
54
src/Arg.cpp
@ -76,53 +76,7 @@ Arg::Arg(const std::string& flag,
|
||||
|
||||
}
|
||||
|
||||
Arg::Arg()
|
||||
:
|
||||
_flag(""),
|
||||
_name(""),
|
||||
_description(""),
|
||||
_required(false),
|
||||
_requireLabel("required"),
|
||||
_valueRequired(false),
|
||||
_alreadySet(false),
|
||||
_visitor( NULL ),
|
||||
_ignoreable(false),
|
||||
_xorSet(false)
|
||||
{ };
|
||||
|
||||
Arg::Arg(const Arg& a)
|
||||
:
|
||||
_flag(a._flag),
|
||||
_name(a._name),
|
||||
_description(a._description),
|
||||
_required(a._required),
|
||||
_requireLabel(a._requireLabel),
|
||||
_valueRequired(a._valueRequired),
|
||||
_alreadySet(a._alreadySet),
|
||||
_visitor( a._visitor ),
|
||||
_ignoreable(a._ignoreable),
|
||||
_xorSet(a._xorSet)
|
||||
{ };
|
||||
|
||||
Arg::~Arg() { };
|
||||
|
||||
Arg& Arg::operator=(const Arg& a)
|
||||
{
|
||||
if ( this != &a )
|
||||
{
|
||||
_flag = a._flag;
|
||||
_name = a._name;
|
||||
_description = a._description;
|
||||
_required = a._required;
|
||||
_requireLabel = a._requireLabel;
|
||||
_valueRequired = a._valueRequired;
|
||||
_alreadySet = a._alreadySet;
|
||||
_visitor = a._visitor;
|
||||
_ignoreable = a._ignoreable;
|
||||
_xorSet = a._xorSet;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
Arg::~Arg() { }
|
||||
|
||||
string Arg::shortID( const string& valueId ) const
|
||||
{
|
||||
@ -196,11 +150,11 @@ string Arg::getDescription() const
|
||||
|
||||
desc += _description;
|
||||
return desc;
|
||||
};
|
||||
}
|
||||
|
||||
const string& Arg::getFlag() const { return _flag; };
|
||||
const string& Arg::getFlag() const { return _flag; }
|
||||
|
||||
const string& Arg::getName() const { return _name; } ;
|
||||
const string& Arg::getName() const { return _name; }
|
||||
|
||||
bool Arg::isRequired() const { return _required; }
|
||||
|
||||
|
@ -48,9 +48,7 @@ SwitchArg::SwitchArg(const string& flag,
|
||||
parser.add( this );
|
||||
}
|
||||
|
||||
SwitchArg::~SwitchArg() { };
|
||||
|
||||
bool SwitchArg::getValue() { return _value; };
|
||||
bool SwitchArg::getValue() { return _value; }
|
||||
|
||||
bool SwitchArg::combinedSwitchesMatch(string& combinedSwitches )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user