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#include "format.h"
13
15
16namespace internal {
17template <typename Char>
19 const std::locale& loc, buffer<Char>& buf,
20 basic_string_view<Char> format_str,
22 using range = buffer_range<Char>;
23 return vformat_to<arg_formatter<range>>(buf, to_string_view(format_str), args,
25}
26
27template <typename Char>
28std::basic_string<Char> vformat(const std::locale& loc,
29 basic_string_view<Char> format_str,
32 internal::vformat_to(loc, buffer, format_str, args);
33 return fmt::to_string(buffer);
34}
35} // namespace internal
36
37template <typename S, typename Char = char_t<S>>
38inline 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
44template <typename S, typename... Args, typename Char = char_t<S>>
45inline std::basic_string<Char> format(const std::locale& loc,
46 const S& format_str, Args&&... args) {
47 return internal::vformat(
48 loc, to_string_view(format_str),
49 {internal::make_args_checked<Args...>(format_str, args...)});
50}
51
52template <typename S, typename OutputIt, typename... Args,
53 typename Char = enable_if_t<
55inline OutputIt vformat_to(OutputIt out, const std::locale& loc,
56 const S& format_str,
59 return vformat_to<arg_formatter<range>>(
60 range(out), to_string_view(format_str), args, internal::locale_ref(loc));
61}
62
63template <typename OutputIt, typename S, typename... Args,
66inline OutputIt format_to(OutputIt out, const std::locale& loc,
67 const S& format_str, Args&&... args) {
68 internal::check_format_string<Args...>(format_str);
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_
OutputIt iterator
Definition core.h:1147
typename std::enable_if< B, T >::type enable_if_t
Definition core.h:204
#define FMT_BEGIN_NAMESPACE
Definition core.h:163
basic_string_view< Char > to_string_view(const Char *s)
Definition core.h:397
#define FMT_ENABLE_IF(...)
Definition core.h:220
typename internal::char_t_impl< S >::type char_t
Definition core.h:458
#define FMT_END_NAMESPACE
Definition core.h:158
OutputIt vformat_to(OutputIt out, const std::locale &loc, const S &format_str, format_args_t< OutputIt, Char > args)
Definition locale.h:55
OutputIt format_to(OutputIt out, const std::locale &loc, const S &format_str, Args &&... args)
Definition locale.h:66
std::basic_string< Char > vformat(const std::locale &loc, const S &format_str, basic_format_args< buffer_context< Char > > args)
Definition locale.h:38
std::basic_string< Char > format(const std::locale &loc, const S &format_str, Args &&... args)
Definition locale.h:45
void vformat_to(basic_memory_buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< Char > > args)
Definition color.h:473
void to_string_view(...)
format_arg_store< buffer_context< Char >, remove_reference_t< Args >... > make_args_checked(const S &format_str, const remove_reference_t< Args > &... args)
Definition core.h:1387
void check_format_string(const S &)
Definition core.h:1369
std::basic_string< Char > vformat(basic_string_view< Char > format_str, basic_format_args< buffer_context< Char > > args)
Definition format.h:3379