Rename some string conversion function to the common 'to_string'

This commit is contained in:
Maxime Coste 2017-09-12 11:31:57 +08:00
parent 90ab5ff93b
commit 63b1d0c353
4 changed files with 6 additions and 9 deletions

View File

@ -52,7 +52,7 @@ Color str_to_color(StringView color)
return Color::Default; return Color::Default;
} }
String color_to_str(Color color) String to_string(Color color)
{ {
if (color.color == Color::RGB) if (color.color == Color::RGB)
{ {
@ -70,7 +70,7 @@ String color_to_str(Color color)
String option_to_string(Color color) String option_to_string(Color color)
{ {
return color_to_str(color); return to_string(color);
} }
void option_from_string(StringView str, Color& color) void option_from_string(StringView str, Color& color)

View File

@ -48,7 +48,7 @@ constexpr bool operator!=(Color lhs, Color rhs)
} }
Color str_to_color(StringView color); Color str_to_color(StringView color);
String color_to_str(Color color); String to_string(Color color);
String option_to_string(Color color); String option_to_string(Color color);
void option_from_string(StringView str, Color& color); void option_from_string(StringView str, Color& color);

View File

@ -42,7 +42,7 @@ static Face parse_face(StringView facedesc)
return res; return res;
} }
String attributes_to_str(Attribute attributes) String to_string(Attribute attributes)
{ {
if (attributes == Attribute::Normal) if (attributes == Attribute::Normal)
return ""; return "";
@ -67,10 +67,7 @@ String attributes_to_str(Attribute attributes)
String to_string(Face face) String to_string(Face face)
{ {
return format("{},{}{}", return format("{},{}{}", face.fg, face.bg, face.attributes);
color_to_str(face.fg),
color_to_str(face.bg),
attributes_to_str(face.attributes));
} }
Face FaceRegistry::operator[](const String& facedesc) Face FaceRegistry::operator[](const String& facedesc)

View File

@ -68,7 +68,7 @@ String to_json(Color color)
sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b); sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b);
return buffer; return buffer;
} }
return to_json(color_to_str(color)); return to_json(to_string(color));
} }
String to_json(Attribute attributes) String to_json(Attribute attributes)