|
|
|
@ -21,13 +21,38 @@ namespace Util::Format {
|
|
|
|
|
template<> |
|
|
|
|
void Formatter<char>::format(Builder& builder, char value) const |
|
|
|
|
{ |
|
|
|
|
builder.putCharacter(value); |
|
|
|
|
if (specifier.type != PresentationType::None && specifier.type != PresentationType::Character) { |
|
|
|
|
// "Type char is a distinct type that has an implementation-defined
|
|
|
|
|
// choice of “signed char” or “unsigned char” as its underlying type."
|
|
|
|
|
// http://eel.is/c++draft/basic#fundamental
|
|
|
|
|
Formatter<signed char> formatter { .specifier = specifier }; |
|
|
|
|
return formatter.format(builder, static_cast<signed char>(value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Formatter<std::string_view> formatter { .specifier = specifier }; |
|
|
|
|
return formatter.format(builder, { &value, 1 }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
void Formatter<bool>::format(Builder& builder, bool value) const |
|
|
|
|
{ |
|
|
|
|
builder.putString(value ? "true" : "false"); |
|
|
|
|
switch (specifier.type) { |
|
|
|
|
case PresentationType::Binary: |
|
|
|
|
case PresentationType::BinaryUppercase: |
|
|
|
|
case PresentationType::Character: |
|
|
|
|
case PresentationType::Decimal: |
|
|
|
|
case PresentationType::Octal: |
|
|
|
|
case PresentationType::Hex: |
|
|
|
|
case PresentationType::HexUppercase: { |
|
|
|
|
Formatter<uint8_t> formatter { .specifier = specifier }; |
|
|
|
|
return formatter.format(builder, static_cast<uint8_t>(value)); |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Formatter<std::string_view> formatter { .specifier = specifier }; |
|
|
|
|
formatter.format(builder, value ? "true" : "false"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// String
|
|
|
|
|