Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2011, 5:51:21 AM (14 years ago)
Author:
rgrieder
Message:

Removed useless and possibly confusion feature: specifying a file with additional command line arguments.
If we ever have too many command line arguments, then something is wrong anyway. And configuring a dedicated server should be done with config values (but a different file).
In general, always prefer config values to CommandLineArguments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/unity_build/src/libraries/core/CommandLineParser.h

    r7401 r8520  
    5151#define SetCommandLineArgument(name, defaultValue) \
    5252    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    53     = orxonox::CommandLineParser::addArgument(#name, defaultValue, false)
    54 #define SetCommandLineOnlyArgument(name, defaultValue) \
    55     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    56     = orxonox::CommandLineParser::addArgument(#name, defaultValue, true)
     53    = orxonox::CommandLineParser::addArgument(#name, defaultValue)
    5754#define SetCommandLineSwitch(name) \
    5855    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    59     = orxonox::CommandLineParser::addArgument(#name, false, false)
    60 #define SetCommandLineOnlySwitch(name) \
    61     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    62     = orxonox::CommandLineParser::addArgument(#name, false, true)
    63 
     56    = orxonox::CommandLineParser::addArgument(#name, false)
    6457
    6558namespace orxonox
     
    112105    private:
    113106        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
    114         CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
     107        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
    115108            : bHasDefaultValue_(true)
    116109            , name_(name)
    117110            , value_(defaultValue)
    118111            , defaultValue_(defaultValue)
    119             , bCommandLineOnly_(bCommandLineOnly)
    120112        { }
    121113
     
    125117
    126118        //! Parses the value string of a command line argument.
    127         void parse(const std::string& value, bool bParsingFile);
     119        void parse(const std::string& value);
    128120
    129121        //! Tells whether the value has been changed by the command line.
     
    137129        MultiType   value_;            //!< The actual value
    138130        MultiType   defaultValue_;     //!< Default value. Should not be changed.
    139         bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
    140131    };
    141132
     
    155146
    156147        //! Parse redirection to internal member method.
    157         static void parseCommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }
    158         static void parseFile() { _getInstance()._parseFile(); }
     148        static void parse(const std::string& cmdLine)
     149        { _getInstance()._parse(cmdLine); }
    159150
    160151        static std::string getUsageInformation();
     
    168159        { return getArgument(name)->getValue(); }
    169160        template <class T>
    170         static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
     161        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
    171162
    172163        static bool existsArgument(const std::string& name)
     
    189180        static CommandLineParser& _getInstance();
    190181
    191         void _parseCommandLine(const std::string& cmdLine);
    192         void _parseFile();
    193         void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
    194         void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
    195         void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
     182        void _parse(const std::string& cmdLine);
     183        void checkFullArgument(const std::string& name, const std::string& value);
     184        void checkShortcut(const std::string& shortcut, const std::string& value);
    196185
    197186        /**
     
    222211    @param defaultValue
    223212        Default value that is used when argument was not given.
    224     @param bCommandLineOnly
    225         Parsing a file or the command line itself
    226213    */
    227214    template <class T>
    228     CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
     215    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)
    229216    {
    230217        OrxAssert(!_getInstance().existsArgument(name),
     
    234221            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
    235222
    236         return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
     223        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
    237224    }
    238225}
Note: See TracChangeset for help on using the changeset viewer.