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

Function splitCStringMap

src/function/cast_from_string_functions.cpp:494–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492// Split map of format: {a=12,b=13}
493template<typename T>
494static bool splitCStringMap(const char* input, uint64_t len, T& state, const CSVOption* option) {
495 auto end = input + len;
496 bool closeBracket = false;
497
498 skipWhitespace(input, end);
499 if (input == end || *input != '{') { // start with {
500 return false;
501 }
502 skipWhitespace(++input, end);
503 if (input == end) {
504 return false;
505 }
506 if (*input == '}') {
507 skipWhitespace(++input, end); // empty
508 return input == end;
509 }
510
511 while (input < end) {
512 if (!parseKeyOrValue(input, end, state, true, closeBracket, option)) {
513 return false;
514 }
515 skipWhitespace(++input, end);
516 if (!parseKeyOrValue(input, end, state, false, closeBracket, option)) {
517 return false;
518 }
519 skipWhitespace(++input, end);
520 if (closeBracket) {
521 return (input == end);
522 }
523 }
524 return false;
525}
526
527template<>
528void CastStringHelper::cast(const char* input, uint64_t len, map_entry_t& /*result*/,

Callers 1

castMethod · 0.85

Calls 2

skipWhitespaceFunction · 0.85
parseKeyOrValueFunction · 0.85

Tested by

no test coverage detected