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