mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-08-04 10:16:41 -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; -*-
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
/******************************************************************************
|
||||
*
|
||||
* file: Arg.h
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2003, Michael E. Smoot .
|
||||
* Copyright (c) 2004, Michael E. Smoot, Daniel Aarno .
|
||||
* All rights reverved.
|
||||
*
|
||||
*
|
||||
* See the file COPYING in the top directory of this distribution for
|
||||
* more information.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* 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
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*****************************************************************************/
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* 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
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef TCLAP_ARGUMENT_H
|
||||
@ -54,14 +54,14 @@ typedef std::istrstream istringstream;
|
||||
|
||||
namespace TCLAP {
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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
|
||||
* anything.
|
||||
* anything.
|
||||
*/
|
||||
class Arg
|
||||
{
|
||||
private:
|
||||
private:
|
||||
|
||||
/**
|
||||
* 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
|
||||
* value.
|
||||
*/
|
||||
static char& delimiterRef() { static char delim = ' '; return delim; }
|
||||
static char& delimiterRef() { static char delim = ' '; return delim; }
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
/**
|
||||
* The single char flag used to identify the argument.
|
||||
* This value (preceded by a dash {-}), can be used to identify
|
||||
* an argument on the command line. The _flag can be blank,
|
||||
* This value (preceded by a dash {-}), can be used to identify
|
||||
* an argument on the command line. The _flag can be blank,
|
||||
* 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.
|
||||
*/
|
||||
std::string _flag;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* _name does NOT include the two dashes as part of the _name. The
|
||||
* _name cannot be blank.
|
||||
@ -96,17 +96,17 @@ class Arg
|
||||
std::string _name;
|
||||
|
||||
/**
|
||||
* Description of the argument.
|
||||
* Description of the argument.
|
||||
*/
|
||||
std::string _description;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Indicating whether the argument is 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.
|
||||
*/
|
||||
std::string _requireLabel;
|
||||
@ -152,9 +152,9 @@ class Arg
|
||||
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
|
||||
* that are meant to be used. Use SwitchArg, ValueArg, MultiArg,
|
||||
* that are meant to be used. Use SwitchArg, ValueArg, MultiArg,
|
||||
* UnlabeledValueArg, or UnlabeledMultiArg instead.
|
||||
*
|
||||
* \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 v - The visitor checked by the argument. Defaults to NULL.
|
||||
*/
|
||||
Arg( const std::string& flag,
|
||||
const std::string& name,
|
||||
const std::string& desc,
|
||||
bool req,
|
||||
Arg( const std::string& flag,
|
||||
const std::string& name,
|
||||
const std::string& desc,
|
||||
bool req,
|
||||
bool valreq,
|
||||
Visitor* v = NULL );
|
||||
|
||||
@ -182,12 +182,12 @@ class Arg
|
||||
* \param argList - The list to add this to.
|
||||
*/
|
||||
virtual void addToList( std::list<Arg*>& argList ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Begin ignoring arguments since the "--" argument was specified.
|
||||
*/
|
||||
static void beginIgnoring() { ignoreRestRef() = true; }
|
||||
|
||||
|
||||
/**
|
||||
* Whether to ignore the rest.
|
||||
*/
|
||||
@ -197,25 +197,25 @@ class Arg
|
||||
* The delimiter that separates an argument flag/name from the
|
||||
* value.
|
||||
*/
|
||||
static char delimiter() { return delimiterRef(); }
|
||||
|
||||
static char delimiter() { return delimiterRef(); }
|
||||
|
||||
/**
|
||||
* 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 '-'.
|
||||
*/
|
||||
static const char flagStartChar() { return '-'; }
|
||||
|
||||
static char flagStartChar() { return '-'; }
|
||||
|
||||
/**
|
||||
* The sting that indicates the beginning of a flag. Currently "-".
|
||||
* Should be identical to flagStartChar.
|
||||
*/
|
||||
static const std::string flagStartString() { return "-"; }
|
||||
|
||||
|
||||
/**
|
||||
* The sting that indicates the beginning of a name. Currently "--".
|
||||
* Should be flagStartChar twice.
|
||||
@ -235,12 +235,12 @@ class Arg
|
||||
|
||||
/**
|
||||
* 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 args - Mutable list of strings. What is
|
||||
* \param args - Mutable list of strings. What is
|
||||
* 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 ==.
|
||||
@ -293,14 +293,14 @@ class Arg
|
||||
bool isSet() const;
|
||||
|
||||
/**
|
||||
* Indicates whether the argument can be ignored, if desired.
|
||||
* Indicates whether the argument can be ignored, if desired.
|
||||
*/
|
||||
bool isIgnoreable() const;
|
||||
|
||||
/**
|
||||
* A method that tests whether a string matches this argument.
|
||||
* 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.
|
||||
* \param s - The string to be compared to the flag/name to determine
|
||||
* whether the arg matches.
|
||||
@ -327,8 +327,8 @@ class Arg
|
||||
|
||||
/**
|
||||
* Trims a value off of the flag.
|
||||
* \param flag - The string from which the flag and value will be
|
||||
* trimmed. Contains the flag once the value has been trimmed.
|
||||
* \param flag - The string from which the flag and value will be
|
||||
* trimmed. Contains the flag once the value has been trimmed.
|
||||
* \param value - Where the value trimmed from the string will
|
||||
* be stored.
|
||||
*/
|
||||
@ -387,11 +387,11 @@ ExtractValue(T &destVal, const std::string& strVal, ValueLike vl)
|
||||
is >> destVal;
|
||||
else
|
||||
break;
|
||||
|
||||
|
||||
valuesRead++;
|
||||
}
|
||||
|
||||
if ( is.fail() )
|
||||
|
||||
if ( is.fail() )
|
||||
throw( ArgParseException("Couldn't read argument value "
|
||||
"from string '" + strVal + "'"));
|
||||
|
||||
@ -419,10 +419,10 @@ ExtractValue(T &destVal, const std::string& strVal, StringLike sl)
|
||||
//BEGIN Arg.cpp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline Arg::Arg(const std::string& flag,
|
||||
const std::string& name,
|
||||
const std::string& desc,
|
||||
bool req,
|
||||
inline Arg::Arg(const std::string& flag,
|
||||
const std::string& name,
|
||||
const std::string& desc,
|
||||
bool req,
|
||||
bool valreq,
|
||||
Visitor* v) :
|
||||
_flag(flag),
|
||||
@ -437,24 +437,24 @@ inline Arg::Arg(const std::string& flag,
|
||||
_xorSet(false),
|
||||
_acceptsMultipleValues(false)
|
||||
{
|
||||
if ( _flag.length() > 1 )
|
||||
if ( _flag.length() > 1 )
|
||||
throw(SpecificationException(
|
||||
"Argument flag can only be one character long", toString() ) );
|
||||
|
||||
if ( _name != ignoreNameString() &&
|
||||
( _flag == Arg::flagStartString() ||
|
||||
_flag == Arg::nameStartString() ||
|
||||
if ( _name != ignoreNameString() &&
|
||||
( _flag == Arg::flagStartString() ||
|
||||
_flag == Arg::nameStartString() ||
|
||||
_flag == " " ) )
|
||||
throw(SpecificationException("Argument flag cannot be either '" +
|
||||
Arg::flagStartString() + "' or '" +
|
||||
throw(SpecificationException("Argument flag cannot be either '" +
|
||||
Arg::flagStartString() + "' or '" +
|
||||
Arg::nameStartString() + "' or a space.",
|
||||
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.find( " ", 0 ) != std::string::npos ) )
|
||||
throw(SpecificationException("Argument name begin with either '" +
|
||||
Arg::flagStartString() + "' or '" +
|
||||
throw(SpecificationException("Argument name begin with either '" +
|
||||
Arg::flagStartString() + "' or '" +
|
||||
Arg::nameStartString() + "' or space.",
|
||||
toString() ) );
|
||||
|
||||
@ -490,7 +490,7 @@ inline std::string Arg::longID( const std::string& valueId ) const
|
||||
|
||||
if ( _valueRequired )
|
||||
id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
|
||||
|
||||
|
||||
id += ", ";
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ inline std::string Arg::longID( const std::string& valueId ) const
|
||||
|
||||
if ( _valueRequired )
|
||||
id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">";
|
||||
|
||||
|
||||
return id;
|
||||
|
||||
}
|
||||
@ -511,7 +511,7 @@ inline bool Arg::operator==(const Arg& a) const
|
||||
return false;
|
||||
}
|
||||
|
||||
inline std::string Arg::getDescription() const
|
||||
inline std::string Arg::getDescription() const
|
||||
{
|
||||
std::string desc = "";
|
||||
if ( _required )
|
||||
@ -521,19 +521,19 @@ inline std::string Arg::getDescription() const
|
||||
// desc += "(value required) ";
|
||||
|
||||
desc += _description;
|
||||
return desc;
|
||||
return desc;
|
||||
}
|
||||
|
||||
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::isValueRequired() const { return _valueRequired; }
|
||||
|
||||
inline bool Arg::isSet() const
|
||||
{
|
||||
inline bool Arg::isSet() const
|
||||
{
|
||||
if ( _alreadySet && !_xorSet )
|
||||
return true;
|
||||
else
|
||||
@ -542,8 +542,8 @@ inline bool Arg::isSet() const
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user