MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / getCmdLineArgumentFloat

Function getCmdLineArgumentFloat

Common/helper_string.h:212–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212inline float getCmdLineArgumentFloat(const int argc, const char **argv,
213 const char *string_ref) {
214 bool bFound = false;
215 float value = -1;
216
217 if (argc >= 1) {
218 for (int i = 1; i < argc; i++) {
219 int string_start = stringRemoveDelimiter('-', argv[i]);
220 const char *string_argv = &argv[i][string_start];
221 int length = static_cast<int>(strlen(string_ref));
222
223 if (!STRNCASECMP(string_argv, string_ref, length)) {
224 if (length + 1 <= static_cast<int>(strlen(string_argv))) {
225 int auto_inc = (string_argv[length] == '=') ? 1 : 0;
226 value = static_cast<float>(atof(&string_argv[length + auto_inc]));
227 } else {
228 value = 0.f;
229 }
230
231 bFound = true;
232 continue;
233 }
234 }
235 }
236
237 if (bFound) {
238 return value;
239 } else {
240 return 0;
241 }
242}
243
244inline bool getCmdLineArgumentString(const int argc, const char **argv,
245 const char *string_ref,

Callers 2

keyboardFuncFunction · 0.85
mainFunction · 0.85

Calls 1

stringRemoveDelimiterFunction · 0.85

Tested by

no test coverage detected