| 102 | } |
| 103 | |
| 104 | bool EatMwmName(base::MemTrie<storage::CountryId, base::VectorValues<bool>> const & countriesTrie, string & s, |
| 105 | storage::CountryId & mwmName) |
| 106 | { |
| 107 | TrimLeadingSpaces(s); |
| 108 | |
| 109 | // Greedily eat as much as possible because some country names are prefixes of others. |
| 110 | optional<size_t> lastPos; |
| 111 | for (size_t i = 0; i < s.size(); ++i) |
| 112 | { |
| 113 | // todo(@m) This must be much faster but MemTrie's iterators do not expose nodes. |
| 114 | if (countriesTrie.HasKey(s.substr(0, i))) |
| 115 | lastPos = i; |
| 116 | } |
| 117 | if (!lastPos) |
| 118 | return false; |
| 119 | |
| 120 | mwmName = s.substr(0, *lastPos); |
| 121 | s = s.substr(*lastPos); |
| 122 | strings::EatPrefix(s, ".mwm"); |
| 123 | return true; |
| 124 | } |
| 125 | |
| 126 | bool EatVersion(string & s, uint32_t & version) |
| 127 | { |
no test coverage detected