Browse Source

LibWeb/MimeSniff: Add move/copy construct and assignment to MimeType

This change exists to avoid having to reparse a MIME type when we
need to move/copy elsewhere.
Kemal Zebari 1 year ago
parent
commit
a2a61d6941

+ 6 - 0
Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp

@@ -64,6 +64,12 @@ MimeType::MimeType(String type, String subtype)
     VERIFY(!m_subtype.is_empty() && contains_only_http_token_code_points(m_subtype));
 }
 
+MimeType::MimeType(MimeType const& other) = default;
+MimeType& MimeType::operator=(MimeType const& other) = default;
+
+MimeType::MimeType(MimeType&& other) = default;
+MimeType& MimeType::operator=(MimeType&& other) = default;
+
 MimeType::~MimeType() = default;
 
 ErrorOr<MimeType> MimeType::create(String type, String subtype)

+ 6 - 0
Userland/Libraries/LibWeb/MimeSniff/MimeType.h

@@ -20,6 +20,12 @@ public:
     static ErrorOr<MimeType> create(String type, String subtype);
     static ErrorOr<Optional<MimeType>> parse(StringView);
 
+    MimeType(MimeType const&);
+    MimeType& operator=(MimeType const&);
+
+    MimeType(MimeType&&);
+    MimeType& operator=(MimeType&&);
+
     ~MimeType();
 
     String const& type() const { return m_type; }