MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / getIntEnvVarValueOrDefault

Function getIntEnvVarValueOrDefault

tests/utils/config.cpp:27–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27int getIntEnvVarValueOrDefault(string name, int defaultValue) {
28
29 string strValue = getEnvVarValue(name);
30 int intValue = defaultValue;
31
32 // overwrite default only when passed variable is interpretable
33 try {
34 intValue = std::stoi(strValue);
35 }
36 catch (const std::out_of_range&) { }
37 catch (const std::invalid_argument&) { }
38 return intValue;
39}
40
41
42/*

Calls 1

getEnvVarValueFunction · 0.85

Tested by

no test coverage detected