From e9dfb0394b4bfde4a7462b52a8130b71a4425c9f Mon Sep 17 00:00:00 2001 From: mes5k Date: Sun, 2 Jan 2011 18:50:47 +0000 Subject: [PATCH] fixed all effective c++ warnings based on patch from Andrew Marlow --- include/tclap/Arg.h | 6 ++++++ include/tclap/ArgTraits.h | 8 +++++++- include/tclap/CmdLine.h | 14 +++++++++++++- include/tclap/HelpVisitor.h | 7 +++++++ include/tclap/MultiArg.h | 15 +++++++++++++-- include/tclap/ValueArg.h | 6 ++++++ include/tclap/ValuesConstraint.h | 3 ++- include/tclap/VersionVisitor.h | 7 +++++++ include/tclap/XorHandler.h | 2 +- include/tclap/ZshCompletionOutput.h | 2 ++ 10 files changed, 64 insertions(+), 6 deletions(-) diff --git a/include/tclap/Arg.h b/include/tclap/Arg.h index 3d44c85..049c04f 100644 --- a/include/tclap/Arg.h +++ b/include/tclap/Arg.h @@ -65,6 +65,12 @@ class Arg { private: + /** + * Prevent accidental copying + */ + Arg(const Arg& rhs); + Arg& operator=(const Arg& rhs); + /** * Indicates whether the rest of the arguments should be ignored. */ diff --git a/include/tclap/ArgTraits.h b/include/tclap/ArgTraits.h index a89ed12..12f6180 100644 --- a/include/tclap/ArgTraits.h +++ b/include/tclap/ArgTraits.h @@ -37,6 +37,7 @@ namespace TCLAP { */ struct ValueLike { typedef ValueLike ValueCategory; + virtual ~ValueLike() {} }; /** @@ -44,7 +45,9 @@ struct ValueLike { * operator=(string). Usefull if the value type contains spaces which * will be broken up into individual tokens by operator>>. */ -struct StringLike {}; +struct StringLike { + virtual ~StringLike() {} +}; /** * A class can inherit from this object to make it have string like @@ -53,6 +56,7 @@ struct StringLike {}; */ struct StringLikeTrait { typedef StringLike ValueCategory; + virtual ~StringLikeTrait() {} }; /** @@ -62,6 +66,7 @@ struct StringLikeTrait { */ struct ValueLikeTrait { typedef ValueLike ValueCategory; + virtual ~ValueLikeTrait() {} }; /** @@ -73,6 +78,7 @@ struct ValueLikeTrait { template struct ArgTraits { typedef typename T::ValueCategory ValueCategory; + virtual ~ArgTraits() {} //typedef ValueLike ValueCategory; }; diff --git a/include/tclap/CmdLine.h b/include/tclap/CmdLine.h index 90d0e65..18e88b2 100644 --- a/include/tclap/CmdLine.h +++ b/include/tclap/CmdLine.h @@ -159,6 +159,12 @@ class CmdLine : public CmdLineInterface private: + /** + * Prevent accidental copying. + */ + CmdLine(const CmdLine& rhs); + CmdLine& operator=(const CmdLine& rhs); + /** * Encapsulates the code common to the constructors * (which is all of it). @@ -318,11 +324,17 @@ inline CmdLine::CmdLine(const std::string& m, char delim, const std::string& v, bool help ) -: _progName("not_set_yet"), + : + _argList(std::list()), + _progName("not_set_yet"), _message(m), _version(v), _numRequired(0), _delimiter(delim), + _xorHandler(XorHandler()), + _argDeleteOnExitList(std::list()), + _visitorDeleteOnExitList(std::list()), + _output(0), _handleExceptions(true), _userSetOutput(false), _helpAndVersion(help) diff --git a/include/tclap/HelpVisitor.h b/include/tclap/HelpVisitor.h index 2cdb997..cc3bd07 100644 --- a/include/tclap/HelpVisitor.h +++ b/include/tclap/HelpVisitor.h @@ -34,6 +34,13 @@ namespace TCLAP { */ class HelpVisitor: public Visitor { + private: + /** + * Prevent accidental copying. + */ + HelpVisitor(const HelpVisitor& rhs); + HelpVisitor& operator=(const HelpVisitor& rhs); + protected: /** diff --git a/include/tclap/MultiArg.h b/include/tclap/MultiArg.h index 460e5cb..34bb2d7 100644 --- a/include/tclap/MultiArg.h +++ b/include/tclap/MultiArg.h @@ -221,6 +221,13 @@ public: virtual void reset(); +private: + /** + * Prevent accidental copying + */ + MultiArg(const MultiArg& rhs); + MultiArg& operator=(const MultiArg& rhs); + }; template @@ -229,8 +236,9 @@ MultiArg::MultiArg(const std::string& flag, const std::string& desc, bool req, const std::string& typeDesc, - Visitor* v) -: Arg( flag, name, desc, req, true, v ), + Visitor* v) : + Arg( flag, name, desc, req, true, v ), + _values(std::vector()), _typeDesc( typeDesc ), _constraint( NULL ), _allowMore(false) @@ -247,6 +255,7 @@ MultiArg::MultiArg(const std::string& flag, CmdLineInterface& parser, Visitor* v) : Arg( flag, name, desc, req, true, v ), + _values(std::vector()), _typeDesc( typeDesc ), _constraint( NULL ), _allowMore(false) @@ -266,6 +275,7 @@ MultiArg::MultiArg(const std::string& flag, Constraint* constraint, Visitor* v) : Arg( flag, name, desc, req, true, v ), + _values(std::vector()), _typeDesc( constraint->shortID() ), _constraint( constraint ), _allowMore(false) @@ -282,6 +292,7 @@ MultiArg::MultiArg(const std::string& flag, CmdLineInterface& parser, Visitor* v) : Arg( flag, name, desc, req, true, v ), + _values(std::vector()), _typeDesc( constraint->shortID() ), _constraint( constraint ), _allowMore(false) diff --git a/include/tclap/ValueArg.h b/include/tclap/ValueArg.h index dbaf3bf..7ac2952 100644 --- a/include/tclap/ValueArg.h +++ b/include/tclap/ValueArg.h @@ -236,6 +236,12 @@ class ValueArg : public Arg virtual void reset() ; +private: + /** + * Prevent accidental copying + */ + ValueArg(const ValueArg& rhs); + ValueArg& operator=(const ValueArg& rhs); }; diff --git a/include/tclap/ValuesConstraint.h b/include/tclap/ValuesConstraint.h index 235939c..cb41f64 100644 --- a/include/tclap/ValuesConstraint.h +++ b/include/tclap/ValuesConstraint.h @@ -97,7 +97,8 @@ class ValuesConstraint : public Constraint template ValuesConstraint::ValuesConstraint(std::vector& allowed) -: _allowed(allowed) +: _allowed(allowed), + _typeDesc("") { for ( unsigned int i = 0; i < _allowed.size(); i++ ) { diff --git a/include/tclap/VersionVisitor.h b/include/tclap/VersionVisitor.h index 3e55921..c110d4f 100644 --- a/include/tclap/VersionVisitor.h +++ b/include/tclap/VersionVisitor.h @@ -36,6 +36,13 @@ namespace TCLAP { */ class VersionVisitor: public Visitor { + private: + /** + * Prevent accidental copying + */ + VersionVisitor(const VersionVisitor& rhs); + VersionVisitor& operator=(const VersionVisitor& rhs); + protected: /** diff --git a/include/tclap/XorHandler.h b/include/tclap/XorHandler.h index af68943..7d5cfc1 100644 --- a/include/tclap/XorHandler.h +++ b/include/tclap/XorHandler.h @@ -49,7 +49,7 @@ class XorHandler /** * Constructor. Does nothing. */ - XorHandler( ) {} + XorHandler( ) : _orList(std::vector< std::vector >()) {} /** * Add a list of Arg*'s that will be orred together. diff --git a/include/tclap/ZshCompletionOutput.h b/include/tclap/ZshCompletionOutput.h index 1ed4381..34f159c 100644 --- a/include/tclap/ZshCompletionOutput.h +++ b/include/tclap/ZshCompletionOutput.h @@ -84,6 +84,8 @@ class ZshCompletionOutput : public CmdLineOutput }; ZshCompletionOutput::ZshCompletionOutput() +: common(std::map()), + theDelimiter('=') { common["host"] = "_hosts"; common["hostname"] = "_hosts";