1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:57:44 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -33,7 +33,7 @@ ErrorOr<void> FavoritesPanel::setup()
if (!index.is_valid())
return;
auto& model = *m_favorites_list->model();
on_selected_favorite_change({ MUST(String::from_deprecated_string(model.index(index.row(), 0).data().to_deprecated_string())),
on_selected_favorite_change({ MUST(String::from_byte_string(model.index(index.row(), 0).data().to_byte_string())),
{ model.index(index.row(), 1).data().as_double(),
model.index(index.row(), 2).data().as_double() },
model.index(index.row(), 3).data().to_i32() });
@ -63,15 +63,15 @@ void FavoritesPanel::load_favorites()
{
Vector<GUI::JsonArrayModel::FieldSpec> favorites_fields;
favorites_fields.empend("name", "Name"_string, Gfx::TextAlignment::CenterLeft, [](JsonObject const& object) -> GUI::Variant {
DeprecatedString name = object.get_deprecated_string("name"sv).release_value();
ByteString name = object.get_byte_string("name"sv).release_value();
double latitude = object.get_double_with_precision_loss("latitude"sv).release_value();
double longitude = object.get_double_with_precision_loss("longitude"sv).release_value();
return DeprecatedString::formatted("{}\n{:.5}, {:.5}", name, latitude, longitude);
return ByteString::formatted("{}\n{:.5}, {:.5}", name, latitude, longitude);
});
favorites_fields.empend("latitude", "Latitude"_string, Gfx::TextAlignment::CenterLeft);
favorites_fields.empend("longitude", "Longitude"_string, Gfx::TextAlignment::CenterLeft);
favorites_fields.empend("zoom", "Zoom"_string, Gfx::TextAlignment::CenterLeft);
m_favorites_list->set_model(*GUI::JsonArrayModel::create(DeprecatedString::formatted("{}/MapsFavorites.json", Core::StandardPaths::config_directory()), move(favorites_fields)));
m_favorites_list->set_model(*GUI::JsonArrayModel::create(ByteString::formatted("{}/MapsFavorites.json", Core::StandardPaths::config_directory()), move(favorites_fields)));
m_favorites_list->model()->invalidate();
favorites_changed();
}
@ -80,7 +80,7 @@ ErrorOr<void> FavoritesPanel::add_favorite(Favorite const& favorite)
{
auto& model = *static_cast<GUI::JsonArrayModel*>(m_favorites_list->model());
Vector<JsonValue> favorite_json;
favorite_json.append(favorite.name.to_deprecated_string());
favorite_json.append(favorite.name.to_byte_string());
favorite_json.append(favorite.latlng.latitude);
favorite_json.append(favorite.latlng.longitude);
favorite_json.append(favorite.zoom);
@ -109,7 +109,7 @@ ErrorOr<void> FavoritesPanel::edit_favorite(int row)
edit_dialog->set_main_widget(widget);
auto& name_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("name_textbox");
name_textbox.set_text(model.index(row, 0).data().to_deprecated_string().split('\n').at(0));
name_textbox.set_text(model.index(row, 0).data().to_byte_string().split('\n').at(0));
name_textbox.set_focus(true);
name_textbox.select_all();
@ -144,7 +144,7 @@ void FavoritesPanel::favorites_changed()
Vector<Favorite> favorites;
for (int index = 0; index < model.row_count(); index++)
favorites.append({ MUST(String::from_deprecated_string(model.index(index, 0).data().to_deprecated_string())),
favorites.append({ MUST(String::from_byte_string(model.index(index, 0).data().to_byte_string())),
{ model.index(index, 1).data().as_double(),
model.index(index, 2).data().as_double() },
model.index(index, 3).data().to_i32() });

View file

@ -73,12 +73,12 @@ MapWidget::MapWidget(Options const& options)
{
m_request_client = Protocol::RequestClient::try_create().release_value_but_fixme_should_propagate_errors();
if (options.attribution_enabled) {
auto attribution_text = options.attribution_text.value_or(MUST(String::from_deprecated_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv, Maps::default_tile_provider_attribution_text))));
auto attribution_text = options.attribution_text.value_or(MUST(String::from_byte_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv, Maps::default_tile_provider_attribution_text))));
URL attribution_url = options.attribution_url.value_or(URL(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionUrl"sv, Maps::default_tile_provider_attribution_url)));
add_panel({ attribution_text, Panel::Position::BottomRight, attribution_url, "attribution"_string });
}
m_marker_image = Gfx::Bitmap::load_from_file("/res/graphics/maps/marker-blue.png"sv).release_value_but_fixme_should_propagate_errors();
m_default_tile_provider = MUST(String::from_deprecated_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderUrlFormat"sv, Maps::default_tile_provider_url_format)));
m_default_tile_provider = MUST(String::from_byte_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderUrlFormat"sv, Maps::default_tile_provider_url_format)));
}
void MapWidget::set_zoom(int zoom)
@ -315,7 +315,7 @@ void MapWidget::process_tile_queue()
auto tile_key = m_tile_queue.dequeue();
// Start HTTP GET request to load image
HashMap<DeprecatedString, DeprecatedString> headers;
HashMap<ByteString, ByteString> headers;
headers.set("User-Agent", "SerenityOS Maps");
headers.set("Accept", "image/png");
URL url(MUST(String::formatted(m_tile_provider.value_or(m_default_tile_provider), tile_key.zoom, tile_key.x, tile_key.y)));

View file

@ -30,10 +30,10 @@ ErrorOr<void> SearchPanel::setup()
m_places_list->set_visible(false);
m_search_textbox->on_return_pressed = [this]() {
search(MUST(String::from_deprecated_string(m_search_textbox->text())));
search(MUST(String::from_byte_string(m_search_textbox->text())));
};
m_search_button->on_click = [this](unsigned) {
search(MUST(String::from_deprecated_string(m_search_textbox->text())));
search(MUST(String::from_byte_string(m_search_textbox->text())));
};
m_places_list->set_item_height(m_places_list->font().preferred_line_height() * 2 + m_places_list->vertical_padding());
@ -59,7 +59,7 @@ void SearchPanel::search(StringView query)
m_start_container->set_visible(false);
// Start HTTP GET request to load people.json
HashMap<DeprecatedString, DeprecatedString> headers;
HashMap<ByteString, ByteString> headers;
headers.set("User-Agent", "SerenityOS Maps");
headers.set("Accept", "application/json");
URL url(MUST(String::formatted("https://nominatim.openstreetmap.org/search?q={}&format=json", AK::URL::percent_encode(query, AK::URL::PercentEncodeSet::Query))));
@ -96,9 +96,9 @@ void SearchPanel::search(StringView query)
// FIXME: Handle JSON parsing errors
auto const& json_place = json_places.at(i).as_object();
MapWidget::LatLng latlng = { json_place.get_deprecated_string("lat"sv).release_value().to_double().release_value(),
json_place.get_deprecated_string("lon"sv).release_value().to_double().release_value() };
String name = MUST(String::formatted("{}\n{:.5}, {:.5}", json_place.get_deprecated_string("display_name"sv).release_value(), latlng.latitude, latlng.longitude));
MapWidget::LatLng latlng = { json_place.get_byte_string("lat"sv).release_value().to_double().release_value(),
json_place.get_byte_string("lon"sv).release_value().to_double().release_value() };
String name = MUST(String::formatted("{}\n{:.5}, {:.5}", json_place.get_byte_string("display_name"sv).release_value(), latlng.latitude, latlng.longitude));
// Calculate the right zoom level for bounding box
auto const& json_boundingbox = json_place.get_array("boundingbox"sv);

View file

@ -19,7 +19,7 @@ UsersMapWidget::UsersMapWidget(Options const& options)
void UsersMapWidget::get_users()
{
// Start HTTP GET request to load people.json
HashMap<DeprecatedString, DeprecatedString> headers;
HashMap<ByteString, ByteString> headers;
headers.set("User-Agent", "SerenityOS Maps");
headers.set("Accept", "application/json");
URL url("https://usermap.serenityos.org/people.json");
@ -48,7 +48,7 @@ void UsersMapWidget::get_users()
for (size_t i = 0; i < json_users.size(); i++) {
auto const& json_user = json_users.at(i).as_object();
User user {
MUST(String::from_deprecated_string(json_user.get_deprecated_string("nick"sv).release_value())),
MUST(String::from_byte_string(json_user.get_byte_string("nick"sv).release_value())),
{ json_user.get_array("coordinates"sv).release_value().at(0).to_double(),
json_user.get_array("coordinates"sv).release_value().at(1).to_double() },
json_user.has_bool("contributor"sv),

View file

@ -68,7 +68,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
map_widget.set_show_users(Config::read_bool("Maps"sv, "MapView"sv, "ShowUsers"sv, false));
// Panels
String init_panel_open_name = TRY(String::from_deprecated_string(Config::read_string("Maps"sv, "Panel"sv, "OpenName"sv, ""sv)));
String init_panel_open_name = TRY(String::from_byte_string(Config::read_string("Maps"sv, "Panel"sv, "OpenName"sv, ""sv)));
int panel_width = Config::read_i32("Maps"sv, "Panel"sv, "Width"sv, INT_MIN);
// Search panel