Blender V5.0
node_enum.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "util/map.h"
8#include "util/param.h"
9
11
12/* Enum
13 *
14 * Utility class for enum values. */
15
16struct NodeEnum {
17 bool empty() const
18 {
19 return left.empty();
20 }
21 void insert(const char *x, const int y)
22 {
23 const ustring ustr_x(x);
24
25 left[ustr_x] = y;
26 right[y] = ustr_x;
27 }
28
29 bool exists(ustring x) const
30 {
31 return left.find(x) != left.end();
32 }
33 bool exists(const int y) const
34 {
35 return right.find(y) != right.end();
36 }
37
38 int operator[](const char *x) const
39 {
40 return left.find(ustring(x))->second;
41 }
42 int operator[](ustring x) const
43 {
44 return left.find(x)->second;
45 }
46 ustring operator[](int y) const
47 {
48 return right.find(y)->second;
49 }
50
51 unordered_map<ustring, int>::const_iterator begin() const
52 {
53 return left.begin();
54 }
55 unordered_map<ustring, int>::const_iterator end() const
56 {
57 return left.end();
58 }
59
60 private:
61 unordered_map<ustring, int> left;
62 unordered_map<int, ustring> right;
63};
64
#define CCL_NAMESPACE_END
static int left
ustring operator[](int y) const
Definition node_enum.h:46
int operator[](ustring x) const
Definition node_enum.h:42
unordered_map< ustring, int >::const_iterator end() const
Definition node_enum.h:55
void insert(const char *x, const int y)
Definition node_enum.h:21
bool empty() const
Definition node_enum.h:17
bool exists(const int y) const
Definition node_enum.h:33
unordered_map< ustring, int >::const_iterator begin() const
Definition node_enum.h:51
int operator[](const char *x) const
Definition node_enum.h:38
bool exists(ustring x) const
Definition node_enum.h:29