MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / LoadOptions

Function LoadOptions

Source/Tools/pidof/pidof.cpp:23–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21std::unordered_set<std::string> Programs;
22
23void LoadOptions(int argc, char** argv) {
24 optparse::OptionParser Parser {};
25
26 Parser.add_option("-s").help("Single shot - Only returns one pid").action("store_true").set_default(SingleShot);
27
28 Parser.add_option("-q")
29 .help("Do not display matched PIDs to stdout. Simply exit with status of true or false if a PID was found")
30 .action("store_true")
31 .set_default(DoNotDisplay);
32
33 Parser.add_option("-z").help("Try to detect zombie processes - Usually zombie processes are skipped").action("store_false").set_default(SkipZombie);
34
35 Parser.add_option("-d").help("Use a different separator if more than one pid is show - Default is space").set_default(Separator);
36
37 Parser.add_option("-o").help("Ignore processes with matched pids").action("append");
38
39 optparse::Values Options = Parser.parse_args(argc, argv);
40
41 SingleShot = Options.get("s");
42 DoNotDisplay = Options.get("q");
43 SkipZombie = Options.get("z");
44 Separator = Options["d"];
45
46 for (const auto& Omit : Options.all("o")) {
47 std::istringstream ss {Omit};
48 std::string sub;
49 while (std::getline(ss, sub, ',')) {
50 int64_t pid;
51 auto ConvResult = std::from_chars(sub.data(), sub.data() + sub.size(), pid, 10);
52
53 // Invalid pid, skip.
54 if (ConvResult.ec == std::errc::invalid_argument) {
55 continue;
56 }
57
58 OmitPids.emplace(pid);
59 }
60 }
61
62 for (const auto& Program : Parser.args()) {
63 Programs.emplace(Program);
64 }
65}
66} // namespace Config
67
68bool FindWineFEXApplication(int64_t PID, std::string_view exe, const std::vector<std::string_view>& Args) {

Callers 1

mainFunction · 0.85

Calls 3

getMethod · 0.80
emplaceMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected