36#ifndef FLUTTER_FML_COMMAND_LINE_H_
37#define FLUTTER_FML_COMMAND_LINE_H_
40#include <initializer_list>
44#include <unordered_map>
47#include "flutter/fml/macros.h"
58 class ConstructionHelper;
84 const std::vector<Option>&
options,
94 const std::string&
argv0()
const {
return argv0_; }
95 const std::vector<Option>&
options()
const {
return options_; }
97 return positional_args_;
102 return has_argv0_ == other.has_argv0_ && argv0_ == other.argv0_ &&
103 options_ == other.options_ &&
104 positional_args_ == other.positional_args_;
111 bool HasOption(std::string_view
name,
size_t* index =
nullptr)
const;
125 std::string_view default_value)
const;
128 bool has_argv0_ =
false;
131 std::vector<Option> options_;
132 std::vector<std::string> positional_args_;
136 std::unordered_map<std::string, size_t> option_index_;
160 bool has_argv0_ =
false;
162 std::vector<CommandLine::Option> options_;
163 std::vector<std::string> positional_args_;
166 bool started_positional_args_ =
false;
181template <
typename InputIterator>
185 InputIterator* first_positional_arg) {
186 if (first_positional_arg) {
187 *first_positional_arg = last;
190 for (
auto it = first; it < last; ++it) {
192 if (first_positional_arg) {
193 *first_positional_arg = it;
203template <
typename InputIterator>
205 InputIterator last) {
206 return CommandLineFromIteratorsFindFirstPositionalArg<InputIterator>(
207 first, last,
nullptr);
213template <
typename InputIterator>
216 InputIterator last) {
219 for (
auto it = first; it < last; ++it) {
243 const char*
const*
argv) {
245 if (command_line.has_value()) {
246 return *command_line;
253template <
typename StringType>
255 std::initializer_list<StringType>
argv) {
const std::string & argv0() const
CommandLine & operator=(const CommandLine &from)
const std::vector< Option > & options() const
std::vector< std::string_view > GetOptionValues(std::string_view name) const
const std::vector< std::string > & positional_args() const
std::string GetOptionValueWithDefault(std::string_view name, std::string_view default_value) const
bool operator==(const CommandLine &other) const
bool HasOption(std::string_view name, size_t *index=nullptr) const
bool GetOptionValue(std::string_view name, std::string *value) const
CommandLine & operator=(CommandLine &&from)
bool operator!=(const CommandLine &other) const
CommandLine(CommandLine &&from)
CommandLine(const CommandLine &from)
CommandLine Build() const
bool ProcessArg(const std::string &arg)
DEF_SWITCHES_START aot vmservice shared library name
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)
CommandLine CommandLineFromInitializerList(std::initializer_list< StringType > argv)
std::vector< std::string > CommandLineToArgv(const CommandLine &command_line)
std::optional< CommandLine > CommandLineFromPlatform()
CommandLine CommandLineFromPlatformOrArgcArgv(int argc, const char *const *argv)
CommandLine CommandLineFromIterators(InputIterator first, InputIterator last)
CommandLine CommandLineFromIteratorsFindFirstPositionalArg(InputIterator first, InputIterator last, InputIterator *first_positional_arg)
CommandLine CommandLineFromIteratorsWithArgv0(const std::string &argv0, InputIterator first, InputIterator last)
bool operator!=(const Option &other) const
bool operator==(const Option &other) const