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

sponsored_object_base.hpp « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e2c273543e56f58310c5fdbc215a216d6da69099 (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
43
44
45
46
47
48
49
50
51
#pragma once

#include "geometry/latlon.hpp"

#include "base/newtype.hpp"

#include <iomanip>
#include <limits>
#include <string>

namespace generator
{
struct SponsoredObjectBase
{
  NEWTYPE(uint32_t, ObjectId);

  static constexpr ObjectId InvalidObjectId()
  {
    return ObjectId(std::numeric_limits<typename ObjectId::RepType>::max());
  }

  virtual ~SponsoredObjectBase() {}

  template<typename Fields>
  static constexpr size_t FieldIndex(Fields field) { return static_cast<size_t>(field); }

  template<typename Fields>
  static constexpr size_t FieldsCount() { return static_cast<size_t>(Fields::Counter); }

  bool HasAddresParts() const { return !m_street.empty() || !m_houseNumber.empty(); }

  ObjectId m_id{InvalidObjectId()};
  ms::LatLon m_latLon = ms::LatLon::Zero();
  std::string m_name;
  std::string m_street;
  std::string m_houseNumber;

  std::string m_address;
  std::string m_descUrl;
};

NEWTYPE_SIMPLE_OUTPUT(SponsoredObjectBase::ObjectId);

inline std::ostream & operator<<(std::ostream & s, SponsoredObjectBase const & h)
{
  s << std::fixed << std::setprecision(7);
  s << "Id: " << h.m_id << "\t Name: " << h.m_name << "\t Address: " << h.m_address
    << "\t lat: " << h.m_latLon.lat << " lon: " << h.m_latLon.lon;
  return s;
}
}  // namespace generator