MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Tools / parse_arguments

Function parse_arguments

vulkaninfo/vulkaninfo.cpp:1314–1385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1312};
1313
1314util::vulkaninfo_optional<ParsedResults> parse_arguments(int argc, char **argv, std::string executable_name) {
1315 ParsedResults results{};
1316 results.default_filename = APP_SHORT_NAME ".txt";
1317 for (int i = 1; i < argc; ++i) {
1318 // A internal-use-only format for communication with the Vulkan Configurator tool
1319 // Usage "--vkconfig_output <path>"
1320 // -o can be used to specify the filename instead
1321 if (0 == strcmp("--vkconfig_output", argv[i])) {
1322 results.output_category = OutputCategory::vkconfig_output;
1323 results.print_to_file = true;
1324 results.default_filename = APP_SHORT_NAME ".json";
1325 if (argc > (i + 1) && argv[i + 1][0] != '-') {
1326#ifdef WIN32
1327 results.filename = (std::string(argv[i + 1]) + "\\" APP_SHORT_NAME ".json");
1328#else
1329 results.filename = (std::string(argv[i + 1]) + "/" APP_SHORT_NAME ".json");
1330#endif
1331 ++i;
1332 }
1333 } else if (strncmp("--json", argv[i], 6) == 0 || strncmp(argv[i], "-j", 2) == 0) {
1334 if (strlen(argv[i]) > 7 && strncmp("--json=", argv[i], 7) == 0) {
1335 results.selected_gpu = static_cast<uint32_t>(strtol(argv[i] + 7, nullptr, 10));
1336 results.has_selected_gpu = true;
1337 }
1338 if (strlen(argv[i]) > 3 && strncmp("-j=", argv[i], 3) == 0) {
1339 results.selected_gpu = static_cast<uint32_t>(strtol(argv[i] + 3, nullptr, 10));
1340 results.has_selected_gpu = true;
1341 }
1342 results.output_category = OutputCategory::profile_json;
1343 results.default_filename = APP_SHORT_NAME ".json";
1344 results.print_to_file = true;
1345 } else if (strcmp(argv[i], "--summary") == 0) {
1346 results.output_category = OutputCategory::summary;
1347 } else if (strcmp(argv[i], "--text") == 0) {
1348 results.output_category = OutputCategory::text;
1349 results.default_filename = APP_SHORT_NAME ".txt";
1350 } else if (strcmp(argv[i], "--html") == 0) {
1351 results.output_category = OutputCategory::html;
1352 results.print_to_file = true;
1353 results.default_filename = APP_SHORT_NAME ".html";
1354 } else if (strcmp(argv[i], "--show-all") == 0) {
1355 results.show.all = true;
1356 results.show.tool_props = true;
1357 results.show.formats = true;
1358 results.show.promoted_structs = true;
1359 results.show.video_props = true;
1360 } else if (strcmp(argv[i], "--show-tool-props") == 0) {
1361 results.show.tool_props = true;
1362 } else if (strcmp(argv[i], "--show-formats") == 0) {
1363 results.show.formats = true;
1364 } else if (strcmp(argv[i], "--show-promoted-structs") == 0) {
1365 results.show.promoted_structs = true;
1366 } else if (strcmp(argv[i], "--show-video-props") == 0) {
1367 results.show.video_props = true;
1368 } else if ((strcmp(argv[i], "--output") == 0 || strcmp(argv[i], "-o") == 0) && argc > (i + 1)) {
1369 if (argv[i + 1][0] == '-') {
1370 std::cout << "-o or --output must be followed by a filename\n";
1371 return {};

Callers 1

mainFunction · 0.85

Calls 1

print_usageFunction · 0.85

Tested by

no test coverage detected