Shows how to use xtd::ustring::sprintf method.
#include <xtd/xtd>
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"}};}
};
int main() {
console::out << string::sprintf(
"%s",
enum_object {week_day::saturday}.
to_string(
"")) << environment::new_line;
console::out << string::sprintf(
"0b%s",
enum_object {week_day::saturday}.
to_string(
"b")) << environment::new_line;
console::out << string::sprintf(
"0b%s",
enum_object {week_day::saturday}.
to_string(
"B")) << environment::new_line;
console::out << string::sprintf(
"0b%s",
enum_object {week_day::saturday}.
to_string(
"d")) << environment::new_line;
console::out << string::sprintf(
"%s",
enum_object {week_day::saturday}.
to_string(
"D")) << environment::new_line;
console::out << string::sprintf(
"%s",
enum_object {week_day::saturday}.
to_string(
"g")) << environment::new_line;
console::out << string::sprintf(
"%s",
enum_object {week_day::saturday}.
to_string(
"G")) << environment::new_line;
console::out << string::sprintf(
"0%s",
enum_object {week_day::saturday}.
to_string(
"o")) << environment::new_line;
console::out << string::sprintf(
"0%s",
enum_object {week_day::saturday}.
to_string(
"O")) << environment::new_line;
console::out << string::sprintf(
"0x%s",
enum_object {week_day::saturday}.
to_string(
"x")) << environment::new_line;
console::out << string::sprintf(
"0x%s",
enum_object {week_day::saturday}.
to_string(
"X")) << environment::new_line;
}
Provides the base class for enumerations.
Definition enum_object.h:42
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition enum_object.h:136
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