MCPcopy Create free account
hub / github.com/duckdb/duckdb / StringToBool

Method StringToBool

tools/shell/shell.cpp:1276–1296  ·  view source on GitHub ↗

** Interpret zArg as either an integer or a boolean value. Return 1 or 0 ** for TRUE and FALSE. Return the integer value if appropriate. */

Source from the content-addressed store, hash-verified

1274** for TRUE and FALSE. Return the integer value if appropriate.
1275*/
1276bool ShellState::StringToBool(const string &zArg) {
1277 idx_t i;
1278 if (zArg[0] == '0' && zArg[1] == 'x') {
1279 for (i = 2; hexDigitValue(zArg[i]) >= 0; i++) {
1280 }
1281 } else {
1282 for (i = 0; zArg[i] >= '0' && zArg[i] <= '9'; i++) {
1283 }
1284 }
1285 if (i > 0 && zArg[i] == 0) {
1286 return bool(ShellState::StringToInt(zArg) & 0xffffffff);
1287 }
1288 if (StringUtil::CIEquals(zArg, "on") || StringUtil::CIEquals(zArg, "yes")) {
1289 return true;
1290 }
1291 if (StringUtil::CIEquals(zArg, "off") || StringUtil::CIEquals(zArg, "no")) {
1292 return false;
1293 }
1294 PrintF(PrintOutput::STDERR, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", zArg.c_str());
1295 return false;
1296}
1297
1298/*
1299** Set or clear a shell flag according to a boolean value.

Callers 10

ToggleBailFunction · 0.80
ToggleBinaryFunction · 0.80
SetLargeNumberRenderingFunction · 0.80
ToggleHeadersFunction · 0.80
ToggleHighlighErrorsFunction · 0.80
ToggleHighlightResultFunction · 0.80
ToggleHighlightingFunction · 0.80
ToggleErrorRenderingFunction · 0.80
ToggleTimerMethod · 0.80

Calls 2

hexDigitValueFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected