From 67c8ff84e1288843689cb15fde68b323f0da1b08 Mon Sep 17 00:00:00 2001 From: mes5k Date: Thu, 16 Sep 2004 03:54:08 +0000 Subject: [PATCH] cleaned up a bunch of things --- include/tclap/Arg.h | 29 +++-------------- include/tclap/ArgException.h | 22 ++++++++----- include/tclap/HelpVisitor.h | 2 +- include/tclap/IgnoreRestVisitor.h | 2 +- include/tclap/MultiArg.h | 18 +++-------- include/tclap/SwitchArg.h | 7 +--- include/tclap/UnlabeledMultiArg.h | 2 +- include/tclap/ValueArg.h | 13 +------- include/tclap/VersionVisitor.h | 2 +- include/tclap/Visitor.h | 4 +-- src/Arg.cpp | 54 +++---------------------------- src/SwitchArg.cpp | 4 +-- 12 files changed, 37 insertions(+), 122 deletions(-) diff --git a/include/tclap/Arg.h b/include/tclap/Arg.h index 151e70e..cfe7273 100644 --- a/include/tclap/Arg.h +++ b/include/tclap/Arg.h @@ -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 diff --git a/include/tclap/ArgException.h b/include/tclap/ArgException.h index 14e38e5..632deeb 100644 --- a/include/tclap/ArgException.h +++ b/include/tclap/ArgException.h @@ -24,6 +24,7 @@ #define __ARG_EXCEPTION_H__ #include +#include 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: diff --git a/include/tclap/HelpVisitor.h b/include/tclap/HelpVisitor.h index 9ee0b86..f3c7fbb 100644 --- a/include/tclap/HelpVisitor.h +++ b/include/tclap/HelpVisitor.h @@ -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. diff --git a/include/tclap/IgnoreRestVisitor.h b/include/tclap/IgnoreRestVisitor.h index 574614a..5e30b36 100644 --- a/include/tclap/IgnoreRestVisitor.h +++ b/include/tclap/IgnoreRestVisitor.h @@ -39,7 +39,7 @@ class IgnoreRestVisitor: public Visitor /** * Constructor. */ - IgnoreRestVisitor() : Visitor() {}; + IgnoreRestVisitor() : Visitor() {} /** * Sets Arg::_ignoreRest. diff --git a/include/tclap/MultiArg.h b/include/tclap/MultiArg.h index 9b90e26..a73abf1 100644 --- a/include/tclap/MultiArg.h +++ b/include/tclap/MultiArg.h @@ -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& getValue() ; + const std::vector& getValue(); /** * Returns the a short id string. Used in the usage. @@ -218,6 +213,9 @@ class MultiArg : public Arg void allowedInit(); }; +/** + * + */ template void MultiArg::allowedInit() { @@ -297,13 +295,7 @@ MultiArg::MultiArg(const std::string& flag, * */ template -MultiArg::~MultiArg() { }; - -/** - * - */ -template -const std::vector& MultiArg::getValue() { return _values; }; +const std::vector& MultiArg::getValue() { return _values; } /** * diff --git a/include/tclap/SwitchArg.h b/include/tclap/SwitchArg.h index b9402e2..a4aa708 100644 --- a/include/tclap/SwitchArg.h +++ b/include/tclap/SwitchArg.h @@ -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(); }; } diff --git a/include/tclap/UnlabeledMultiArg.h b/include/tclap/UnlabeledMultiArg.h index 3d4b7ee..033c97e 100644 --- a/include/tclap/UnlabeledMultiArg.h +++ b/include/tclap/UnlabeledMultiArg.h @@ -181,7 +181,7 @@ UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, : MultiArg("", name, desc, false, typeDesc, v) { _ignoreable = ignoreable; -}; +} template UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, diff --git a/include/tclap/ValueArg.h b/include/tclap/ValueArg.h index d763957..c7895e6 100644 --- a/include/tclap/ValueArg.h +++ b/include/tclap/ValueArg.h @@ -209,11 +209,6 @@ class ValueArg : public Arg const std::vector& 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::ValueArg(const std::string& flag, } -/** - * Destructor implementation. - */ -template -ValueArg::~ValueArg() { }; - /** * Implementation of getValue(). */ template -T& ValueArg::getValue() { return _value; }; +T& ValueArg::getValue() { return _value; } /** * Implementation of processArg(). diff --git a/include/tclap/VersionVisitor.h b/include/tclap/VersionVisitor.h index 074f286..4f5f4e3 100644 --- a/include/tclap/VersionVisitor.h +++ b/include/tclap/VersionVisitor.h @@ -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. diff --git a/include/tclap/Visitor.h b/include/tclap/Visitor.h index b6f5441..ef84aec 100644 --- a/include/tclap/Visitor.h +++ b/include/tclap/Visitor.h @@ -35,12 +35,12 @@ class Visitor /** * Constructor. Does nothing. */ - Visitor() {}; + Visitor() { } /** * Does nothing. Should be overridden by child. */ - virtual void visit() {}; + virtual void visit() { } }; } diff --git a/src/Arg.cpp b/src/Arg.cpp index 5b75691..39b2f36 100644 --- a/src/Arg.cpp +++ b/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; } diff --git a/src/SwitchArg.cpp b/src/SwitchArg.cpp index 42bc889..91618bf 100644 --- a/src/SwitchArg.cpp +++ b/src/SwitchArg.cpp @@ -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 ) {