spdlog
Loading...
Searching...
No Matches
fmt.cpp
Go to the documentation of this file.
1// Slightly modified version of fmt lib's format.cc source file.
2// Copyright (c) 2012 - 2016, Victor Zverovich
3// All rights reserved.
4
5#ifndef SPDLOG_COMPILED_LIB
6# error Please define SPDLOG_COMPILED_LIB to compile this file.
7#endif
8
9#if !defined(SPDLOG_FMT_EXTERNAL)
11
13namespace detail {
14
15template<typename T>
16int format_float(char *buf, std::size_t size, const char *format, int precision, T value)
17{
18# ifdef FMT_FUZZ
19 if (precision > 100000)
20 throw std::runtime_error("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) : snprintf_ptr(buf, size, format, precision, value);
25}
26
29} // namespace detail
30
31// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
32int (*instantiate_format_float)(double, int, detail::float_specs, detail::buffer<char> &) = detail::format_float;
33
34# ifndef FMT_STATIC_THOUSANDS_SEPARATOR
35template FMT_API detail::locale_ref::locale_ref(const std::locale &loc);
36template FMT_API std::locale detail::locale_ref::get<std::locale>() const;
37# endif
38
39// Explicit instantiations for char.
40
43
44template FMT_API void detail::buffer<char>::append(const char *, const char *);
45
46// DEPRECATED!
47// There is no correspondent extern template in format.h because of
48// incompatibility between clang and gcc (#2377).
49template FMT_API void detail::vformat_to(
50 detail::buffer<char> &, string_view, basic_format_args<FMT_BUFFER_CONTEXT(char)>, detail::locale_ref);
51
52template FMT_API int detail::snprintf_float(double, int, detail::float_specs, detail::buffer<char> &);
53template FMT_API int detail::snprintf_float(long double, int, detail::float_specs, detail::buffer<char> &);
54template FMT_API int detail::format_float(double, int, detail::float_specs, detail::buffer<char> &);
55template FMT_API int detail::format_float(long double, int, detail::float_specs, detail::buffer<char> &);
56
57// Explicit instantiations for wchar_t.
58
61
62template FMT_API void detail::buffer<wchar_t>::append(const wchar_t *, const wchar_t *);
63
64template struct detail::basic_data<void>;
65
67
68#endif // !SPDLOG_FMT_EXTERNAL
Definition core.h:1120
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:583
#define FMT_BEGIN_NAMESPACE
Definition core.h:235
#define FMT_API
Definition core.h:264
#define FMT_BUFFER_CONTEXT(Char)
Definition core.h:1641
T
Definition core.h:320
#define FMT_END_NAMESPACE
Definition core.h:230
#define FMT_NOEXCEPT
Definition core.h:156
int(* instantiate_format_float)(double, int, detail::float_specs, detail::buffer< char > &)
Definition fmt.cpp:32
#define FMT_SNPRINTF
Definition format-inl.h:44
decimal_fp< T > to_decimal(T x) FMT_NOEXCEPT
Definition args.h:19
int snprintf_float(T value, int precision, float_specs specs, buffer< char > &buf)
int format_float(T value, int precision, float_specs specs, buffer< char > &buf)
FMT_FUNC auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result< Char >
Definition format-inl.h:107
FMT_FUNC Char decimal_point_impl(locale_ref loc)
Definition format-inl.h:113