#include <xtd/console>
#include <xtd/environment>
#include <xtd/format>
enum class cap {title, middle, end};
auto print_boolean(const string& text, bool value, cap c) {
if (c == cap::title)
console::out
<< "┌───────────┬────────────┬──────────────────────────────────┐" << environment::new_line
<< "│ boolean │ format │ representation │" << environment::new_line
<< "├───────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {} │ " << format(
"{}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:b} │ " << format(
"{:b}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:b4} │ " << format(
"{:b4}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:b8} │ " << format(
"{:b8}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:B} │ " << format(
"{:B}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:B4} │ " << format(
"{:B4}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:B8} │ " << format(
"{:B8}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:d} │ " << format(
"{:d}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:d2} │ " << format(
"{:d2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:D} │ " << format(
"{:D}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:D2} │ " << format(
"{:D2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:g} │ " << format(
"{:g}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:G} │ " << format(
"{:G}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:o} │ " << format(
"{:o}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:o3} │ " << format(
"{:o3}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:O} │ " << format(
"{:O}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:O3} │ " << format(
"{:O3}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:x} │ " << format(
"{:x}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:x5} │ " << format(
"{:x5}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:X} │ " << format(
"{:X}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(9) <<
" │ {:X5} │ " << format(
"{:X5}", value).
pad_right(32) <<
" │" << environment::new_line;
if (c != cap::end)
console::out << "├───────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
else
console::out << "└───────────┴────────────┴──────────────────────────────────┘" << environment::new_line;
}
auto main() -> int {
print_boolean("true", true, cap::title);
print_boolean("false", false, cap::middle);
print_boolean("1", 1, cap::middle);
print_boolean("0", 0, cap::end);
}
basic_string pad_right(xtd::size total_width) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:1597
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10