Show how to use format xtd::format class enum classes flags.
#include <xtd/console>
#include <xtd/enum_class>
#include <xtd/environment>
#include <xtd/string>
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 main() -> int {
console::out << string::format("{}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("0b{:b}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("0b{:B}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("{:d}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("{:D}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("{:g}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("{:G}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("0{:o}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("0{:O}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("0x{:x}", text_styles::bold | text_styles::italic) << environment::new_line;
console::out << string::format("0x{:X}", text_styles::bold | text_styles::italic) << environment::new_line;
}
#define flags_attribute_(namespace_name, enum_type)
Provides the set attribute struct for enumerations helper.
Definition flags_attribute.h: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.h:22
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Provides the registration struct for enumerations.
Definition enum_register.h:38