Changeset 7424 for sandbox_qt/src/libraries/core/CommandLineParser.cc
- Timestamp:
- Sep 12, 2010, 2:48:11 PM (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sandbox_qt/src/libraries/core/CommandLineParser.cc
r7418 r7424 32 32 #include <sstream> 33 33 34 #include "util/Convert.h"34 //#include "util/Convert.h" 35 35 #include "util/Debug.h" 36 36 #include "util/Exception.h" … … 54 54 if (bParsingFile && this->bCommandLineOnly_) 55 55 ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files."); 56 if (value_.getType() == MT_Type::Bool) 57 { 58 // simulate command line switch 59 bool temp; 60 if (convertValue(&temp, value)) 56 if (value_.type() == QVariant::Bool) 57 { 58 // Command line switch activated 59 this->bHasDefaultValue_ = false; 60 this->value_ = true; 61 } 62 else 63 { 64 QVariant temp(QString::fromStdString(value)); 65 if (!temp.convert(value_.type())) 66 ThrowException(Argument, "Could not read command line argument '" + getName() + "'."); 67 else 61 68 { 62 69 this->bHasDefaultValue_ = false; 63 70 this->value_ = temp; 64 71 } 65 else if (value.empty())66 {67 this->bHasDefaultValue_ = false;68 this->value_ = true;69 }70 else71 ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");72 }73 else74 {75 if (!value_.setValue(value))76 {77 value_.setValue(defaultValue_);78 ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");79 }80 else81 this->bHasDefaultValue_ = false;82 72 } 83 73 } … … 302 292 infoStr << " "; 303 293 infoStr << "--" << it->second->getName() << ' '; 304 if (it->second->getValue(). getType() != MT_Type::Bool)294 if (it->second->getValue().type() != QVariant::Bool) 305 295 infoStr << "ARG "; 306 296 else … … 362 352 void CommandLineParser::_parseFile() 363 353 { 364 const std::string& filename = CommandLineParser::getValue("optionsFile"). getString();354 const std::string& filename = CommandLineParser::getValue("optionsFile").toString().toStdString(); 365 355 366 356 // look for additional arguments in given file or start.ini as default
Note: See TracChangeset
for help on using the changeset viewer.