Blender V5.0
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
5#pragma once
6
7#include "BLI_generic_key.hh"
8#include "BLI_string_ref.hh"
10#include "BLI_utility_mixins.hh"
11
12namespace blender {
13
16 private:
17 std::string value_;
19 StringRef value_ref_;
20
21 public:
22 GenericStringKey(StringRef value) : value_ref_(value) {}
23
24 uint64_t hash() const override
25 {
26 return get_default_hash(value_ref_);
27 }
28
30
31 bool equal_to(const GenericKey &other) const override
32 {
33 if (const auto *other_typed = dynamic_cast<const GenericStringKey *>(&other)) {
34 return value_ref_ == other_typed->value_ref_;
35 }
36 return false;
37 }
38
39 std::unique_ptr<GenericKey> to_storable() const override
40 {
41 auto storable_key = std::make_unique<GenericStringKey>("");
42 storable_key->value_ = value_ref_;
43 storable_key->value_ref_ = storable_key->value_;
44 return storable_key;
45 }
46};
47
48} // namespace blender
#define BLI_STRUCT_EQUALITY_OPERATORS_1(Type, m)
unsigned long long int uint64_t
uint64_t hash() const override
std::unique_ptr< GenericKey > to_storable() const override
bool equal_to(const GenericKey &other) const override
NonMovable(NonMovable &&other)=delete
uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:233