mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 14:13:45 +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:
44
indexer/custom_keyvalue.hpp
Normal file
44
indexer/custom_keyvalue.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/buffer_vector.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
namespace indexer
|
||||
{
|
||||
|
||||
class CustomKeyValue
|
||||
{
|
||||
buffer_vector<std::pair<uint8_t, uint64_t>, 2> m_vals;
|
||||
|
||||
public:
|
||||
CustomKeyValue() = default;
|
||||
explicit CustomKeyValue(std::string_view buffer);
|
||||
|
||||
void Add(uint8_t k, uint64_t v) { m_vals.emplace_back(k, v); }
|
||||
|
||||
std::optional<uint64_t> Get(uint8_t k) const
|
||||
{
|
||||
for (auto const & v : m_vals)
|
||||
{
|
||||
if (v.first == k)
|
||||
return v.second;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
uint64_t GetSure(uint8_t k) const
|
||||
{
|
||||
auto const res = Get(k);
|
||||
ASSERT(res, ());
|
||||
return *res;
|
||||
}
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
friend std::string DebugPrint(CustomKeyValue const & kv);
|
||||
};
|
||||
|
||||
} // namespace indexer
|
||||
Reference in New Issue
Block a user