MCPcopy Create free account
hub / github.com/Snapchat/Valdi / readList

Function readList

valdi_core/src/valdi_core/cpp/Schema/ValueSchemaParser.cpp:21–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20template<typename T, typename F>
21static bool readList(TextParser& parser, char characterStart, char characterEnd, F&& itemParser) {
22 if (!parser.parse(characterStart)) {
23 return false;
24 }
25
26 bool needsComma = false;
27
28 for (;;) {
29 if (!parser.ensureNotAtEnd()) {
30 return false;
31 }
32 if (parser.tryParse(characterEnd)) {
33 break;
34 }
35 if (needsComma) {
36 if (!parser.parse(',')) {
37 break;
38 }
39 parser.tryParseWhitespaces();
40 } else {
41 needsComma = true;
42 }
43
44 auto item = itemParser(parser);
45 if (!item) {
46 return false;
47 }
48 }
49
50 return true;
51}
52
53template<typename T, typename F>
54static std::optional<ParseListVector<T>> parseList(TextParser& parser,

Callers

nothing calls this directly

Calls 4

tryParseWhitespacesMethod · 0.80
parseMethod · 0.45
ensureNotAtEndMethod · 0.45
tryParseMethod · 0.45

Tested by

no test coverage detected