mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
60
coding/serdes_binary_header.hpp
Normal file
60
coding/serdes_binary_header.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/write_to_sink.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace coding
|
||||
{
|
||||
namespace binary
|
||||
{
|
||||
struct HeaderSizeOfVisitor
|
||||
{
|
||||
void operator()(uint64_t v, char const * /* name */ = nullptr) { m_size += sizeof(v); }
|
||||
|
||||
template <typename R>
|
||||
void operator()(R & r, char const * /* name */ = nullptr)
|
||||
{
|
||||
r.Visit(*this);
|
||||
}
|
||||
|
||||
uint64_t m_size = 0;
|
||||
};
|
||||
|
||||
template <typename Sink>
|
||||
struct HeaderSerVisitor
|
||||
{
|
||||
HeaderSerVisitor(Sink & sink) : m_sink(sink) {}
|
||||
|
||||
void operator()(uint64_t v, char const * /* name */ = nullptr) { WriteToSink(m_sink, v); }
|
||||
|
||||
template <typename R>
|
||||
void operator()(R & r, char const * /* name */ = nullptr)
|
||||
{
|
||||
r.Visit(*this);
|
||||
}
|
||||
|
||||
Sink & m_sink;
|
||||
};
|
||||
|
||||
template <typename Source>
|
||||
struct HeaderDesVisitor
|
||||
{
|
||||
HeaderDesVisitor(Source & source): m_source(source) {}
|
||||
|
||||
void operator()(uint64_t & v, char const * /* name */ = nullptr)
|
||||
{
|
||||
v = ReadPrimitiveFromSource<uint64_t>(m_source);
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
void operator()(R & r, char const * /* name */ = nullptr)
|
||||
{
|
||||
r.Visit(*this);
|
||||
}
|
||||
|
||||
Source & m_source;
|
||||
};
|
||||
} // namespace binary
|
||||
} // namespace coding
|
||||
Reference in New Issue
Block a user