mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:07:44 +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
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace DNS {
|
||||
|
||||
Answer::Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, DeprecatedString const& record_data, bool mdns_cache_flush)
|
||||
Answer::Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, ByteString const& record_data, bool mdns_cache_flush)
|
||||
: m_name(name)
|
||||
, m_type(type)
|
||||
, m_class_code(class_code)
|
||||
|
@ -115,11 +115,11 @@ ErrorOr<void> encode(Encoder& encoder, DNS::Answer const& answer)
|
|||
template<>
|
||||
ErrorOr<DNS::Answer> decode(Decoder& decoder)
|
||||
{
|
||||
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||
auto name = TRY(decoder.decode<ByteString>());
|
||||
auto record_type = TRY(decoder.decode<DNS::RecordType>());
|
||||
auto class_code = TRY(decoder.decode<DNS::RecordClass>());
|
||||
auto ttl = TRY(decoder.decode<u32>());
|
||||
auto record_data = TRY(decoder.decode<DeprecatedString>());
|
||||
auto record_data = TRY(decoder.decode<ByteString>());
|
||||
auto cache_flush = TRY(decoder.decode<bool>());
|
||||
|
||||
return DNS::Answer { name, record_type, class_code, ttl, record_data, cache_flush };
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Name.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/Types.h>
|
||||
|
@ -36,7 +36,7 @@ enum class RecordClass : u16 {
|
|||
class Answer {
|
||||
public:
|
||||
Answer() = default;
|
||||
Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, DeprecatedString const& record_data, bool mdns_cache_flush);
|
||||
Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, ByteString const& record_data, bool mdns_cache_flush);
|
||||
|
||||
Name const& name() const { return m_name; }
|
||||
RecordType type() const { return m_type; }
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_cache_flush ? MDNS_CACHE_FLUSH : 0); }
|
||||
u32 ttl() const { return m_ttl; }
|
||||
time_t received_time() const { return m_received_time; }
|
||||
DeprecatedString const& record_data() const { return m_record_data; }
|
||||
ByteString const& record_data() const { return m_record_data; }
|
||||
bool mdns_cache_flush() const { return m_mdns_cache_flush; }
|
||||
|
||||
bool has_expired() const;
|
||||
|
@ -58,7 +58,7 @@ private:
|
|||
RecordClass m_class_code { 0 };
|
||||
u32 m_ttl { 0 };
|
||||
time_t m_received_time { 0 };
|
||||
DeprecatedString m_record_data;
|
||||
ByteString m_record_data;
|
||||
bool m_mdns_cache_flush { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace DNS {
|
||||
|
||||
Name::Name(DeprecatedString const& name)
|
||||
Name::Name(ByteString const& name)
|
||||
{
|
||||
if (name.ends_with('.'))
|
||||
m_name = name.substring(0, name.length() - 1);
|
||||
|
@ -38,7 +38,7 @@ ErrorOr<Name> Name::parse(ReadonlyBytes data, size_t& offset, size_t recursion_l
|
|||
if (builder.length() > MAX_NAME_SIZE)
|
||||
return Error::from_string_literal("Domain name exceeds maximum allowed length");
|
||||
// This terminates the name.
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
} else if ((b & 0xc0) == 0xc0) {
|
||||
// The two bytes tell us the offset when to continue from.
|
||||
if (offset >= data.size())
|
||||
|
@ -48,7 +48,7 @@ ErrorOr<Name> Name::parse(ReadonlyBytes data, size_t& offset, size_t recursion_l
|
|||
builder.append(rest_of_name.as_string());
|
||||
if (builder.length() > MAX_NAME_SIZE)
|
||||
return Error::from_string_literal("Domain name exceeds maximum allowed length");
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
} else {
|
||||
// This is the length of a part.
|
||||
if (offset + b >= data.size())
|
||||
|
@ -84,7 +84,7 @@ void Name::randomize_case()
|
|||
}
|
||||
builder.append(c);
|
||||
}
|
||||
m_name = builder.to_deprecated_string();
|
||||
m_name = builder.to_byte_string();
|
||||
}
|
||||
|
||||
ErrorOr<void> Name::write_to_stream(Stream& stream) const
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
|
||||
namespace DNS {
|
||||
|
@ -15,12 +15,12 @@ namespace DNS {
|
|||
class Name {
|
||||
public:
|
||||
Name() = default;
|
||||
Name(DeprecatedString const&);
|
||||
Name(ByteString const&);
|
||||
|
||||
static ErrorOr<Name> parse(ReadonlyBytes data, size_t& offset, size_t recursion_level = 0);
|
||||
|
||||
size_t serialized_size() const;
|
||||
DeprecatedString const& as_string() const { return m_name; }
|
||||
ByteString const& as_string() const { return m_name; }
|
||||
ErrorOr<void> write_to_stream(Stream&) const;
|
||||
|
||||
void randomize_case();
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
DeprecatedString m_name;
|
||||
ByteString m_name;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ ErrorOr<Packet> Packet::from_raw_packet(ReadonlyBytes bytes)
|
|||
if (record.data_length() > bytes.size() - offset)
|
||||
return Error::from_string_literal("Unexpected EOF when parsing DNS packet");
|
||||
|
||||
DeprecatedString data;
|
||||
ByteString data;
|
||||
|
||||
switch ((RecordType)record.type()) {
|
||||
case RecordType::PTR: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue