#include <xtd/console>
#include <xtd/enum_class>
#include <xtd/environment>
#include <xtd/format>
enum class text_styles {
normal = 0b0,
bold = 0b1,
italic = 0b10,
underline = 0b100,
strikeout = 0b1000,
};
explicit operator auto()
const noexcept {
return xtd::enum_collection<text_styles> {{text_styles::normal,
"normal"}, {text_styles::bold,
"bold"}, {text_styles::italic,
"italic"}, {text_styles::underline,
"underline"}, {text_styles::strikeout,
"strikeout"}};}
};
auto print_text_styles(const string& text, text_styles value, cap c) {
if (c == cap::title)
console::out
<< "┌───────────────────────────────────────────────┬────────────┬──────────────────────────────────┐" << environment::new_line
<< "│ text_styles │ format │ representation │" << environment::new_line
<< "├───────────────────────────────────────────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {} │ " <<
format(
"{}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:b} │ " <<
format(
"{:b}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:b4} │ " <<
format(
"{:b4}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:B} │ " <<
format(
"{:B}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:B4} │ " <<
format(
"{:B4}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:d} │ " <<
format(
"{:d}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:d1} │ " <<
format(
"{:d1}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:D} │ " <<
format(
"{:D}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:D1} │ " <<
format(
"{:D1}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:g} │ " <<
format(
"{:g}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:G} │ " <<
format(
"{:G}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:o} │ " <<
format(
"{:o}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:o2} │ " <<
format(
"{:o2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:O} │ " <<
format(
"{:O}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:O2} │ " <<
format(
"{:O2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:x} │ " <<
format(
"{:x}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:x2} │ " <<
format(
"{:x2}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {:X} │ " <<
format(
"{:X}", value).
pad_right(32) <<
" │" << environment::new_line;
console::out <<
"│ " <<
text.pad_right(45) <<
" │ {: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_text_styles("text_styles::normal", text_styles::normal, cap::title);
print_text_styles("text_styles::bold|text_styles::italic", text_styles::bold|text_styles::italic, cap::middle);
print_text_styles("text_styles::strikeout", text_styles::strikeout, 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
#define flags_attribute_(namespace_name, enum_type)
Provides the set attribute struct for enumerations helper.
Definition flags_attribute.hpp:34
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