OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Provides a simple class, |CommandLine|, for dealing with command lines (and | 5 // Provides a simple class, |CommandLine|, for dealing with command lines (and |
6 // flags and positional arguments). | 6 // flags and positional arguments). |
7 // | 7 // |
8 // * Options (a.k.a. flags or switches) are all of the form "--name=<value>" (or | 8 // * Options (a.k.a. flags or switches) are all of the form "--name=<value>" (or |
9 // "--name", but this is indistinguishable from "--name="), where <value> is a | 9 // "--name", but this is indistinguishable from "--name="), where <value> is a |
10 // string. Not supported: "-name", "-n", "--name <value>", "-n <value>", etc. | 10 // string. Not supported: "-name", "-n", "--name <value>", "-n <value>", etc. |
(...skipping 18 matching lines...) Expand all Loading... |
29 // not being able to distinguish "no value" from "empty value"). | 29 // not being able to distinguish "no value" from "empty value"). |
30 // | 30 // |
31 // [*] This is somewhat annoying for users, but: a. it's standard Unix behavior | 31 // [*] This is somewhat annoying for users, but: a. it's standard Unix behavior |
32 // for most command line parsers, b. it makes "my_program *" (etc.) safer (which | 32 // for most command line parsers, b. it makes "my_program *" (etc.) safer (which |
33 // mostly explains a.), c. it makes parsing "subcommands", like "my_program | 33 // mostly explains a.), c. it makes parsing "subcommands", like "my_program |
34 // --flag_for_my_program subcommand --flag_for_subcommand" saner. | 34 // --flag_for_my_program subcommand --flag_for_subcommand" saner. |
35 | 35 |
36 #ifndef MOJO_EDK_UTIL_COMMAND_LINE_H_ | 36 #ifndef MOJO_EDK_UTIL_COMMAND_LINE_H_ |
37 #define MOJO_EDK_UTIL_COMMAND_LINE_H_ | 37 #define MOJO_EDK_UTIL_COMMAND_LINE_H_ |
38 | 38 |
39 #include <cstddef> | 39 #include <stddef.h> |
| 40 |
40 #include <initializer_list> | 41 #include <initializer_list> |
41 #include <string> | 42 #include <string> |
42 #include <unordered_map> | 43 #include <unordered_map> |
43 #include <vector> | 44 #include <vector> |
44 | 45 |
45 #include "mojo/public/cpp/system/macros.h" | 46 #include "mojo/public/cpp/system/macros.h" |
46 | 47 |
47 namespace mojo { | 48 namespace mojo { |
48 namespace util { | 49 namespace util { |
49 | 50 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 216 |
216 // This is the "opposite" of the above factory functions, transforming a | 217 // This is the "opposite" of the above factory functions, transforming a |
217 // |CommandLine| into a vector of argument strings according to the rules | 218 // |CommandLine| into a vector of argument strings according to the rules |
218 // outlined at the top of this file. | 219 // outlined at the top of this file. |
219 std::vector<std::string> CommandLineToArgv(const CommandLine& command_line); | 220 std::vector<std::string> CommandLineToArgv(const CommandLine& command_line); |
220 | 221 |
221 } // namespace util | 222 } // namespace util |
222 } // namespace mojo | 223 } // namespace mojo |
223 | 224 |
224 #endif // MOJO_EDK_UTIL_COMMAND_LINE_H_ | 225 #endif // MOJO_EDK_UTIL_COMMAND_LINE_H_ |
OLD | NEW |