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

Method ForEach

libs/map/gps_track_storage.cpp:219–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219void GpsTrackStorage::ForEach(std::function<bool(TItem const & item)> const & fn)
220{
221 ASSERT(m_stream.is_open(), ());
222
223 size_t i = 0;
224
225 // Set read position to the first item
226 m_stream.seekg(GetItemOffset(i), ios::beg);
227 if (!m_stream.good())
228 MYTHROW(ReadException, ("File:", m_filePath));
229
230 vector<char> buff(min(kItemBlockSize, m_itemCount) * kPointSize);
231 for (; i < m_itemCount;)
232 {
233 size_t const n = min(m_itemCount - i, kItemBlockSize);
234
235 m_stream.read(&buff[0], n * kPointSize);
236 if (!m_stream.good())
237 MYTHROW(ReadException, ("File:", m_filePath));
238
239 for (size_t j = 0; j < n; ++j)
240 {
241 TItem item;
242 Unpack(&buff[0] + j * kPointSize, item);
243 if (!fn(item))
244 return;
245 }
246
247 i += n;
248 }
249}

Callers 8

ForEachPointMethod · 0.45
InitCollectionMethod · 0.45
NotifyCallbackMethod · 0.45
FormatNewBookmarkNameMethod · 0.45
UNIT_TESTFunction · 0.45
UNIT_TESTFunction · 0.45
UNIT_TESTFunction · 0.45
UNIT_TESTFunction · 0.45

Calls 4

ASSERTFunction · 0.85
GetItemOffsetFunction · 0.85
UnpackFunction · 0.85
readMethod · 0.45

Tested by 3

UNIT_TESTFunction · 0.36
UNIT_TESTFunction · 0.36
UNIT_TESTFunction · 0.36