MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / parseArguments

Method parseArguments

DAEValidator/library/src/ArgumentParser.cpp:170–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 }
169
170 bool ArgumentParser::parseArguments()
171 {
172 try
173 {
174 auto noSwitchArgumentIt = mNoSwitchArguments.begin();
175 for (size_t arg = 1; arg < mCommandLine.size();)
176 {
177 auto it = mArguments.find(mCommandLine[arg]);
178 if (it == mArguments.end())
179 {
180 if (noSwitchArgumentIt != mNoSwitchArguments.end())
181 {
182 Argument& argument = *noSwitchArgumentIt;
183 argument.setValue(mCommandLine[arg]);
184 argument.isSet(true);
185 ++noSwitchArgumentIt;
186 ++arg;
187 continue;
188 }
189
190 throw UnknowArgumentException(mCommandLine[arg]);
191 }
192
193 Argument & argument = it->second;
194 argument.isSet(true);
195 for (size_t subArg = 0; subArg < argument.getNumParameters(); ++subArg)
196 {
197 size_t index = arg + subArg + 1;
198 if (index >= mCommandLine.size())
199 {
200 throw MissingArgumentParameterException(mCommandLine[arg]);
201 }
202 argument.setValue(mCommandLine[index], subArg);
203 }
204 arg += 1 + argument.getNumParameters();
205 }
206
207 for (const auto & argument : mArguments)
208 {
209 if (argument.second.isRequired() && !argument.second.isSet())
210 {
211 throw MissingArgumentException(argument.first);
212 }
213 }
214
215 for (const auto & argument : mNoSwitchArguments)
216 {
217 if (argument.isRequired() && !argument.isSet())
218 {
219 throw MissingArgumentException(argument.getHint());
220 }
221 }
222 }
223 catch (exception& e)
224 {
225 mParseError = e.what();
226 return false;
227 }

Callers 2

mainFunction · 0.80
TEST_METHODFunction · 0.80

Calls 11

getNumParametersMethod · 0.80
isRequiredMethod · 0.80
beginMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
setValueMethod · 0.45
isSetMethod · 0.45
whatMethod · 0.45

Tested by 1

TEST_METHODFunction · 0.64