#pragma once // // This file is distributed under the MIT License. See LICENSE.md for details. // #include #include #include #include "llvm/ADT/StringRef.h" namespace pipeline { template class Option { public: constexpr Option(const char *Name, T Default) : Default(std::forward(Default)), Name(Name) {} using Type = std::decay_t; T Default; const char *Name; }; template concept HasOptions = requires(T) { { T::Options }; }; /// TODO: Remove after updating to clang-format with concept support. struct ClangFormatPleaseDoNotBreakMyCode; // clang-format off // clang-format on namespace detail { template constexpr auto &getOptionInfo() { return std::get(Invokable::Options); } template llvm::StringRef getOptionName() { return getOptionInfo().Name; } template using ArgTypeImpl = std::decay_t())>; template using OptionTypeImpl = typename ArgTypeImpl::Type; template constexpr bool IsConstCharPtr = std::is_same_v, const char *>; template using OptionType = std::conditional_t, std::string, OptionTypeImpl>; template llvm::StringRef getTypeName() { return typeNameImpl>(); } template OptionType getOptionDefault() { return getOptionInfo().Default; } } // namespace detail } // namespace pipeline