MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / parseKeyOrValue

Function parseKeyOrValue

src/function/cast_from_string_functions.cpp:460–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458
459template<typename T>
460static bool parseKeyOrValue(const char*& input, const char* end, T& state, bool isKey,
461 bool& closeBracket, const CSVOption* option) {
462 auto start = input;
463 uint64_t lvl = 0;
464
465 while (input < end) {
466 if (*input == '"' || *input == '\'') {
467 if (!skipToCloseQuotes(input, end)) {
468 return false;
469 }
470 } else if (*input == '{') {
471 if (!skipToClose(input, end, lvl, '}', option)) {
472 return false;
473 }
474 } else if (*input == CopyConstants::DEFAULT_CSV_LIST_BEGIN_CHAR) {
475 if (!skipToClose(input, end, lvl, CopyConstants::DEFAULT_CSV_LIST_END_CHAR, option)) {
476 return false;
477 }
478 } else if (isKey && *input == '=') {
479 return state.handleKey(start, input, option);
480 } else if (!isKey && (*input == ',' || *input == '}')) {
481 state.handleValue(start, input, option);
482 if (*input == '}') {
483 closeBracket = true;
484 }
485 return true;
486 }
487 input++;
488 }
489 return false;
490}
491
492// Split map of format: {a=12,b=13}
493template<typename T>

Callers 1

splitCStringMapFunction · 0.85

Calls 4

skipToCloseQuotesFunction · 0.85
skipToCloseFunction · 0.85
handleKeyMethod · 0.45
handleValueMethod · 0.45

Tested by

no test coverage detected