1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:37:34 +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

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Variant.h>
#include <LibRegex/Regex.h>
@ -23,7 +23,7 @@ struct internal_regex_t {
Optional<Variant<NonnullOwnPtr<Regex<PosixExtended>>, NonnullOwnPtr<Regex<PosixBasic>>>> re;
size_t re_pat_errpos;
ReError re_pat_err;
String re_pat;
DeprecatedString re_pat;
};
static internal_regex_t* impl_from(regex_t* re)
@ -55,7 +55,7 @@ int regcomp(regex_t* reg, char const* pattern, int cflags)
preg->cflags = cflags;
String pattern_str(pattern);
DeprecatedString pattern_str(pattern);
if (is_extended)
preg->re = make<Regex<PosixExtended>>(pattern_str, PosixOptions {} | (PosixFlags)cflags | PosixFlags::SkipTrimEmptyMatches);
else
@ -152,9 +152,9 @@ int regexec(regex_t const* reg, char const* string, size_t nmatch, regmatch_t pm
return REG_NOMATCH;
}
inline static String get_error(ReError errcode)
inline static DeprecatedString get_error(ReError errcode)
{
String error;
DeprecatedString error;
switch ((ReError)errcode) {
case REG_NOERR:
error = "No error";
@ -211,7 +211,7 @@ inline static String get_error(ReError errcode)
size_t regerror(int errcode, regex_t const* reg, char* errbuf, size_t errbuf_size)
{
String error;
DeprecatedString error;
auto const* preg = impl_from(reg);
if (!preg)

View file

@ -517,7 +517,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
if (input.view.length() < state.string_position + length)
return ExecutionResult::Failed_ExecuteLowPrioForks;
Optional<String> str;
Optional<DeprecatedString> str;
Vector<u16, 1> utf16;
Vector<u32> data;
data.ensure_capacity(length);
@ -878,9 +878,9 @@ ALWAYS_INLINE void OpCode_Compare::compare_script_extension(MatchInput const& in
}
}
String OpCode_Compare::arguments_string() const
DeprecatedString OpCode_Compare::arguments_string() const
{
return String::formatted("argc={}, args={} ", arguments_count(), arguments_size());
return DeprecatedString::formatted("argc={}, args={} ", arguments_count(), arguments_size());
}
Vector<CompareTypeAndValuePair> OpCode_Compare::flat_compares() const
@ -927,16 +927,16 @@ Vector<CompareTypeAndValuePair> OpCode_Compare::flat_compares() const
return result;
}
Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput const&> input) const
Vector<DeprecatedString> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput const&> input) const
{
Vector<String> result;
Vector<DeprecatedString> result;
size_t offset { state().instruction_position + 3 };
RegexStringView const& view = ((input.has_value()) ? input.value().view : StringView {});
for (size_t i = 0; i < arguments_count(); ++i) {
auto compare_type = (CharacterCompareType)m_bytecode->at(offset++);
result.empend(String::formatted("type={} [{}]", (size_t)compare_type, character_compare_type_name(compare_type)));
result.empend(DeprecatedString::formatted("type={} [{}]", (size_t)compare_type, character_compare_type_name(compare_type)));
auto string_start_offset = state().string_position_before_match;
@ -944,39 +944,39 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput
auto ch = m_bytecode->at(offset++);
auto is_ascii = is_ascii_printable(ch);
if (is_ascii)
result.empend(String::formatted(" value='{:c}'", static_cast<char>(ch)));
result.empend(DeprecatedString::formatted(" value='{:c}'", static_cast<char>(ch)));
else
result.empend(String::formatted(" value={:x}", ch));
result.empend(DeprecatedString::formatted(" value={:x}", ch));
if (!view.is_null() && view.length() > string_start_offset) {
if (is_ascii) {
result.empend(String::formatted(
result.empend(DeprecatedString::formatted(
" compare against: '{}'",
view.substring_view(string_start_offset, string_start_offset > view.length() ? 0 : 1).to_string()));
} else {
auto str = view.substring_view(string_start_offset, string_start_offset > view.length() ? 0 : 1).to_string();
u8 buf[8] { 0 };
__builtin_memcpy(buf, str.characters(), min(str.length(), sizeof(buf)));
result.empend(String::formatted(" compare against: {:x},{:x},{:x},{:x},{:x},{:x},{:x},{:x}",
result.empend(DeprecatedString::formatted(" compare against: {:x},{:x},{:x},{:x},{:x},{:x},{:x},{:x}",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]));
}
}
} else if (compare_type == CharacterCompareType::Reference) {
auto ref = m_bytecode->at(offset++);
result.empend(String::formatted(" number={}", ref));
result.empend(DeprecatedString::formatted(" number={}", ref));
if (input.has_value()) {
if (state().capture_group_matches.size() > input->match_index) {
auto& match = state().capture_group_matches[input->match_index];
if (match.size() > ref) {
auto& group = match[ref];
result.empend(String::formatted(" left={}", group.left_column));
result.empend(String::formatted(" right={}", group.left_column + group.view.length_in_code_units()));
result.empend(String::formatted(" contents='{}'", group.view));
result.empend(DeprecatedString::formatted(" left={}", group.left_column));
result.empend(DeprecatedString::formatted(" right={}", group.left_column + group.view.length_in_code_units()));
result.empend(DeprecatedString::formatted(" contents='{}'", group.view));
} else {
result.empend(String::formatted(" (invalid ref, max={})", match.size() - 1));
result.empend(DeprecatedString::formatted(" (invalid ref, max={})", match.size() - 1));
}
} else {
result.empend(String::formatted(" (invalid index {}, max={})", input->match_index, state().capture_group_matches.size() - 1));
result.empend(DeprecatedString::formatted(" (invalid index {}, max={})", input->match_index, state().capture_group_matches.size() - 1));
}
}
} else if (compare_type == CharacterCompareType::String) {
@ -984,33 +984,33 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput
StringBuilder str_builder;
for (size_t i = 0; i < length; ++i)
str_builder.append(m_bytecode->at(offset++));
result.empend(String::formatted(" value=\"{}\"", str_builder.string_view().substring_view(0, length)));
result.empend(DeprecatedString::formatted(" value=\"{}\"", str_builder.string_view().substring_view(0, length)));
if (!view.is_null() && view.length() > state().string_position)
result.empend(String::formatted(
result.empend(DeprecatedString::formatted(
" compare against: \"{}\"",
input.value().view.substring_view(string_start_offset, string_start_offset + length > view.length() ? 0 : length).to_string()));
} else if (compare_type == CharacterCompareType::CharClass) {
auto character_class = (CharClass)m_bytecode->at(offset++);
result.empend(String::formatted(" ch_class={} [{}]", (size_t)character_class, character_class_name(character_class)));
result.empend(DeprecatedString::formatted(" ch_class={} [{}]", (size_t)character_class, character_class_name(character_class)));
if (!view.is_null() && view.length() > state().string_position)
result.empend(String::formatted(
result.empend(DeprecatedString::formatted(
" compare against: '{}'",
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_string()));
} else if (compare_type == CharacterCompareType::CharRange) {
auto value = (CharRange)m_bytecode->at(offset++);
result.empend(String::formatted(" ch_range={:x}-{:x}", value.from, value.to));
result.empend(DeprecatedString::formatted(" ch_range={:x}-{:x}", value.from, value.to));
if (!view.is_null() && view.length() > state().string_position)
result.empend(String::formatted(
result.empend(DeprecatedString::formatted(
" compare against: '{}'",
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_string()));
} else if (compare_type == CharacterCompareType::LookupTable) {
auto count = m_bytecode->at(offset++);
for (size_t j = 0; j < count; ++j) {
auto range = (CharRange)m_bytecode->at(offset++);
result.append(String::formatted(" {:x}-{:x}", range.from, range.to));
result.append(DeprecatedString::formatted(" {:x}-{:x}", range.from, range.to));
}
if (!view.is_null() && view.length() > state().string_position)
result.empend(String::formatted(
result.empend(DeprecatedString::formatted(
" compare against: '{}'",
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_string()));
} else if (compare_type == CharacterCompareType::GeneralCategory
@ -1019,7 +1019,7 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput
|| compare_type == CharacterCompareType::ScriptExtension) {
auto value = m_bytecode->at(offset++);
result.empend(String::formatted(" value={}", value));
result.empend(DeprecatedString::formatted(" value={}", value));
}
}
return result;

View file

@ -570,12 +570,12 @@ public:
return *m_state;
}
String to_string() const
DeprecatedString to_string() const
{
return String::formatted("[{:#02X}] {}", (int)opcode_id(), name(opcode_id()));
return DeprecatedString::formatted("[{:#02X}] {}", (int)opcode_id(), name(opcode_id()));
}
virtual String arguments_string() const = 0;
virtual DeprecatedString arguments_string() const = 0;
ALWAYS_INLINE ByteCode const& bytecode() const { return *m_bytecode; }
@ -589,7 +589,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::Exit; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_FailForks final : public OpCode {
@ -597,7 +597,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::FailForks; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_Save final : public OpCode {
@ -605,7 +605,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::Save; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_Restore final : public OpCode {
@ -613,7 +613,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::Restore; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_GoBack final : public OpCode {
@ -622,7 +622,7 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::GoBack; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE size_t count() const { return argument(0); }
String arguments_string() const override { return String::formatted("count={}", count()); }
DeprecatedString arguments_string() const override { return DeprecatedString::formatted("count={}", count()); }
};
class OpCode_Jump final : public OpCode {
@ -631,9 +631,9 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::Jump; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE ssize_t offset() const { return argument(0); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
return String::formatted("offset={} [&{}]", offset(), state().instruction_position + size() + offset());
return DeprecatedString::formatted("offset={} [&{}]", offset(), state().instruction_position + size() + offset());
}
};
@ -643,9 +643,9 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::ForkJump; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE ssize_t offset() const { return argument(0); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
return String::formatted("offset={} [&{}], sp: {}", offset(), state().instruction_position + size() + offset(), state().string_position);
return DeprecatedString::formatted("offset={} [&{}], sp: {}", offset(), state().instruction_position + size() + offset(), state().string_position);
}
};
@ -661,9 +661,9 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::ForkStay; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE ssize_t offset() const { return argument(0); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
return String::formatted("offset={} [&{}], sp: {}", offset(), state().instruction_position + size() + offset(), state().string_position);
return DeprecatedString::formatted("offset={} [&{}], sp: {}", offset(), state().instruction_position + size() + offset(), state().string_position);
}
};
@ -678,7 +678,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::CheckBegin; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_CheckEnd final : public OpCode {
@ -686,7 +686,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::CheckEnd; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_CheckBoundary final : public OpCode {
@ -696,7 +696,7 @@ public:
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE size_t arguments_count() const { return 1; }
ALWAYS_INLINE BoundaryCheckType type() const { return static_cast<BoundaryCheckType>(argument(0)); }
String arguments_string() const override { return String::formatted("kind={} ({})", (long unsigned int)argument(0), boundary_check_type_name(type())); }
DeprecatedString arguments_string() const override { return DeprecatedString::formatted("kind={} ({})", (long unsigned int)argument(0), boundary_check_type_name(type())); }
};
class OpCode_ClearCaptureGroup final : public OpCode {
@ -705,7 +705,7 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::ClearCaptureGroup; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE size_t id() const { return argument(0); }
String arguments_string() const override { return String::formatted("id={}", id()); }
DeprecatedString arguments_string() const override { return DeprecatedString::formatted("id={}", id()); }
};
class OpCode_SaveLeftCaptureGroup final : public OpCode {
@ -714,7 +714,7 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::SaveLeftCaptureGroup; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE size_t id() const { return argument(0); }
String arguments_string() const override { return String::formatted("id={}", id()); }
DeprecatedString arguments_string() const override { return DeprecatedString::formatted("id={}", id()); }
};
class OpCode_SaveRightCaptureGroup final : public OpCode {
@ -723,7 +723,7 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::SaveRightCaptureGroup; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE size_t id() const { return argument(0); }
String arguments_string() const override { return String::formatted("id={}", id()); }
DeprecatedString arguments_string() const override { return DeprecatedString::formatted("id={}", id()); }
};
class OpCode_SaveRightNamedCaptureGroup final : public OpCode {
@ -734,9 +734,9 @@ public:
ALWAYS_INLINE StringView name() const { return { reinterpret_cast<char*>(argument(0)), length() }; }
ALWAYS_INLINE size_t length() const { return argument(1); }
ALWAYS_INLINE size_t id() const { return argument(2); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
return String::formatted("name={}, length={}", name(), length());
return DeprecatedString::formatted("name={}, length={}", name(), length());
}
};
@ -747,8 +747,8 @@ public:
ALWAYS_INLINE size_t size() const override { return arguments_size() + 3; }
ALWAYS_INLINE size_t arguments_count() const { return argument(0); }
ALWAYS_INLINE size_t arguments_size() const { return argument(1); }
String arguments_string() const override;
Vector<String> variable_arguments_to_string(Optional<MatchInput const&> input = {}) const;
DeprecatedString arguments_string() const override;
Vector<DeprecatedString> variable_arguments_to_string(Optional<MatchInput const&> input = {}) const;
Vector<CompareTypeAndValuePair> flat_compares() const;
static bool matches_character_class(CharClass, u32, bool insensitive);
@ -771,10 +771,10 @@ public:
ALWAYS_INLINE size_t offset() const { return argument(0); }
ALWAYS_INLINE u64 count() const { return argument(1); }
ALWAYS_INLINE size_t id() const { return argument(2); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
auto reps = id() < state().repetition_marks.size() ? state().repetition_marks.at(id()) : 0;
return String::formatted("offset={} count={} id={} rep={}, sp: {}", offset(), count() + 1, id(), reps + 1, state().string_position);
return DeprecatedString::formatted("offset={} count={} id={} rep={}, sp: {}", offset(), count() + 1, id(), reps + 1, state().string_position);
}
};
@ -784,10 +784,10 @@ public:
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::ResetRepeat; }
ALWAYS_INLINE size_t size() const override { return 2; }
ALWAYS_INLINE size_t id() const { return argument(0); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
auto reps = id() < state().repetition_marks.size() ? state().repetition_marks.at(id()) : 0;
return String::formatted("id={} rep={}", id(), reps + 1);
return DeprecatedString::formatted("id={} rep={}", id(), reps + 1);
}
};
@ -796,7 +796,7 @@ public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::Checkpoint; }
ALWAYS_INLINE size_t size() const override { return 1; }
String arguments_string() const override { return String::empty(); }
DeprecatedString arguments_string() const override { return DeprecatedString::empty(); }
};
class OpCode_JumpNonEmpty final : public OpCode {
@ -807,9 +807,9 @@ public:
ALWAYS_INLINE ssize_t offset() const { return argument(0); }
ALWAYS_INLINE ssize_t checkpoint() const { return argument(1); }
ALWAYS_INLINE OpCodeId form() const { return (OpCodeId)argument(2); }
String arguments_string() const override
DeprecatedString arguments_string() const override
{
return String::formatted("{} offset={} [&{}], cp={} [&{}]",
return DeprecatedString::formatted("{} offset={} [&{}], cp={} [&{}]",
opcode_id_name(form()),
offset(), state().instruction_position + size() + offset(),
checkpoint(), state().instruction_position + size() + checkpoint());

View file

@ -55,7 +55,7 @@ public:
fflush(m_file);
}
void print_opcode(String const& system, OpCode& opcode, MatchState& state, size_t recursion = 0, bool newline = true) const
void print_opcode(DeprecatedString const& system, OpCode& opcode, MatchState& state, size_t recursion = 0, bool newline = true) const
{
out(m_file, "{:15} | {:5} | {:9} | {:35} | {:30} | {:20}",
system.characters(),
@ -63,7 +63,7 @@ public:
recursion,
opcode.to_string().characters(),
opcode.arguments_string().characters(),
String::formatted("ip: {:3}, sp: {:3}", state.instruction_position, state.string_position));
DeprecatedString::formatted("ip: {:3}, sp: {:3}", state.instruction_position, state.string_position));
if (newline)
outln();
if (newline && is<OpCode_Compare>(opcode)) {
@ -119,7 +119,7 @@ public:
}
private:
String m_debug_stripline;
DeprecatedString m_debug_stripline;
FILE* m_file;
};

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Types.h>
#ifdef AK_OS_SERENITY
# include <bits/regex_defs.h>
@ -39,7 +39,7 @@ enum class Error : u8 {
InvalidCharacterClassEscape = __Regex_InvalidCharacterClassEscape, // Invalid escaped entity in character class.
};
inline String get_error_string(Error error)
inline DeprecatedString get_error_string(Error error)
{
switch (error) {
case Error::NoError:

View file

@ -9,11 +9,11 @@
#include "Forward.h"
#include "RegexOptions.h"
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/HashMap.h>
#include <AK/MemMem.h>
#include <AK/RedBlackTree.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <AK/Utf16View.h>
@ -157,7 +157,7 @@ class RegexStringView {
public:
RegexStringView() = default;
RegexStringView(String const& string)
RegexStringView(DeprecatedString const& string)
: m_view(string.view())
{
}
@ -182,7 +182,7 @@ public:
{
}
explicit RegexStringView(String&&) = delete;
explicit RegexStringView(DeprecatedString&&) = delete;
StringView string_view() const
{
@ -266,7 +266,7 @@ public:
return view;
}
RegexStringView construct_as_same(Span<u32> data, Optional<String>& optional_string_storage, Vector<u16, 1>& optional_utf16_storage) const
RegexStringView construct_as_same(Span<u32> data, Optional<DeprecatedString>& optional_string_storage, Vector<u16, 1>& optional_utf16_storage) const
{
auto view = m_view.visit(
[&]<typename T>(T const&) {
@ -381,7 +381,7 @@ public:
return view;
}
String to_string() const
DeprecatedString to_string() const
{
return m_view.visit(
[](StringView view) { return view.to_string(); },
@ -440,7 +440,7 @@ public:
[&](StringView view) { return view == cstring; });
}
bool operator==(String const& string) const
bool operator==(DeprecatedString const& string) const
{
return m_view.visit(
[&](Utf32View) { return to_string() == string; },
@ -573,7 +573,7 @@ public:
{
}
Match(String string_, size_t const line_, size_t const column_, size_t const global_offset_)
Match(DeprecatedString string_, size_t const line_, size_t const column_, size_t const global_offset_)
: string(move(string_))
, view(string.value().view())
, line(line_)

View file

@ -6,7 +6,7 @@
#include <AK/BumpAllocator.h>
#include <AK/Debug.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <LibRegex/RegexMatcher.h>
#include <LibRegex/RegexParser.h>
@ -31,7 +31,7 @@ regex::Parser::Result Regex<Parser>::parse_pattern(StringView pattern, typename
}
template<class Parser>
Regex<Parser>::Regex(String pattern, typename ParserTraits<Parser>::OptionsType regex_options)
Regex<Parser>::Regex(DeprecatedString pattern, typename ParserTraits<Parser>::OptionsType regex_options)
: pattern_value(move(pattern))
{
regex::Lexer lexer(pattern_value);
@ -45,7 +45,7 @@ Regex<Parser>::Regex(String pattern, typename ParserTraits<Parser>::OptionsType
}
template<class Parser>
Regex<Parser>::Regex(regex::Parser::Result parse_result, String pattern, typename ParserTraits<Parser>::OptionsType regex_options)
Regex<Parser>::Regex(regex::Parser::Result parse_result, DeprecatedString pattern, typename ParserTraits<Parser>::OptionsType regex_options)
: pattern_value(move(pattern))
, parser_result(move(parse_result))
{
@ -87,7 +87,7 @@ typename ParserTraits<Parser>::OptionsType Regex<Parser>::options() const
}
template<class Parser>
String Regex<Parser>::error_string(Optional<String> message) const
DeprecatedString Regex<Parser>::error_string(Optional<DeprecatedString> message) const
{
StringBuilder eb;
eb.append("Error during parsing of regular expression:\n"sv);

View file

@ -83,22 +83,22 @@ private:
template<class Parser>
class Regex final {
public:
String pattern_value;
DeprecatedString pattern_value;
regex::Parser::Result parser_result;
OwnPtr<Matcher<Parser>> matcher { nullptr };
mutable size_t start_offset { 0 };
static regex::Parser::Result parse_pattern(StringView pattern, typename ParserTraits<Parser>::OptionsType regex_options = {});
explicit Regex(String pattern, typename ParserTraits<Parser>::OptionsType regex_options = {});
Regex(regex::Parser::Result parse_result, String pattern, typename ParserTraits<Parser>::OptionsType regex_options = {});
explicit Regex(DeprecatedString pattern, typename ParserTraits<Parser>::OptionsType regex_options = {});
Regex(regex::Parser::Result parse_result, DeprecatedString pattern, typename ParserTraits<Parser>::OptionsType regex_options = {});
~Regex() = default;
Regex(Regex&&);
Regex& operator=(Regex&&);
typename ParserTraits<Parser>::OptionsType options() const;
void print_bytecode(FILE* f = stdout) const;
String error_string(Optional<String> message = {}) const;
DeprecatedString error_string(Optional<DeprecatedString> message = {}) const;
RegexResult match(RegexStringView view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
@ -114,7 +114,7 @@ public:
return matcher->match(views, regex_options);
}
String replace(RegexStringView view, StringView replacement_pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
DeprecatedString replace(RegexStringView view, StringView replacement_pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
if (!matcher || parser_result.error != Error::NoError)
return {};

View file

@ -9,9 +9,9 @@
#include "RegexDebug.h"
#include <AK/AnyOf.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/GenericLexer.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringUtils.h>
#include <AK/TemporaryChange.h>
@ -74,7 +74,7 @@ ALWAYS_INLINE Token Parser::consume(TokenType type, Error error)
return consume();
}
ALWAYS_INLINE bool Parser::consume(String const& str)
ALWAYS_INLINE bool Parser::consume(DeprecatedString const& str)
{
size_t potentially_go_back { 1 };
for (auto ch : str) {

View file

@ -82,7 +82,7 @@ protected:
ALWAYS_INLINE bool match_ordinary_characters();
ALWAYS_INLINE Token consume();
ALWAYS_INLINE Token consume(TokenType type, Error error);
ALWAYS_INLINE bool consume(String const&);
ALWAYS_INLINE bool consume(DeprecatedString const&);
ALWAYS_INLINE Optional<u32> consume_escaped_code_point(bool unicode);
ALWAYS_INLINE bool try_skip(StringView);
ALWAYS_INLINE bool lookahead_any(StringView);