fixed all effective c++ warnings based on patch from Andrew Marlow

This commit is contained in:
mes5k 2011-01-02 18:50:47 +00:00
parent 55963f2d3e
commit e9dfb0394b
10 changed files with 64 additions and 6 deletions

View File

@ -65,6 +65,12 @@ class Arg
{ {
private: private:
/**
* Prevent accidental copying
*/
Arg(const Arg& rhs);
Arg& operator=(const Arg& rhs);
/** /**
* Indicates whether the rest of the arguments should be ignored. * Indicates whether the rest of the arguments should be ignored.
*/ */

View File

@ -37,6 +37,7 @@ namespace TCLAP {
*/ */
struct ValueLike { struct ValueLike {
typedef ValueLike ValueCategory; typedef ValueLike ValueCategory;
virtual ~ValueLike() {}
}; };
/** /**
@ -44,7 +45,9 @@ struct ValueLike {
* operator=(string). Usefull if the value type contains spaces which * operator=(string). Usefull if the value type contains spaces which
* will be broken up into individual tokens by operator>>. * 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 * A class can inherit from this object to make it have string like
@ -53,6 +56,7 @@ struct StringLike {};
*/ */
struct StringLikeTrait { struct StringLikeTrait {
typedef StringLike ValueCategory; typedef StringLike ValueCategory;
virtual ~StringLikeTrait() {}
}; };
/** /**
@ -62,6 +66,7 @@ struct StringLikeTrait {
*/ */
struct ValueLikeTrait { struct ValueLikeTrait {
typedef ValueLike ValueCategory; typedef ValueLike ValueCategory;
virtual ~ValueLikeTrait() {}
}; };
/** /**
@ -73,6 +78,7 @@ struct ValueLikeTrait {
template<typename T> template<typename T>
struct ArgTraits { struct ArgTraits {
typedef typename T::ValueCategory ValueCategory; typedef typename T::ValueCategory ValueCategory;
virtual ~ArgTraits() {}
//typedef ValueLike ValueCategory; //typedef ValueLike ValueCategory;
}; };

View File

@ -159,6 +159,12 @@ class CmdLine : public CmdLineInterface
private: private:
/**
* Prevent accidental copying.
*/
CmdLine(const CmdLine& rhs);
CmdLine& operator=(const CmdLine& rhs);
/** /**
* Encapsulates the code common to the constructors * Encapsulates the code common to the constructors
* (which is all of it). * (which is all of it).
@ -318,11 +324,17 @@ inline CmdLine::CmdLine(const std::string& m,
char delim, char delim,
const std::string& v, const std::string& v,
bool help ) bool help )
: _progName("not_set_yet"), :
_argList(std::list<Arg*>()),
_progName("not_set_yet"),
_message(m), _message(m),
_version(v), _version(v),
_numRequired(0), _numRequired(0),
_delimiter(delim), _delimiter(delim),
_xorHandler(XorHandler()),
_argDeleteOnExitList(std::list<Arg*>()),
_visitorDeleteOnExitList(std::list<Visitor*>()),
_output(0),
_handleExceptions(true), _handleExceptions(true),
_userSetOutput(false), _userSetOutput(false),
_helpAndVersion(help) _helpAndVersion(help)

View File

@ -34,6 +34,13 @@ namespace TCLAP {
*/ */
class HelpVisitor: public Visitor class HelpVisitor: public Visitor
{ {
private:
/**
* Prevent accidental copying.
*/
HelpVisitor(const HelpVisitor& rhs);
HelpVisitor& operator=(const HelpVisitor& rhs);
protected: protected:
/** /**

View File

@ -221,6 +221,13 @@ public:
virtual void reset(); virtual void reset();
private:
/**
* Prevent accidental copying
*/
MultiArg<T>(const MultiArg<T>& rhs);
MultiArg<T>& operator=(const MultiArg<T>& rhs);
}; };
template<class T> template<class T>
@ -229,8 +236,9 @@ MultiArg<T>::MultiArg(const std::string& flag,
const std::string& desc, const std::string& desc,
bool req, bool req,
const std::string& typeDesc, const std::string& typeDesc,
Visitor* v) Visitor* v) :
: Arg( flag, name, desc, req, true, v ), Arg( flag, name, desc, req, true, v ),
_values(std::vector<T>()),
_typeDesc( typeDesc ), _typeDesc( typeDesc ),
_constraint( NULL ), _constraint( NULL ),
_allowMore(false) _allowMore(false)
@ -247,6 +255,7 @@ MultiArg<T>::MultiArg(const std::string& flag,
CmdLineInterface& parser, CmdLineInterface& parser,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_values(std::vector<T>()),
_typeDesc( typeDesc ), _typeDesc( typeDesc ),
_constraint( NULL ), _constraint( NULL ),
_allowMore(false) _allowMore(false)
@ -266,6 +275,7 @@ MultiArg<T>::MultiArg(const std::string& flag,
Constraint<T>* constraint, Constraint<T>* constraint,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_values(std::vector<T>()),
_typeDesc( constraint->shortID() ), _typeDesc( constraint->shortID() ),
_constraint( constraint ), _constraint( constraint ),
_allowMore(false) _allowMore(false)
@ -282,6 +292,7 @@ MultiArg<T>::MultiArg(const std::string& flag,
CmdLineInterface& parser, CmdLineInterface& parser,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_values(std::vector<T>()),
_typeDesc( constraint->shortID() ), _typeDesc( constraint->shortID() ),
_constraint( constraint ), _constraint( constraint ),
_allowMore(false) _allowMore(false)

View File

@ -236,6 +236,12 @@ class ValueArg : public Arg
virtual void reset() ; virtual void reset() ;
private:
/**
* Prevent accidental copying
*/
ValueArg<T>(const ValueArg<T>& rhs);
ValueArg<T>& operator=(const ValueArg<T>& rhs);
}; };

View File

@ -97,7 +97,8 @@ class ValuesConstraint : public Constraint<T>
template<class T> template<class T>
ValuesConstraint<T>::ValuesConstraint(std::vector<T>& allowed) ValuesConstraint<T>::ValuesConstraint(std::vector<T>& allowed)
: _allowed(allowed) : _allowed(allowed),
_typeDesc("")
{ {
for ( unsigned int i = 0; i < _allowed.size(); i++ ) for ( unsigned int i = 0; i < _allowed.size(); i++ )
{ {

View File

@ -36,6 +36,13 @@ namespace TCLAP {
*/ */
class VersionVisitor: public Visitor class VersionVisitor: public Visitor
{ {
private:
/**
* Prevent accidental copying
*/
VersionVisitor(const VersionVisitor& rhs);
VersionVisitor& operator=(const VersionVisitor& rhs);
protected: protected:
/** /**

View File

@ -49,7 +49,7 @@ class XorHandler
/** /**
* Constructor. Does nothing. * Constructor. Does nothing.
*/ */
XorHandler( ) {} XorHandler( ) : _orList(std::vector< std::vector<Arg*> >()) {}
/** /**
* Add a list of Arg*'s that will be orred together. * Add a list of Arg*'s that will be orred together.

View File

@ -84,6 +84,8 @@ class ZshCompletionOutput : public CmdLineOutput
}; };
ZshCompletionOutput::ZshCompletionOutput() ZshCompletionOutput::ZshCompletionOutput()
: common(std::map<std::string, std::string>()),
theDelimiter('=')
{ {
common["host"] = "_hosts"; common["host"] = "_hosts";
common["hostname"] = "_hosts"; common["hostname"] = "_hosts";