Scippy

SoPlex

Sequential object-oriented simPlex

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 <locale>
12 
13 #include "format.h"
14 
16 
17 namespace detail {
18 template <typename Char>
19 std::basic_string<Char> vformat(
20  const std::locale& loc, basic_string_view<Char> format_str,
23  detail::vformat_to(buffer, format_str, args, detail::locale_ref(loc));
24  return fmt::to_string(buffer);
25 }
26 } // namespace detail
27 
28 template <typename S, typename Char = char_t<S>>
29 inline std::basic_string<Char> vformat(
30  const std::locale& loc, const S& format_str,
32  return detail::vformat(loc, to_string_view(format_str), args);
33 }
34 
35 template <typename S, typename... Args, typename Char = char_t<S>>
36 inline std::basic_string<Char> format(const std::locale& loc,
37  const S& format_str, Args&&... args) {
38  return detail::vformat(loc, to_string_view(format_str),
39  fmt::make_args_checked<Args...>(format_str, args...));
40 }
41 
42 template <typename S, typename OutputIt, typename... Args,
43  typename Char = char_t<S>,
45 inline OutputIt vformat_to(
46  OutputIt out, const std::locale& loc, const S& format_str,
48  decltype(detail::get_buffer<Char>(out)) buf(detail::get_buffer_init(out));
49  vformat_to(buf, to_string_view(format_str), args, detail::locale_ref(loc));
50  return detail::get_iterator(buf);
51 }
52 
53 template <typename OutputIt, typename S, typename... Args,
55 inline auto format_to(OutputIt out, const std::locale& loc,
56  const S& format_str, Args&&... args) ->
58  const auto& vargs = fmt::make_args_checked<Args...>(format_str, args...);
59  return vformat_to(out, loc, to_string_view(format_str), vargs);
60 }
61 
63 
64 #endif // FMT_LOCALE_H_
#define FMT_BEGIN_NAMESPACE
Definition: core.h:203
void to_string_view(...)
std::basic_string< Char > format(const std::locale &loc, const S &format_str, Args &&... args)
Definition: locale.h:36
auto make_args_checked(const S &format_str, const remove_reference_t< Args > &... args) -> format_arg_store< buffer_context< Char >, remove_reference_t< Args >... >
Definition: core.h:1617
void vformat_to(buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char >>> args)
Definition: color.h:473
typename type_identity< T >::type type_identity_t
Definition: core.h:270
std::basic_string< Char > vformat(basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char >>> args)
Definition: format.h:3845
type
Definition: core.h:977
#define FMT_END_NAMESPACE
Definition: core.h:198
Definition: chrono.h:284
std::string to_string(const T &value)
Definition: format.h:3730
#define FMT_ENABLE_IF(...)
Definition: core.h:277
typename detail::char_t_impl< S >::type char_t
Definition: core.h:540
auto get_iterator(Buffer &buf) -> decltype(buf.out())
Definition: core.h:888
OutputIt get_buffer_init(OutputIt out)
Definition: core.h:880
auto format_to(OutputIt out, const std::locale &loc, const S &format_str, Args &&... args) -> typename std::enable_if< enable, OutputIt >::type
Definition: locale.h:55