Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 12, 2010, 2:48:11 PM (15 years ago)
Author:
rgrieder
Message:

Added CommandlineParser again and adjusted it to work with QVariant instead of MultiType.
Also removed obsolete Game class.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • sandbox_qt/src/libraries/core/CommandLineParser.cc

    r7418 r7424  
    3232#include <sstream>
    3333
    34 #include "util/Convert.h"
     34//#include "util/Convert.h"
    3535#include "util/Debug.h"
    3636#include "util/Exception.h"
     
    5454        if (bParsingFile && this->bCommandLineOnly_)
    5555            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
    6168            {
    6269                this->bHasDefaultValue_ = false;
    6370                this->value_ = temp;
    6471            }
    65             else if (value.empty())
    66             {
    67                 this->bHasDefaultValue_ = false;
    68                 this->value_ = true;
    69             }
    70             else
    71                 ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
    72         }
    73         else
    74         {
    75             if (!value_.setValue(value))
    76             {
    77                 value_.setValue(defaultValue_);
    78                 ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
    79             }
    80             else
    81                 this->bHasDefaultValue_ = false;
    8272        }
    8373    }
     
    302292                infoStr << "      ";
    303293            infoStr << "--" << it->second->getName() << ' ';
    304             if (it->second->getValue().getType() != MT_Type::Bool)
     294            if (it->second->getValue().type() != QVariant::Bool)
    305295                infoStr << "ARG ";
    306296            else
     
    362352    void CommandLineParser::_parseFile()
    363353    {
    364         const std::string& filename = CommandLineParser::getValue("optionsFile").getString();
     354        const std::string& filename = CommandLineParser::getValue("optionsFile").toString().toStdString();
    365355
    366356        // look for additional arguments in given file or start.ini as default
Note: See TracChangeset for help on using the changeset viewer.