Show how to use format xtd::format class with enums.
#include <xtd/console>
#include <xtd/enum>
#include <xtd/environment>
#include <xtd/string>
enum 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 main() -> int {
console::out << string::format("{}", week_day::saturday) << environment::new_line;
console::out << string::format("0b{:b}", week_day::saturday) << environment::new_line;
console::out << string::format("0b{:B}", week_day::saturday) << environment::new_line;
console::out << string::format("{:d}", week_day::saturday) << environment::new_line;
console::out << string::format("{:D}", week_day::saturday) << environment::new_line;
console::out << string::format("{:g}", week_day::saturday) << environment::new_line;
console::out << string::format("{:G}", week_day::saturday) << environment::new_line;
console::out << string::format("0{:o}", week_day::saturday) << environment::new_line;
console::out << string::format("0{:O}", week_day::saturday) << environment::new_line;
console::out << string::format("0x{:x}", week_day::saturday) << environment::new_line;
console::out << string::format("0x{:X}", week_day::saturday) << environment::new_line;
}
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