MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / parse

Method parse

src/OpenLoco/src/CommandLine.cpp:184–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182 }
183
184 bool parse()
185 {
186 auto noMoreOptions = false;
187 for (size_t i = 0; i < _args.size(); i++)
188 {
189 auto& arg = _args[i];
190 if (!noMoreOptions && isLongOption(arg))
191 {
192 auto count = getOptionArgCount(arg);
193 if (count)
194 {
195 if (*count == 0)
196 {
197 setOption(arg);
198 }
199 else if (!appendValues(arg, *count, i))
200 {
201 return false;
202 }
203 }
204 else
205 {
206 setArgumentUnknownError(arg);
207 return false;
208 }
209 }
210 else if (!noMoreOptions && isShortOption(arg))
211 {
212 for (auto c : arg.substr(1))
213 {
214 auto count = getOptionArgCount(arg);
215 if (count)
216 {
217 if (*count == 0)
218 {
219 setOption(arg);
220 }
221 else if (!appendValues(arg, *count, i))
222 {
223 return false;
224 }
225 }
226 else
227 {
228 setArgumentUnknownError(std::string_view(&c, 1));
229 return false;
230 }
231 }
232 }
233 else if (!noMoreOptions && arg == "--")
234 {
235 noMoreOptions = true;
236 }
237 else
238 {
239 appendValue("", arg);
240 }
241 }

Callers 1

parseCommandLineFunction · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected