Livox SDK API  V2.2.0
locale.h
Go to the documentation of this file.
1 // Formatting library for C++ - std::locale support
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7 
8 #ifndef FMT_LOCALE_H_
9 #define FMT_LOCALE_H_
10 
11 #include "format.h"
12 #include <locale>
13 
15 
16 namespace internal {
17 template <typename Char>
19  const std::locale &loc, basic_buffer<Char> &buf,
20  basic_string_view<Char> format_str,
23  return vformat_to<arg_formatter<range>>(
24  buf, to_string_view(format_str), args, internal::locale_ref(loc));
25 }
26 
27 template <typename Char>
28 std::basic_string<Char> vformat(
29  const std::locale &loc, basic_string_view<Char> format_str,
32  internal::vformat_to(loc, buffer, format_str, args);
33  return fmt::to_string(buffer);
34 }
35 }
36 
37 template <typename S, typename Char = FMT_CHAR(S)>
38 inline std::basic_string<Char> vformat(
39  const std::locale &loc, const S &format_str,
41  return internal::vformat(loc, to_string_view(format_str), args);
42 }
43 
44 template <typename S, typename... Args>
45 inline std::basic_string<FMT_CHAR(S)> format(
46  const std::locale &loc, const S &format_str, const Args &... args) {
47  return internal::vformat(
48  loc, to_string_view(format_str),
49  *internal::checked_args<S, Args...>(format_str, args...));
50 }
51 
52 template <typename String, typename OutputIt, typename... Args>
53 inline typename std::enable_if<internal::is_output_iterator<OutputIt>::value,
54  OutputIt>::type
55  vformat_to(OutputIt out, const std::locale &loc, const String &format_str,
56  typename format_args_t<OutputIt, FMT_CHAR(String)>::type args) {
58  return vformat_to<arg_formatter<range>>(
59  range(out), to_string_view(format_str), args, internal::locale_ref(loc));
60 }
61 
62 template <typename OutputIt, typename S, typename... Args>
63 inline typename std::enable_if<
66  format_to(OutputIt out, const std::locale &loc, const S &format_str,
67  const Args &... args) {
68  internal::check_format_string<Args...>(format_str);
69  typedef typename format_context_t<OutputIt, FMT_CHAR(S)>::type context;
70  format_arg_store<context, Args...> as{args...};
71  return vformat_to(out, loc, to_string_view(format_str),
73 }
74 
76 
77 #endif // FMT_LOCALE_H_
std::enable_if< internal::is_output_iterator< OutputIt >::value, OutputIt >::type vformat_to(OutputIt out, const std::locale &loc, const String &format_str, typename format_args_t< OutputIt, typename char_t< String >::type >::type args)
Definition: locale.h:55
#define FMT_END_NAMESPACE
Definition: core.h:153
std::enable_if< internal::is_string< S >::value &&internal::is_output_iterator< OutputIt >::value, OutputIt >::type format_to(OutputIt out, const std::locale &loc, const S &format_str, const Args &...args)
Definition: locale.h:66
std::basic_string< Char > vformat(const std::locale &loc, const S &format_str, basic_format_args< typename buffer_context< Char >::type > args)
Definition: locale.h:38
basic_buffer< char > buffer
Definition: core.h:291
#define FMT_CHAR(S)
Definition: core.h:1320
string_view_t & to_string_view(spdlog::level::level_enum l) noexcept
Definition: common.h:135
std::string to_string(const T &value)
Definition: format.h:3209
#define FMT_BEGIN_NAMESPACE
Definition: core.h:155
std::enable_if<!is_compile_string< S >::value >::type check_format_string(const S &)
Definition: core.h:1352
std::basic_string< typename char_t< S >::type > format(const std::locale &loc, const S &format_str, const Args &...args)
Definition: locale.h:45