22322 {
22323 string catalog;
22324 string schema;
22325 string entry;
22326 bool finished = false;
22327normal:
22328 for (; idx < input.size(); idx++) {
22329 if (input[idx] == '"') {
22330 idx++;
22331 goto quoted;
22332 } else if (input[idx] == '.') {
22333 goto separator;
22334 } else if (input[idx] == ',') {
22335 finished = true;
22336 goto separator;
22337 }
22338 entry += input[idx];
22339 }
22340 finished = true;
22341 goto separator;
22342quoted:
22344 for (; idx < input.size(); idx++) {
22345 if (input[idx] == '"') {
22347 idx++;
22348 if (idx < input.size() && input[idx] == '"') {
22349
22350 entry += input[idx];
22351 continue;
22352 }
22353 goto normal;
22354 }
22355 entry += input[idx];
22356 }
22357 throw ParserException("Unterminated quote in qualified name!");
22358separator:
22359 if (entry.empty()) {
22360 throw ParserException("Unexpected dot - empty CatalogSearchEntry");
22361 }
22362 if (schema.empty()) {
22363
22364 schema = std::move(entry);
22365 } else if (catalog.empty()) {
22366
22367 catalog = std::move(schema);
22368 schema = std::move(entry);
22369 } else {
22370 throw ParserException("Too many dots - expected [schema] or [catalog.schema] for CatalogSearchEntry");
22371 }
22372 entry = "";
22373 idx++;
22374 if (finished) {
22375 goto final;
22376 }
22377 goto normal;
22378final:
22379 if (schema.empty()) {
22380 throw ParserException("Unexpected end of entry - empty CatalogSearchEntry");
22381 }
22382 return CatalogSearchEntry(std::move(catalog), std::move(schema));
22383}