Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 12, 2010, 2:48:11 PM (14 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.h

    r7418 r7424  
    4646#include <fstream>
    4747#include <map>
     48#include <QVariant>
    4849#include "util/OrxAssert.h"
    49 #include "util/MultiType.h"
    5050
    5151#define SetCommandLineArgument(name, defaultValue) \
     
    6767    /**
    6868    @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.
    7070
    7171        Whenever you want to have an option specified by a command line switch,
     
    106106
    107107        //! Returns the actual value of the argument. Can be equal to default value.
    108         MultiType getValue() const { return value_; }
     108        QVariant getValue() const { return value_; }
    109109        //! Returns the given default value as type T.
    110         MultiType getDefaultValue() const { return defaultValue_; }
     110        QVariant getDefaultValue() const { return defaultValue_; }
    111111
    112112    private:
    113113        //! 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)
    115115            : bHasDefaultValue_(true)
    116116            , name_(name)
     
    135135        std::string usageInformation_; //!< Tells about the usage of this parameter
    136136
    137         MultiType   value_;            //!< The actual value
    138         MultiType   defaultValue_;     //!< Default value. Should not be changed.
     137        QVariant    value_;            //!< The actual value
     138        QVariant    defaultValue_;     //!< Default value. Should not be changed.
    139139        bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
    140140    };
     
    165165        static void getValue(const std::string& name, T* value)
    166166        { *value = (T)(getArgument(name)->getValue()); }
    167         static MultiType getValue(const std::string& name)
     167        static QVariant getValue(const std::string& name)
    168168        { return getArgument(name)->getValue(); }
    169169        template <class T>
     
    211211    inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
    212212    {
    213         *value = getArgument(name)->getValue().getString();
     213        *value = getArgument(name)->getValue().toString().toStdString();
    214214    }
    215215
     
    230230        OrxAssert(!_getInstance().existsArgument(name),
    231231            "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,
    233233               "Boolean command line arguments with positive default values are not supported." << std::endl
    234234            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
Note: See TracChangeset for help on using the changeset viewer.