xtd 0.2.0
Loading...
Searching...
No Matches
__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
12
13
15template<typename char_t>
16inline std::basic_string<char_t> __boolean_formatter(const std::basic_string<char_t>& fmt, bool value, const std::locale& loc) {
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: __format_exception("Invalid format expression"); return {};
31 }
32}
Contains throw format exception method.
Contains __numeric_formatter method.