mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:47:46 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -20,14 +20,14 @@ enum class Version {
|
|||
};
|
||||
|
||||
struct Doctype {
|
||||
DeprecatedString type;
|
||||
ByteString type;
|
||||
Vector<MarkupDeclaration> markup_declarations;
|
||||
Optional<ExternalID> external_id;
|
||||
};
|
||||
|
||||
class Document {
|
||||
public:
|
||||
explicit Document(NonnullOwnPtr<Node> root, Optional<Doctype> doctype, HashMap<Name, DeprecatedString> processing_instructions, Version version)
|
||||
explicit Document(NonnullOwnPtr<Node> root, Optional<Doctype> doctype, HashMap<Name, ByteString> processing_instructions, Version version)
|
||||
: m_root(move(root))
|
||||
, m_processing_instructions(move(processing_instructions))
|
||||
, m_version(version)
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
Node& root() { return *m_root; }
|
||||
Node const& root() const { return *m_root; }
|
||||
|
||||
HashMap<Name, DeprecatedString> const& processing_instructions() const { return m_processing_instructions; }
|
||||
HashMap<Name, ByteString> const& processing_instructions() const { return m_processing_instructions; }
|
||||
|
||||
Version version() const { return m_version; }
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
private:
|
||||
NonnullOwnPtr<Node> m_root;
|
||||
HashMap<Name, DeprecatedString> m_processing_instructions;
|
||||
HashMap<Name, ByteString> m_processing_instructions;
|
||||
Version m_version;
|
||||
Optional<Doctype> m_explicit_doctype;
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -73,7 +73,7 @@ struct AttributeListDeclaration {
|
|||
};
|
||||
struct Enumeration {
|
||||
// FIXME: NMToken
|
||||
HashTable<DeprecatedString> tokens;
|
||||
HashTable<ByteString> tokens;
|
||||
};
|
||||
using Type = Variant<StringType, TokenizedType, NotationType, Enumeration>;
|
||||
|
||||
|
@ -82,10 +82,10 @@ struct AttributeListDeclaration {
|
|||
struct Implied {
|
||||
};
|
||||
struct Fixed {
|
||||
DeprecatedString value;
|
||||
ByteString value;
|
||||
};
|
||||
struct DefaultValue {
|
||||
DeprecatedString value;
|
||||
ByteString value;
|
||||
};
|
||||
|
||||
using Default = Variant<Required, Implied, Fixed, DefaultValue>;
|
||||
|
@ -100,11 +100,11 @@ struct AttributeListDeclaration {
|
|||
};
|
||||
|
||||
struct PublicID {
|
||||
DeprecatedString public_literal;
|
||||
ByteString public_literal;
|
||||
};
|
||||
|
||||
struct SystemID {
|
||||
DeprecatedString system_literal;
|
||||
ByteString system_literal;
|
||||
};
|
||||
|
||||
struct ExternalID {
|
||||
|
@ -119,12 +119,12 @@ struct EntityDefinition {
|
|||
|
||||
struct GEDeclaration {
|
||||
Name name;
|
||||
Variant<DeprecatedString, EntityDefinition> definition;
|
||||
Variant<ByteString, EntityDefinition> definition;
|
||||
};
|
||||
|
||||
struct PEDeclaration {
|
||||
Name name;
|
||||
Variant<DeprecatedString, ExternalID> definition;
|
||||
Variant<ByteString, ExternalID> definition;
|
||||
};
|
||||
|
||||
using EntityDeclaration = Variant<GEDeclaration, PEDeclaration>;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -16,7 +16,7 @@ namespace XML {
|
|||
|
||||
struct Attribute {
|
||||
Name name;
|
||||
DeprecatedString value;
|
||||
ByteString value;
|
||||
};
|
||||
|
||||
struct Offset {
|
||||
|
@ -30,11 +30,11 @@ struct Node {
|
|||
StringBuilder builder;
|
||||
};
|
||||
struct Comment {
|
||||
DeprecatedString text;
|
||||
ByteString text;
|
||||
};
|
||||
struct Element {
|
||||
Name name;
|
||||
HashMap<Name, DeprecatedString> attributes;
|
||||
HashMap<Name, ByteString> attributes;
|
||||
Vector<NonnullOwnPtr<Node>> children;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
|
||||
namespace XML {
|
||||
|
||||
// FIXME: Maybe extend this to something more sophisticated?
|
||||
using Name = DeprecatedString;
|
||||
using Name = ByteString;
|
||||
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ ErrorOr<void, ParseError> Parser::parse_internal()
|
|||
if (auto it = find_if(matched_source.begin(), matched_source.end(), s_restricted_characters); !it.is_end()) {
|
||||
return parse_error(
|
||||
it.index(),
|
||||
DeprecatedString::formatted("Invalid character #{:x} used in document", *it));
|
||||
ByteString::formatted("Invalid character #{:x} used in document", *it));
|
||||
}
|
||||
|
||||
if (!m_lexer.is_eof())
|
||||
|
@ -261,7 +261,7 @@ ErrorOr<void, ParseError> Parser::expect(StringView expected)
|
|||
|
||||
if (!m_lexer.consume_specific(expected)) {
|
||||
if (m_options.treat_errors_as_fatal)
|
||||
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected '{}'", expected));
|
||||
return parse_error(m_lexer.tell(), ByteString::formatted("Expected '{}'", expected));
|
||||
}
|
||||
|
||||
rollback.disarm();
|
||||
|
@ -275,7 +275,7 @@ requires(IsCallableWithArguments<Pred, bool, char>) ErrorOr<StringView, ParseErr
|
|||
auto start = m_lexer.tell();
|
||||
if (!m_lexer.next_is(predicate)) {
|
||||
if (m_options.treat_errors_as_fatal)
|
||||
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected {}", description));
|
||||
return parse_error(m_lexer.tell(), ByteString::formatted("Expected {}", description));
|
||||
}
|
||||
|
||||
m_lexer.ignore();
|
||||
|
@ -296,7 +296,7 @@ requires(IsCallableWithArguments<Pred, bool, char>) ErrorOr<StringView, ParseErr
|
|||
|
||||
if (m_lexer.tell() == start) {
|
||||
if (m_options.treat_errors_as_fatal) {
|
||||
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected {}", description));
|
||||
return parse_error(m_lexer.tell(), ByteString::formatted("Expected {}", description));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ ErrorOr<void, ParseError> Parser::parse_version_info()
|
|||
m_in_compatibility_mode = true;
|
||||
} else {
|
||||
if (version_string != "1.1" && m_options.treat_errors_as_fatal)
|
||||
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected '1.1', found '{}'", version_string));
|
||||
return parse_error(m_lexer.tell(), ByteString::formatted("Expected '1.1', found '{}'", version_string));
|
||||
}
|
||||
|
||||
m_version = Version::Version11;
|
||||
|
@ -524,7 +524,7 @@ ErrorOr<void, ParseError> Parser::parse_processing_instruction()
|
|||
auto accept = accept_rule();
|
||||
|
||||
auto target = TRY(parse_processing_instruction_target());
|
||||
DeprecatedString data;
|
||||
ByteString data;
|
||||
if (auto result = skip_whitespace(Required::Yes); !result.is_error())
|
||||
data = m_lexer.consume_until("?>");
|
||||
TRY(expect("?>"sv));
|
||||
|
@ -576,7 +576,7 @@ ErrorOr<Name, ParseError> Parser::parse_name()
|
|||
builder.append(rest);
|
||||
|
||||
rollback.disarm();
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 2.8.28. doctypedecl, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-doctypedecl
|
||||
|
@ -601,7 +601,7 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
|
|||
if (resource_result.is_error()) {
|
||||
return parse_error(
|
||||
id_start,
|
||||
DeprecatedString::formatted("Failed to resolve external subset '{}': {}", doctype.external_id->system_id.system_literal, resource_result.error()));
|
||||
ByteString::formatted("Failed to resolve external subset '{}': {}", doctype.external_id->system_id.system_literal, resource_result.error()));
|
||||
}
|
||||
StringView resolved_source = resource_result.value();
|
||||
TemporaryChange source { m_source, resolved_source };
|
||||
|
@ -610,7 +610,7 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
|
|||
if (!m_lexer.is_eof()) {
|
||||
return parse_error(
|
||||
m_lexer.tell(),
|
||||
DeprecatedString::formatted("Failed to resolve external subset '{}': garbage after declarations", doctype.external_id->system_id.system_literal));
|
||||
ByteString::formatted("Failed to resolve external subset '{}': garbage after declarations", doctype.external_id->system_id.system_literal));
|
||||
}
|
||||
doctype.markup_declarations.extend(move(declarations));
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
|
|||
auto accept = accept_rule();
|
||||
|
||||
auto name = TRY(parse_name());
|
||||
HashMap<Name, DeprecatedString> attributes;
|
||||
HashMap<Name, ByteString> attributes;
|
||||
|
||||
while (true) {
|
||||
if (auto result = skip_whitespace(Required::Yes); result.is_error())
|
||||
|
@ -723,7 +723,7 @@ ErrorOr<Attribute, ParseError> Parser::parse_attribute()
|
|||
}
|
||||
|
||||
// 2.3.10. AttValue, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-AttValue
|
||||
ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value()
|
||||
ErrorOr<ByteString, ParseError> Parser::parse_attribute_value()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
|
@ -740,7 +740,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value()
|
|||
return text;
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value_inner(StringView disallow)
|
||||
ErrorOr<ByteString, ParseError> Parser::parse_attribute_value_inner(StringView disallow)
|
||||
{
|
||||
StringBuilder builder;
|
||||
while (true) {
|
||||
|
@ -754,7 +754,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value_inner(String
|
|||
|
||||
if (m_lexer.next_is('&')) {
|
||||
auto reference = TRY(parse_reference());
|
||||
if (auto* char_reference = reference.get_pointer<DeprecatedString>())
|
||||
if (auto* char_reference = reference.get_pointer<ByteString>())
|
||||
builder.append(*char_reference);
|
||||
else
|
||||
builder.append(TRY(resolve_reference(reference.get<EntityReference>(), ReferencePlacement::AttributeValue)));
|
||||
|
@ -762,14 +762,14 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value_inner(String
|
|||
builder.append(m_lexer.consume());
|
||||
}
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
||||
constexpr static auto s_characters = ranges_for_search<Range(0x1, 0xd7ff), Range(0xe000, 0xfffd), Range(0x10000, 0x10ffff)>();
|
||||
|
||||
// 4.1.67. Reference, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Reference
|
||||
ErrorOr<Variant<Parser::EntityReference, DeprecatedString>, ParseError> Parser::parse_reference()
|
||||
ErrorOr<Variant<Parser::EntityReference, ByteString>, ParseError> Parser::parse_reference()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
|
@ -811,7 +811,7 @@ ErrorOr<Variant<Parser::EntityReference, DeprecatedString>, ParseError> Parser::
|
|||
builder.append_code_point(*code_point);
|
||||
|
||||
rollback.disarm();
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
auto name = name_result.release_value();
|
||||
|
@ -833,7 +833,7 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_start_tag()
|
|||
auto accept = accept_rule();
|
||||
|
||||
auto name = TRY(parse_name());
|
||||
HashMap<Name, DeprecatedString> attributes;
|
||||
HashMap<Name, ByteString> attributes;
|
||||
|
||||
while (true) {
|
||||
if (auto result = skip_whitespace(Required::Yes); result.is_error())
|
||||
|
@ -891,7 +891,7 @@ ErrorOr<void, ParseError> Parser::parse_content()
|
|||
if (auto result = parse_reference(); !result.is_error()) {
|
||||
auto reference = result.release_value();
|
||||
auto reference_offset = m_lexer.offset_for(node_start);
|
||||
if (auto char_reference = reference.get_pointer<DeprecatedString>())
|
||||
if (auto char_reference = reference.get_pointer<ByteString>())
|
||||
append_text(*char_reference, reference_offset);
|
||||
else
|
||||
append_text(TRY(resolve_reference(reference.get<EntityReference>(), ReferencePlacement::Content)), reference_offset);
|
||||
|
@ -1028,7 +1028,7 @@ ErrorOr<Optional<MarkupDeclaration>, ParseError> Parser::parse_markup_declaratio
|
|||
}
|
||||
|
||||
// 2.8.28a DeclSep, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-DeclSep
|
||||
ErrorOr<Optional<DeprecatedString>, ParseError> Parser::parse_declaration_separator()
|
||||
ErrorOr<Optional<ByteString>, ParseError> Parser::parse_declaration_separator()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
|
@ -1042,7 +1042,7 @@ ErrorOr<Optional<DeprecatedString>, ParseError> Parser::parse_declaration_separa
|
|||
|
||||
if (auto result = skip_whitespace(Required::Yes); !result.is_error()) {
|
||||
rollback.disarm();
|
||||
return Optional<DeprecatedString> {};
|
||||
return Optional<ByteString> {};
|
||||
}
|
||||
|
||||
return parse_error(m_lexer.tell(), "Expected either whitespace, or a PEReference");
|
||||
|
@ -1178,7 +1178,7 @@ ErrorOr<AttributeListDeclaration::Definition, ParseError> Parser::parse_attribut
|
|||
TRY(expect(")"sv));
|
||||
type = AttributeListDeclaration::NotationType { move(names) };
|
||||
} else {
|
||||
HashTable<DeprecatedString> names;
|
||||
HashTable<ByteString> names;
|
||||
TRY(expect("("sv));
|
||||
TRY(skip_whitespace());
|
||||
names.set(TRY(parse_nm_token()));
|
||||
|
@ -1463,7 +1463,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_general_entity_declaration(
|
|||
{
|
||||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
Variant<DeprecatedString, EntityDefinition, Empty> definition;
|
||||
Variant<ByteString, EntityDefinition, Empty> definition;
|
||||
|
||||
// GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
|
||||
TRY(expect("<!ENTITY"sv));
|
||||
|
@ -1493,7 +1493,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_general_entity_declaration(
|
|||
rollback.disarm();
|
||||
return GEDeclaration {
|
||||
move(name),
|
||||
move(definition).downcast<DeprecatedString, EntityDefinition>(),
|
||||
move(definition).downcast<ByteString, EntityDefinition>(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1503,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_parameter_entity_declaratio
|
|||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
|
||||
Variant<DeprecatedString, ExternalID, Empty> definition;
|
||||
Variant<ByteString, ExternalID, Empty> definition;
|
||||
// PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
|
||||
TRY(expect("<!ENTITY"sv));
|
||||
auto accept = accept_rule();
|
||||
|
@ -1525,7 +1525,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_parameter_entity_declaratio
|
|||
rollback.disarm();
|
||||
return PEDeclaration {
|
||||
move(name),
|
||||
move(definition).downcast<DeprecatedString, ExternalID>(),
|
||||
move(definition).downcast<ByteString, ExternalID>(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1639,7 +1639,7 @@ ErrorOr<Name, ParseError> Parser::parse_notation_data_declaration()
|
|||
}
|
||||
|
||||
// 2.3.9 EntityValue, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EntityValue
|
||||
ErrorOr<DeprecatedString, ParseError> Parser::parse_entity_value()
|
||||
ErrorOr<ByteString, ParseError> Parser::parse_entity_value()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
auto rule = enter_rule();
|
||||
|
@ -1672,7 +1672,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_entity_value()
|
|||
TRY(expect(quote));
|
||||
|
||||
rollback.disarm();
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 2.7.18 CDSect, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-CDSect
|
||||
|
@ -1734,11 +1734,11 @@ ErrorOr<void, ParseError> Parser::parse_text_declaration()
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference const& reference, ReferencePlacement placement)
|
||||
ErrorOr<ByteString, ParseError> Parser::resolve_reference(EntityReference const& reference, ReferencePlacement placement)
|
||||
{
|
||||
static HashTable<Name> reference_lookup {};
|
||||
if (reference_lookup.contains(reference.name))
|
||||
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Invalid recursive definition for '{}'", reference.name));
|
||||
return parse_error(m_lexer.tell(), ByteString::formatted("Invalid recursive definition for '{}'", reference.name));
|
||||
|
||||
reference_lookup.set(reference.name);
|
||||
ScopeGuard remove_lookup {
|
||||
|
@ -1747,7 +1747,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference
|
|||
}
|
||||
};
|
||||
|
||||
Optional<DeprecatedString> resolved;
|
||||
Optional<ByteString> resolved;
|
||||
if (m_doctype.has_value()) {
|
||||
// FIXME: Split these up and resolve them ahead of time.
|
||||
for (auto& declaration : m_doctype->markup_declarations) {
|
||||
|
@ -1760,23 +1760,23 @@ ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference
|
|||
if (ge_declaration->name != reference.name)
|
||||
continue;
|
||||
TRY(ge_declaration->definition.visit(
|
||||
[&](DeprecatedString const& definition) -> ErrorOr<void, ParseError> {
|
||||
[&](ByteString const& definition) -> ErrorOr<void, ParseError> {
|
||||
resolved = definition;
|
||||
return {};
|
||||
},
|
||||
[&](EntityDefinition const& definition) -> ErrorOr<void, ParseError> {
|
||||
if (placement == ReferencePlacement::AttributeValue)
|
||||
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Attribute references external entity '{}'", reference.name));
|
||||
return parse_error(m_lexer.tell(), ByteString::formatted("Attribute references external entity '{}'", reference.name));
|
||||
|
||||
if (definition.notation.has_value())
|
||||
return parse_error(0u, DeprecatedString::formatted("Entity reference to unparsed entity '{}'", reference.name));
|
||||
return parse_error(0u, ByteString::formatted("Entity reference to unparsed entity '{}'", reference.name));
|
||||
|
||||
if (!m_options.resolve_external_resource)
|
||||
return parse_error(0u, DeprecatedString::formatted("Failed to resolve external entity '{}'", reference.name));
|
||||
return parse_error(0u, ByteString::formatted("Failed to resolve external entity '{}'", reference.name));
|
||||
|
||||
auto result = m_options.resolve_external_resource(definition.id.system_id, definition.id.public_id);
|
||||
if (result.is_error())
|
||||
return parse_error(0u, DeprecatedString::formatted("Failed to resolve external entity '{}': {}", reference.name, result.error()));
|
||||
return parse_error(0u, ByteString::formatted("Failed to resolve external entity '{}': {}", reference.name, result.error()));
|
||||
|
||||
resolved = result.release_value();
|
||||
return {};
|
||||
|
@ -1796,7 +1796,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference
|
|||
return "'";
|
||||
if (reference.name == "quot")
|
||||
return "\"";
|
||||
return parse_error(0u, DeprecatedString::formatted("Reference to undeclared entity '{}'", reference.name));
|
||||
return parse_error(0u, ByteString::formatted("Reference to undeclared entity '{}'", reference.name));
|
||||
}
|
||||
|
||||
StringView resolved_source = *resolved;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
@ -23,16 +23,16 @@ namespace XML {
|
|||
|
||||
struct ParseError {
|
||||
size_t offset;
|
||||
DeprecatedString error;
|
||||
ByteString error;
|
||||
};
|
||||
|
||||
struct Listener {
|
||||
virtual ~Listener() { }
|
||||
|
||||
virtual void set_source(DeprecatedString) { }
|
||||
virtual void set_source(ByteString) { }
|
||||
virtual void document_start() { }
|
||||
virtual void document_end() { }
|
||||
virtual void element_start(Name const&, HashMap<Name, DeprecatedString> const&) { }
|
||||
virtual void element_start(Name const&, HashMap<Name, ByteString> const&) { }
|
||||
virtual void element_end(Name const&) { }
|
||||
virtual void text(StringView) { }
|
||||
virtual void comment(StringView) { }
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
bool preserve_cdata { true };
|
||||
bool preserve_comments { false };
|
||||
bool treat_errors_as_fatal { true };
|
||||
Function<ErrorOr<DeprecatedString>(SystemID const&, Optional<PublicID> const&)> resolve_external_resource {};
|
||||
Function<ErrorOr<ByteString>(SystemID const&, Optional<PublicID> const&)> resolve_external_resource {};
|
||||
};
|
||||
|
||||
Parser(StringView source, Options options)
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
AttributeValue,
|
||||
Content,
|
||||
};
|
||||
ErrorOr<DeprecatedString, ParseError> resolve_reference(EntityReference const&, ReferencePlacement);
|
||||
ErrorOr<ByteString, ParseError> resolve_reference(EntityReference const&, ReferencePlacement);
|
||||
|
||||
enum class Required {
|
||||
No,
|
||||
|
@ -120,12 +120,12 @@ private:
|
|||
ErrorOr<Name, ParseError> parse_end_tag();
|
||||
ErrorOr<void, ParseError> parse_content();
|
||||
ErrorOr<Attribute, ParseError> parse_attribute();
|
||||
ErrorOr<DeprecatedString, ParseError> parse_attribute_value();
|
||||
ErrorOr<Variant<EntityReference, DeprecatedString>, ParseError> parse_reference();
|
||||
ErrorOr<ByteString, ParseError> parse_attribute_value();
|
||||
ErrorOr<Variant<EntityReference, ByteString>, ParseError> parse_reference();
|
||||
ErrorOr<StringView, ParseError> parse_char_data();
|
||||
ErrorOr<Vector<MarkupDeclaration>, ParseError> parse_internal_subset();
|
||||
ErrorOr<Optional<MarkupDeclaration>, ParseError> parse_markup_declaration();
|
||||
ErrorOr<Optional<DeprecatedString>, ParseError> parse_declaration_separator();
|
||||
ErrorOr<Optional<ByteString>, ParseError> parse_declaration_separator();
|
||||
ErrorOr<Vector<MarkupDeclaration>, ParseError> parse_external_subset_declaration();
|
||||
ErrorOr<ElementDeclaration, ParseError> parse_element_declaration();
|
||||
ErrorOr<AttributeListDeclaration, ParseError> parse_attribute_list_declaration();
|
||||
|
@ -140,12 +140,12 @@ private:
|
|||
ErrorOr<PublicID, ParseError> parse_public_id();
|
||||
ErrorOr<SystemID, ParseError> parse_system_id();
|
||||
ErrorOr<ExternalID, ParseError> parse_external_id();
|
||||
ErrorOr<DeprecatedString, ParseError> parse_entity_value();
|
||||
ErrorOr<ByteString, ParseError> parse_entity_value();
|
||||
ErrorOr<Name, ParseError> parse_notation_data_declaration();
|
||||
ErrorOr<StringView, ParseError> parse_public_id_literal();
|
||||
ErrorOr<StringView, ParseError> parse_system_id_literal();
|
||||
ErrorOr<StringView, ParseError> parse_cdata_section();
|
||||
ErrorOr<DeprecatedString, ParseError> parse_attribute_value_inner(StringView disallow);
|
||||
ErrorOr<ByteString, ParseError> parse_attribute_value_inner(StringView disallow);
|
||||
ErrorOr<Vector<MarkupDeclaration>, ParseError> parse_external_subset();
|
||||
ErrorOr<void, ParseError> parse_text_declaration();
|
||||
|
||||
|
@ -198,7 +198,7 @@ private:
|
|||
rule_name = rule_name.substring_view(6);
|
||||
m_parse_errors.append({
|
||||
error.offset,
|
||||
DeprecatedString::formatted("{}: {}", rule_name, error.error),
|
||||
ByteString::formatted("{}: {}", rule_name, error.error),
|
||||
});
|
||||
}
|
||||
return error;
|
||||
|
@ -213,11 +213,11 @@ private:
|
|||
Node* m_entered_node { nullptr };
|
||||
Version m_version { Version::Version11 };
|
||||
bool m_in_compatibility_mode { false };
|
||||
DeprecatedString m_encoding;
|
||||
ByteString m_encoding;
|
||||
bool m_standalone { false };
|
||||
HashMap<Name, DeprecatedString> m_processing_instructions;
|
||||
HashMap<Name, ByteString> m_processing_instructions;
|
||||
struct AcceptedRule {
|
||||
Optional<DeprecatedString> rule {};
|
||||
Optional<ByteString> rule {};
|
||||
bool accept { false };
|
||||
} m_current_rule {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue