[storage] Moved the CountryDef serialization code closer to the class definition.

This commit is contained in:
Maxim Pimenov 2019-05-30 13:35:21 +03:00 committed by Tatiana Yan
parent 92990307e3
commit 5b0f8e3e0d
7 changed files with 33 additions and 45 deletions

View file

@ -4,7 +4,7 @@
#include "platform/platform.hpp"
#include "storage/country_polygon.hpp"
#include "storage/country_decl.hpp"
#include "indexer/scales.hpp"

View file

@ -16,7 +16,6 @@ set(
country_info_reader_light.hpp
country_parent_getter.cpp
country_parent_getter.hpp
country_polygon.hpp
country_tree.cpp
country_tree.hpp
diff_scheme/diff_manager.cpp

View file

@ -1,10 +1,18 @@
#pragma once
#include "storage/storage_defines.hpp"
#include "storage/country_decl.hpp"
#include "coding/geometry_coding.hpp"
#include "coding/point_coding.hpp"
#include "coding/read_write_utils.hpp"
#include "coding/varint.hpp"
#include "geometry/rect2d.hpp"
#include <cstdint>
#include <string>
#include <utility>
namespace storage
{
@ -38,4 +46,27 @@ struct CountryInfo
/// (if empty - equals to file name of country - no additional memory)
std::string m_name;
};
template <class Source>
void Read(Source & src, CountryDef & p)
{
rw::Read(src, p.m_countryId);
std::pair<int64_t, int64_t> r;
r.first = ReadVarInt<int64_t>(src);
r.second = ReadVarInt<int64_t>(src);
p.m_rect = Int64ToRectObsolete(r, serial::GeometryCodingParams().GetCoordBits());
}
template <class Sink>
void Write(Sink & sink, CountryDef const & p)
{
rw::Write(sink, p.m_countryId);
std::pair<int64_t, int64_t> const r =
RectToInt64Obsolete(p.m_rect, serial::GeometryCodingParams().GetCoordBits());
WriteVarInt(sink, r.first);
WriteVarInt(sink, r.second);
}
} // namespace storage

View file

@ -1,6 +1,6 @@
#include "storage/country_info_getter.hpp"
#include "storage/country_polygon.hpp"
#include "storage/country_decl.hpp"
#include "storage/country_tree.hpp"
#include "platform/local_country_file_utils.hpp"

View file

@ -1,7 +1,6 @@
#include "storage/country_info_reader_light.hpp"
#include "storage/country_decl.hpp"
#include "storage/country_polygon.hpp"
#include "platform/platform.hpp"
#include "platform/preferred_languages.hpp"

View file

@ -1,37 +0,0 @@
#pragma once
#include "storage/country_decl.hpp"
#include "coding/geometry_coding.hpp"
#include "coding/point_coding.hpp"
#include "coding/read_write_utils.hpp"
#include "coding/varint.hpp"
#include <cstdint>
#include <utility>
namespace storage
{
template <class Source>
void Read(Source & src, CountryDef & p)
{
rw::Read(src, p.m_countryId);
std::pair<int64_t, int64_t> r;
r.first = ReadVarInt<int64_t>(src);
r.second = ReadVarInt<int64_t>(src);
p.m_rect = Int64ToRectObsolete(r, serial::GeometryCodingParams().GetCoordBits());
}
template <class Sink>
void Write(Sink & sink, CountryDef const & p)
{
rw::Write(sink, p.m_countryId);
std::pair<int64_t, int64_t> const r =
RectToInt64Obsolete(p.m_rect, serial::GeometryCodingParams().GetCoordBits());
WriteVarInt(sink, r.first);
WriteVarInt(sink, r.second);
}
} // namespace storage

View file

@ -66,7 +66,6 @@
674125231B4C05FA00A3E828 /* storage_defines.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6741251D1B4C05FA00A3E828 /* storage_defines.cpp */; };
675343091A3F5A2600A0A8C3 /* country_decl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675342F21A3F5A2600A0A8C3 /* country_decl.cpp */; };
6753430A1A3F5A2600A0A8C3 /* country_decl.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342F31A3F5A2600A0A8C3 /* country_decl.hpp */; };
6753430D1A3F5A2600A0A8C3 /* country_polygon.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342F61A3F5A2600A0A8C3 /* country_polygon.hpp */; };
6753430F1A3F5A2600A0A8C3 /* country.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342F81A3F5A2600A0A8C3 /* country.hpp */; };
675343191A3F5A2600A0A8C3 /* storage_defines.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675343021A3F5A2600A0A8C3 /* storage_defines.hpp */; };
6753431A1A3F5A2600A0A8C3 /* storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675343031A3F5A2600A0A8C3 /* storage.cpp */; };
@ -292,7 +291,6 @@
675342E01A3F59EF00A0A8C3 /* libstorage.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libstorage.a; sourceTree = BUILT_PRODUCTS_DIR; };
675342F21A3F5A2600A0A8C3 /* country_decl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = country_decl.cpp; sourceTree = "<group>"; };
675342F31A3F5A2600A0A8C3 /* country_decl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = country_decl.hpp; sourceTree = "<group>"; };
675342F61A3F5A2600A0A8C3 /* country_polygon.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = country_polygon.hpp; sourceTree = "<group>"; };
675342F81A3F5A2600A0A8C3 /* country.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = country.hpp; sourceTree = "<group>"; };
675343021A3F5A2600A0A8C3 /* storage_defines.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = storage_defines.hpp; sourceTree = "<group>"; };
675343031A3F5A2600A0A8C3 /* storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = storage.cpp; sourceTree = "<group>"; };
@ -613,7 +611,6 @@
6741251D1B4C05FA00A3E828 /* storage_defines.cpp */,
675342F21A3F5A2600A0A8C3 /* country_decl.cpp */,
675342F31A3F5A2600A0A8C3 /* country_decl.hpp */,
675342F61A3F5A2600A0A8C3 /* country_polygon.hpp */,
675342F81A3F5A2600A0A8C3 /* country.hpp */,
675343021A3F5A2600A0A8C3 /* storage_defines.hpp */,
675343031A3F5A2600A0A8C3 /* storage.cpp */,
@ -664,7 +661,6 @@
files = (
674125201B4C05FA00A3E828 /* map_files_downloader.hpp in Headers */,
56D8CB9A1CAC17A80003F420 /* test_defines.hpp in Headers */,
6753430D1A3F5A2600A0A8C3 /* country_polygon.hpp in Headers */,
F68CC5C01F38B967007527C7 /* diff_types.hpp in Headers */,
401ECED51F56C50900DFDF76 /* country_parent_getter.hpp in Headers */,
34C9BCFD1C6CCF85000DC38D /* country_name_getter.hpp in Headers */,