#include <xtd/console>
#include <xtd/enum_class>
#include <xtd/environment>
#include <xtd/format>
enum class week_day {
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday
};
explicit operator auto()
const noexcept {
return xtd::enum_collection<week_day> {{week_day::monday,
"monday"}, {week_day::tuesday,
"tuesday"}, {week_day::wednesday,
"wednesday"}, {week_day::thursday,
"thursday"}, {week_day::friday,
"friday"}, {week_day::saturday,
"saturday"}, {week_day::sunday,
"sunday"}};}
};
auto print_week_day(const string& text, week_day value, cap c) {
if (c == cap::title)
console::out
<< "┌──────────────────────┬────────────┬──────────────────────────────────┐" << environment::new_line
<< "│ week_day │ format │ representation │" << environment::new_line
<< "├──────────────────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {} │ " <<
format(
"{}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:b} │ " <<
format(
"{:b}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:b4} │ " <<
format(
"{:b4}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:B} │ " <<
format(
"{:B}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:B4} │ " <<
format(
"{:B4}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:d} │ " <<
format(
"{:d}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:d1} │ " <<
format(
"{:d1}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:D} │ " <<
format(
"{:D}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:D1} │ " <<
format(
"{:D1}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:g} │ " <<
format(
"{:g}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:G} │ " <<
format(
"{:G}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:o} │ " <<
format(
"{:o}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:o2} │ " <<
format(
"{:o2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:O} │ " <<
format(
"{:O}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:O2} │ " <<
format(
"{:O2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:x} │ " <<
format(
"{:x}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:x2} │ " <<
format(
"{:x2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:X} │ " <<
format(
"{:X}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(20) <<
" │ {:X2} │ " <<
format(
"{:X2}", 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_week_day("week_day::monday", week_day::monday, cap::title);
print_week_day("week_day::thursday", week_day::thursday, cap::middle);
print_week_day("week_day::sunday", week_day::sunday, 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
std::vector< xtd::collections::generic::key_value_pair< enum_t, xtd::string > > enum_collection
Represents a pair of an enum_t value and a string of an enum of type enum_t.
Definition enum_collection.hpp:22
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Provides the registration struct for enumerations.
Definition enum_register.hpp:38