Changeset 3246 for code/branches/core4/src/core/CommandLine.h
- Timestamp:
- Jun 29, 2009, 1:43:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/CommandLine.h
r3196 r3246 38 38 #define SetCommandLineArgument(name, defaultValue) \ 39 39 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 40 = orxonox::CommandLine::addArgument(#name, defaultValue) 40 = orxonox::CommandLine::addArgument(#name, defaultValue, false) 41 #define SetCommandLineOnlyArgument(name, defaultValue) \ 42 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 43 = orxonox::CommandLine::addArgument(#name, defaultValue, true) 41 44 #define SetCommandLineSwitch(name) \ 42 45 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 43 = orxonox::CommandLine::addArgument(#name, false) 46 = orxonox::CommandLine::addArgument(#name, false, false) 47 #define SetCommandLineOnlySwitch(name) \ 48 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 49 = orxonox::CommandLine::addArgument(#name, false, true) 44 50 45 51 … … 93 99 private: 94 100 //! Constructor initialises both value_ and defaultValue_ with defaultValue. 95 CommandLineArgument(const std::string& name, const MultiType& defaultValue )101 CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly) 96 102 : bHasDefaultValue_(true) 97 103 , name_(name) 98 104 , value_(defaultValue) 99 105 , defaultValue_(defaultValue) 106 , bCommandLineOnly_(bCommandLineOnly) 100 107 { } 101 108 … … 105 112 106 113 //! Parses the value string of a command line argument. 107 void parse(const std::string& value );114 void parse(const std::string& value, bool bParsingFile); 108 115 109 116 //! Tells whether the value has been changed by the command line. … … 115 122 std::string usageInformation_; //!< Tells about the usage of this parameter 116 123 117 MultiType value_; //!< The actual value 118 MultiType defaultValue_; //!< Default value. Should not be changed. 124 MultiType value_; //!< The actual value 125 MultiType defaultValue_; //!< Default value. Should not be changed. 126 bool bCommandLineOnly_; //!< Whether you cannot specify the value in a text file 119 127 }; 120 128 … … 134 142 135 143 //! Parse redirection to internal member method. 136 static void parseAll(int argc, char** argv) { _getInstance()._parseAll(argc, argv); } 144 static void parseCommandLine(int argc, char** argv) { _getInstance()._parseCommandLine(argc, argv); } 145 static void parseFile() { _getInstance()._parseFile(); } 137 146 138 147 static std::string getUsageInformation(); … … 146 155 { return getArgument(name)->getValue(); } 147 156 template <class T> 148 static CommandLineArgument& addArgument(const std::string& name, T defaultValue );157 static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly); 149 158 150 159 static bool existsArgument(const std::string& name) … … 165 174 static CommandLine& _getInstance(); 166 175 167 void _parseAll(int argc, char** argv); 168 void _parse(const std::vector<std::string>& arguments); 169 void checkFullArgument(const std::string& name, const std::string& value); 170 void checkShortcut(const std::string& shortcut, const std::string& value); 176 void _parseCommandLine(int argc, char** argv); 177 void _parseFile(); 178 void _parse(const std::vector<std::string>& arguments, bool bParsingFile); 179 void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile); 180 void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile); 171 181 172 182 /** … … 199 209 */ 200 210 template <class T> 201 CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue )211 CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly) 202 212 { 203 213 OrxAssert(!_getInstance().existsArgument(name), 204 214 "Cannot add a command line argument with name '" + name + "' twice."); 205 215 206 return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue ));216 return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly)); 207 217 } 208 218 }
Note: See TracChangeset
for help on using the changeset viewer.