MCPcopy Create free account
hub / github.com/comaps/comaps / EatMwmName

Function EatMwmName

libs/search/processor.cpp:104–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104bool 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
126bool EatVersion(string & s, uint32_t & version)
127{

Callers 1

SearchByFeatureIdMethod · 0.85

Calls 4

TrimLeadingSpacesFunction · 0.85
EatPrefixFunction · 0.85
sizeMethod · 0.45
HasKeyMethod · 0.45

Tested by

no test coverage detected