Jan Eilers | c9bc80e | 2020-10-29 15:25:48 +0000 | [diff] [blame] | 1 | // Formatting library for C++ |
| 2 | // |
| 3 | // Copyright (c) 2012 - 2016, Victor Zverovich |
| 4 | // All rights reserved. |
Jim Flynn | 6217c3d | 2022-06-14 10:58:23 +0100 | [diff] [blame] | 5 | // SPDX-License-Identifier: MIT |
Jan Eilers | c9bc80e | 2020-10-29 15:25:48 +0000 | [diff] [blame] | 6 | // |
| 7 | // For the license information refer to format.h. |
| 8 | |
| 9 | #include "fmt/format-inl.h" |
| 10 | |
| 11 | FMT_BEGIN_NAMESPACE |
| 12 | namespace detail { |
| 13 | |
| 14 | template <typename T> |
| 15 | int format_float(char* buf, std::size_t size, const char* format, int precision, |
| 16 | T value) { |
| 17 | #ifdef FMT_FUZZ |
| 18 | if (precision > 100000) |
| 19 | throw std::runtime_error( |
| 20 | "fuzz mode - avoid large allocation inside snprintf"); |
| 21 | #endif |
| 22 | // Suppress the warning about nonliteral format string. |
| 23 | int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF; |
| 24 | return precision < 0 ? snprintf_ptr(buf, size, format, value) |
| 25 | : snprintf_ptr(buf, size, format, precision, value); |
| 26 | } |
| 27 | } // namespace detail |
| 28 | |
| 29 | template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>; |
| 30 | |
| 31 | // Workaround a bug in MSVC2013 that prevents instantiation of format_float. |
| 32 | int (*instantiate_format_float)(double, int, detail::float_specs, |
| 33 | detail::buffer<char>&) = detail::format_float; |
| 34 | |
| 35 | #ifndef FMT_STATIC_THOUSANDS_SEPARATOR |
| 36 | template FMT_API detail::locale_ref::locale_ref(const std::locale& loc); |
| 37 | template FMT_API std::locale detail::locale_ref::get<std::locale>() const; |
| 38 | #endif |
| 39 | |
| 40 | // Explicit instantiations for char. |
| 41 | |
| 42 | template FMT_API std::string detail::grouping_impl<char>(locale_ref); |
| 43 | template FMT_API char detail::thousands_sep_impl(locale_ref); |
| 44 | template FMT_API char detail::decimal_point_impl(locale_ref); |
| 45 | |
| 46 | template FMT_API void detail::buffer<char>::append(const char*, const char*); |
| 47 | |
| 48 | template FMT_API FMT_BUFFER_CONTEXT(char)::iterator detail::vformat_to( |
| 49 | detail::buffer<char>&, string_view, |
| 50 | basic_format_args<FMT_BUFFER_CONTEXT(char)>); |
| 51 | |
| 52 | template FMT_API int detail::snprintf_float(double, int, detail::float_specs, |
| 53 | detail::buffer<char>&); |
| 54 | template FMT_API int detail::snprintf_float(long double, int, |
| 55 | detail::float_specs, |
| 56 | detail::buffer<char>&); |
| 57 | template FMT_API int detail::format_float(double, int, detail::float_specs, |
| 58 | detail::buffer<char>&); |
| 59 | template FMT_API int detail::format_float(long double, int, detail::float_specs, |
| 60 | detail::buffer<char>&); |
| 61 | |
| 62 | // Explicit instantiations for wchar_t. |
| 63 | |
| 64 | template FMT_API std::string detail::grouping_impl<wchar_t>(locale_ref); |
| 65 | template FMT_API wchar_t detail::thousands_sep_impl(locale_ref); |
| 66 | template FMT_API wchar_t detail::decimal_point_impl(locale_ref); |
| 67 | |
| 68 | template FMT_API void detail::buffer<wchar_t>::append(const wchar_t*, |
| 69 | const wchar_t*); |
| 70 | FMT_END_NAMESPACE |