xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
internal
__boolean_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
13
15
template
<
typename
char
_t>
16
[[nodiscard]]
inline
auto
__boolean_formatter(
const
std::basic_string<char_t>& fmt,
bool
value,
const
std::locale& loc) -> std::basic_string<char_t> {
17
if
(fmt.empty())
return
value
? std::basic_string<char_t> {
't'
,
'r'
,
'u'
,
'e'
} : std::basic_string<char_t> {
'f'
,
'a'
,
'l'
,
's'
,
'e'
};
18
19
switch
(fmt[0]) {
20
case
'b'
:
21
case
'B'
:
22
case
'd'
:
23
case
'D'
:
24
case
'o'
:
25
case
'O'
:
26
case
'x'
:
27
case
'X'
:
return
__numeric_formatter(fmt, value ? 1 : 0, loc);
28
case
'g'
:
29
case
'G'
:
return
value
? std::basic_string<char_t> {
't'
,
'r'
,
'u'
,
'e'
} : std::basic_string<char_t> {
'f'
,
'a'
,
'l'
,
's'
,
'e'
};
30
default
:
xtd::helpers::throw_helper::throws
(
xtd::helpers::exception_case::format
,
"Invalid format expression"
);
31
}
32
}
__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::expressions::operator_precedence::value
@ value
Represnets the constant operator precedence (42).
Definition
operator_precedence.hpp:30
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.