KOSMIndoorMap
7#ifndef KOSM_STRINGPOOL_H
8#define KOSM_STRINGPOOL_H
10#include "kosm_export.h"
17enum class StringMemory { Persistent, Transient };
20class KOSM_EXPORT StringKeyRegistryBase
23 explicit StringKeyRegistryBase();
24 StringKeyRegistryBase(StringKeyRegistryBase&&)
noexcept;
25 StringKeyRegistryBase& operator=(StringKeyRegistryBase&&)
noexcept;
26 ~StringKeyRegistryBase();
28 [[nodiscard]]
const char* makeKeyInternal(
const char *name, std::size_t len, StringMemory memOpt);
29 [[nodiscard]]
const char* keyInternal(
const char *name)
const;
31 std::vector<char*> m_pool;
32 std::vector<const char*> m_registry;
39class StringKeyRegistry :
protected StringKeyRegistryBase
42 explicit StringKeyRegistry() =
default;
43 StringKeyRegistry(
const StringKeyRegistry&) =
delete;
44 StringKeyRegistry(StringKeyRegistry&&) =
default;
45 ~StringKeyRegistry() =
default;
46 StringKeyRegistry& operator=(
const StringKeyRegistry&) =
delete;
47 StringKeyRegistry& operator=(StringKeyRegistry&&) =
default;
50 inline T
makeKey(
const char *name, StringMemory memOpt)
52 return makeKey(name, std::strlen(name), memOpt);
54 inline T
makeKey(
const char *name, std::size_t len, StringMemory memOpt)
57 key.key = makeKeyInternal(name, len, memOpt);
62 inline T
key(
const char *name)
const
65 key.key = keyInternal(name);
74 constexpr inline StringKey() =
default;
75 constexpr inline const char* name()
const {
return key; }
76 constexpr inline bool isNull()
const {
return !key; }
79 inline constexpr bool operator<(StringKey other)
const {
return key < other.key; }
80 inline constexpr bool operator==(StringKey other)
const {
return key == other.key; }
81 inline constexpr bool operator!=(StringKey other)
const {
return key != other.key; }
84 explicit constexpr inline StringKey(
const char *keyData) : key(keyData) {}
87 template <
typename T>
friend class StringKeyRegistry;
88 const char* key =
nullptr;
T makeKey(const char *name, StringMemory memOpt)
Add a new string to the registry if needed, or returns an existing one if already present.
T key(const char *name) const
Looks up an existing key, if that doesn't exist an null key is returned.
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:54:42 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.