mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-08-04 02:06:29 -04:00
Silence some compiler warnings. The const on return-by-value is ignored.
This commit is contained in:
parent
3431fcfd78
commit
8769a07cee
@ -1,25 +1,25 @@
|
|||||||
// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
|
// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* file: Arg.h
|
* file: Arg.h
|
||||||
*
|
*
|
||||||
* Copyright (c) 2003, Michael E. Smoot .
|
* Copyright (c) 2003, Michael E. Smoot .
|
||||||
* Copyright (c) 2004, Michael E. Smoot, Daniel Aarno .
|
* Copyright (c) 2004, Michael E. Smoot, Daniel Aarno .
|
||||||
* All rights reverved.
|
* All rights reverved.
|
||||||
*
|
*
|
||||||
* See the file COPYING in the top directory of this distribution for
|
* See the file COPYING in the top directory of this distribution for
|
||||||
* more information.
|
* more information.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef TCLAP_ARGUMENT_H
|
#ifndef TCLAP_ARGUMENT_H
|
||||||
@ -54,14 +54,14 @@ typedef std::istrstream istringstream;
|
|||||||
|
|
||||||
namespace TCLAP {
|
namespace TCLAP {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A virtual base class that defines the essential data for all arguments.
|
* A virtual base class that defines the essential data for all arguments.
|
||||||
* This class, or one of its existing children, must be subclassed to do
|
* This class, or one of its existing children, must be subclassed to do
|
||||||
* anything.
|
* anything.
|
||||||
*/
|
*/
|
||||||
class Arg
|
class Arg
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the rest of the arguments should be ignored.
|
* Indicates whether the rest of the arguments should be ignored.
|
||||||
@ -72,23 +72,23 @@ class Arg
|
|||||||
* The delimiter that separates an argument flag/name from the
|
* The delimiter that separates an argument flag/name from the
|
||||||
* value.
|
* value.
|
||||||
*/
|
*/
|
||||||
static char& delimiterRef() { static char delim = ' '; return delim; }
|
static char& delimiterRef() { static char delim = ' '; return delim; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The single char flag used to identify the argument.
|
* The single char flag used to identify the argument.
|
||||||
* This value (preceded by a dash {-}), can be used to identify
|
* This value (preceded by a dash {-}), can be used to identify
|
||||||
* an argument on the command line. The _flag can be blank,
|
* an argument on the command line. The _flag can be blank,
|
||||||
* in fact this is how unlabeled args work. Unlabeled args must
|
* in fact this is how unlabeled args work. Unlabeled args must
|
||||||
* override appropriate functions to get correct handling. Note
|
* override appropriate functions to get correct handling. Note
|
||||||
* that the _flag does NOT include the dash as part of the flag.
|
* that the _flag does NOT include the dash as part of the flag.
|
||||||
*/
|
*/
|
||||||
std::string _flag;
|
std::string _flag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single work namd indentifying the argument.
|
* A single work namd indentifying the argument.
|
||||||
* This value (preceded by two dashed {--}) can also be used
|
* This value (preceded by two dashed {--}) can also be used
|
||||||
* to identify an argument on the command line. Note that the
|
* to identify an argument on the command line. Note that the
|
||||||
* _name does NOT include the two dashes as part of the _name. The
|
* _name does NOT include the two dashes as part of the _name. The
|
||||||
* _name cannot be blank.
|
* _name cannot be blank.
|
||||||
@ -96,17 +96,17 @@ class Arg
|
|||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of the argument.
|
* Description of the argument.
|
||||||
*/
|
*/
|
||||||
std::string _description;
|
std::string _description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicating whether the argument is required.
|
* Indicating whether the argument is required.
|
||||||
*/
|
*/
|
||||||
bool _required;
|
bool _required;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label to be used in usage description. Normally set to
|
* Label to be used in usage description. Normally set to
|
||||||
* "required", but can be changed when necessary.
|
* "required", but can be changed when necessary.
|
||||||
*/
|
*/
|
||||||
std::string _requireLabel;
|
std::string _requireLabel;
|
||||||
@ -152,9 +152,9 @@ class Arg
|
|||||||
void _checkWithVisitor() const;
|
void _checkWithVisitor() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary constructor. YOU (yes you) should NEVER construct an Arg
|
* Primary constructor. YOU (yes you) should NEVER construct an Arg
|
||||||
* directly, this is a base class that is extended by various children
|
* directly, this is a base class that is extended by various children
|
||||||
* that are meant to be used. Use SwitchArg, ValueArg, MultiArg,
|
* that are meant to be used. Use SwitchArg, ValueArg, MultiArg,
|
||||||
* UnlabeledValueArg, or UnlabeledMultiArg instead.
|
* UnlabeledValueArg, or UnlabeledMultiArg instead.
|
||||||
*
|
*
|
||||||
* \param flag - The flag identifying the argument.
|
* \param flag - The flag identifying the argument.
|
||||||
@ -164,10 +164,10 @@ class Arg
|
|||||||
* \param valreq - Whether the a value is required for the argument.
|
* \param valreq - Whether the a value is required for the argument.
|
||||||
* \param v - The visitor checked by the argument. Defaults to NULL.
|
* \param v - The visitor checked by the argument. Defaults to NULL.
|
||||||
*/
|
*/
|
||||||
Arg( const std::string& flag,
|
Arg( const std::string& flag,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& desc,
|
const std::string& desc,
|
||||||
bool req,
|
bool req,
|
||||||
bool valreq,
|
bool valreq,
|
||||||
Visitor* v = NULL );
|
Visitor* v = NULL );
|
||||||
|
|
||||||
@ -182,12 +182,12 @@ class Arg
|
|||||||
* \param argList - The list to add this to.
|
* \param argList - The list to add this to.
|
||||||
*/
|
*/
|
||||||
virtual void addToList( std::list<Arg*>& argList ) const;
|
virtual void addToList( std::list<Arg*>& argList ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begin ignoring arguments since the "--" argument was specified.
|
* Begin ignoring arguments since the "--" argument was specified.
|
||||||
*/
|
*/
|
||||||
static void beginIgnoring() { ignoreRestRef() = true; }
|
static void beginIgnoring() { ignoreRestRef() = true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to ignore the rest.
|
* Whether to ignore the rest.
|
||||||
*/
|
*/
|
||||||
@ -197,25 +197,25 @@ class Arg
|
|||||||
* The delimiter that separates an argument flag/name from the
|
* The delimiter that separates an argument flag/name from the
|
||||||
* value.
|
* value.
|
||||||
*/
|
*/
|
||||||
static char delimiter() { return delimiterRef(); }
|
static char delimiter() { return delimiterRef(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The char used as a place holder when SwitchArgs are combined.
|
* The char used as a place holder when SwitchArgs are combined.
|
||||||
* Currently set to the bell char (ASCII 7).
|
* Currently set to the bell char (ASCII 7).
|
||||||
*/
|
*/
|
||||||
static const char blankChar() { return (char)7; }
|
static char blankChar() { return (char)7; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The char that indicates the beginning of a flag. Currently '-'.
|
* The char that indicates the beginning of a flag. Currently '-'.
|
||||||
*/
|
*/
|
||||||
static const char flagStartChar() { return '-'; }
|
static char flagStartChar() { return '-'; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sting that indicates the beginning of a flag. Currently "-".
|
* The sting that indicates the beginning of a flag. Currently "-".
|
||||||
* Should be identical to flagStartChar.
|
* Should be identical to flagStartChar.
|
||||||
*/
|
*/
|
||||||
static const std::string flagStartString() { return "-"; }
|
static const std::string flagStartString() { return "-"; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sting that indicates the beginning of a name. Currently "--".
|
* The sting that indicates the beginning of a name. Currently "--".
|
||||||
* Should be flagStartChar twice.
|
* Should be flagStartChar twice.
|
||||||
@ -235,12 +235,12 @@ class Arg
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure virtual method meant to handle the parsing and value assignment
|
* Pure virtual method meant to handle the parsing and value assignment
|
||||||
* of the string on the command line.
|
* of the string on the command line.
|
||||||
* \param i - Pointer the the current argument in the list.
|
* \param i - Pointer the the current argument in the list.
|
||||||
* \param args - Mutable list of strings. What is
|
* \param args - Mutable list of strings. What is
|
||||||
* passed in from main.
|
* passed in from main.
|
||||||
*/
|
*/
|
||||||
virtual bool processArg(int *i, std::vector<std::string>& args) = 0;
|
virtual bool processArg(int *i, std::vector<std::string>& args) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operator ==.
|
* Operator ==.
|
||||||
@ -293,14 +293,14 @@ class Arg
|
|||||||
bool isSet() const;
|
bool isSet() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the argument can be ignored, if desired.
|
* Indicates whether the argument can be ignored, if desired.
|
||||||
*/
|
*/
|
||||||
bool isIgnoreable() const;
|
bool isIgnoreable() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method that tests whether a string matches this argument.
|
* A method that tests whether a string matches this argument.
|
||||||
* This is generally called by the processArg() method. This
|
* This is generally called by the processArg() method. This
|
||||||
* method could be re-implemented by a child to change how
|
* method could be re-implemented by a child to change how
|
||||||
* arguments are specified on the command line.
|
* arguments are specified on the command line.
|
||||||
* \param s - The string to be compared to the flag/name to determine
|
* \param s - The string to be compared to the flag/name to determine
|
||||||
* whether the arg matches.
|
* whether the arg matches.
|
||||||
@ -327,8 +327,8 @@ class Arg
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Trims a value off of the flag.
|
* Trims a value off of the flag.
|
||||||
* \param flag - The string from which the flag and value will be
|
* \param flag - The string from which the flag and value will be
|
||||||
* trimmed. Contains the flag once the value has been trimmed.
|
* trimmed. Contains the flag once the value has been trimmed.
|
||||||
* \param value - Where the value trimmed from the string will
|
* \param value - Where the value trimmed from the string will
|
||||||
* be stored.
|
* be stored.
|
||||||
*/
|
*/
|
||||||
@ -387,11 +387,11 @@ ExtractValue(T &destVal, const std::string& strVal, ValueLike vl)
|
|||||||
is >> destVal;
|
is >> destVal;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
valuesRead++;
|
valuesRead++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is.fail() )
|
if ( is.fail() )
|
||||||
throw( ArgParseException("Couldn't read argument value "
|
throw( ArgParseException("Couldn't read argument value "
|
||||||
"from string '" + strVal + "'"));
|
"from string '" + strVal + "'"));
|
||||||
|
|
||||||
@ -419,10 +419,10 @@ ExtractValue(T &destVal, const std::string& strVal, StringLike sl)
|
|||||||
//BEGIN Arg.cpp
|
//BEGIN Arg.cpp
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline Arg::Arg(const std::string& flag,
|
inline Arg::Arg(const std::string& flag,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& desc,
|
const std::string& desc,
|
||||||
bool req,
|
bool req,
|
||||||
bool valreq,
|
bool valreq,
|
||||||
Visitor* v) :
|
Visitor* v) :
|
||||||
_flag(flag),
|
_flag(flag),
|
||||||
@ -437,24 +437,24 @@ inline Arg::Arg(const std::string& flag,
|
|||||||
_xorSet(false),
|
_xorSet(false),
|
||||||
_acceptsMultipleValues(false)
|
_acceptsMultipleValues(false)
|
||||||
{
|
{
|
||||||
if ( _flag.length() > 1 )
|
if ( _flag.length() > 1 )
|
||||||
throw(SpecificationException(
|
throw(SpecificationException(
|
||||||
"Argument flag can only be one character long", toString() ) );
|
"Argument flag can only be one character long", toString() ) );
|
||||||
|
|
||||||
if ( _name != ignoreNameString() &&
|
if ( _name != ignoreNameString() &&
|
||||||
( _flag == Arg::flagStartString() ||
|
( _flag == Arg::flagStartString() ||
|
||||||
_flag == Arg::nameStartString() ||
|
_flag == Arg::nameStartString() ||
|
||||||
_flag == " " ) )
|
_flag == " " ) )
|
||||||
throw(SpecificationException("Argument flag cannot be either '" +
|
throw(SpecificationException("Argument flag cannot be either '" +
|
||||||
Arg::flagStartString() + "' or '" +
|
Arg::flagStartString() + "' or '" +
|
||||||
Arg::nameStartString() + "' or a space.",
|
Arg::nameStartString() + "' or a space.",
|
||||||
toString() ) );
|
toString() ) );
|
||||||
|
|
||||||
if ( ( _name.substr( 0, Arg::flagStartString().length() ) == Arg::flagStartString() ) ||
|
if ( ( _name.substr( 0, Arg::flagStartString().length() ) == Arg::flagStartString() ) ||
|
||||||
( _name.substr( 0, Arg::nameStartString().length() ) == Arg::nameStartString() ) ||
|
( _name.substr( 0, Arg::nameStartString().length() ) == Arg::nameStartString() ) ||
|
||||||
( _name.find( " ", 0 ) != std::string::npos ) )
|
( _name.find( " ", 0 ) != std::string::npos ) )
|
||||||
throw(SpecificationException("Argument name begin with either '" +
|
throw(SpecificationException("Argument name begin with either '" +
|
||||||
Arg::flagStartString() + "' or '" +
|
Arg::flagStartString() + "' or '" +
|
||||||
Arg::nameStartString() + "' or space.",
|
Arg::nameStartString() + "' or space.",
|
||||||
toString() ) );
|
toString() ) );
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ inline std::string Arg::longID( const std::string& valueId ) const
|
|||||||
|
|
||||||
if ( _valueRequired )
|
if ( _valueRequired )
|
||||||
id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
|
id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
|
||||||
|
|
||||||
id += ", ";
|
id += ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,7 +498,7 @@ inline std::string Arg::longID( const std::string& valueId ) const
|
|||||||
|
|
||||||
if ( _valueRequired )
|
if ( _valueRequired )
|
||||||
id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
|
id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -511,7 +511,7 @@ inline bool Arg::operator==(const Arg& a) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string Arg::getDescription() const
|
inline std::string Arg::getDescription() const
|
||||||
{
|
{
|
||||||
std::string desc = "";
|
std::string desc = "";
|
||||||
if ( _required )
|
if ( _required )
|
||||||
@ -521,19 +521,19 @@ inline std::string Arg::getDescription() const
|
|||||||
// desc += "(value required) ";
|
// desc += "(value required) ";
|
||||||
|
|
||||||
desc += _description;
|
desc += _description;
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& Arg::getFlag() const { return _flag; }
|
inline const std::string& Arg::getFlag() const { return _flag; }
|
||||||
|
|
||||||
inline const std::string& Arg::getName() const { return _name; }
|
inline const std::string& Arg::getName() const { return _name; }
|
||||||
|
|
||||||
inline bool Arg::isRequired() const { return _required; }
|
inline bool Arg::isRequired() const { return _required; }
|
||||||
|
|
||||||
inline bool Arg::isValueRequired() const { return _valueRequired; }
|
inline bool Arg::isValueRequired() const { return _valueRequired; }
|
||||||
|
|
||||||
inline bool Arg::isSet() const
|
inline bool Arg::isSet() const
|
||||||
{
|
{
|
||||||
if ( _alreadySet && !_xorSet )
|
if ( _alreadySet && !_xorSet )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -542,8 +542,8 @@ inline bool Arg::isSet() const
|
|||||||
|
|
||||||
inline bool Arg::isIgnoreable() const { return _ignoreable; }
|
inline bool Arg::isIgnoreable() const { return _ignoreable; }
|
||||||
|
|
||||||
inline void Arg::setRequireLabel( const std::string& s)
|
inline void Arg::setRequireLabel( const std::string& s)
|
||||||
{
|
{
|
||||||
_requireLabel = s;
|
_requireLabel = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user