SoPlex Documentation
Loading...
Searching...
No Matches
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
17namespace detail {
18template <typename Char>
19std::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
28template <typename S, typename Char = char_t<S>>
29inline 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
35template <typename S, typename... Args, typename Char = char_t<S>>
36inline 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
42template <typename S, typename OutputIt, typename... Args,
43 typename Char = char_t<S>,
45inline OutputIt vformat_to(
46 OutputIt out, const std::locale& loc, const S& format_str,
49 vformat_to(buf, to_string_view(format_str), args, detail::locale_ref(loc));
50 return detail::get_iterator(buf);
51}
52
53template <typename OutputIt, typename S, typename... Args,
55inline auto format_to(OutputIt out, const std::locale& loc,
56 const S& format_str, Args&&... args) ->
57 typename std::enable_if<enable, OutputIt>::type {
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_
typename detail::char_t_impl< S >::type char_t
Definition core.h:540
#define FMT_BEGIN_NAMESPACE
Definition core.h:203
basic_string_view< Char > to_string_view(const Char *s)
Definition core.h:468
#define FMT_ENABLE_IF(...)
Definition core.h:277
typename type_identity< T >::type type_identity_t
Definition core.h:270
#define FMT_END_NAMESPACE
Definition core.h:198
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
std::basic_string< Char > vformat(const std::locale &loc, const S &format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition locale.h:29
OutputIt vformat_to(OutputIt out, const std::locale &loc, const S &format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition locale.h:45
std::basic_string< Char > format(const std::locale &loc, const S &format_str, Args &&... args)
Definition locale.h:36
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
iterator_buffer< OutputIt, T > get_buffer(OutputIt)
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
OutputIt get_buffer_init(OutputIt out)
Definition core.h:880
auto get_iterator(Buffer &buf) -> decltype(buf.out())
Definition core.h:888