Noticed while helping validate the soon to be released OpenImageIO 3.x. This cleanup makes 2 sets of changes to accommodate removed APIs [1]: - Remove `ustringHash` since it's been defined as `std::hash<ustring>` for quite some time and is fully removed in 3.0. - Replace `TypeDesc::Type*` types with just `Type*` as the former has been removed in 3.0. Cycles was using a mix of the deprecated and modern forms anyhow. [1] https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/main/docs/Deprecations-3.0.md Pull Request: https://projects.blender.org/blender/blender/pulls/129136
66 lines
1.1 KiB
C++
66 lines
1.1 KiB
C++
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#pragma once
|
|
|
|
#include "util/map.h"
|
|
#include "util/param.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
/* Enum
|
|
*
|
|
* Utility class for enum values. */
|
|
|
|
struct NodeEnum {
|
|
bool empty() const
|
|
{
|
|
return left.empty();
|
|
}
|
|
void insert(const char *x, int y)
|
|
{
|
|
ustring ustr_x(x);
|
|
|
|
left[ustr_x] = y;
|
|
right[y] = ustr_x;
|
|
}
|
|
|
|
bool exists(ustring x) const
|
|
{
|
|
return left.find(x) != left.end();
|
|
}
|
|
bool exists(int y) const
|
|
{
|
|
return right.find(y) != right.end();
|
|
}
|
|
|
|
int operator[](const char *x) const
|
|
{
|
|
return left.find(ustring(x))->second;
|
|
}
|
|
int operator[](ustring x) const
|
|
{
|
|
return left.find(x)->second;
|
|
}
|
|
ustring operator[](int y) const
|
|
{
|
|
return right.find(y)->second;
|
|
}
|
|
|
|
unordered_map<ustring, int>::const_iterator begin() const
|
|
{
|
|
return left.begin();
|
|
}
|
|
unordered_map<ustring, int>::const_iterator end() const
|
|
{
|
|
return left.end();
|
|
}
|
|
|
|
private:
|
|
unordered_map<ustring, int> left;
|
|
unordered_map<int, ustring> right;
|
|
};
|
|
|
|
CCL_NAMESPACE_END
|