mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +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:
46
indexer/custom_keyvalue.cpp
Normal file
46
indexer/custom_keyvalue.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "custom_keyvalue.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/varint.hpp"
|
||||
#include "coding/writer.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace indexer
|
||||
{
|
||||
|
||||
CustomKeyValue::CustomKeyValue(std::string_view buffer)
|
||||
{
|
||||
MemReader reader(buffer.data(), buffer.size());
|
||||
ReaderSource src(reader);
|
||||
|
||||
while (src.Size() > 0)
|
||||
{
|
||||
uint8_t const type = ReadPrimitiveFromSource<uint8_t>(src);
|
||||
m_vals.emplace_back(type, ReadVarUint<uint64_t>(src));
|
||||
}
|
||||
}
|
||||
|
||||
std::string CustomKeyValue::ToString() const
|
||||
{
|
||||
std::string res;
|
||||
MemWriter<std::string> writer(res);
|
||||
for (auto const & v : m_vals)
|
||||
{
|
||||
WriteToSink(writer, v.first);
|
||||
WriteVarUint(writer, v.second);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string DebugPrint(CustomKeyValue const & kv)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "CustomKeyValue [";
|
||||
for (auto const & v : kv.m_vals)
|
||||
ss << "(" << v.first << ", " << v.second << "), ";
|
||||
ss << "]";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
} // namespace indexer
|
||||
Reference in New Issue
Block a user