Fix: Don't allow right-click to close world generation progress window. (#13084)
[openttd-github.git] / src / core / format.hpp
blobd0267e4394f7e20de2aa11616525a898479a98ed
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD 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, version 2.
4 * OpenTTD 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.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file format.hpp String formatting functions and helpers. */
10 #ifndef FORMAT_HPP
11 #define FORMAT_HPP
13 #include "../3rdparty/fmt/format.h"
14 #include "strong_typedef_type.hpp"
16 template <typename E, typename Char>
17 struct fmt::formatter<E, Char, std::enable_if_t<std::is_enum<E>::value>> : fmt::formatter<typename std::underlying_type<E>::type> {
18 using underlying_type = typename std::underlying_type<E>::type;
19 using parent = typename fmt::formatter<underlying_type>;
21 constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx)
23 return parent::parse(ctx);
26 fmt::format_context::iterator format(const E &e, format_context &ctx) const
28 return parent::format(underlying_type(e), ctx);
32 template <typename T, typename Char>
33 struct fmt::formatter<T, Char, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value>> : fmt::formatter<typename T::BaseType> {
34 using underlying_type = typename T::BaseType;
35 using parent = typename fmt::formatter<underlying_type>;
37 constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx)
39 return parent::parse(ctx);
42 fmt::format_context::iterator format(const T &t, format_context &ctx) const
44 return parent::format(t.base(), ctx);
48 #endif /* FORMAT_HPP */