changed namespace std handling

This commit is contained in:
mes5k 2004-09-07 18:24:48 +00:00
parent 4e311b2219
commit a01538d7ba
21 changed files with 188 additions and 192 deletions

View File

@ -2,6 +2,7 @@
#include <tclap/CmdLine.h> #include <tclap/CmdLine.h>
using namespace TCLAP; using namespace TCLAP;
using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
using namespace TCLAP; using namespace TCLAP;
using namespace std;
int _intTest; int _intTest;
float _floatTest; float _floatTest;

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
using namespace TCLAP; using namespace TCLAP;
using namespace std;
bool _boolTestB; bool _boolTestB;
string _stringTest; string _stringTest;

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
using namespace TCLAP; using namespace TCLAP;
using namespace std;
bool _boolTestB; bool _boolTestB;
bool _boolTestA; bool _boolTestA;

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
using namespace TCLAP; using namespace TCLAP;
using namespace std;
string _orTest; string _orTest;
string _orTest2; string _orTest2;

View File

@ -2,6 +2,7 @@
#include <tclap/CmdLine.h> #include <tclap/CmdLine.h>
using namespace TCLAP; using namespace TCLAP;
using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

View File

@ -30,8 +30,6 @@
#include <tclap/ArgException.h> #include <tclap/ArgException.h>
#include <tclap/Visitor.h> #include <tclap/Visitor.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -66,7 +64,7 @@ class Arg
* 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.
*/ */
string _flag; std::string _flag;
/** /**
* A single work namd indentifying the argument. * A single work namd indentifying the argument.
@ -75,12 +73,12 @@ class Arg
* _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.
*/ */
string _name; std::string _name;
/** /**
* Description of the argument. * Description of the argument.
*/ */
string _description; std::string _description;
/** /**
* Indicating whether the argument is required. * Indicating whether the argument is required.
@ -91,7 +89,7 @@ class Arg
* 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.
*/ */
string _requireLabel; std::string _requireLabel;
/** /**
* Indicates whether a value is required for the argument. * Indicates whether a value is required for the argument.
@ -137,7 +135,7 @@ class Arg
* Adds this to the specified list of Args. * Adds this to the specified list of Args.
* \param argList - The list to add this to. * \param argList - The list to add this to.
*/ */
virtual void addToList( 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.
@ -165,18 +163,18 @@ class Arg
* 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 string flagStartString; static const std::string flagStartString;
/** /**
* 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.
*/ */
static const string nameStartString; static const std::string nameStartString;
/** /**
* The name used to identify the ignore rest argument. * The name used to identify the ignore rest argument.
*/ */
static const string ignoreNameString; static const std::string ignoreNameString;
/** /**
* Sets the delimiter for all arguments. * Sets the delimiter for all arguments.
@ -193,9 +191,9 @@ 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 string& flag, Arg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
bool valreq, bool valreq,
Visitor* v = NULL); Visitor* v = NULL);
@ -235,7 +233,7 @@ class Arg
* \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, vector<string>& args); virtual bool processArg(int *i, std::vector<std::string>& args);
/** /**
@ -248,17 +246,17 @@ class Arg
/** /**
* Returns the argument flag. * Returns the argument flag.
*/ */
const string& getFlag() const; const std::string& getFlag() const;
/** /**
* Returns the argument name. * Returns the argument name.
*/ */
const string& getName() const; const std::string& getName() const;
/** /**
* Returns the argument description. * Returns the argument description.
*/ */
string getDescription() const; std::string getDescription() const;
/** /**
* Indicates whether the argument is required. * Indicates whether the argument is required.
@ -301,25 +299,25 @@ class Arg
* \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.
*/ */
virtual bool argMatches( const string& s ) const; virtual bool argMatches( const std::string& s ) const;
/** /**
* Returns a simple string representation of the argument. * Returns a simple string representation of the argument.
* Primarily for debugging. * Primarily for debugging.
*/ */
virtual string toString() const; virtual std::string toString() const;
/** /**
* Returns a short ID for the usage. * Returns a short ID for the usage.
* \param valueId - The value used in the id. * \param valueId - The value used in the id.
*/ */
virtual string shortID( const string& valueId = "val" ) const; virtual std::string shortID( const std::string& valueId = "val" ) const;
/** /**
* Returns a long ID for the usage. * Returns a long ID for the usage.
* \param valueId - The value used in the id. * \param valueId - The value used in the id.
*/ */
virtual string longID( const string& valueId = "val" ) const; virtual std::string longID( const std::string& valueId = "val" ) const;
/** /**
* Trims a value off of the flag. * Trims a value off of the flag.
@ -328,7 +326,7 @@ class Arg
* \param value - Where the value trimmed from the string will * \param value - Where the value trimmed from the string will
* be stored. * be stored.
*/ */
virtual void trimFlag( string& flag, string& value ) const; virtual void trimFlag( std::string& flag, std::string& value ) const;
/** /**
* Checks whether a given string has blank chars, indicating that * Checks whether a given string has blank chars, indicating that
@ -336,22 +334,22 @@ class Arg
* false. * false.
* \param s - string to be checked. * \param s - string to be checked.
*/ */
bool _hasBlanks( const string& s ) const; bool _hasBlanks( const std::string& s ) const;
/** /**
* Sets the requireLabel. Used by XorHandler. You shouldn't ever * Sets the requireLabel. Used by XorHandler. You shouldn't ever
* use this. * use this.
* \param s - Set the requireLabel to this value. * \param s - Set the requireLabel to this value.
*/ */
void setRequireLabel( const string& s ); void setRequireLabel( const std::string& s );
}; };
/** /**
* Typedef of a list iterator. * Typedef of a list iterator.
*/ */
typedef list<Arg*>::iterator ArgIterator; typedef std::list<Arg*>::iterator ArgIterator;
typedef vector<Arg*>::iterator ArgVectorIterator; typedef std::vector<Arg*>::iterator ArgVectorIterator;
} }

View File

@ -25,8 +25,6 @@
#include <string> #include <string>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -43,8 +41,8 @@ class ArgException
* \param id - The text identifying the argument source * \param id - The text identifying the argument source
* of the exception. * of the exception.
*/ */
ArgException( const string& text = "undefined exception", ArgException( const std::string& text = "undefined exception",
const string& id = "undefined" ) const std::string& id = "undefined" )
: _errorText(text), _argId( id ) {}; : _errorText(text), _argId( id ) {};
/** /**
@ -78,12 +76,12 @@ class ArgException
/** /**
* Returns the error text. * Returns the error text.
*/ */
string error() { return ( _errorText ); }; std::string error() { return ( _errorText ); };
/** /**
* Returns the argument id. * Returns the argument id.
*/ */
string argId() std::string argId()
{ {
if ( _argId == "undefined" ) if ( _argId == "undefined" )
return " "; return " ";
@ -96,12 +94,12 @@ class ArgException
/** /**
* The text of the exception message. * The text of the exception message.
*/ */
string _errorText; std::string _errorText;
/** /**
* The argument related to this exception. * The argument related to this exception.
*/ */
string _argId; std::string _argId;
}; };

View File

@ -44,8 +44,6 @@
#include <iomanip> #include <iomanip>
#include <algorithm> #include <algorithm>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -60,22 +58,22 @@ class CmdLine
* The list of arguments that will be tested against the * The list of arguments that will be tested against the
* command line. * command line.
*/ */
list<Arg*> _argList; std::list<Arg*> _argList;
/** /**
* The name of the program. Set to argv[0]. * The name of the program. Set to argv[0].
*/ */
string _progName; std::string _progName;
/** /**
* A message used to describe the program. Used in the usage output. * A message used to describe the program. Used in the usage output.
*/ */
string _message; std::string _message;
/** /**
* The version to be displayed with the --version switch. * The version to be displayed with the --version switch.
*/ */
string _version; std::string _version;
/** /**
* The number of arguments that are required to be present on * The number of arguments that are required to be present on
@ -101,20 +99,20 @@ class CmdLine
* into a single argument. * into a single argument.
* \param s - The message to be used in the usage. * \param s - The message to be used in the usage.
*/ */
bool _emptyCombined(const string& s); bool _emptyCombined(const std::string& s);
/** /**
* Writes a brief usage message with short args. * Writes a brief usage message with short args.
* \param os - The stream to write the message to. * \param os - The stream to write the message to.
*/ */
void _shortUsage( ostream& os ); void _shortUsage( std::ostream& os );
/** /**
* Writes a longer usage message with long and short args, * Writes a longer usage message with long and short args,
* provides descriptions and prints message. * provides descriptions and prints message.
* \param os - The stream to write the message to. * \param os - The stream to write the message to.
*/ */
void _longUsage( ostream& os ); void _longUsage( std::ostream& os );
private: private:
@ -136,9 +134,9 @@ class CmdLine
* \param version - The version number to be used in the * \param version - The version number to be used in the
* --version switch. * --version switch.
*/ */
CmdLine(const string& name, CmdLine(const std::string& name,
const string& message, const std::string& message,
const string& version = "none" ); const std::string& version = "none" );
/** /**
* Command line constructor. Defines how the arguments will be * Command line constructor. Defines how the arguments will be
@ -150,9 +148,9 @@ class CmdLine
* \param version - The version number to be used in the * \param version - The version number to be used in the
* --version switch. * --version switch.
*/ */
CmdLine(const string& message, CmdLine(const std::string& message,
const char delimiter = ' ', const char delimiter = ' ',
const string& version = "none" ); const std::string& version = "none" );
/** /**
* Adds an argument to the list of arguments to be parsed. * Adds an argument to the list of arguments to be parsed.
@ -179,7 +177,7 @@ class CmdLine
* add does not need to be called. * add does not need to be called.
* \param xors - List of Args to be added and xor'd. * \param xors - List of Args to be added and xor'd.
*/ */
void xorAdd( vector<Arg*>& xors ); void xorAdd( std::vector<Arg*>& xors );
/** /**
* Prints the usage to stdout and exits. * Prints the usage to stdout and exits.

View File

@ -28,8 +28,6 @@
#include <sstream> #include <sstream>
#include <tclap/Visitor.h> #include <tclap/Visitor.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -45,7 +43,7 @@ class MultiArg : public Arg
/** /**
* The list of values parsed from the CmdLine. * The list of values parsed from the CmdLine.
*/ */
vector<T> _values; std::vector<T> _values;
/** /**
* A list of allowed values. * A list of allowed values.
@ -53,12 +51,12 @@ class MultiArg : public Arg
* for this arg is not found in this list, then an exception is * for this arg is not found in this list, then an exception is
* thrown. If the list is empty, then any value is allowed. * thrown. If the list is empty, then any value is allowed.
*/ */
vector<T> _allowed; std::vector<T> _allowed;
/** /**
* The description of type T to be used in the usage. * The description of type T to be used in the usage.
*/ */
string _typeDesc; std::string _typeDesc;
/** /**
* Extracts the value from the string. * Extracts the value from the string.
@ -67,13 +65,13 @@ class MultiArg : public Arg
* \param val - The string to be read. * \param val - The string to be read.
*/ */
void _extractValue( const string& val ); void _extractValue( const std::string& val );
/** /**
* Checks to see if parsed value is in allowed list. * Checks to see if parsed value is in allowed list.
* \param val - value parsed (only used in output). * \param val - value parsed (only used in output).
*/ */
void _checkAllowed( const string& val ); void _checkAllowed( const std::string& val );
public: public:
@ -94,11 +92,11 @@ class MultiArg : public Arg
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
MultiArg( const string& flag, MultiArg( const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
const string& typeDesc, const std::string& typeDesc,
Visitor* v = NULL); Visitor* v = NULL);
/** /**
@ -116,11 +114,11 @@ class MultiArg : public Arg
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
MultiArg( const string& flag, MultiArg( const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
const vector<T>& allowed, const std::vector<T>& allowed,
Visitor* v = NULL); Visitor* v = NULL);
/** /**
@ -136,25 +134,25 @@ class MultiArg : public Arg
* \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. Passed from main(). * \param args - Mutable list of strings. Passed from main().
*/ */
virtual bool processArg(int* i, vector<string>& args); virtual bool processArg(int* i, std::vector<std::string>& args);
/** /**
* Returns a vector of type T containing the values parsed from * Returns a vector of type T containing the values parsed from
* the command line. * the command line.
*/ */
const vector<T>& getValue() ; const std::vector<T>& getValue() ;
/** /**
* Returns the a short id string. Used in the usage. * Returns the a short id string. Used in the usage.
* \param val - value to be used. * \param val - value to be used.
*/ */
virtual string shortID(const string& val="val") const; virtual std::string shortID(const std::string& val="val") const;
/** /**
* Returns the a long id string. Used in the usage. * Returns the a long id string. Used in the usage.
* \param val - value to be used. * \param val - value to be used.
*/ */
virtual string longID(const string& val="val") const; virtual std::string longID(const std::string& val="val") const;
/** /**
* Once we've matched the first value, then the arg is no longer * Once we've matched the first value, then the arg is no longer
@ -168,11 +166,11 @@ class MultiArg : public Arg
* *
*/ */
template<class T> template<class T>
MultiArg<T>::MultiArg(const string& flag, MultiArg<T>::MultiArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
const string& typeDesc, const std::string& typeDesc,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_typeDesc( typeDesc ) _typeDesc( typeDesc )
@ -183,21 +181,21 @@ MultiArg<T>::MultiArg(const string& flag,
* *
*/ */
template<class T> template<class T>
MultiArg<T>::MultiArg(const string& flag, MultiArg<T>::MultiArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
const vector<T>& allowed, const std::vector<T>& allowed,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_allowed( allowed ) _allowed( allowed )
{ {
for ( unsigned int i = 0; i < _allowed.size(); i++ ) for ( unsigned int i = 0; i < _allowed.size(); i++ )
{ {
ostringstream os; std::ostringstream os;
os << _allowed[i]; os << _allowed[i];
string temp( os.str() ); std::string temp( os.str() );
if ( i > 0 ) if ( i > 0 )
_typeDesc += "|"; _typeDesc += "|";
@ -216,13 +214,13 @@ MultiArg<T>::~MultiArg() { };
* *
*/ */
template<class T> template<class T>
const vector<T>& MultiArg<T>::getValue() { return _values; }; const std::vector<T>& MultiArg<T>::getValue() { return _values; };
/** /**
* *
*/ */
template<class T> template<class T>
bool MultiArg<T>::processArg(int *i, vector<string>& args) bool MultiArg<T>::processArg(int *i, std::vector<std::string>& args)
{ {
if ( _ignoreable && Arg::ignoreRest() ) if ( _ignoreable && Arg::ignoreRest() )
return false; return false;
@ -230,8 +228,8 @@ bool MultiArg<T>::processArg(int *i, vector<string>& args)
if ( _hasBlanks( args[*i] ) ) if ( _hasBlanks( args[*i] ) )
return false; return false;
string flag = args[*i]; std::string flag = args[*i];
string value = ""; std::string value = "";
trimFlag( flag, value ); trimFlag( flag, value );
@ -264,10 +262,10 @@ bool MultiArg<T>::processArg(int *i, vector<string>& args)
* *
*/ */
template<class T> template<class T>
void MultiArg<T>::_extractValue( const string& val ) void MultiArg<T>::_extractValue( const std::string& val )
{ {
T temp; T temp;
istringstream is(val); std::istringstream is(val);
int valuesRead = 0; int valuesRead = 0;
while ( is.good() ) while ( is.good() )
@ -300,7 +298,7 @@ void MultiArg<T>::_extractValue( const string& val )
* because there is no way to tell operator>> to ignore spaces. * because there is no way to tell operator>> to ignore spaces.
*/ */
template<> template<>
void MultiArg<string>::_extractValue( const string& val ) void MultiArg<std::string>::_extractValue( const std::string& val )
{ {
_values.push_back( val ); _values.push_back( val );
@ -311,7 +309,7 @@ void MultiArg<string>::_extractValue( const string& val )
* Checks to see if the value parsed is in the allowed list. * Checks to see if the value parsed is in the allowed list.
*/ */
template<class T> template<class T>
void MultiArg<T>::_checkAllowed( const string& val ) void MultiArg<T>::_checkAllowed( const std::string& val )
{ {
if ( _allowed.size() > 0 ) if ( _allowed.size() > 0 )
if ( find(_allowed.begin(),_allowed.end(),_values.back()) if ( find(_allowed.begin(),_allowed.end(),_values.back())
@ -324,9 +322,9 @@ void MultiArg<T>::_checkAllowed( const string& val )
* *
*/ */
template<class T> template<class T>
string MultiArg<T>::shortID(const string& val) const std::string MultiArg<T>::shortID(const std::string& val) const
{ {
string id = Arg::shortID(_typeDesc) + " ... "; std::string id = Arg::shortID(_typeDesc) + " ... ";
return id; return id;
} }
@ -335,9 +333,9 @@ string MultiArg<T>::shortID(const string& val) const
* *
*/ */
template<class T> template<class T>
string MultiArg<T>::longID(const string& val) const std::string MultiArg<T>::longID(const std::string& val) const
{ {
string id = Arg::longID(_typeDesc) + " (accepted multiple times)"; std::string id = Arg::longID(_typeDesc) + " (accepted multiple times)";
return id; return id;
} }

View File

@ -26,8 +26,6 @@
#include <algorithm> #include <algorithm>
#include <string> #include <string>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -40,8 +38,8 @@ namespace TCLAP {
* \param secondLineOffset - The number of spaces to indent the second * \param secondLineOffset - The number of spaces to indent the second
* and all subsequent lines in addition to indentSpaces. * and all subsequent lines in addition to indentSpaces.
*/ */
void spacePrint( ostream& os, void spacePrint( std::ostream& os,
const string& s, const std::string& s,
int maxWidth, int maxWidth,
int indentSpaces=0, int indentSpaces=0,
int secondLineOffset=0 ); int secondLineOffset=0 );

View File

@ -29,8 +29,6 @@
#include <tclap/Arg.h> #include <tclap/Arg.h>
#include <tclap/ArgException.h> #include <tclap/ArgException.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -62,9 +60,9 @@ class SwitchArg : public Arg
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
SwitchArg(const string& flag, SwitchArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool def, bool def,
Visitor* v = NULL); Visitor* v = NULL);
@ -81,13 +79,13 @@ class SwitchArg : public Arg
* \param args - Mutable list of strings. Passed * \param args - Mutable list of strings. Passed
* in from main(). * in from main().
*/ */
virtual bool processArg(int* i, vector<string>& args); virtual bool processArg(int* i, std::vector<std::string>& args);
/** /**
* Checks a string to see if any of the chars in the string * Checks a string to see if any of the chars in the string
* match the flag for this Switch. * match the flag for this Switch.
*/ */
bool combinedSwitchesMatch(string& combined); bool combinedSwitchesMatch(std::string& combined);
/** /**
* Returns bool, whether or not the switch has been set. * Returns bool, whether or not the switch has been set.

View File

@ -30,8 +30,6 @@
#include <tclap/Arg.h> #include <tclap/Arg.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -42,6 +40,7 @@ namespace TCLAP {
template<class T> template<class T>
class UnlabeledMultiArg : public MultiArg<T> class UnlabeledMultiArg : public MultiArg<T>
{ {
#ifdef TWO_STAGE_NAME_LOOKUP #ifdef TWO_STAGE_NAME_LOOKUP
//If compiler has two stage name lookup (as gcc >= 3.4 does) //If compiler has two stage name lookup (as gcc >= 3.4 does)
//this is requried to prevent undef. symbols //this is requried to prevent undef. symbols
@ -70,9 +69,9 @@ class UnlabeledMultiArg : public MultiArg<T>
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
UnlabeledMultiArg( const string& name, UnlabeledMultiArg( const std::string& name,
const string& desc, const std::string& desc,
const string& typeDesc, const std::string& typeDesc,
bool ignoreable = false, bool ignoreable = false,
Visitor* v = NULL ); Visitor* v = NULL );
@ -89,9 +88,9 @@ class UnlabeledMultiArg : public MultiArg<T>
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
UnlabeledMultiArg( const string& name, UnlabeledMultiArg( const std::string& name,
const string& desc, const std::string& desc,
const vector<T>& allowed, const std::vector<T>& allowed,
bool ignoreable = false, bool ignoreable = false,
Visitor* v = NULL ); Visitor* v = NULL );
@ -103,19 +102,19 @@ class UnlabeledMultiArg : public MultiArg<T>
* \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. Passed from main(). * \param args - Mutable list of strings. Passed from main().
*/ */
virtual bool processArg(int* i, vector<string>& args); virtual bool processArg(int* i, std::vector<std::string>& args);
/** /**
* Returns the a short id string. Used in the usage. * Returns the a short id string. Used in the usage.
* \param val - value to be used. * \param val - value to be used.
*/ */
virtual string shortID(const string& val="val") const; virtual std::string shortID(const std::string& val="val") const;
/** /**
* Returns the a long id string. Used in the usage. * Returns the a long id string. Used in the usage.
* \param val - value to be used. * \param val - value to be used.
*/ */
virtual string longID(const string& val="val") const; virtual std::string longID(const std::string& val="val") const;
/** /**
* Opertor ==. * Opertor ==.
@ -127,13 +126,13 @@ class UnlabeledMultiArg : public MultiArg<T>
* Pushes this to back of list rather than front. * Pushes this to back of list rather than front.
* \param argList - The list this should be added to. * \param argList - The list this should be added to.
*/ */
virtual void addToList( list<Arg*>& argList ) const; virtual void addToList( std::list<Arg*>& argList ) const;
}; };
template<class T> template<class T>
UnlabeledMultiArg<T>::UnlabeledMultiArg(const string& name, UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
const string& desc, const std::string& desc,
const string& typeDesc, const std::string& typeDesc,
bool ignoreable, bool ignoreable,
Visitor* v) Visitor* v)
: MultiArg<T>("", name, desc, false, typeDesc, v) : MultiArg<T>("", name, desc, false, typeDesc, v)
@ -142,9 +141,9 @@ UnlabeledMultiArg<T>::UnlabeledMultiArg(const string& name,
}; };
template<class T> template<class T>
UnlabeledMultiArg<T>::UnlabeledMultiArg(const string& name, UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name,
const string& desc, const std::string& desc,
const vector<T>& allowed, const std::vector<T>& allowed,
bool ignoreable, bool ignoreable,
Visitor* v) Visitor* v)
: MultiArg<T>("", name, desc, false, allowed, v) : MultiArg<T>("", name, desc, false, allowed, v)
@ -153,7 +152,7 @@ UnlabeledMultiArg<T>::UnlabeledMultiArg(const string& name,
}; };
template<class T> template<class T>
bool UnlabeledMultiArg<T>::processArg(int *i, vector<string>& args) bool UnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args)
{ {
if ( _hasBlanks( args[*i] ) ) if ( _hasBlanks( args[*i] ) )
@ -166,17 +165,17 @@ bool UnlabeledMultiArg<T>::processArg(int *i, vector<string>& args)
} }
template<class T> template<class T>
string UnlabeledMultiArg<T>::shortID(const string& val) const std::string UnlabeledMultiArg<T>::shortID(const std::string& val) const
{ {
string id = "<" + _typeDesc + "> ..."; std::string id = "<" + _typeDesc + "> ...";
return id; return id;
} }
template<class T> template<class T>
string UnlabeledMultiArg<T>::longID(const string& val) const std::string UnlabeledMultiArg<T>::longID(const std::string& val) const
{ {
string id = "<" + _typeDesc + "> (accepted multiple times)"; std::string id = "<" + _typeDesc + "> (accepted multiple times)";
return id; return id;
} }
@ -191,7 +190,7 @@ bool UnlabeledMultiArg<T>::operator==(const Arg& a) const
} }
template<class T> template<class T>
void UnlabeledMultiArg<T>::addToList( list<Arg*>& argList ) const void UnlabeledMultiArg<T>::addToList( std::list<Arg*>& argList ) const
{ {
argList.push_back( (Arg*)this ); argList.push_back( (Arg*)this );
} }

View File

@ -30,8 +30,6 @@
#include <tclap/Arg.h> #include <tclap/Arg.h>
#include <tclap/ValueArg.h> #include <tclap/ValueArg.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -81,10 +79,10 @@ class UnlabeledValueArg : public ValueArg<T>
* \param v - Optional Vistor. You should leave this blank unless * \param v - Optional Vistor. You should leave this blank unless
* you have a very good reason. * you have a very good reason.
*/ */
UnlabeledValueArg(const string& name, UnlabeledValueArg(const std::string& name,
const string& desc, const std::string& desc,
T value, T value,
const string& typeDesc, const std::string& typeDesc,
bool ignoreable = false, bool ignoreable = false,
Visitor* v = NULL); Visitor* v = NULL);
@ -109,10 +107,10 @@ class UnlabeledValueArg : public ValueArg<T>
* \param v - Optional Vistor. You should leave this blank unless * \param v - Optional Vistor. You should leave this blank unless
* you have a very good reason. * you have a very good reason.
*/ */
UnlabeledValueArg(const string& name, UnlabeledValueArg(const std::string& name,
const string& desc, const std::string& desc,
T value, T value,
const vector<T>& allowed, const std::vector<T>& allowed,
bool ignoreable = false, bool ignoreable = false,
Visitor* v = NULL); Visitor* v = NULL);
@ -124,17 +122,17 @@ class UnlabeledValueArg : public ValueArg<T>
* \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. * \param args - Mutable list of strings.
*/ */
virtual bool processArg(int* i, vector<string>& args); virtual bool processArg(int* i, std::vector<std::string>& args);
/** /**
* Overrides shortID for specific behavior. * Overrides shortID for specific behavior.
*/ */
virtual string shortID(const string& val="val") const; virtual std::string shortID(const std::string& val="val") const;
/** /**
* Overrides longID for specific behavior. * Overrides longID for specific behavior.
*/ */
virtual string longID(const string& val="val") const; virtual std::string longID(const std::string& val="val") const;
/** /**
* Overrides operator== for specific behavior. * Overrides operator== for specific behavior.
@ -145,17 +143,17 @@ class UnlabeledValueArg : public ValueArg<T>
* Instead of pushing to the front of list, push to the back. * Instead of pushing to the front of list, push to the back.
* \param argList - The list to add this to. * \param argList - The list to add this to.
*/ */
virtual void addToList( list<Arg*>& argList ) const; virtual void addToList( std::list<Arg*>& argList ) const;
}; };
/** /**
* Constructor implemenation. * Constructor implemenation.
*/ */
template<class T> template<class T>
UnlabeledValueArg<T>::UnlabeledValueArg(const string& name, UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name,
const string& desc, const std::string& desc,
T val, T val,
const string& typeDesc, const std::string& typeDesc,
bool ignoreable, bool ignoreable,
Visitor* v) Visitor* v)
: ValueArg<T>("", name, desc, true, val, typeDesc, v) : ValueArg<T>("", name, desc, true, val, typeDesc, v)
@ -167,10 +165,10 @@ UnlabeledValueArg<T>::UnlabeledValueArg(const string& name,
* Constructor implemenation. * Constructor implemenation.
*/ */
template<class T> template<class T>
UnlabeledValueArg<T>::UnlabeledValueArg(const string& name, UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name,
const string& desc, const std::string& desc,
T val, T val,
const vector<T>& allowed, const std::vector<T>& allowed,
bool ignoreable, bool ignoreable,
Visitor* v) Visitor* v)
: ValueArg<T>("", name, desc, true, val, allowed, v) : ValueArg<T>("", name, desc, true, val, allowed, v)
@ -182,7 +180,7 @@ UnlabeledValueArg<T>::UnlabeledValueArg(const string& name,
* Implementation of processArg(). * Implementation of processArg().
*/ */
template<class T> template<class T>
bool UnlabeledValueArg<T>::processArg(int *i, vector<string>& args) bool UnlabeledValueArg<T>::processArg(int *i, std::vector<std::string>& args)
{ {
if ( _alreadySet ) if ( _alreadySet )
@ -202,9 +200,9 @@ bool UnlabeledValueArg<T>::processArg(int *i, vector<string>& args)
* Overriding shortID for specific output. * Overriding shortID for specific output.
*/ */
template<class T> template<class T>
string UnlabeledValueArg<T>::shortID(const string& val) const std::string UnlabeledValueArg<T>::shortID(const std::string& val) const
{ {
string id = "<" + _typeDesc + ">"; std::string id = "<" + _typeDesc + ">";
return id; return id;
} }
@ -213,12 +211,12 @@ string UnlabeledValueArg<T>::shortID(const string& val) const
* Overriding longID for specific output. * Overriding longID for specific output.
*/ */
template<class T> template<class T>
string UnlabeledValueArg<T>::longID(const string& val) const std::string UnlabeledValueArg<T>::longID(const std::string& val) const
{ {
// Ideally we would like to be able to use RTTI to return the name // Ideally we would like to be able to use RTTI to return the name
// of the type required for this argument. However, g++ at least, // of the type required for this argument. However, g++ at least,
// doesn't appear to return terribly useful "names" of the types. // doesn't appear to return terribly useful "names" of the types.
string id = "<" + _typeDesc + ">"; std::string id = "<" + _typeDesc + ">";
return id; return id;
} }
@ -236,7 +234,7 @@ bool UnlabeledValueArg<T>::operator==(const Arg& a ) const
} }
template<class T> template<class T>
void UnlabeledValueArg<T>::addToList( list<Arg*>& argList ) const void UnlabeledValueArg<T>::addToList( std::list<Arg*>& argList ) const
{ {
argList.push_back( (Arg*)this ); argList.push_back( (Arg*)this );
} }

View File

@ -29,8 +29,6 @@
#include <tclap/Visitor.h> #include <tclap/Visitor.h>
#include <tclap/Arg.h> #include <tclap/Arg.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -59,7 +57,7 @@ class ValueArg : public Arg
* for this arg is not found in this list, then an exception is * for this arg is not found in this list, then an exception is
* thrown. If the list is empty, then any value is allowed. * thrown. If the list is empty, then any value is allowed.
*/ */
vector<T> _allowed; std::vector<T> _allowed;
/** /**
* A human readable description of the type to be parsed. * A human readable description of the type to be parsed.
@ -68,7 +66,7 @@ class ValueArg : public Arg
* consistent support for human readable names, we are left to our * consistent support for human readable names, we are left to our
* own devices. * own devices.
*/ */
string _typeDesc; std::string _typeDesc;
/** /**
* Extracts the value from the string. * Extracts the value from the string.
@ -76,13 +74,13 @@ class ValueArg : public Arg
* is thrown. * is thrown.
* \param val - value to be parsed. * \param val - value to be parsed.
*/ */
void _extractValue( const string& val ); void _extractValue( const std::string& val );
/** /**
* Checks to see if parsed value is in allowed list. * Checks to see if parsed value is in allowed list.
* \param val - value parsed (only used in output). * \param val - value parsed (only used in output).
*/ */
void _checkAllowed( const string& val ); void _checkAllowed( const std::string& val );
public: public:
@ -109,12 +107,12 @@ class ValueArg : public Arg
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
ValueArg(const string& flag, ValueArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
T value, T value,
const string& typeDesc, const std::string& typeDesc,
Visitor* v = NULL); Visitor* v = NULL);
/** /**
@ -138,12 +136,12 @@ class ValueArg : public Arg
* \param v - An optional visitor. You probably should not * \param v - An optional visitor. You probably should not
* use this unless you have a very good reason. * use this unless you have a very good reason.
*/ */
ValueArg(const string& flag, ValueArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
T value, T value,
const vector<T>& allowed, const std::vector<T>& allowed,
Visitor* v = NULL); Visitor* v = NULL);
/** /**
@ -160,7 +158,7 @@ class ValueArg : public Arg
* \param args - Mutable list of strings. Passed * \param args - Mutable list of strings. Passed
* in from main(). * in from main().
*/ */
virtual bool processArg(int* i, vector<string>& args); virtual bool processArg(int* i, std::vector<std::string>& args);
/** /**
* Returns the value of the argument. * Returns the value of the argument.
@ -171,13 +169,13 @@ class ValueArg : public Arg
* Specialization of shortID. * Specialization of shortID.
* \param val - value to be used. * \param val - value to be used.
*/ */
virtual string shortID(const string& val = "val") const; virtual std::string shortID(const std::string& val = "val") const;
/** /**
* Specialization of longID. * Specialization of longID.
* \param val - value to be used. * \param val - value to be used.
*/ */
virtual string longID(const string& val = "val") const; virtual std::string longID(const std::string& val = "val") const;
}; };
@ -186,12 +184,12 @@ class ValueArg : public Arg
* Constructor implementation. * Constructor implementation.
*/ */
template<class T> template<class T>
ValueArg<T>::ValueArg(const string& flag, ValueArg<T>::ValueArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
T val, T val,
const string& typeDesc, const std::string& typeDesc,
Visitor* v) Visitor* v)
: Arg(flag, name, desc, req, true, v), : Arg(flag, name, desc, req, true, v),
_value( val ), _value( val ),
@ -202,12 +200,12 @@ ValueArg<T>::ValueArg(const string& flag,
* Constructor with allowed list. * Constructor with allowed list.
*/ */
template<class T> template<class T>
ValueArg<T>::ValueArg(const string& flag, ValueArg<T>::ValueArg(const std::string& flag,
const string& name, const std::string& name,
const string& desc, const std::string& desc,
bool req, bool req,
T val, T val,
const vector<T>& allowed, const std::vector<T>& allowed,
Visitor* v) Visitor* v)
: Arg(flag, name, desc, req, true, v), : Arg(flag, name, desc, req, true, v),
_value( val ), _value( val ),
@ -215,10 +213,10 @@ ValueArg<T>::ValueArg(const string& flag,
{ {
for ( unsigned int i = 0; i < _allowed.size(); i++ ) for ( unsigned int i = 0; i < _allowed.size(); i++ )
{ {
ostringstream os; std::ostringstream os;
os << _allowed[i]; os << _allowed[i];
string temp( os.str() ); std::string temp( os.str() );
if ( i > 0 ) if ( i > 0 )
_typeDesc += "|"; _typeDesc += "|";
@ -243,7 +241,7 @@ T& ValueArg<T>::getValue() { return _value; };
* Implementation of processArg(). * Implementation of processArg().
*/ */
template<class T> template<class T>
bool ValueArg<T>::processArg(int *i, vector<string>& args) bool ValueArg<T>::processArg(int *i, std::vector<std::string>& args)
{ {
if ( _ignoreable && Arg::ignoreRest() ) if ( _ignoreable && Arg::ignoreRest() )
return false; return false;
@ -251,9 +249,9 @@ bool ValueArg<T>::processArg(int *i, vector<string>& args)
if ( _hasBlanks( args[*i] ) ) if ( _hasBlanks( args[*i] ) )
return false; return false;
string flag = args[*i]; std::string flag = args[*i];
string value = ""; std::string value = "";
trimFlag( flag, value ); trimFlag( flag, value );
if ( argMatches( flag ) ) if ( argMatches( flag ) )
@ -289,9 +287,9 @@ bool ValueArg<T>::processArg(int *i, vector<string>& args)
* Implementation of _extractValue. * Implementation of _extractValue.
*/ */
template<class T> template<class T>
void ValueArg<T>::_extractValue( const string& val ) void ValueArg<T>::_extractValue( const std::string& val )
{ {
istringstream is(val); std::istringstream is(val);
int valuesRead = 0; int valuesRead = 0;
while ( is.good() ) while ( is.good() )
@ -320,7 +318,7 @@ void ValueArg<T>::_extractValue( const string& val )
* read 'X'... and thus the specialization. * read 'X'... and thus the specialization.
*/ */
template<> template<>
void ValueArg<string>::_extractValue( const string& val ) void ValueArg<std::string>::_extractValue( const std::string& val )
{ {
_value = val; _value = val;
_checkAllowed( val ); _checkAllowed( val );
@ -330,7 +328,7 @@ void ValueArg<string>::_extractValue( const string& val )
* Checks to see if the value parsed is in the allowed list. * Checks to see if the value parsed is in the allowed list.
*/ */
template<class T> template<class T>
void ValueArg<T>::_checkAllowed( const string& val ) void ValueArg<T>::_checkAllowed( const std::string& val )
{ {
if ( _allowed.size() > 0 ) if ( _allowed.size() > 0 )
if ( find(_allowed.begin(),_allowed.end(),_value) == _allowed.end() ) if ( find(_allowed.begin(),_allowed.end(),_value) == _allowed.end() )
@ -342,7 +340,7 @@ void ValueArg<T>::_checkAllowed( const string& val )
* Implementation of shortID. * Implementation of shortID.
*/ */
template<class T> template<class T>
string ValueArg<T>::shortID(const string& val) const std::string ValueArg<T>::shortID(const std::string& val) const
{ {
return Arg::shortID( _typeDesc ); return Arg::shortID( _typeDesc );
} }
@ -351,7 +349,7 @@ string ValueArg<T>::shortID(const string& val) const
* Implementation of longID. * Implementation of longID.
*/ */
template<class T> template<class T>
string ValueArg<T>::longID(const string& val) const std::string ValueArg<T>::longID(const std::string& val) const
{ {
return Arg::longID( _typeDesc ); return Arg::longID( _typeDesc );
} }

View File

@ -29,8 +29,6 @@
#include <algorithm> #include <algorithm>
#include <ostream> #include <ostream>
using namespace std;
namespace TCLAP { namespace TCLAP {
/** /**
@ -44,7 +42,7 @@ class XorHandler
/** /**
* The list of of lists of Arg's to be or'd together. * The list of of lists of Arg's to be or'd together.
*/ */
vector< vector<Arg*> > _orList; std::vector< std::vector<Arg*> > _orList;
public: public:
@ -57,7 +55,7 @@ class XorHandler
* Add a list of Arg*'s that will be orred together. * Add a list of Arg*'s that will be orred together.
* \param ors - list of Arg* that will be xor'd. * \param ors - list of Arg* that will be xor'd.
*/ */
void add( vector<Arg*>& ors ); void add( std::vector<Arg*>& ors );
/** /**
* Checks whether the specified Arg is in one of the xor lists and * Checks whether the specified Arg is in one of the xor lists and
@ -71,13 +69,13 @@ class XorHandler
/** /**
* Returns the XOR specific short usage. * Returns the XOR specific short usage.
*/ */
string shortUsage(); std::string shortUsage();
/** /**
* Prints the XOR specific long usage. * Prints the XOR specific long usage.
* \param os - Stream to print to. * \param os - Stream to print to.
*/ */
void printLongUsage(ostream& os); void printLongUsage(std::ostream& os);
/** /**
* Simply checks whether the Arg is contained in one of the arg * Simply checks whether the Arg is contained in one of the arg

View File

@ -22,6 +22,8 @@
#include <tclap/Arg.h> #include <tclap/Arg.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
// defaults // defaults

View File

@ -22,6 +22,8 @@
#include <tclap/CommandLine.h> #include <tclap/CommandLine.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
CmdLine::CmdLine(const string& n, const string& m, const string& v ) CmdLine::CmdLine(const string& n, const string& m, const string& v )

View File

@ -22,8 +22,9 @@
#include <tclap/PrintSensibly.h> #include <tclap/PrintSensibly.h>
namespace TCLAP { using namespace std;
namespace TCLAP {
void spacePrint( ostream& os, void spacePrint( ostream& os,
const string& s, const string& s,

View File

@ -22,6 +22,8 @@
#include <tclap/SwitchArg.h> #include <tclap/SwitchArg.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
SwitchArg::SwitchArg(const string& flag, SwitchArg::SwitchArg(const string& flag,

View File

@ -22,6 +22,8 @@
#include <tclap/XorHandler.h> #include <tclap/XorHandler.h>
using namespace std;
namespace TCLAP { namespace TCLAP {
XorHandler::XorHandler( ) XorHandler::XorHandler( )