cesium-native 0.45.0
Loading...
Searching...
No Matches
Enum.h
1#pragma once
2
3#include <CesiumGltf/EnumSpec.h>
4#include <CesiumGltf/Library.h>
5
6#include <algorithm>
7#include <optional>
8#include <string_view>
9
10namespace CesiumGltf {
12struct CESIUMGLTF_API Enum final : public EnumSpec {
13 Enum() = default;
14
23 template <typename T>
24 std::optional<std::string_view> getName(T enumValue) const {
25 const auto found = std::find_if(
26 this->values.begin(),
27 this->values.end(),
28 [value = static_cast<int64_t>(enumValue)](
29 const CesiumGltf::EnumValue& enumValue) {
30 return enumValue.value == value;
31 });
32
33 if (found == this->values.end()) {
34 return std::nullopt;
35 }
36
37 return found->name;
38 }
39};
40} // namespace CesiumGltf
Classes for working with glTF models.
An object defining the values of an enum.
Definition EnumSpec.h:17
An enum value.
Definition EnumValue.h:16
This class is not meant to be instantiated directly. Use Enum instead.
Definition Enum.h:12
std::optional< std::string_view > getName(T enumValue) const
Obtains the name corresponding to the given enum integer value from this enum definition.
Definition Enum.h:24