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

data_header.hpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa7decf3102f96b13258c1ec26bc03f7cce360f3 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include "../base/std_serialization.hpp"

#include "../storage/defines.hpp"

#include "../coding/streams_sink.hpp"

#include "../geometry/rect2d.hpp"

#include "../std/string.hpp"
#include "../std/tuple.hpp"

#include "../base/start_mem_debug.hpp"

namespace feature
{   
  /// All file sizes are in bytes
  class DataHeader
  {
  private:
    typedef tuple<
              pair<int64_t, int64_t> // boundary;
            > params_t;
    params_t m_params;

    enum param_t { EBoundary };

    template <int N>
    typename tuple_element<N, params_t>::type const & Get() const { return m_params.get<N>(); }
    template <int N, class T>
    void Set(T const & t) { m_params.get<N>() = t; }

  public:
    DataHeader();

    /// Zeroes all fields
    void Reset();

    m2::RectD const Bounds() const;
    void SetBounds(m2::RectD const & r);

    /// @name Serialization
    //@{
    template <class TWriter> void Save(TWriter & writer) const
    {
      stream::SinkWriterStream<TWriter> w(writer);
      w << MAPS_MAJOR_VERSION_BINARY_FORMAT;
      serial::save_tuple(w, m_params);
    }
    /// @return false if header can't be read (invalid or newer version format)
    template <class TReader> bool Load(TReader & reader)
    {
      stream::SinkReaderStream<TReader> r(reader);

      uint32_t ver;
      r >> ver;
      if (ver > MAPS_MAJOR_VERSION_BINARY_FORMAT)
        return false;
      Reset();
      serial::load_tuple(r, m_params);
      return true;
    }
    //@}
  };

}

#include "../base/stop_mem_debug.hpp"