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,
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>
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) {
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_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
const S & format_str
Definition: format.h:3342
Definition: 044_section.h:5
format_arg_store< context, Args... > as
Definition: format.h:3345
static QCString args
Definition: declinfo.cpp:674
#define FMT_END_NAMESPACE
Definition: core.h:153
std::enable_if<!is_compile_string< S >::value >::type check_format_string(const S &)
Definition: core.h:1352
buffer_context< Char >::type::iterator vformat_to(internal::basic_buffer< Char > &buf, basic_string_view< Char > format_str, basic_format_args< typename buffer_context< Char >::type > args)
Definition: format.h:3233
dummy_string_view to_string_view(...)
format_context_t< OutputIt, FMT_CHAR(S)>::type context
Definition: format.h:3344
typedef FMT_CHAR(S) Char
std::basic_string< Char > vformat(basic_string_view< Char > format_str, basic_format_args< typename buffer_context< Char >::type > args)
Definition: format.h:3410
JAVACC_STRING_TYPE String
Definition: JavaCC.h:22
basic_buffer< char > buffer
Definition: core.h:291
OutputIt iterator
Definition: core.h:990
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
std::basic_string< FMT_CHAR(S)> format(const std::locale &loc, const S &format_str, const Args &...args)
Definition: locale.h:45
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34