xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
internal
__enum_formatter.hpp
Go to the documentation of this file.
1
3
#pragma once
5
#if !defined(__XTD_CORE_INTERNAL__)
6
#error "Do not include this file: Internal use only"
7
#endif
9
10
#include "
__numeric_formatter.hpp
"
11
#include "
../helpers/throw_helper.hpp
"
12
14
template
<
typename
enum_t>
15
[[nodiscard]]
auto
__enum_to_string__(enum_t value)
noexcept
-> std::string;
16
17
template
<
typename
char
_t,
typename
value_t>
18
[[nodiscard]]
inline
auto
__enum_formatter(
const
std::basic_string<char_t>& format, value_t value,
const
std::locale& loc) -> std::basic_string<char_t> {
19
auto
fmt =
format
;
20
if
(fmt.empty()) fmt = {
'G'
};
21
22
switch
(fmt[0]) {
23
case
'b'
:
24
case
'B'
:
25
case
'd'
:
26
case
'D'
:
27
case
'o'
:
28
case
'O'
:
29
case
'x'
:
30
case
'X'
:
return
__numeric_formatter(fmt,
static_cast<
long
long
int
>
(value), loc);
31
case
'g'
:
32
case
'G'
:
return
__enum_to_string__(value);
33
default
:
xtd::helpers::throw_helper::throws
(
xtd::helpers::exception_case::format
,
"Invalid format expression"
);
34
}
35
}
__numeric_formatter.hpp
xtd::helpers::throw_helper::throws
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
xtd::format
auto format(const xtd::string &fmt, args_t &&... args) -> xtd::string
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition
format.hpp:21
xtd::helpers::exception_case::format
@ format
The format is not valid.
Definition
exception_case.hpp:51
throw_helper.hpp
Contains xtd::helpers::throw_helper class.
Generated on
for xtd by
Gammasoft
. All rights reserved.