TMwmSize CountryFile::GetRemoteSize(MapOptions filesMask) const { uint32_t size = 0; if (HasOptions(filesMask, MapOptions::Map)) size += m_mapSize; if (HasOptions(filesMask, MapOptions::CarRouting)) size += m_routingSize; return size; }
void QueuedCountry::AddOptions(MapOptions opt) { for (MapOptions file : {MapOptions::Map, MapOptions::CarRouting}) { if (HasOptions(opt, file) && !HasOptions(m_init, file)) { m_init = SetOptions(m_init, file); m_left = SetOptions(m_left, file); } } }
void QueuedCountry::RemoveOptions(MapOptions opt) { for (MapOptions file : {MapOptions::Map, MapOptions::CarRouting, MapOptions::Diff}) { if (HasOptions(opt, file) && HasOptions(m_init, file)) { m_init = UnsetOptions(m_init, file); m_left = UnsetOptions(m_left, file); } } if (HasOptions(opt, m_current)) m_current = LeastSignificantOption(m_left); }
bool QueuedCountry::SwitchToNextFile() { ASSERT(HasOptions(m_left, m_current), ("Current file (", m_current, ") is not specified in left files (", m_left, ").")); m_left = UnsetOptions(m_left, m_current); m_current = LeastSignificantOption(m_left); return m_current != MapOptions::Nothing; }
void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries) { // Check whether a request was scheduled to be run on the thread. if (!m_fetcherThread) return; m_fetcherThread->Join(); for (auto const & point : m_fetcherThread->GetRoutineAs<OnlineCrossFetcher>()->GetMwmPoints()) { string name = m_countryFileFn(point); auto localFile = m_countryLocalFileFn(name); if (localFile && HasOptions(localFile->GetFiles(), MapOptions::MapWithCarRouting)) continue; LOG(LINFO, ("Needs: ", name)); countries.emplace_back(move(name)); } m_fetcherThread.reset(); }
bool dhcp_message::NextOption(dhcp_option_cookie& cookie, message_option& option, const uint8*& data, size_t& size) const { if (cookie.state == 0) { if (!HasOptions()) return false; cookie.state++; cookie.next = options; } uint32 bytesLeft = 0; switch (cookie.state) { case 1: // options from "options" bytesLeft = sizeof(options) + cookie.next - options; break; case 2: // options from "file" bytesLeft = sizeof(options) + cookie.next - options; break; case 3: // options from "server_name" bytesLeft = sizeof(options) + cookie.next - options; break; } while (true) { if (bytesLeft == 0) { // TODO: suppport OPTION_OVERLOAD! cookie.state = 4; return false; } option = (message_option)cookie.next[0]; if (option == OPTION_END) { cookie.state = 4; return false; } else if (option == OPTION_PAD) { bytesLeft--; cookie.next++; continue; } size = cookie.next[1]; data = &cookie.next[2]; cookie.next += 2 + size; if (option == OPTION_OVERLOAD) { cookie.file_has_options = data[0] & 1; cookie.server_name_has_options = data[0] & 2; continue; } return true; } }