mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:17:44 +00:00
AK: Move Stream
and SeekableStream
from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the `Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is defined by `SeekableStream`, since defining its own would require us to qualify it with `AK::SeekMode` everywhere.
This commit is contained in:
parent
5f2ea31816
commit
8464da1439
96 changed files with 620 additions and 586 deletions
|
@ -64,7 +64,7 @@ bool HexDocumentMemory::write_to_file(NonnullRefPtr<Core::File> file)
|
|||
if (!file->write(m_buffer.data(), m_buffer.size()))
|
||||
return false;
|
||||
for (auto& change : m_changes) {
|
||||
file->seek(change.key, Core::SeekMode::SetPosition);
|
||||
file->seek(change.key, SeekMode::SetPosition);
|
||||
file->write(&change.value, 1);
|
||||
}
|
||||
return true;
|
||||
|
@ -79,7 +79,7 @@ HexDocumentFile::HexDocumentFile(NonnullRefPtr<Core::File> file)
|
|||
void HexDocumentFile::write_to_file()
|
||||
{
|
||||
for (auto& change : m_changes) {
|
||||
m_file->seek(change.key, Core::SeekMode::SetPosition);
|
||||
m_file->seek(change.key, SeekMode::SetPosition);
|
||||
m_file->write(&change.value, 1);
|
||||
}
|
||||
clear_changes();
|
||||
|
@ -105,7 +105,7 @@ bool HexDocumentFile::write_to_file(NonnullRefPtr<Core::File> file)
|
|||
}
|
||||
|
||||
for (auto& change : m_changes) {
|
||||
file->seek(change.key, Core::SeekMode::SetPosition);
|
||||
file->seek(change.key, SeekMode::SetPosition);
|
||||
file->write(&change.value, 1);
|
||||
}
|
||||
|
||||
|
@ -149,12 +149,12 @@ void HexDocumentFile::set_file(NonnullRefPtr<Core::File> file)
|
|||
m_file = file;
|
||||
|
||||
off_t size = 0;
|
||||
if (!file->seek(0, Core::SeekMode::FromEndPosition, &size)) {
|
||||
if (!file->seek(0, SeekMode::FromEndPosition, &size)) {
|
||||
m_file_size = 0;
|
||||
} else {
|
||||
m_file_size = size;
|
||||
}
|
||||
file->seek(0, Core::SeekMode::SetPosition);
|
||||
file->seek(0, SeekMode::SetPosition);
|
||||
|
||||
clear_changes();
|
||||
// make sure the next get operation triggers a read
|
||||
|
@ -169,7 +169,7 @@ NonnullRefPtr<Core::File> HexDocumentFile::file() const
|
|||
void HexDocumentFile::ensure_position_in_buffer(size_t position)
|
||||
{
|
||||
if (position < m_buffer_file_pos || position >= m_buffer_file_pos + m_buffer.size()) {
|
||||
m_file->seek(position, Core::SeekMode::SetPosition);
|
||||
m_file->seek(position, SeekMode::SetPosition);
|
||||
m_file->read(m_buffer.data(), m_buffer.size());
|
||||
m_buffer_file_pos = position;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ RefPtr<Gfx::Bitmap> Image::copy_bitmap(Selection const& selection) const
|
|||
return cropped_bitmap_or_error.release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ErrorOr<void> Image::export_bmp_to_file(NonnullOwnPtr<Core::Stream::Stream> stream, bool preserve_alpha_channel) const
|
||||
ErrorOr<void> Image::export_bmp_to_file(NonnullOwnPtr<AK::Stream> stream, bool preserve_alpha_channel) const
|
||||
{
|
||||
auto bitmap_format = preserve_alpha_channel ? Gfx::BitmapFormat::BGRA8888 : Gfx::BitmapFormat::BGRx8888;
|
||||
auto bitmap = TRY(compose_bitmap(bitmap_format));
|
||||
|
@ -183,7 +183,7 @@ ErrorOr<void> Image::export_bmp_to_file(NonnullOwnPtr<Core::Stream::Stream> stre
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> Image::export_png_to_file(NonnullOwnPtr<Core::Stream::Stream> stream, bool preserve_alpha_channel) const
|
||||
ErrorOr<void> Image::export_png_to_file(NonnullOwnPtr<AK::Stream> stream, bool preserve_alpha_channel) const
|
||||
{
|
||||
auto bitmap_format = preserve_alpha_channel ? Gfx::BitmapFormat::BGRA8888 : Gfx::BitmapFormat::BGRx8888;
|
||||
auto bitmap = TRY(compose_bitmap(bitmap_format));
|
||||
|
@ -193,7 +193,7 @@ ErrorOr<void> Image::export_png_to_file(NonnullOwnPtr<Core::Stream::Stream> stre
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> Image::export_qoi_to_file(NonnullOwnPtr<Core::Stream::Stream> stream) const
|
||||
ErrorOr<void> Image::export_qoi_to_file(NonnullOwnPtr<AK::Stream> stream) const
|
||||
{
|
||||
auto bitmap = TRY(compose_bitmap(Gfx::BitmapFormat::BGRA8888));
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ public:
|
|||
void paint_into(GUI::Painter&, Gfx::IntRect const& dest_rect) const;
|
||||
|
||||
ErrorOr<void> serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const;
|
||||
ErrorOr<void> export_bmp_to_file(NonnullOwnPtr<Core::Stream::Stream>, bool preserve_alpha_channel) const;
|
||||
ErrorOr<void> export_png_to_file(NonnullOwnPtr<Core::Stream::Stream>, bool preserve_alpha_channel) const;
|
||||
ErrorOr<void> export_qoi_to_file(NonnullOwnPtr<Core::Stream::Stream>) const;
|
||||
ErrorOr<void> export_bmp_to_file(NonnullOwnPtr<AK::Stream>, bool preserve_alpha_channel) const;
|
||||
ErrorOr<void> export_png_to_file(NonnullOwnPtr<AK::Stream>, bool preserve_alpha_channel) const;
|
||||
ErrorOr<void> export_qoi_to_file(NonnullOwnPtr<AK::Stream>) const;
|
||||
|
||||
void move_layer_to_front(Layer&);
|
||||
void move_layer_to_back(Layer&);
|
||||
|
|
|
@ -88,7 +88,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
|
|||
update_preview();
|
||||
}
|
||||
|
||||
auto CSVExportDialogPage::generate(Core::Stream::Stream& stream, GenerationType type) -> ErrorOr<void>
|
||||
auto CSVExportDialogPage::generate(AK::Stream& stream, GenerationType type) -> ErrorOr<void>
|
||||
{
|
||||
auto delimiter = TRY([this]() -> ErrorOr<DeprecatedString> {
|
||||
if (m_delimiter_other_radio->is_checked()) {
|
||||
|
|
|
@ -27,7 +27,7 @@ struct CSVExportDialogPage {
|
|||
Preview
|
||||
};
|
||||
|
||||
ErrorOr<void> generate(Core::Stream::Stream&, GenerationType);
|
||||
ErrorOr<void> generate(AK::Stream&, GenerationType);
|
||||
|
||||
protected:
|
||||
void update_preview();
|
||||
|
|
|
@ -15,13 +15,13 @@ namespace Writer {
|
|||
class CSV {
|
||||
public:
|
||||
template<typename ContainerType>
|
||||
static ErrorOr<void> generate(Core::Stream::Stream& output, ContainerType const& data, Vector<StringView> headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
static ErrorOr<void> generate(AK::Stream& output, ContainerType const& data, Vector<StringView> headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
{
|
||||
return XSV<ContainerType>::generate(output, data, { ",", "\"", WriterTraits::Repeat }, move(headers), behaviors);
|
||||
}
|
||||
|
||||
template<typename ContainerType>
|
||||
static ErrorOr<void> generate_preview(Core::Stream::Stream& output, ContainerType const& data, Vector<StringView> headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
static ErrorOr<void> generate_preview(AK::Stream& output, ContainerType const& data, Vector<StringView> headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
{
|
||||
return XSV<ContainerType>::generate_preview(output, data, { ",", "\"", WriterTraits::Repeat }, move(headers), behaviors);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ constexpr WriterBehavior default_behaviors()
|
|||
template<typename ContainerType, typename HeaderType = Vector<StringView>>
|
||||
class XSV {
|
||||
public:
|
||||
static ErrorOr<void> generate(Core::Stream::Stream& output, ContainerType const& data, WriterTraits traits, HeaderType headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
static ErrorOr<void> generate(AK::Stream& output, ContainerType const& data, WriterTraits traits, HeaderType headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
{
|
||||
auto writer = XSV(output, data, traits, headers, behaviors);
|
||||
auto with_headers = has_flag(writer.m_behaviors, WriterBehavior::WriteHeaders);
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> generate_preview(Core::Stream::Stream& output, ContainerType const& data, WriterTraits traits, HeaderType headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
static ErrorOr<void> generate_preview(AK::Stream& output, ContainerType const& data, WriterTraits traits, HeaderType headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
{
|
||||
auto writer = XSV(output, data, traits, headers, behaviors);
|
||||
auto lines_written = 0;
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
XSV(Core::Stream::Stream& output, ContainerType const& data, WriterTraits traits, HeaderType headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
XSV(AK::Stream& output, ContainerType const& data, WriterTraits traits, HeaderType headers = {}, WriterBehavior behaviors = default_behaviors())
|
||||
: m_data(data)
|
||||
, m_traits(move(traits))
|
||||
, m_behaviors(behaviors)
|
||||
|
@ -170,7 +170,7 @@ private:
|
|||
WriterTraits m_traits;
|
||||
WriterBehavior m_behaviors;
|
||||
HeaderType m_names;
|
||||
Core::Stream::Stream& m_output;
|
||||
AK::Stream& m_output;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue