| 18 | ViewNodePath::ViewNodePath(std::vector<ViewNodePathEntry> entries) : _entries(std::move(entries)) {} |
| 19 | |
| 20 | Result<ViewNodePath> ViewNodePath::parse(const std::string_view& str) { |
| 21 | std::vector<ViewNodePathEntry> entries; |
| 22 | |
| 23 | TextParser parser(str); |
| 24 | |
| 25 | while (!parser.isAtEnd()) { |
| 26 | if (!entries.empty()) { |
| 27 | if (!parser.tryParse('.') && !parser.tryParse(':')) { |
| 28 | parser.setErrorAtCurrentPosition("Missing dot or colon separator"); |
| 29 | return parser.getError(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | auto identifier = parser.parseIdentifier(); |
| 34 | if (!identifier) { |
| 35 | return parser.getError(); |
| 36 | } |
| 37 | |
| 38 | int itemIndex = 0; |
| 39 | if (parser.tryParse('[')) { |
| 40 | auto itemIndexResult = parser.parseInt(); |
| 41 | if (!itemIndexResult || !parser.parse(']')) { |
| 42 | return parser.getError(); |
| 43 | } |
| 44 | itemIndex = itemIndexResult.value(); |
| 45 | } |
| 46 | |
| 47 | entries.emplace_back(StringCache::getGlobal().makeString(identifier.value()), itemIndex); |
| 48 | } |
| 49 | |
| 50 | return ViewNodePath(std::move(entries)); |
| 51 | } |
| 52 | |
| 53 | const std::vector<ViewNodePathEntry>& ViewNodePath::getEntries() const { |
| 54 | return _entries; |
nothing calls this directly
no test coverage detected