Blender V5.3
BLI_generic_key_string.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_generic_key.hh"
12#include "BLI_string_ref.hh"
13#include "BLI_utility_mixins.hh"
14
15namespace blender {
16
19 private:
20 std::string value_;
22 StringRef value_ref_;
23
24 public:
25 GenericStringKey(StringRef value) : value_ref_(value) {}
26
27 uint64_t hash() const override
28 {
29 return get_default_hash(value_ref_);
30 }
31
32 friend bool operator==(const GenericStringKey &a, const GenericStringKey &b)
33 {
34 return a.value_ref_ == b.value_ref_;
35 }
36
37 bool equal_to(const GenericKey &other) const override
38 {
39 if (const auto *other_typed = dynamic_cast<const GenericStringKey *>(&other)) {
40 return value_ref_ == other_typed->value_ref_;
41 }
42 return false;
43 }
44
45 std::unique_ptr<GenericKey> to_storable() const override
46 {
47 auto storable_key = std::make_unique<GenericStringKey>("");
48 storable_key->value_ = value_ref_;
49 storable_key->value_ref_ = storable_key->value_;
50 return storable_key;
51 }
52};
53
54} // namespace blender
uint64_t hash() const override
friend bool operator==(const GenericStringKey &a, const GenericStringKey &b)
std::unique_ptr< GenericKey > to_storable() const override
bool equal_to(const GenericKey &other) const override
NonMovable(NonMovable &&other)=delete
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:252