1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:27:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -5,6 +5,7 @@
*/
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/FixedArray.h>
#include <AK/FlyString.h>
#include <AK/Format.h>
@ -12,7 +13,6 @@
#include <AK/Math.h>
#include <AK/ScopeGuard.h>
#include <AK/StdLibExtras.h>
#include <AK/String.h>
#include <AK/Try.h>
#include <AK/TypedTransfer.h>
#include <AK/UFixedBigInt.h>
@ -63,11 +63,11 @@ MaybeLoaderError FlacLoaderPlugin::parse_header()
auto bit_input = LOADER_TRY(BigEndianInputBitStream::construct(*m_stream));
// A mixture of VERIFY and the non-crashing TRY().
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_data_start_location), String::formatted("FLAC header: {}", msg) }; \
} \
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_data_start_location), DeprecatedString::formatted("FLAC header: {}", msg) }; \
} \
} while (0)
// Magic number
@ -280,7 +280,7 @@ MaybeLoaderError FlacLoaderPlugin::seek(int int_sample_index)
dbgln_if(AFLACLOADER_DEBUG, "Seeking to seektable: sample index {}, byte offset {}, sample count {}", target_seekpoint.sample_index, target_seekpoint.byte_offset, target_seekpoint.num_samples);
auto position = target_seekpoint.byte_offset + m_data_start_location;
if (m_stream->seek(static_cast<i64>(position), Core::Stream::SeekMode::SetPosition).is_error())
return LoaderError { LoaderError::Category::IO, m_loaded_samples, String::formatted("Invalid seek position {}", position) };
return LoaderError { LoaderError::Category::IO, m_loaded_samples, DeprecatedString::formatted("Invalid seek position {}", position) };
auto remaining_samples_after_seekpoint = sample_index - m_data_start_location;
if (remaining_samples_after_seekpoint > 0)
@ -326,11 +326,11 @@ LoaderSamples FlacLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_i
// 11.21. FRAME
MaybeLoaderError FlacLoaderPlugin::next_frame(Span<Sample> target_vector)
{
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_current_sample_or_frame), String::formatted("FLAC header: {}", msg) }; \
} \
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_current_sample_or_frame), DeprecatedString::formatted("FLAC header: {}", msg) }; \
} \
} while (0)
auto bit_stream = LOADER_TRY(BigEndianInputBitStream::construct(*m_stream));
@ -561,7 +561,7 @@ ErrorOr<PcmSampleFormat, LoaderError> FlacLoaderPlugin::convert_bit_depth_code(u
case 7:
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), "Reserved sample size" };
default:
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), String::formatted("Unsupported sample size {}", bit_depth_code) };
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), DeprecatedString::formatted("Unsupported sample size {}", bit_depth_code) };
}
}
@ -818,7 +818,7 @@ ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram
decoded[i] += 4 * decoded[i - 1] - 6 * decoded[i - 2] + 4 * decoded[i - 3] - decoded[i - 4];
break;
default:
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), String::formatted("Unrecognized predictor order {}", subframe.order) };
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), DeprecatedString::formatted("Unrecognized predictor order {}", subframe.order) };
}
return decoded;
}

View file

@ -62,7 +62,7 @@ public:
virtual int total_samples() override { return static_cast<int>(m_total_samples); }
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
virtual String format_name() override { return "FLAC (.flac)"; }
virtual DeprecatedString format_name() override { return "FLAC (.flac)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
bool is_fixed_blocksize_stream() const { return m_min_block_size == m_max_block_size; }

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
namespace Audio {
@ -40,7 +40,7 @@ enum class ID3PictureType : u32 {
// Note: This was first implemented for Flac but is compatible with ID3v2
struct PictureData {
ID3PictureType type {};
String mime_string {};
DeprecatedString mime_string {};
Vector<u32> description_string {};
u32 width {};

View file

@ -52,7 +52,7 @@ public:
virtual u16 num_channels() = 0;
// Human-readable name of the file format, of the form <full abbreviation> (.<ending>)
virtual String format_name() = 0;
virtual DeprecatedString format_name() = 0;
virtual PcmSampleFormat pcm_format() = 0;
Vector<PictureData> const& pictures() const { return m_pictures; };
@ -77,7 +77,7 @@ public:
int total_samples() const { return m_plugin->total_samples(); }
u32 sample_rate() const { return m_plugin->sample_rate(); }
u16 num_channels() const { return m_plugin->num_channels(); }
String format_name() const { return m_plugin->format_name(); }
DeprecatedString format_name() const { return m_plugin->format_name(); }
u16 bits_per_sample() const { return pcm_bits_per_sample(m_plugin->pcm_format()); }
Vector<PictureData> const& pictures() const { return m_plugin->pictures(); };

View file

@ -28,7 +28,7 @@ struct LoaderError {
Category category { Category::Unknown };
// Binary index: where in the file the error occurred.
size_t index { 0 };
FlyString description { String::empty() };
FlyString description { DeprecatedString::empty() };
constexpr LoaderError() = default;
LoaderError(Category category, size_t index, FlyString description)
@ -54,7 +54,7 @@ struct LoaderError {
{
if (error.is_errno()) {
auto code = error.code();
description = String::formatted("{} ({})", strerror(code), code);
description = DeprecatedString::formatted("{} ({})", strerror(code), code);
if (code == EBADF || code == EBUSY || code == EEXIST || code == EIO || code == EISDIR || code == ENOENT || code == ENOMEM || code == EPIPE)
category = Category::IO;
} else {

View file

@ -39,7 +39,7 @@ public:
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
virtual String format_name() override { return "MP3 (.mp3)"; }
virtual DeprecatedString format_name() override { return "MP3 (.mp3)"; }
private:
MaybeLoaderError initialize();

View file

@ -27,10 +27,10 @@ u16 pcm_bits_per_sample(PcmSampleFormat format)
}
}
String sample_format_name(PcmSampleFormat format)
DeprecatedString sample_format_name(PcmSampleFormat format)
{
bool is_float = format == PcmSampleFormat::Float32 || format == PcmSampleFormat::Float64;
return String::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE");
return DeprecatedString::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE");
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Types.h>
namespace Audio {
@ -23,5 +23,5 @@ enum class PcmSampleFormat : u8 {
// Most of the read code only cares about how many bits to read or write
u16 pcm_bits_per_sample(PcmSampleFormat format);
String sample_format_name(PcmSampleFormat format);
DeprecatedString sample_format_name(PcmSampleFormat format);
}

View file

@ -210,10 +210,10 @@ MaybeLoaderError WavLoaderPlugin::parse_header()
return value;
};
#define CHECK_OK(category, msg) \
do { \
if (!ok) \
return LoaderError { category, String::formatted("Parsing failed: {}", msg) }; \
#define CHECK_OK(category, msg) \
do { \
if (!ok) \
return LoaderError { category, DeprecatedString::formatted("Parsing failed: {}", msg) }; \
} while (0)
u32 riff = TRY(read_u32());

View file

@ -7,11 +7,11 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FixedArray.h>
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
#include <AK/Span.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibAudio/Loader.h>
#include <LibCore/File.h>
@ -45,7 +45,7 @@ public:
virtual int total_samples() override { return static_cast<int>(m_total_samples); }
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
virtual String format_name() override { return "RIFF WAVE (.wav)"; }
virtual DeprecatedString format_name() override { return "RIFF WAVE (.wav)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
private:

View file

@ -33,7 +33,7 @@ void WavWriter::set_file(StringView path)
{
m_file = Core::File::construct(path);
if (!m_file->open(Core::OpenMode::ReadWrite)) {
m_error_string = String::formatted("Can't open file: {}", m_file->error_string());
m_error_string = DeprecatedString::formatted("Can't open file: {}", m_file->error_string());
return;
}
m_file->seek(44);

View file

@ -38,12 +38,12 @@ public:
void set_sample_rate(int sample_rate) { m_sample_rate = sample_rate; }
void set_bits_per_sample(int bits_per_sample) { m_bits_per_sample = bits_per_sample; }
void clear_error() { m_error_string = String(); }
void clear_error() { m_error_string = DeprecatedString(); }
private:
void write_header();
RefPtr<Core::File> m_file;
String m_error_string;
DeprecatedString m_error_string;
bool m_finalized { false };
u32 m_sample_rate;