Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reader.cpp « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f519a9e79c25048e21f464e717bba8c8170254c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "coding/reader.hpp"

#include "base/string_utils.hpp"


void Reader::ReadAsString(string & s) const
{
  s.clear();
  size_t const sz = static_cast<size_t>(Size());
  s.resize(sz);
  Read(0, &s[0], sz);
}

bool Reader::IsEqual(string const & name1, string const & name2)
{
#if defined(OMIM_OS_WINDOWS)
  return strings::EqualNoCase(name1, name2);
#else
  return (name1 == name2);
#endif
}

namespace
{
  bool AssertPosAndSizeImpl(uint64_t pos, uint64_t size, uint64_t readerSize)
  {
    bool const ret1 = (pos + size <= readerSize);
    bool const ret2 = (size <= static_cast<size_t>(-1));
    ASSERT ( ret1 && ret2, (pos, size, readerSize) );
    return (ret1 && ret2);
  }
}

bool MemReader::AssertPosAndSize(uint64_t pos, uint64_t size) const
{
  return AssertPosAndSizeImpl(pos, size, Size());
}

bool SharedMemReader::AssertPosAndSize(uint64_t pos, uint64_t size) const
{
  return AssertPosAndSizeImpl(pos, size, Size());
}