mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:17:45 +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:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
void Cell::set_data(String new_data)
|
||||
void Cell::set_data(DeprecatedString new_data)
|
||||
{
|
||||
// If we are a formula, we do not save the beginning '=', if the new_data is "" we can simply change our kind
|
||||
if (m_kind == Formula && m_data.is_empty() && new_data.is_empty()) {
|
||||
|
@ -80,7 +80,7 @@ CellType const& Cell::type() const
|
|||
return *CellType::get_by_name("Identity"sv);
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> Cell::typed_display() const
|
||||
JS::ThrowCompletionOr<DeprecatedString> Cell::typed_display() const
|
||||
{
|
||||
return type().display(const_cast<Cell&>(*this), m_type_metadata);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ JS::Value Cell::js_data()
|
|||
return JS::js_string(m_sheet->interpreter().heap(), m_data);
|
||||
}
|
||||
|
||||
String Cell::source() const
|
||||
DeprecatedString Cell::source() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (m_kind == Formula)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "Forward.h"
|
||||
#include "JSIntegration.h"
|
||||
#include "Position.h"
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibGUI/Command.h>
|
||||
|
@ -24,7 +24,7 @@ struct Cell : public Weakable<Cell> {
|
|||
Formula,
|
||||
};
|
||||
|
||||
Cell(String data, Position position, WeakPtr<Sheet> sheet)
|
||||
Cell(DeprecatedString data, Position position, WeakPtr<Sheet> sheet)
|
||||
: m_dirty(false)
|
||||
, m_data(move(data))
|
||||
, m_kind(LiteralString)
|
||||
|
@ -33,7 +33,7 @@ struct Cell : public Weakable<Cell> {
|
|||
{
|
||||
}
|
||||
|
||||
Cell(String source, JS::Value&& cell_value, Position position, WeakPtr<Sheet> sheet)
|
||||
Cell(DeprecatedString source, JS::Value&& cell_value, Position position, WeakPtr<Sheet> sheet)
|
||||
: m_dirty(false)
|
||||
, m_data(move(source))
|
||||
, m_evaluated_data(move(cell_value))
|
||||
|
@ -45,7 +45,7 @@ struct Cell : public Weakable<Cell> {
|
|||
|
||||
void reference_from(Cell*);
|
||||
|
||||
void set_data(String new_data);
|
||||
void set_data(DeprecatedString new_data);
|
||||
void set_data(JS::Value new_data);
|
||||
bool dirty() const { return m_dirty; }
|
||||
void clear_dirty() { m_dirty = false; }
|
||||
|
@ -55,7 +55,7 @@ struct Cell : public Weakable<Cell> {
|
|||
if (!m_name_for_javascript.is_empty())
|
||||
return m_name_for_javascript;
|
||||
|
||||
m_name_for_javascript = String::formatted("cell {}", m_position.to_cell_identifier(sheet));
|
||||
m_name_for_javascript = DeprecatedString::formatted("cell {}", m_position.to_cell_identifier(sheet));
|
||||
return m_name_for_javascript;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ struct Cell : public Weakable<Cell> {
|
|||
return m_thrown_value;
|
||||
}
|
||||
|
||||
String const& data() const { return m_data; }
|
||||
DeprecatedString const& data() const { return m_data; }
|
||||
const JS::Value& evaluated_data() const { return m_evaluated_data; }
|
||||
Kind kind() const { return m_kind; }
|
||||
Vector<WeakPtr<Cell>> const& referencing_cells() const { return m_referencing_cells; }
|
||||
|
@ -94,14 +94,14 @@ struct Cell : public Weakable<Cell> {
|
|||
m_conditional_formats = move(fmts);
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> typed_display() const;
|
||||
JS::ThrowCompletionOr<DeprecatedString> typed_display() const;
|
||||
JS::ThrowCompletionOr<JS::Value> typed_js_data() const;
|
||||
|
||||
CellType const& type() const;
|
||||
CellTypeMetadata const& type_metadata() const { return m_type_metadata; }
|
||||
CellTypeMetadata& type_metadata() { return m_type_metadata; }
|
||||
|
||||
String source() const;
|
||||
DeprecatedString source() const;
|
||||
|
||||
JS::Value js_data();
|
||||
|
||||
|
@ -116,7 +116,7 @@ struct Cell : public Weakable<Cell> {
|
|||
private:
|
||||
bool m_dirty { false };
|
||||
bool m_evaluated_externally { false };
|
||||
String m_data;
|
||||
DeprecatedString m_data;
|
||||
JS::Value m_evaluated_data;
|
||||
JS::Value m_thrown_value;
|
||||
Kind m_kind { LiteralString };
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
CellType const* m_type { nullptr };
|
||||
CellTypeMetadata m_type_metadata;
|
||||
Position m_position;
|
||||
mutable String m_name_for_javascript;
|
||||
mutable DeprecatedString m_name_for_javascript;
|
||||
|
||||
Vector<ConditionalFormat> m_conditional_formats;
|
||||
Format m_evaluated_formats;
|
||||
|
|
|
@ -17,9 +17,9 @@ DateCell::DateCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
JS::ThrowCompletionOr<DeprecatedString> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<DeprecatedString> {
|
||||
auto& vm = cell.sheet().global_object().vm();
|
||||
auto timestamp = TRY(js_value(cell, metadata));
|
||||
auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(vm))).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S"sv : metadata.format.view());
|
||||
|
@ -39,7 +39,7 @@ JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, CellTypeMetadata
|
|||
return JS::Value(value / 1000); // Turn it to seconds
|
||||
}
|
||||
|
||||
String DateCell::metadata_hint(MetadataName metadata) const
|
||||
DeprecatedString DateCell::metadata_hint(MetadataName metadata) const
|
||||
{
|
||||
if (metadata == MetadataName::Format)
|
||||
return "Date format string as supported by `strftime'";
|
||||
|
|
|
@ -16,9 +16,9 @@ class DateCell : public CellType {
|
|||
public:
|
||||
DateCell();
|
||||
virtual ~DateCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
DeprecatedString metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
#include "Format.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/PrintfImplementation.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
@ -37,7 +37,7 @@ struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentL
|
|||
}
|
||||
};
|
||||
|
||||
String format_double(char const* format, double value)
|
||||
DeprecatedString format_double(char const* format, double value)
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto putch = [&](auto, auto ch) { builder.append(ch); };
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
String format_double(char const* format, double value);
|
||||
DeprecatedString format_double(char const* format, double value);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ IdentityCell::IdentityCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
JS::ThrowCompletionOr<DeprecatedString> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto& vm = cell.sheet().global_object().vm();
|
||||
auto data = cell.js_data();
|
||||
|
@ -30,7 +30,7 @@ JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMeta
|
|||
return cell.js_data();
|
||||
}
|
||||
|
||||
String IdentityCell::metadata_hint(MetadataName metadata) const
|
||||
DeprecatedString IdentityCell::metadata_hint(MetadataName metadata) const
|
||||
{
|
||||
if (metadata == MetadataName::Length)
|
||||
return "Ignored";
|
||||
|
|
|
@ -15,9 +15,9 @@ class IdentityCell : public CellType {
|
|||
public:
|
||||
IdentityCell();
|
||||
virtual ~IdentityCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
DeprecatedString metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ NumericCell::NumericCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
JS::ThrowCompletionOr<DeprecatedString> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> {
|
||||
return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<DeprecatedString> {
|
||||
auto& vm = cell.sheet().global_object().vm();
|
||||
auto value = TRY(js_value(cell, metadata));
|
||||
String string;
|
||||
DeprecatedString string;
|
||||
if (metadata.format.is_empty())
|
||||
string = TRY(value.to_string(vm));
|
||||
else
|
||||
|
@ -43,7 +43,7 @@ JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, CellTypeMetad
|
|||
});
|
||||
}
|
||||
|
||||
String NumericCell::metadata_hint(MetadataName metadata) const
|
||||
DeprecatedString NumericCell::metadata_hint(MetadataName metadata) const
|
||||
{
|
||||
if (metadata == MetadataName::Format)
|
||||
return "Format string as accepted by `printf', all numeric formats refer to the same value (the cell's value)";
|
||||
|
|
|
@ -26,9 +26,9 @@ class NumericCell : public CellType {
|
|||
public:
|
||||
NumericCell();
|
||||
virtual ~NumericCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
DeprecatedString metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ StringCell::StringCell()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
JS::ThrowCompletionOr<DeprecatedString> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto& vm = cell.sheet().global_object().vm();
|
||||
auto string = TRY(cell.js_data().to_string(vm));
|
||||
|
@ -31,7 +31,7 @@ JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, CellTypeMetada
|
|||
return JS::js_string(cell.sheet().interpreter().heap(), string);
|
||||
}
|
||||
|
||||
String StringCell::metadata_hint(MetadataName metadata) const
|
||||
DeprecatedString StringCell::metadata_hint(MetadataName metadata) const
|
||||
{
|
||||
if (metadata == MetadataName::Format)
|
||||
return "Ignored";
|
||||
|
|
|
@ -15,9 +15,9 @@ class StringCell : public CellType {
|
|||
public:
|
||||
StringCell();
|
||||
virtual ~StringCell() override = default;
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
|
||||
String metadata_hint(MetadataName) const override;
|
||||
DeprecatedString metadata_hint(MetadataName) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
||||
static HashMap<String, Spreadsheet::CellType*> s_cell_types;
|
||||
static HashMap<DeprecatedString, Spreadsheet::CellType*> s_cell_types;
|
||||
static Spreadsheet::StringCell s_string_cell;
|
||||
static Spreadsheet::NumericCell s_numeric_cell;
|
||||
static Spreadsheet::IdentityCell s_identity_cell;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "../ConditionalFormatting.h"
|
||||
#include "../Forward.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/TextAlignment.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
@ -18,7 +18,7 @@ namespace Spreadsheet {
|
|||
|
||||
struct CellTypeMetadata {
|
||||
int length { -1 };
|
||||
String format;
|
||||
DeprecatedString format;
|
||||
Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterRight };
|
||||
Format static_format;
|
||||
};
|
||||
|
@ -35,18 +35,18 @@ public:
|
|||
static CellType const* get_by_name(StringView);
|
||||
static Vector<StringView> names();
|
||||
|
||||
virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const = 0;
|
||||
virtual String metadata_hint(MetadataName) const { return {}; }
|
||||
virtual DeprecatedString metadata_hint(MetadataName) const { return {}; }
|
||||
virtual ~CellType() = default;
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
|
||||
protected:
|
||||
CellType(StringView name);
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet,
|
|||
ok_button.on_click = [&](auto) { done(ExecResult::OK); };
|
||||
}
|
||||
|
||||
Vector<String> const g_horizontal_alignments { "Left", "Center", "Right" };
|
||||
Vector<String> const g_vertical_alignments { "Top", "Center", "Bottom" };
|
||||
Vector<String> g_types;
|
||||
Vector<DeprecatedString> const g_horizontal_alignments { "Left", "Center", "Right" };
|
||||
Vector<DeprecatedString> const g_vertical_alignments { "Top", "Center", "Bottom" };
|
||||
Vector<DeprecatedString> g_types;
|
||||
|
||||
constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::TextAlignment alignment)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
|
|||
right_side.set_fixed_width(170);
|
||||
|
||||
auto& type_list = left_side.add<GUI::ListView>();
|
||||
type_list.set_model(*GUI::ItemListModel<String>::create(g_types));
|
||||
type_list.set_model(*GUI::ItemListModel<DeprecatedString>::create(g_types));
|
||||
type_list.set_should_hide_unnecessary_scrollbars(true);
|
||||
type_list.on_selection_change = [&] {
|
||||
const auto& index = type_list.selection().first();
|
||||
|
@ -189,7 +189,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
|
|||
checkbox.on_checked = [&](auto checked) {
|
||||
editor.set_enabled(checked);
|
||||
if (!checked)
|
||||
m_format = String::empty();
|
||||
m_format = DeprecatedString::empty();
|
||||
editor.set_text(m_format);
|
||||
};
|
||||
editor.on_change = [&] {
|
||||
|
@ -215,7 +215,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
|
|||
|
||||
auto& horizontal_combobox = alignment_tab.add<GUI::ComboBox>();
|
||||
horizontal_combobox.set_only_allow_values_from_model(true);
|
||||
horizontal_combobox.set_model(*GUI::ItemListModel<String>::create(g_horizontal_alignments));
|
||||
horizontal_combobox.set_model(*GUI::ItemListModel<DeprecatedString>::create(g_horizontal_alignments));
|
||||
horizontal_combobox.set_selected_index((int)m_horizontal_alignment);
|
||||
horizontal_combobox.on_change = [&](auto&, const GUI::ModelIndex& index) {
|
||||
switch (index.row()) {
|
||||
|
@ -247,7 +247,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
|
|||
|
||||
auto& vertical_combobox = alignment_tab.add<GUI::ComboBox>();
|
||||
vertical_combobox.set_only_allow_values_from_model(true);
|
||||
vertical_combobox.set_model(*GUI::ItemListModel<String>::create(g_vertical_alignments));
|
||||
vertical_combobox.set_model(*GUI::ItemListModel<DeprecatedString>::create(g_vertical_alignments));
|
||||
vertical_combobox.set_selected_index((int)m_vertical_alignment);
|
||||
vertical_combobox.on_change = [&](auto&, const GUI::ModelIndex& index) {
|
||||
switch (index.row()) {
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
CellType const* m_type { nullptr };
|
||||
|
||||
int m_length { -1 };
|
||||
String m_format;
|
||||
DeprecatedString m_format;
|
||||
HorizontalAlignment m_horizontal_alignment { HorizontalAlignment::Right };
|
||||
VerticalAlignment m_vertical_alignment { VerticalAlignment::Center };
|
||||
Format m_static_format;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Forward.h"
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibGUI/AbstractScrollableWidget.h>
|
||||
#include <LibGfx/Color.h>
|
||||
|
||||
|
@ -19,7 +19,7 @@ struct Format {
|
|||
};
|
||||
|
||||
struct ConditionalFormat : public Format {
|
||||
String condition;
|
||||
DeprecatedString condition;
|
||||
};
|
||||
|
||||
enum class FormatType {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include "ExportDialog.h"
|
||||
#include "Spreadsheet.h"
|
||||
#include "Workbook.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <Applications/Spreadsheet/CSVExportGML.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/FileStream.h>
|
||||
|
@ -35,7 +35,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
|
|||
{
|
||||
m_headers.extend(m_data.take_first());
|
||||
|
||||
auto temp_template = String::formatted("{}/spreadsheet-csv-export.{}.XXXXXX", Core::StandardPaths::tempfile_directory(), getpid());
|
||||
auto temp_template = DeprecatedString::formatted("{}/spreadsheet-csv-export.{}.XXXXXX", Core::StandardPaths::tempfile_directory(), getpid());
|
||||
auto temp_path = ByteBuffer::create_uninitialized(temp_template.length() + 1).release_value_but_fixme_should_propagate_errors();
|
||||
auto buf = reinterpret_cast<char*>(temp_path.data());
|
||||
auto copy_ok = temp_template.copy_characters_to_buffer(buf, temp_path.size());
|
||||
|
@ -74,7 +74,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
|
|||
|
||||
m_data_preview_text_editor->set_should_hide_unnecessary_scrollbars(true);
|
||||
|
||||
m_quote_escape_combo_box->set_model(GUI::ItemListModel<String>::create(m_quote_escape_items));
|
||||
m_quote_escape_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(m_quote_escape_items));
|
||||
|
||||
// By default, use commas, double quotes with repeat, disable headers, and quote only the fields that require quoting.
|
||||
m_delimiter_comma_radio->set_checked(true);
|
||||
|
@ -106,8 +106,8 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet)
|
|||
|
||||
auto CSVExportDialogPage::make_writer() -> Optional<XSV>
|
||||
{
|
||||
String delimiter;
|
||||
String quote;
|
||||
DeprecatedString delimiter;
|
||||
DeprecatedString quote;
|
||||
Writer::WriterTraits::QuoteEscape quote_escape;
|
||||
|
||||
// Delimiter
|
||||
|
@ -156,7 +156,7 @@ auto CSVExportDialogPage::make_writer() -> Optional<XSV>
|
|||
};
|
||||
|
||||
auto behaviors = Writer::default_behaviors();
|
||||
Vector<String> empty_headers;
|
||||
Vector<DeprecatedString> empty_headers;
|
||||
auto* headers = &empty_headers;
|
||||
|
||||
if (should_export_headers) {
|
||||
|
@ -213,7 +213,7 @@ void CSVExportDialogPage::update_preview()
|
|||
m_data_preview_text_editor->update();
|
||||
}
|
||||
|
||||
Result<void, String> CSVExportDialogPage::move_into(String const& target)
|
||||
Result<void, DeprecatedString> CSVExportDialogPage::move_into(DeprecatedString const& target)
|
||||
{
|
||||
auto& source = m_temp_output_file_path;
|
||||
|
||||
|
@ -232,26 +232,26 @@ Result<void, String> CSVExportDialogPage::move_into(String const& target)
|
|||
Core::File::AddDuplicateFileMarker::No);
|
||||
|
||||
if (result.is_error())
|
||||
return String::formatted("{}", static_cast<Error const&>(result.error()));
|
||||
return DeprecatedString::formatted("{}", static_cast<Error const&>(result.error()));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
perror("rename");
|
||||
return String { strerror(saved_errno) };
|
||||
return DeprecatedString { strerror(saved_errno) };
|
||||
}
|
||||
|
||||
Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File& file, Workbook& workbook)
|
||||
Result<void, DeprecatedString> ExportDialog::make_and_run_for(StringView mime, Core::File& file, Workbook& workbook)
|
||||
{
|
||||
auto wizard = GUI::WizardDialog::construct(GUI::Application::the()->active_window());
|
||||
wizard->set_title("File Export Wizard");
|
||||
wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
|
||||
|
||||
auto export_xsv = [&]() -> Result<void, String> {
|
||||
auto export_xsv = [&]() -> Result<void, DeprecatedString> {
|
||||
// FIXME: Prompt for the user to select a specific sheet to export
|
||||
// For now, export the first sheet (if available)
|
||||
if (!workbook.has_sheets())
|
||||
return String { "The workbook has no sheets to export!" };
|
||||
return DeprecatedString { "The workbook has no sheets to export!" };
|
||||
|
||||
CSVExportDialogPage page { workbook.sheets().first() };
|
||||
wizard->replace_page(page.page());
|
||||
|
@ -260,18 +260,18 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File&
|
|||
if (result == GUI::Dialog::ExecResult::OK) {
|
||||
auto& writer = page.writer();
|
||||
if (!writer.has_value())
|
||||
return String { "CSV Export failed" };
|
||||
return DeprecatedString { "CSV Export failed" };
|
||||
if (writer->has_error())
|
||||
return String::formatted("CSV Export failed: {}", writer->error_string());
|
||||
return DeprecatedString::formatted("CSV Export failed: {}", writer->error_string());
|
||||
|
||||
// No error, move the temp file to the expected location
|
||||
return page.move_into(file.filename());
|
||||
} else {
|
||||
return String { "CSV Export was cancelled" };
|
||||
return DeprecatedString { "CSV Export was cancelled" };
|
||||
}
|
||||
};
|
||||
|
||||
auto export_worksheet = [&]() -> Result<void, String> {
|
||||
auto export_worksheet = [&]() -> Result<void, DeprecatedString> {
|
||||
JsonArray array;
|
||||
for (auto& sheet : workbook.sheets())
|
||||
array.append(sheet.to_json());
|
||||
|
@ -299,23 +299,23 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File&
|
|||
} else {
|
||||
auto page = GUI::WizardPage::construct(
|
||||
"Export File Format",
|
||||
String::formatted("Select the format you wish to export to '{}' as", LexicalPath::basename(file.filename())));
|
||||
DeprecatedString::formatted("Select the format you wish to export to '{}' as", LexicalPath::basename(file.filename())));
|
||||
|
||||
page->on_next_page = [] { return nullptr; };
|
||||
|
||||
page->body_widget().load_from_gml(select_format_page_gml);
|
||||
auto format_combo_box = page->body_widget().find_descendant_of_type_named<GUI::ComboBox>("select_format_page_format_combo_box");
|
||||
|
||||
Vector<String> supported_formats {
|
||||
Vector<DeprecatedString> supported_formats {
|
||||
"CSV (text/csv)",
|
||||
"Spreadsheet Worksheet",
|
||||
};
|
||||
format_combo_box->set_model(GUI::ItemListModel<String>::create(supported_formats));
|
||||
format_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(supported_formats));
|
||||
|
||||
wizard->push_page(page);
|
||||
|
||||
if (wizard->exec() != GUI::Dialog::ExecResult::OK)
|
||||
return String { "Export was cancelled" };
|
||||
return DeprecatedString { "Export was cancelled" };
|
||||
|
||||
if (format_combo_box->selected_index() == 0)
|
||||
return export_xsv();
|
||||
|
|
|
@ -18,21 +18,21 @@ class Sheet;
|
|||
class Workbook;
|
||||
|
||||
struct CSVExportDialogPage {
|
||||
using XSV = Writer::XSV<Vector<Vector<String>>, Vector<String>>;
|
||||
using XSV = Writer::XSV<Vector<Vector<DeprecatedString>>, Vector<DeprecatedString>>;
|
||||
|
||||
explicit CSVExportDialogPage(Sheet const&);
|
||||
|
||||
NonnullRefPtr<GUI::WizardPage> page() { return *m_page; }
|
||||
Optional<XSV>& writer() { return m_previously_made_writer; }
|
||||
Result<void, String> move_into(String const& target);
|
||||
Result<void, DeprecatedString> move_into(DeprecatedString const& target);
|
||||
|
||||
protected:
|
||||
void update_preview();
|
||||
Optional<XSV> make_writer();
|
||||
|
||||
private:
|
||||
Vector<Vector<String>> m_data;
|
||||
Vector<String> m_headers;
|
||||
Vector<Vector<DeprecatedString>> m_data;
|
||||
Vector<DeprecatedString> m_headers;
|
||||
Optional<XSV> m_previously_made_writer;
|
||||
RefPtr<GUI::WizardPage> m_page;
|
||||
RefPtr<GUI::RadioButton> m_delimiter_comma_radio;
|
||||
|
@ -49,17 +49,17 @@ private:
|
|||
RefPtr<GUI::CheckBox> m_export_header_check_box;
|
||||
RefPtr<GUI::CheckBox> m_quote_all_fields_check_box;
|
||||
RefPtr<GUI::TextEditor> m_data_preview_text_editor;
|
||||
Vector<String> m_quote_escape_items {
|
||||
Vector<DeprecatedString> m_quote_escape_items {
|
||||
// Note: Keep in sync with Writer::WriterTraits::QuoteEscape.
|
||||
"Repeat",
|
||||
"Backslash",
|
||||
};
|
||||
|
||||
String m_temp_output_file_path;
|
||||
DeprecatedString m_temp_output_file_path;
|
||||
};
|
||||
|
||||
struct ExportDialog {
|
||||
static Result<void, String> make_and_run_for(StringView mime, Core::File& file, Workbook&);
|
||||
static Result<void, DeprecatedString> make_and_run_for(StringView mime, Core::File& file, Workbook&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
String key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; }
|
||||
DeprecatedString key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; }
|
||||
|
||||
void set_from(JsonObject const& object)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
Vector<String> m_keys;
|
||||
Vector<DeprecatedString> m_keys;
|
||||
};
|
||||
|
||||
RefPtr<HelpWindow> HelpWindow::s_the { nullptr };
|
||||
|
@ -86,7 +86,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
auto entry = LexicalPath::basename(url.path());
|
||||
auto doc_option = m_docs.get(entry);
|
||||
if (!doc_option.is_object()) {
|
||||
GUI::MessageBox::show_error(this, String::formatted("No documentation entry found for '{}'", url.path()));
|
||||
GUI::MessageBox::show_error(this, DeprecatedString::formatted("No documentation entry found for '{}'", url.path()));
|
||||
return;
|
||||
}
|
||||
auto& doc = doc_option.as_object();
|
||||
|
@ -94,13 +94,13 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
|
||||
auto* example_data_ptr = doc.get_ptr("example_data"sv);
|
||||
if (!example_data_ptr || !example_data_ptr->is_object()) {
|
||||
GUI::MessageBox::show_error(this, String::formatted("No example data found for '{}'", url.path()));
|
||||
GUI::MessageBox::show_error(this, DeprecatedString::formatted("No example data found for '{}'", url.path()));
|
||||
return;
|
||||
}
|
||||
auto& example_data = example_data_ptr->as_object();
|
||||
|
||||
if (!example_data.has_object(name)) {
|
||||
GUI::MessageBox::show_error(this, String::formatted("Example '{}' not found for '{}'", name, url.path()));
|
||||
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Example '{}' not found for '{}'", name, url.path()));
|
||||
return;
|
||||
}
|
||||
auto& value = example_data.get(name);
|
||||
|
@ -108,13 +108,13 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
auto window = GUI::Window::construct(this);
|
||||
window->resize(size());
|
||||
window->set_icon(icon());
|
||||
window->set_title(String::formatted("Spreadsheet Help - Example {} for {}", name, entry));
|
||||
window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
|
||||
window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
|
||||
|
||||
auto& widget = window->set_main_widget<SpreadsheetWidget>(window, NonnullRefPtrVector<Sheet> {}, false);
|
||||
auto sheet = Sheet::from_json(value.as_object(), widget.workbook());
|
||||
if (!sheet) {
|
||||
GUI::MessageBox::show_error(this, String::formatted("Corrupted example '{}' in '{}'", name, url.path()));
|
||||
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, url.path()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
};
|
||||
}
|
||||
|
||||
String HelpWindow::render(StringView key)
|
||||
DeprecatedString HelpWindow::render(StringView key)
|
||||
{
|
||||
VERIFY(m_docs.has_object(key));
|
||||
auto& doc = m_docs.get(key).as_object();
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
private:
|
||||
static RefPtr<HelpWindow> s_the;
|
||||
String render(StringView key);
|
||||
DeprecatedString render(StringView key);
|
||||
HelpWindow(GUI::Window* parent = nullptr);
|
||||
|
||||
JsonObject m_docs;
|
||||
|
|
|
@ -53,7 +53,7 @@ CSVImportDialogPage::CSVImportDialogPage(StringView csv)
|
|||
m_data_preview_error_label = m_page->body_widget().find_descendant_of_type_named<GUI::Label>("data_preview_error_label");
|
||||
m_data_preview_widget = m_page->body_widget().find_descendant_of_type_named<GUI::StackWidget>("data_preview_widget");
|
||||
|
||||
m_quote_escape_combo_box->set_model(GUI::ItemListModel<String>::create(m_quote_escape_items));
|
||||
m_quote_escape_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(m_quote_escape_items));
|
||||
|
||||
// By default, use commas, double quotes with repeat, and disable headers.
|
||||
m_delimiter_comma_radio->set_checked(true);
|
||||
|
@ -86,8 +86,8 @@ CSVImportDialogPage::CSVImportDialogPage(StringView csv)
|
|||
|
||||
auto CSVImportDialogPage::make_reader() -> Optional<Reader::XSV>
|
||||
{
|
||||
String delimiter;
|
||||
String quote;
|
||||
DeprecatedString delimiter;
|
||||
DeprecatedString quote;
|
||||
Reader::ParserTraits::QuoteEscape quote_escape;
|
||||
|
||||
// Delimiter
|
||||
|
@ -162,7 +162,7 @@ void CSVImportDialogPage::update_preview()
|
|||
auto& reader = *m_previously_made_reader;
|
||||
if (reader.has_error()) {
|
||||
m_data_preview_table_view->set_model(nullptr);
|
||||
m_data_preview_error_label->set_text(String::formatted("XSV parse error:\n{}", reader.error_string()));
|
||||
m_data_preview_error_label->set_text(DeprecatedString::formatted("XSV parse error:\n{}", reader.error_string()));
|
||||
m_data_preview_widget->set_active_widget(m_data_preview_error_label);
|
||||
return;
|
||||
}
|
||||
|
@ -170,18 +170,18 @@ void CSVImportDialogPage::update_preview()
|
|||
auto headers = reader.headers();
|
||||
|
||||
m_data_preview_table_view->set_model(
|
||||
GUI::ItemListModel<Reader::XSV::Row, Reader::XSV, Vector<String>>::create(reader, headers, min(8ul, reader.size())));
|
||||
GUI::ItemListModel<Reader::XSV::Row, Reader::XSV, Vector<DeprecatedString>>::create(reader, headers, min(8ul, reader.size())));
|
||||
m_data_preview_widget->set_active_widget(m_data_preview_table_view);
|
||||
m_data_preview_table_view->update();
|
||||
}
|
||||
|
||||
Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, Core::File& file, Workbook& workbook)
|
||||
Result<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, Core::File& file, Workbook& workbook)
|
||||
{
|
||||
auto wizard = GUI::WizardDialog::construct(&parent);
|
||||
wizard->set_title("File Import Wizard");
|
||||
wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
|
||||
|
||||
auto import_xsv = [&]() -> Result<NonnullRefPtrVector<Sheet>, String> {
|
||||
auto import_xsv = [&]() -> Result<NonnullRefPtrVector<Sheet>, DeprecatedString> {
|
||||
auto contents = file.read_all();
|
||||
CSVImportDialogPage page { contents };
|
||||
wizard->replace_page(page.page());
|
||||
|
@ -195,7 +195,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W
|
|||
if (reader.has_value()) {
|
||||
reader->parse();
|
||||
if (reader.value().has_error())
|
||||
return String::formatted("CSV Import failed: {}", reader.value().error_string());
|
||||
return DeprecatedString::formatted("CSV Import failed: {}", reader.value().error_string());
|
||||
|
||||
auto sheet = Sheet::from_xsv(reader.value(), workbook);
|
||||
if (sheet)
|
||||
|
@ -204,11 +204,11 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W
|
|||
|
||||
return sheets;
|
||||
} else {
|
||||
return String { "CSV Import was cancelled" };
|
||||
return DeprecatedString { "CSV Import was cancelled" };
|
||||
}
|
||||
};
|
||||
|
||||
auto import_worksheet = [&]() -> Result<NonnullRefPtrVector<Sheet>, String> {
|
||||
auto import_worksheet = [&]() -> Result<NonnullRefPtrVector<Sheet>, DeprecatedString> {
|
||||
auto json_value_option = JsonParser(file.read_all()).parse();
|
||||
if (json_value_option.is_error()) {
|
||||
StringBuilder sb;
|
||||
|
@ -250,23 +250,23 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W
|
|||
} else {
|
||||
auto page = GUI::WizardPage::construct(
|
||||
"Import File Format",
|
||||
String::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(file.filename())));
|
||||
DeprecatedString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(file.filename())));
|
||||
|
||||
page->on_next_page = [] { return nullptr; };
|
||||
|
||||
page->body_widget().load_from_gml(select_format_page_gml);
|
||||
auto format_combo_box = page->body_widget().find_descendant_of_type_named<GUI::ComboBox>("select_format_page_format_combo_box");
|
||||
|
||||
Vector<String> supported_formats {
|
||||
Vector<DeprecatedString> supported_formats {
|
||||
"CSV (text/csv)",
|
||||
"Spreadsheet Worksheet",
|
||||
};
|
||||
format_combo_box->set_model(GUI::ItemListModel<String>::create(supported_formats));
|
||||
format_combo_box->set_model(GUI::ItemListModel<DeprecatedString>::create(supported_formats));
|
||||
|
||||
wizard->push_page(page);
|
||||
|
||||
if (wizard->exec() != GUI::Dialog::ExecResult::OK)
|
||||
return String { "Import was cancelled" };
|
||||
return DeprecatedString { "Import was cancelled" };
|
||||
|
||||
if (format_combo_box->selected_index() == 0)
|
||||
return import_xsv();
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
RefPtr<GUI::TableView> m_data_preview_table_view;
|
||||
RefPtr<GUI::Label> m_data_preview_error_label;
|
||||
RefPtr<GUI::StackWidget> m_data_preview_widget;
|
||||
Vector<String> m_quote_escape_items {
|
||||
Vector<DeprecatedString> m_quote_escape_items {
|
||||
// Note: Keep in sync with Reader::ParserTraits::QuoteEscape.
|
||||
"Repeat",
|
||||
"Backslash",
|
||||
|
@ -56,7 +56,7 @@ private:
|
|||
};
|
||||
|
||||
struct ImportDialog {
|
||||
static Result<NonnullRefPtrVector<Sheet>, String> make_and_run_for(GUI::Window& parent, StringView mime, Core::File& file, Workbook&);
|
||||
static Result<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, Core::File& file, Workbook&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
|
|||
return JS::js_undefined();
|
||||
|
||||
if (cell->kind() == Spreadsheet::Cell::Kind::Formula)
|
||||
return JS::js_string(vm, String::formatted("={}", cell->data()));
|
||||
return JS::js_string(vm, DeprecatedString::formatted("={}", cell->data()));
|
||||
|
||||
return JS::js_string(vm, cell->data());
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_index)
|
|||
auto& sheet = sheet_object->m_sheet;
|
||||
auto column_index = sheet.column_index(column_name_str);
|
||||
if (!column_index.has_value())
|
||||
return vm.throw_completion<JS::TypeError>(String::formatted("'{}' is not a valid column", column_name_str));
|
||||
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("'{}' is not a valid column", column_name_str));
|
||||
|
||||
return JS::Value((i32)column_index.value());
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_arithmetic)
|
|||
auto& sheet = sheet_object->m_sheet;
|
||||
auto new_column = sheet.column_arithmetic(column_name_str, offset_number);
|
||||
if (!new_column.has_value())
|
||||
return vm.throw_completion<JS::TypeError>(String::formatted("'{}' is not a valid column", column_name_str));
|
||||
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("'{}' is not a valid column", column_name_str));
|
||||
|
||||
return JS::js_string(vm, new_column.release_value());
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound)
|
|||
auto& sheet = sheet_object->m_sheet;
|
||||
auto maybe_column_index = sheet.column_index(column_name_str);
|
||||
if (!maybe_column_index.has_value())
|
||||
return vm.throw_completion<JS::TypeError>(String::formatted("'{}' is not a valid column", column_name_str));
|
||||
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("'{}' is not a valid column", column_name_str));
|
||||
|
||||
auto bounds = sheet.written_data_bounds(*maybe_column_index);
|
||||
return JS::Value(bounds.row);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace Spreadsheet {
|
||||
|
||||
struct FunctionAndArgumentIndex {
|
||||
String function_name;
|
||||
DeprecatedString function_name;
|
||||
size_t argument_index { 0 };
|
||||
};
|
||||
Optional<FunctionAndArgumentIndex> get_function_and_argument_index(StringView source);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/URL.h>
|
||||
|
||||
|
@ -37,7 +37,7 @@ struct Position {
|
|||
return row == other.row && column == other.column;
|
||||
}
|
||||
|
||||
String to_cell_identifier(Sheet const& sheet) const;
|
||||
DeprecatedString to_cell_identifier(Sheet const& sheet) const;
|
||||
URL to_url(Sheet const& sheet) const;
|
||||
|
||||
size_t column { 0 };
|
||||
|
|
|
@ -25,9 +25,9 @@ void XSV::set_error(ReadError error)
|
|||
m_error = error;
|
||||
}
|
||||
|
||||
Vector<String> XSV::headers() const
|
||||
Vector<DeprecatedString> XSV::headers() const
|
||||
{
|
||||
Vector<String> headers;
|
||||
Vector<DeprecatedString> headers;
|
||||
if (has_explicit_headers()) {
|
||||
for (auto& field : m_names)
|
||||
headers.append(field.is_string_view ? field.as_string_view : field.as_string.view());
|
||||
|
@ -37,7 +37,7 @@ Vector<String> XSV::headers() const
|
|||
return headers;
|
||||
|
||||
for ([[maybe_unused]] auto& field : m_rows.first())
|
||||
headers.append(String::empty());
|
||||
headers.append(DeprecatedString::empty());
|
||||
}
|
||||
|
||||
return headers;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -31,8 +31,8 @@ ParserBehavior operator&(ParserBehavior left, ParserBehavior right);
|
|||
ParserBehavior operator|(ParserBehavior left, ParserBehavior right);
|
||||
|
||||
struct ParserTraits {
|
||||
String separator;
|
||||
String quote { "\"" };
|
||||
DeprecatedString separator;
|
||||
DeprecatedString quote { "\"" };
|
||||
enum QuoteEscape {
|
||||
Repeat,
|
||||
Backslash,
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
void parse();
|
||||
bool has_error() const { return m_error != ReadError::None; }
|
||||
ReadError error() const { return m_error; }
|
||||
String error_string() const
|
||||
DeprecatedString error_string() const
|
||||
{
|
||||
switch (m_error) {
|
||||
#define E(x, y) \
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
size_t size() const { return m_rows.size(); }
|
||||
Vector<String> headers() const;
|
||||
Vector<DeprecatedString> headers() const;
|
||||
[[nodiscard]] bool has_explicit_headers() const { return (static_cast<u32>(m_behaviors) & static_cast<u32>(ParserBehavior::ReadHeaders)) != 0; }
|
||||
|
||||
class Row {
|
||||
|
@ -185,7 +185,7 @@ public:
|
|||
private:
|
||||
struct Field {
|
||||
StringView as_string_view;
|
||||
String as_string; // This member only used if the parser couldn't use the original source verbatim.
|
||||
DeprecatedString as_string; // This member only used if the parser couldn't use the original source verbatim.
|
||||
bool is_string_view { true };
|
||||
|
||||
bool operator==(StringView other) const
|
||||
|
|
|
@ -114,9 +114,9 @@ static Optional<size_t> convert_from_string(StringView str, unsigned base = 26,
|
|||
return value;
|
||||
}
|
||||
|
||||
String Sheet::add_column()
|
||||
DeprecatedString Sheet::add_column()
|
||||
{
|
||||
auto next_column = String::bijective_base_from(m_columns.size());
|
||||
auto next_column = DeprecatedString::bijective_base_from(m_columns.size());
|
||||
m_columns.append(next_column);
|
||||
return next_column;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ Optional<size_t> Sheet::column_index(StringView column_name) const
|
|||
return index;
|
||||
}
|
||||
|
||||
Optional<String> Sheet::column_arithmetic(StringView column_name, int offset)
|
||||
Optional<DeprecatedString> Sheet::column_arithmetic(StringView column_name, int offset)
|
||||
{
|
||||
auto maybe_index = column_index(column_name);
|
||||
if (!maybe_index.has_value())
|
||||
|
@ -270,7 +270,7 @@ Optional<Position> Sheet::position_from_url(const URL& url) const
|
|||
}
|
||||
|
||||
// FIXME: Figure out a way to do this cross-process.
|
||||
VERIFY(url.path() == String::formatted("/{}", getpid()));
|
||||
VERIFY(url.path() == DeprecatedString::formatted("/{}", getpid()));
|
||||
|
||||
return parse_cell_name(url.fragment());
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ Position Sheet::written_data_bounds(Optional<size_t> column_index) const
|
|||
bool Sheet::columns_are_standard() const
|
||||
{
|
||||
for (size_t i = 0; i < m_columns.size(); ++i) {
|
||||
if (m_columns[i] != String::bijective_base_from(i))
|
||||
if (m_columns[i] != DeprecatedString::bijective_base_from(i))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -605,9 +605,9 @@ JsonObject Sheet::to_json() const
|
|||
return object;
|
||||
}
|
||||
|
||||
Vector<Vector<String>> Sheet::to_xsv() const
|
||||
Vector<Vector<DeprecatedString>> Sheet::to_xsv() const
|
||||
{
|
||||
Vector<Vector<String>> data;
|
||||
Vector<Vector<DeprecatedString>> data;
|
||||
|
||||
auto bottom_right = written_data_bounds();
|
||||
|
||||
|
@ -615,7 +615,7 @@ Vector<Vector<String>> Sheet::to_xsv() const
|
|||
size_t column_count = m_columns.size();
|
||||
if (columns_are_standard()) {
|
||||
column_count = bottom_right.column + 1;
|
||||
Vector<String> cols;
|
||||
Vector<DeprecatedString> cols;
|
||||
for (size_t i = 0; i < column_count; ++i)
|
||||
cols.append(m_columns[i]);
|
||||
data.append(move(cols));
|
||||
|
@ -624,7 +624,7 @@ Vector<Vector<String>> Sheet::to_xsv() const
|
|||
}
|
||||
|
||||
for (size_t i = 0; i <= bottom_right.row; ++i) {
|
||||
Vector<String> row;
|
||||
Vector<DeprecatedString> row;
|
||||
row.resize(column_count);
|
||||
for (size_t j = 0; j < column_count; ++j) {
|
||||
auto cell = at({ j, i });
|
||||
|
@ -652,7 +652,7 @@ RefPtr<Sheet> Sheet::from_xsv(Reader::XSV const& xsv, Workbook& workbook)
|
|||
} else {
|
||||
sheet->m_columns.ensure_capacity(cols.size());
|
||||
for (size_t i = 0; i < cols.size(); ++i)
|
||||
sheet->m_columns.append(String::bijective_base_from(i));
|
||||
sheet->m_columns.append(DeprecatedString::bijective_base_from(i));
|
||||
}
|
||||
for (size_t i = 0; i < max(rows, Sheet::default_row_count); ++i)
|
||||
sheet->add_row();
|
||||
|
@ -712,7 +712,7 @@ JsonObject Sheet::gather_documentation() const
|
|||
return m_cached_documentation.value();
|
||||
}
|
||||
|
||||
String Sheet::generate_inline_documentation_for(StringView function, size_t argument_index)
|
||||
DeprecatedString Sheet::generate_inline_documentation_for(StringView function, size_t argument_index)
|
||||
{
|
||||
if (!m_cached_documentation.has_value())
|
||||
gather_documentation();
|
||||
|
@ -720,13 +720,13 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu
|
|||
auto& docs = m_cached_documentation.value();
|
||||
auto entry = docs.get(function);
|
||||
if (entry.is_null() || !entry.is_object())
|
||||
return String::formatted("{}(...???{})", function, argument_index);
|
||||
return DeprecatedString::formatted("{}(...???{})", function, argument_index);
|
||||
|
||||
auto& entry_object = entry.as_object();
|
||||
size_t argc = entry_object.get("argc"sv).to_int(0);
|
||||
auto argnames_value = entry_object.get("argnames"sv);
|
||||
if (!argnames_value.is_array())
|
||||
return String::formatted("{}(...{}???{})", function, argc, argument_index);
|
||||
return DeprecatedString::formatted("{}(...{}???{})", function, argc, argument_index);
|
||||
auto& argnames = argnames_value.as_array();
|
||||
StringBuilder builder;
|
||||
builder.appendff("{}(", function);
|
||||
|
@ -748,9 +748,9 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String Position::to_cell_identifier(Sheet const& sheet) const
|
||||
DeprecatedString Position::to_cell_identifier(Sheet const& sheet) const
|
||||
{
|
||||
return String::formatted("{}{}", sheet.column(column), row);
|
||||
return DeprecatedString::formatted("{}{}", sheet.column(column), row);
|
||||
}
|
||||
|
||||
URL Position::to_url(Sheet const& sheet) const
|
||||
|
@ -758,12 +758,12 @@ URL Position::to_url(Sheet const& sheet) const
|
|||
URL url;
|
||||
url.set_scheme("spreadsheet");
|
||||
url.set_host("cell");
|
||||
url.set_paths({ String::number(getpid()) });
|
||||
url.set_paths({ DeprecatedString::number(getpid()) });
|
||||
url.set_fragment(to_cell_identifier(sheet));
|
||||
return url;
|
||||
}
|
||||
|
||||
CellChange::CellChange(Cell& cell, String const& previous_data)
|
||||
CellChange::CellChange(Cell& cell, DeprecatedString const& previous_data)
|
||||
: m_cell(cell)
|
||||
, m_previous_data(previous_data)
|
||||
{
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include "Cell.h"
|
||||
#include "Forward.h"
|
||||
#include "Readers/XSV.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/Types.h>
|
||||
|
@ -24,7 +24,7 @@ namespace Spreadsheet {
|
|||
|
||||
class CellChange {
|
||||
public:
|
||||
CellChange(Cell&, String const&);
|
||||
CellChange(Cell&, DeprecatedString const&);
|
||||
|
||||
auto& cell() { return m_cell; }
|
||||
auto& previous_data() { return m_previous_data; }
|
||||
|
@ -32,8 +32,8 @@ public:
|
|||
|
||||
private:
|
||||
Cell& m_cell;
|
||||
String m_previous_data;
|
||||
String m_new_data;
|
||||
DeprecatedString m_previous_data;
|
||||
DeprecatedString m_new_data;
|
||||
};
|
||||
|
||||
class Sheet : public Core::Object {
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
Optional<Position> parse_cell_name(StringView) const;
|
||||
Optional<size_t> column_index(StringView column_name) const;
|
||||
Optional<String> column_arithmetic(StringView column_name, int offset);
|
||||
Optional<DeprecatedString> column_arithmetic(StringView column_name, int offset);
|
||||
|
||||
Cell* from_url(const URL&);
|
||||
Cell const* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
|
||||
|
@ -60,10 +60,10 @@ public:
|
|||
JsonObject to_json() const;
|
||||
static RefPtr<Sheet> from_json(JsonObject const&, Workbook&);
|
||||
|
||||
Vector<Vector<String>> to_xsv() const;
|
||||
Vector<Vector<DeprecatedString>> to_xsv() const;
|
||||
static RefPtr<Sheet> from_xsv(Reader::XSV const&, Workbook&);
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(StringView name) { m_name = name; }
|
||||
|
||||
JsonObject gather_documentation() const;
|
||||
|
@ -85,17 +85,17 @@ public:
|
|||
if (auto cell = at(position))
|
||||
return *cell;
|
||||
|
||||
m_cells.set(position, make<Cell>(String::empty(), position, *this));
|
||||
m_cells.set(position, make<Cell>(DeprecatedString::empty(), position, *this));
|
||||
return *at(position);
|
||||
}
|
||||
|
||||
size_t add_row();
|
||||
String add_column();
|
||||
DeprecatedString add_column();
|
||||
|
||||
size_t row_count() const { return m_rows; }
|
||||
size_t column_count() const { return m_columns.size(); }
|
||||
Vector<String> const& columns() const { return m_columns; }
|
||||
String const& column(size_t index)
|
||||
Vector<DeprecatedString> const& columns() const { return m_columns; }
|
||||
DeprecatedString const& column(size_t index)
|
||||
{
|
||||
for (size_t i = column_count(); i < index; ++i)
|
||||
add_column();
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
VERIFY(column_count() > index);
|
||||
return m_columns[index];
|
||||
}
|
||||
String const& column(size_t index) const
|
||||
DeprecatedString const& column(size_t index) const
|
||||
{
|
||||
VERIFY(column_count() > index);
|
||||
return m_columns[index];
|
||||
|
@ -142,14 +142,14 @@ public:
|
|||
|
||||
bool columns_are_standard() const;
|
||||
|
||||
String generate_inline_documentation_for(StringView function, size_t argument_index);
|
||||
DeprecatedString generate_inline_documentation_for(StringView function, size_t argument_index);
|
||||
|
||||
private:
|
||||
explicit Sheet(Workbook&);
|
||||
explicit Sheet(StringView name, Workbook&);
|
||||
|
||||
String m_name;
|
||||
Vector<String> m_columns;
|
||||
DeprecatedString m_name;
|
||||
Vector<DeprecatedString> m_columns;
|
||||
size_t m_rows { 0 };
|
||||
HashMap<Position, NonnullOwnPtr<Cell>> m_cells;
|
||||
HashTable<Position> m_selected_cells;
|
||||
|
|
|
@ -21,9 +21,9 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
if (role == GUI::ModelRole::Display) {
|
||||
auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() });
|
||||
if (!cell)
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
|
||||
Function<String(JS::Value)> to_string_as_exception = [&](JS::Value value) {
|
||||
Function<DeprecatedString(JS::Value)> to_string_as_exception = [&](JS::Value value) {
|
||||
auto& vm = cell->sheet().global_object().vm();
|
||||
StringBuilder builder;
|
||||
builder.append("Error: "sv);
|
||||
|
@ -154,7 +154,7 @@ RefPtr<Core::MimeData> SheetModel::mime_data(const GUI::ModelSelection& selectio
|
|||
|
||||
Position cursor_position { (size_t)cursor->column(), (size_t)cursor->row() };
|
||||
auto mime_data_buffer = mime_data->data("text/x-spreadsheet-data");
|
||||
auto new_data = String::formatted("{}\n{}",
|
||||
auto new_data = DeprecatedString::formatted("{}\n{}",
|
||||
cursor_position.to_url(m_sheet).to_string(),
|
||||
StringView(mime_data_buffer));
|
||||
mime_data->set_data("text/x-spreadsheet-data", new_data.to_byte_buffer());
|
||||
|
@ -162,7 +162,7 @@ RefPtr<Core::MimeData> SheetModel::mime_data(const GUI::ModelSelection& selectio
|
|||
return mime_data;
|
||||
}
|
||||
|
||||
String SheetModel::column_name(int index) const
|
||||
DeprecatedString SheetModel::column_name(int index) const
|
||||
{
|
||||
if (index < 0)
|
||||
return {};
|
||||
|
@ -202,7 +202,7 @@ CellsUndoCommand::CellsUndoCommand(Vector<CellChange> cell_changes)
|
|||
m_cell_changes = cell_changes;
|
||||
}
|
||||
|
||||
CellsUndoCommand::CellsUndoCommand(Cell& cell, String const& previous_data)
|
||||
CellsUndoCommand::CellsUndoCommand(Cell& cell, DeprecatedString const& previous_data)
|
||||
{
|
||||
m_cell_changes.append(CellChange(cell, previous_data));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_sheet->row_count(); }
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_sheet->column_count(); }
|
||||
virtual String column_name(int) const override;
|
||||
virtual DeprecatedString column_name(int) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
|
||||
virtual RefPtr<Core::MimeData> mime_data(const GUI::ModelSelection&) const override;
|
||||
virtual bool is_editable(const GUI::ModelIndex&) const override;
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
void update();
|
||||
|
||||
Function<void(Cell&, String&)> on_cell_data_change;
|
||||
Function<void(Cell&, DeprecatedString&)> on_cell_data_change;
|
||||
Function<void(Vector<CellChange>)> on_cells_data_change;
|
||||
|
||||
private:
|
||||
|
@ -48,7 +48,7 @@ private:
|
|||
|
||||
class CellsUndoCommand : public GUI::Command {
|
||||
public:
|
||||
CellsUndoCommand(Cell&, String const&);
|
||||
CellsUndoCommand(Cell&, DeprecatedString const&);
|
||||
CellsUndoCommand(Vector<CellChange>);
|
||||
|
||||
virtual void undo() override;
|
||||
|
|
|
@ -100,8 +100,8 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
auto* sheet_ptr = m_tab_context_menu_sheet_view->sheet_if_available();
|
||||
VERIFY(sheet_ptr); // How did we get here without a sheet?
|
||||
auto& sheet = *sheet_ptr;
|
||||
String new_name;
|
||||
if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet"sv) == GUI::Dialog::ExecResult::OK) {
|
||||
DeprecatedString new_name;
|
||||
if (GUI::InputBox::show(window(), new_name, DeprecatedString::formatted("New name for '{}'", sheet.name()), "Rename sheet"sv) == GUI::Dialog::ExecResult::OK) {
|
||||
sheet.set_name(new_name);
|
||||
sheet.update();
|
||||
m_tab_widget->set_tab_title(static_cast<GUI::Widget&>(*m_tab_context_menu_sheet_view), new_name);
|
||||
|
@ -109,7 +109,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
});
|
||||
m_tab_context_menu->add_action(*m_rename_action);
|
||||
m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) {
|
||||
NonnullRefPtrVector<Sheet> new_sheets;
|
||||
new_sheets.append(m_workbook->add_sheet(name));
|
||||
|
@ -154,7 +154,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
});
|
||||
|
||||
m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
String name = "workbook";
|
||||
DeprecatedString name = "workbook";
|
||||
auto response = FileSystemAccessClient::Client::the().try_save_file(window(), name, "sheets");
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
@ -324,7 +324,7 @@ void SpreadsheetWidget::resize_event(GUI::ResizeEvent& event)
|
|||
m_inline_documentation_window->set_rect(m_cell_value_editor->screen_relative_rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6));
|
||||
}
|
||||
|
||||
void SpreadsheetWidget::clipboard_content_did_change(String const& mime_type)
|
||||
void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mime_type)
|
||||
{
|
||||
if (auto* sheet = current_worksheet_if_available())
|
||||
m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv));
|
||||
|
@ -637,7 +637,7 @@ void SpreadsheetWidget::clipboard_action(bool is_cut)
|
|||
text_builder.append(cell_data->data());
|
||||
first = false;
|
||||
}
|
||||
HashMap<String, String> metadata;
|
||||
HashMap<DeprecatedString, DeprecatedString> metadata;
|
||||
metadata.set("text/x-spreadsheet-data", url_builder.to_string());
|
||||
dbgln(url_builder.to_string());
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
void add_sheet();
|
||||
void add_sheet(NonnullRefPtr<Sheet>&&);
|
||||
|
||||
String const& current_filename() const { return m_workbook->current_filename(); }
|
||||
DeprecatedString const& current_filename() const { return m_workbook->current_filename(); }
|
||||
SpreadsheetView* current_view() { return static_cast<SpreadsheetView*>(m_tab_widget->active_widget()); }
|
||||
Sheet* current_worksheet_if_available() { return current_view() ? current_view()->sheet_if_available() : nullptr; }
|
||||
void update_window_title();
|
||||
|
@ -58,7 +58,7 @@ private:
|
|||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
|
||||
// ^GUI::Clipboard::ClipboardClient
|
||||
virtual void clipboard_content_did_change(String const& mime_type) override;
|
||||
virtual void clipboard_content_did_change(DeprecatedString const& mime_type) override;
|
||||
|
||||
explicit SpreadsheetWidget(GUI::Window& window, NonnullRefPtrVector<Sheet>&& sheets = {}, bool should_add_sheet_if_empty = true);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_wind
|
|||
m_vm->enable_default_host_import_module_dynamically_hook();
|
||||
}
|
||||
|
||||
bool Workbook::set_filename(String const& filename)
|
||||
bool Workbook::set_filename(DeprecatedString const& filename)
|
||||
{
|
||||
if (m_current_filename == filename)
|
||||
return false;
|
||||
|
@ -52,7 +52,7 @@ bool Workbook::set_filename(String const& filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
Result<bool, String> Workbook::open_file(Core::File& file)
|
||||
Result<bool, DeprecatedString> Workbook::open_file(Core::File& file)
|
||||
{
|
||||
auto mime = Core::guess_mime_type_based_on_filename(file.filename());
|
||||
|
||||
|
@ -64,7 +64,7 @@ Result<bool, String> Workbook::open_file(Core::File& file)
|
|||
return true;
|
||||
}
|
||||
|
||||
Result<bool, String> Workbook::write_to_file(Core::File& file)
|
||||
Result<bool, DeprecatedString> Workbook::write_to_file(Core::File& file)
|
||||
{
|
||||
auto mime = Core::guess_mime_type_based_on_filename(file.filename());
|
||||
|
||||
|
@ -76,7 +76,7 @@ Result<bool, String> Workbook::write_to_file(Core::File& file)
|
|||
return true;
|
||||
}
|
||||
|
||||
Result<bool, String> Workbook::import_file(Core::File& file)
|
||||
Result<bool, DeprecatedString> Workbook::import_file(Core::File& file)
|
||||
{
|
||||
auto mime = Core::guess_mime_type_based_on_filename(file.filename());
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ class Workbook {
|
|||
public:
|
||||
Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window);
|
||||
|
||||
Result<bool, String> open_file(Core::File&);
|
||||
Result<bool, String> write_to_file(Core::File&);
|
||||
Result<bool, DeprecatedString> open_file(Core::File&);
|
||||
Result<bool, DeprecatedString> write_to_file(Core::File&);
|
||||
|
||||
Result<bool, String> import_file(Core::File&);
|
||||
Result<bool, DeprecatedString> import_file(Core::File&);
|
||||
|
||||
String const& current_filename() const { return m_current_filename; }
|
||||
bool set_filename(String const& filename);
|
||||
DeprecatedString const& current_filename() const { return m_current_filename; }
|
||||
bool set_filename(DeprecatedString const& filename);
|
||||
bool dirty() { return m_dirty; }
|
||||
void set_dirty(bool dirty) { m_dirty = dirty; }
|
||||
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
JS::ExecutionContext m_main_execution_context;
|
||||
GUI::Window& m_parent_window;
|
||||
|
||||
String m_current_filename;
|
||||
DeprecatedString m_current_filename;
|
||||
bool m_dirty { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ TEST_CASE(can_write_with_header)
|
|||
|
||||
TEST_CASE(can_write_with_different_behaviors)
|
||||
{
|
||||
Vector<Vector<String>> data = {
|
||||
Vector<Vector<DeprecatedString>> data = {
|
||||
{ "Well", "Hello\"", "Friends" },
|
||||
{ "We\"ll", "Hello,", " Friends" },
|
||||
};
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Stream.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -35,8 +35,8 @@ inline WriterBehavior operator|(WriterBehavior left, WriterBehavior right)
|
|||
}
|
||||
|
||||
struct WriterTraits {
|
||||
String separator;
|
||||
String quote { "\"" };
|
||||
DeprecatedString separator;
|
||||
DeprecatedString quote { "\"" };
|
||||
enum QuoteEscape {
|
||||
Repeat,
|
||||
Backslash,
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
|
||||
bool has_error() const { return m_error != WriteError::None; }
|
||||
WriteError error() const { return m_error; }
|
||||
String error_string() const
|
||||
DeprecatedString error_string() const
|
||||
{
|
||||
switch (m_error) {
|
||||
#define E(x, y) \
|
||||
|
@ -137,7 +137,7 @@ private:
|
|||
template<typename T>
|
||||
void write_entry(T&& entry)
|
||||
{
|
||||
auto string = String::formatted("{}", FormatIfSupported(entry));
|
||||
auto string = DeprecatedString::formatted("{}", FormatIfSupported(entry));
|
||||
|
||||
auto safe_to_write_normally = (m_behaviors & WriterBehavior::QuoteAll) == WriterBehavior::None
|
||||
&& !string.contains('\n')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue