Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
fml::internal::CommandLineBuilder Class Referencefinal

#include <command_line.h>

Public Member Functions

 CommandLineBuilder ()
 
 ~CommandLineBuilder ()
 
bool ProcessArg (const std::string &arg)
 
CommandLine Build () const
 

Detailed Description

Definition at line 147 of file command_line.h.

Constructor & Destructor Documentation

◆ CommandLineBuilder()

fml::internal::CommandLineBuilder::CommandLineBuilder ( )

Definition at line 86 of file command_line.cc.

86{}

◆ ~CommandLineBuilder()

fml::internal::CommandLineBuilder::~CommandLineBuilder ( )

Definition at line 87 of file command_line.cc.

87{}

Member Function Documentation

◆ Build()

CommandLine fml::internal::CommandLineBuilder::Build ( ) const

Definition at line 132 of file command_line.cc.

132 {
133 if (!has_argv0_) {
134 return CommandLine();
135 }
136 return CommandLine(argv0_, options_, positional_args_);
137}

◆ ProcessArg()

bool fml::internal::CommandLineBuilder::ProcessArg ( const std::string &  arg)

Definition at line 89 of file command_line.cc.

89 {
90 if (!has_argv0_) {
91 has_argv0_ = true;
92 argv0_ = arg;
93 return false;
94 }
95
96 // If we've seen a positional argument, then the remaining arguments are also
97 // positional.
98 if (started_positional_args_) {
99 bool rv = positional_args_.empty();
100 positional_args_.push_back(arg);
101 return rv;
102 }
103
104 // Anything that doesn't start with "--" is a positional argument.
105 if (arg.size() < 2u || arg[0] != '-' || arg[1] != '-') {
106 bool rv = positional_args_.empty();
107 started_positional_args_ = true;
108 positional_args_.push_back(arg);
109 return rv;
110 }
111
112 // "--" ends option processing, but isn't stored as a positional argument.
113 if (arg.size() == 2u) {
114 started_positional_args_ = true;
115 return false;
116 }
117
118 // Note: The option name *must* be at least one character, so start at
119 // position 3 -- "--=foo" will yield a name of "=foo" and no value. (Passing a
120 // starting |pos| that's "too big" is OK.)
121 size_t equals_pos = arg.find('=', 3u);
122 if (equals_pos == std::string::npos) {
123 options_.push_back(CommandLine::Option(arg.substr(2u)));
124 return false;
125 }
126
127 options_.push_back(CommandLine::Option(arg.substr(2u, equals_pos - 2u),
128 arg.substr(equals_pos + 1u)));
129 return false;
130}

The documentation for this class was generated from the following files: