mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:57:35 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -15,7 +15,7 @@
|
|||
namespace Web::MimeSniff {
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match
|
||||
bool is_javascript_mime_type_essence_match(String const& string)
|
||||
bool is_javascript_mime_type_essence_match(DeprecatedString const& string)
|
||||
{
|
||||
// NOTE: The mime type parser automatically lowercases the essence.
|
||||
auto type = MimeType::from_string(string);
|
||||
|
@ -37,7 +37,7 @@ static bool contains_only_http_quoted_string_token_code_points(StringView string
|
|||
return true;
|
||||
}
|
||||
|
||||
MimeType::MimeType(String type, String subtype)
|
||||
MimeType::MimeType(DeprecatedString type, DeprecatedString subtype)
|
||||
: m_type(move(type))
|
||||
, m_subtype(move(subtype))
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ Optional<MimeType> MimeType::from_string(StringView string)
|
|||
break;
|
||||
|
||||
// 7. Let parameterValue be null.
|
||||
String parameter_value;
|
||||
DeprecatedString parameter_value;
|
||||
|
||||
// 8. If the code point at position within input is U+0022 ("), then:
|
||||
if (lexer.peek() == '"') {
|
||||
|
@ -177,15 +177,15 @@ Optional<MimeType> MimeType::from_string(StringView string)
|
|||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#mime-type-essence
|
||||
String MimeType::essence() const
|
||||
DeprecatedString MimeType::essence() const
|
||||
{
|
||||
// The essence of a MIME type mimeType is mimeType’s type, followed by U+002F (/), followed by mimeType’s subtype.
|
||||
// FIXME: I believe this can easily be cached as I don't think anything directly changes the type and subtype.
|
||||
return String::formatted("{}/{}", m_type, m_subtype);
|
||||
return DeprecatedString::formatted("{}/{}", m_type, m_subtype);
|
||||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#serialize-a-mime-type
|
||||
String MimeType::serialized() const
|
||||
DeprecatedString MimeType::serialized() const
|
||||
{
|
||||
// 1. Let serialization be the concatenation of mimeType’s type, U+002F (/), and mimeType’s subtype.
|
||||
StringBuilder serialization;
|
||||
|
@ -212,7 +212,7 @@ String MimeType::serialized() const
|
|||
|
||||
// 2. Prepend U+0022 (") to value.
|
||||
// 3. Append U+0022 (") to value.
|
||||
value = String::formatted("\"{}\"", value);
|
||||
value = DeprecatedString::formatted("\"{}\"", value);
|
||||
}
|
||||
|
||||
// 5. Append value to serialization.
|
||||
|
@ -223,7 +223,7 @@ String MimeType::serialized() const
|
|||
return serialization.to_string();
|
||||
}
|
||||
|
||||
void MimeType::set_parameter(String const& name, String const& value)
|
||||
void MimeType::set_parameter(DeprecatedString const& name, DeprecatedString const& value)
|
||||
{
|
||||
// https://mimesniff.spec.whatwg.org/#parameters
|
||||
// A MIME type’s parameters is an ordered map whose keys are ASCII strings and values are strings limited to HTTP quoted-string token code points.
|
||||
|
|
|
@ -7,44 +7,44 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Web::MimeSniff {
|
||||
|
||||
bool is_javascript_mime_type_essence_match(String const&);
|
||||
bool is_javascript_mime_type_essence_match(DeprecatedString const&);
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#mime-type
|
||||
class MimeType {
|
||||
public:
|
||||
static Optional<MimeType> from_string(StringView);
|
||||
|
||||
MimeType(String type, String subtype);
|
||||
MimeType(DeprecatedString type, DeprecatedString subtype);
|
||||
~MimeType();
|
||||
|
||||
String const& type() const { return m_type; }
|
||||
String const& subtype() const { return m_subtype; }
|
||||
OrderedHashMap<String, String> const& parameters() const { return m_parameters; }
|
||||
DeprecatedString const& type() const { return m_type; }
|
||||
DeprecatedString const& subtype() const { return m_subtype; }
|
||||
OrderedHashMap<DeprecatedString, DeprecatedString> const& parameters() const { return m_parameters; }
|
||||
|
||||
bool is_javascript() const;
|
||||
|
||||
void set_parameter(String const& name, String const& value);
|
||||
void set_parameter(DeprecatedString const& name, DeprecatedString const& value);
|
||||
|
||||
String essence() const;
|
||||
String serialized() const;
|
||||
DeprecatedString essence() const;
|
||||
DeprecatedString serialized() const;
|
||||
|
||||
private:
|
||||
// https://mimesniff.spec.whatwg.org/#type
|
||||
// A MIME type’s type is a non-empty ASCII string.
|
||||
String m_type;
|
||||
DeprecatedString m_type;
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#subtype
|
||||
// A MIME type’s subtype is a non-empty ASCII string.
|
||||
String m_subtype;
|
||||
DeprecatedString m_subtype;
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#parameters
|
||||
// A MIME type’s parameters is an ordered map whose keys are ASCII strings and values are strings limited to HTTP quoted-string token code points. It is initially empty.
|
||||
OrderedHashMap<String, String> m_parameters;
|
||||
OrderedHashMap<DeprecatedString, DeprecatedString> m_parameters;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue