Changeset 7424 for sandbox_qt/src/libraries/core/CommandLineParser.h
- Timestamp:
- Sep 12, 2010, 2:48:11 PM (14 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sandbox_qt/src/libraries/core/CommandLineParser.h
r7418 r7424 46 46 #include <fstream> 47 47 #include <map> 48 #include <QVariant> 48 49 #include "util/OrxAssert.h" 49 #include "util/MultiType.h"50 50 51 51 #define SetCommandLineArgument(name, defaultValue) \ … … 67 67 /** 68 68 @brief 69 Container class for a command line argument of any type supported by MultiType.69 Container class for a command line argument of any type supported by QVariant. 70 70 71 71 Whenever you want to have an option specified by a command line switch, … … 106 106 107 107 //! Returns the actual value of the argument. Can be equal to default value. 108 MultiTypegetValue() const { return value_; }108 QVariant getValue() const { return value_; } 109 109 //! Returns the given default value as type T. 110 MultiTypegetDefaultValue() const { return defaultValue_; }110 QVariant getDefaultValue() const { return defaultValue_; } 111 111 112 112 private: 113 113 //! Constructor initialises both value_ and defaultValue_ with defaultValue. 114 CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)114 CommandLineArgument(const std::string& name, const QVariant& defaultValue, bool bCommandLineOnly) 115 115 : bHasDefaultValue_(true) 116 116 , name_(name) … … 135 135 std::string usageInformation_; //!< Tells about the usage of this parameter 136 136 137 MultiTypevalue_; //!< The actual value138 MultiTypedefaultValue_; //!< Default value. Should not be changed.137 QVariant value_; //!< The actual value 138 QVariant defaultValue_; //!< Default value. Should not be changed. 139 139 bool bCommandLineOnly_; //!< Whether you cannot specify the value in a text file 140 140 }; … … 165 165 static void getValue(const std::string& name, T* value) 166 166 { *value = (T)(getArgument(name)->getValue()); } 167 static MultiTypegetValue(const std::string& name)167 static QVariant getValue(const std::string& name) 168 168 { return getArgument(name)->getValue(); } 169 169 template <class T> … … 211 211 inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value) 212 212 { 213 *value = getArgument(name)->getValue(). getString();213 *value = getArgument(name)->getValue().toString().toStdString(); 214 214 } 215 215 … … 230 230 OrxAssert(!_getInstance().existsArgument(name), 231 231 "Cannot add a command line argument with name '" + name + "' twice."); 232 OrxAssert( MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true,232 OrxAssert(QVariant(defaultValue).type() != QVariant::Bool || QVariant(defaultValue).toBool() != true, 233 233 "Boolean command line arguments with positive default values are not supported." << std::endl 234 234 << "Please use SetCommandLineSwitch and adjust your argument: " << name);
Note: See TracChangeset
for help on using the changeset viewer.