| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 50e42c9 commit cb62c24
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,8 +28,8 @@ EnvironmentOptions* PerIsolateOptions::get_per_env_options() { | |||
| 28 | 28 | namespace options_parser { | |
| 29 | 29 | ||
| 30 | 30 | template <typename Options> | |
| 31 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 32 | - const std::string& help_text, | ||
| 31 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 32 | + const char* help_text, | ||
| 33 | 33 | bool Options::* field, | |
| 34 | 34 | OptionEnvvarSettings env_setting) { | |
| 35 | 35 | options_.emplace(name, | |
@@ -40,8 +40,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, | |||
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | 42 | template <typename Options> | |
| 43 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 44 | - const std::string& help_text, | ||
| 43 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 44 | + const char* help_text, | ||
| 45 | 45 | uint64_t Options::* field, | |
| 46 | 46 | OptionEnvvarSettings env_setting) { | |
| 47 | 47 | options_.emplace( | |
@@ -53,8 +53,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, | |||
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | 55 | template <typename Options> | |
| 56 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 57 | - const std::string& help_text, | ||
| 56 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 57 | + const char* help_text, | ||
| 58 | 58 | int64_t Options::* field, | |
| 59 | 59 | OptionEnvvarSettings env_setting) { | |
| 60 | 60 | options_.emplace( | |
@@ -66,8 +66,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, | |||
| 66 | 66 | } | |
| 67 | 67 | ||
| 68 | 68 | template <typename Options> | |
| 69 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 70 | - const std::string& help_text, | ||
| 69 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 70 | + const char* help_text, | ||
| 71 | 71 | std::string Options::* field, | |
| 72 | 72 | OptionEnvvarSettings env_setting) { | |
| 73 | 73 | options_.emplace( | |
@@ -80,8 +80,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, | |||
| 80 | 80 | ||
| 81 | 81 | template <typename Options> | |
| 82 | 82 | void OptionsParser<Options>::AddOption( | |
| 83 | - const std::string& name, | ||
| 84 | - const std::string& help_text, | ||
| 83 | + const char* name, | ||
| 84 | + const char* help_text, | ||
| 85 | 85 | std::vector<std::string> Options::* field, | |
| 86 | 86 | OptionEnvvarSettings env_setting) { | |
| 87 | 87 | options_.emplace(name, OptionInfo { | |
@@ -93,8 +93,8 @@ void OptionsParser<Options>::AddOption( | |||
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | 95 | template <typename Options> | |
| 96 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 97 | - const std::string& help_text, | ||
| 96 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 97 | + const char* help_text, | ||
| 98 | 98 | HostPort Options::* field, | |
| 99 | 99 | OptionEnvvarSettings env_setting) { | |
| 100 | 100 | options_.emplace( | |
@@ -106,44 +106,44 @@ void OptionsParser<Options>::AddOption(const std::string& name, | |||
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | 108 | template <typename Options> | |
| 109 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 110 | - const std::string& help_text, | ||
| 109 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 110 | + const char* help_text, | ||
| 111 | 111 | NoOp no_op_tag, | |
| 112 | 112 | OptionEnvvarSettings env_setting) { | |
| 113 | 113 | options_.emplace(name, OptionInfo{kNoOp, nullptr, env_setting, help_text}); | |
| 114 | 114 | } | |
| 115 | 115 | ||
| 116 | 116 | template <typename Options> | |
| 117 | - void OptionsParser<Options>::AddOption(const std::string& name, | ||
| 118 | - const std::string& help_text, | ||
| 117 | + void OptionsParser<Options>::AddOption(const char* name, | ||
| 118 | + const char* help_text, | ||
| 119 | 119 | V8Option v8_option_tag, | |
| 120 | 120 | OptionEnvvarSettings env_setting) { | |
| 121 | 121 | options_.emplace(name, | |
| 122 | 122 | OptionInfo{kV8Option, nullptr, env_setting, help_text}); | |
| 123 | 123 | } | |
| 124 | 124 | ||
| 125 | 125 | template <typename Options> | |
| 126 | - void OptionsParser<Options>::AddAlias(const std::string& from, | ||
| 127 | - const std::string& to) { | ||
| 126 | + void OptionsParser<Options>::AddAlias(const char* from, | ||
| 127 | + const char* to) { | ||
| 128 | 128 | aliases_[from] = { to }; | |
| 129 | 129 | } | |
| 130 | 130 | ||
| 131 | 131 | template <typename Options> | |
| 132 | - void OptionsParser<Options>::AddAlias(const std::string& from, | ||
| 132 | + void OptionsParser<Options>::AddAlias(const char* from, | ||
| 133 | 133 | const std::vector<std::string>& to) { | |
| 134 | 134 | aliases_[from] = to; | |
| 135 | 135 | } | |
| 136 | 136 | ||
| 137 | 137 | template <typename Options> | |
| 138 | 138 | void OptionsParser<Options>::AddAlias( | |
| 139 | - const std::string& from, | ||
| 139 | + const char* from, | ||
| 140 | 140 | const std::initializer_list<std::string>& to) { | |
| 141 | 141 | AddAlias(from, std::vector<std::string>(to)); | |
| 142 | 142 | } | |
| 143 | 143 | ||
| 144 | 144 | template <typename Options> | |
| 145 | - void OptionsParser<Options>::Implies(const std::string& from, | ||
| 146 | - const std::string& to) { | ||
| 145 | + void OptionsParser<Options>::Implies(const char* from, | ||
| 146 | + const char* to) { | ||
| 147 | 147 | auto it = options_.find(to); | |
| 148 | 148 | CHECK_NE(it, options_.end()); | |
| 149 | 149 | CHECK_EQ(it->second.type, kBoolean); | |
@@ -153,8 +153,8 @@ void OptionsParser<Options>::Implies(const std::string& from, | |||
| 153 | 153 | } | |
| 154 | 154 | ||
| 155 | 155 | template <typename Options> | |
| 156 | - void OptionsParser<Options>::ImpliesNot(const std::string& from, | ||
| 157 | - const std::string& to) { | ||
| 156 | + void OptionsParser<Options>::ImpliesNot(const char* from, | ||
| 157 | + const char* to) { | ||
| 158 | 158 | auto it = options_.find(to); | |
| 159 | 159 | CHECK_NE(it, options_.end()); | |
| 160 | 160 | CHECK_EQ(it->second.type, kBoolean); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -239,43 +239,39 @@ class OptionsParser { | |||
| 239 | 239 | struct NoOp {}; | |
| 240 | 240 | struct V8Option {}; | |
| 241 | 241 | ||
| 242 | - // TODO(addaleax): A lot of the `std::string` usage here could be reduced | ||
| 243 | - // to simple `const char*`s if it's reasonable to expect the values to be | ||
| 244 | - // known at compile-time. | ||
| 245 | - | ||
| 246 | 242 | // These methods add a single option to the parser. Optionally, it can be | |
| 247 | 243 | // specified whether the option should be allowed from environment variable | |
| 248 | 244 | // sources (i.e. NODE_OPTIONS). | |
| 249 | - void AddOption(const std::string& name, | ||
| 250 | - const std::string& help_text, | ||
| 245 | + void AddOption(const char* name, | ||
| 246 | + const char* help_text, | ||
| 251 | 247 | bool Options::* field, | |
| 252 | 248 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 253 | - void AddOption(const std::string& name, | ||
| 254 | - const std::string& help_text, | ||
| 249 | + void AddOption(const char* name, | ||
| 250 | + const char* help_text, | ||
| 255 | 251 | uint64_t Options::* field, | |
| 256 | 252 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 257 | - void AddOption(const std::string& name, | ||
| 258 | - const std::string& help_text, | ||
| 253 | + void AddOption(const char* name, | ||
| 254 | + const char* help_text, | ||
| 259 | 255 | int64_t Options::* field, | |
| 260 | 256 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 261 | - void AddOption(const std::string& name, | ||
| 262 | - const std::string& help_text, | ||
| 257 | + void AddOption(const char* name, | ||
| 258 | + const char* help_text, | ||
| 263 | 259 | std::string Options::* field, | |
| 264 | 260 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 265 | - void AddOption(const std::string& name, | ||
| 266 | - const std::string& help_text, | ||
| 261 | + void AddOption(const char* name, | ||
| 262 | + const char* help_text, | ||
| 267 | 263 | std::vector<std::string> Options::* field, | |
| 268 | 264 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 269 | - void AddOption(const std::string& name, | ||
| 270 | - const std::string& help_text, | ||
| 265 | + void AddOption(const char* name, | ||
| 266 | + const char* help_text, | ||
| 271 | 267 | HostPort Options::* field, | |
| 272 | 268 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 273 | - void AddOption(const std::string& name, | ||
| 274 | - const std::string& help_text, | ||
| 269 | + void AddOption(const char* name, | ||
| 270 | + const char* help_text, | ||
| 275 | 271 | NoOp no_op_tag, | |
| 276 | 272 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 277 | - void AddOption(const std::string& name, | ||
| 278 | - const std::string& help_text, | ||
| 273 | + void AddOption(const char* name, | ||
| 274 | + const char* help_text, | ||
| 279 | 275 | V8Option v8_option_tag, | |
| 280 | 276 | OptionEnvvarSettings env_setting = kDisallowedInEnvironment); | |
| 281 | 277 | ||
@@ -286,15 +282,15 @@ class OptionsParser { | |||
| 286 | 282 | // the option is presented in that form (i.e. with a '='). | |
| 287 | 283 | // If `from` has the form "--option-a <arg>", the alias will only be expanded | |
| 288 | 284 | // if the option has a non-option argument (not starting with -) following it. | |
| 289 | - void AddAlias(const std::string& from, const std::string& to); | ||
| 290 | - void AddAlias(const std::string& from, const std::vector<std::string>& to); | ||
| 291 | - void AddAlias(const std::string& from, | ||
| 285 | + void AddAlias(const char* from, const char* to); | ||
| 286 | + void AddAlias(const char* from, const std::vector<std::string>& to); | ||
| 287 | + void AddAlias(const char* from, | ||
| 292 | 288 | const std::initializer_list<std::string>& to); | |
| 293 | 289 | ||
| 294 | 290 | // Add implications from some arbitrary option to a boolean one, either | |
| 295 | 291 | // in a way that makes `from` set `to` to true or to false. | |
| 296 | - void Implies(const std::string& from, const std::string& to); | ||
| 297 | - void ImpliesNot(const std::string& from, const std::string& to); | ||
| 292 | + void Implies(const char* from, const char* to); | ||
| 293 | + void ImpliesNot(const char* from, const char* to); | ||
| 298 | 294 | ||
| 299 | 295 | // Insert options from another options parser into this one, along with | |
| 300 | 296 | // a method that yields the target options type from this parser's options | |
| Back | FazBrowse Home | New Git URL |
0 commit comments