VapourSynth-llvmexpr
Loading...
Searching...
No Matches
EnumName.hpp File Reference
#include <array>
#include <string_view>
#include <type_traits>
#include <utility>
Include dependency graph for EnumName.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  llvmexpr_enum_detail

Functions

template<auto value>
consteval std::string_view enum_name ()
template<typename T, std::size_t N>
consteval bool llvmexpr_enum_detail::is_valid_enum ()
template<typename T, std::size_t N = 1>
consteval std::size_t llvmexpr_enum_detail::find_upper_bound ()
template<typename T, std::size_t Low, std::size_t High>
consteval std::size_t llvmexpr_enum_detail::binary_search_count ()
template<typename T>
consteval std::size_t llvmexpr_enum_detail::enum_count ()
template<typename T, std::size_t... Is>
consteval auto llvmexpr_enum_detail::make_names_impl (std::index_sequence< Is... >)
template<typename T>
consteval auto llvmexpr_enum_detail::make_names ()
template<typename T>
constexpr std::size_t enum_max ()
template<typename T>
constexpr std::string_view enum_name (T value)

Function Documentation

◆ enum_max()

template<typename T>
std::size_t enum_max ( )
constexpr

Definition at line 110 of file EnumName.hpp.

110 {
112}
consteval std::size_t enum_count()
Definition EnumName.hpp:95

References llvmexpr_enum_detail::enum_count().

◆ enum_name() [1/2]

template<auto value>
std::string_view enum_name ( )
consteval

Copyright (C) 2025 yuygfgg

This file is part of Vapoursynth-llvmexpr.

Vapoursynth-llvmexpr is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Vapoursynth-llvmexpr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Vapoursynth-llvmexpr. If not, see https://www.gnu.org/licenses/.

The implementation is modified from https://github.com/Neargye/magic_enum which is licensed under the MIT License.

MIT License

Copyright (c) 2019 - 2024 Daniil Goncharov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 57 of file EnumName.hpp.

57 {
58 constexpr std::string_view NAME = __PRETTY_FUNCTION__;
59 constexpr auto START = NAME.find('=') + 2;
60 constexpr auto END = NAME.size() - 1;
61 constexpr auto FULL = NAME.substr(START, END - START);
62 constexpr auto LAST_COLON = FULL.rfind("::");
63 return LAST_COLON == std::string_view::npos ? FULL
64 : FULL.substr(LAST_COLON + 2);
65}

Referenced by infix2postfix::AnalysisEngine::formatDiagnostics(), llvmexpr_enum_detail::is_valid_enum(), llvmexpr_enum_detail::make_names_impl(), and analysis::PropWriteTypeSafetyPass::run().

◆ enum_name() [2/2]

template<typename T>
std::string_view enum_name ( T value)
constexpr

Definition at line 116 of file EnumName.hpp.

116 {
117 static constexpr auto NAMES = llvmexpr_enum_detail::make_names<T>();
118 const auto index = static_cast<std::size_t>(std::to_underlying(value));
119 return index < NAMES.size() ? NAMES[index] : std::string_view{};
120}
consteval auto make_names()
Definition EnumName.hpp:105

References llvmexpr_enum_detail::make_names().