1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 05:24:58 +00:00
serenity/Userland/Services/Clipboard/Storage.h
Ali Mohammad Pur 5e1499d104 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')
2023-12-17 18:25:10 +03:30

55 lines
1.2 KiB
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <LibCore/AnonymousBuffer.h>
namespace Clipboard {
class Storage {
public:
static Storage& the();
~Storage() = default;
bool has_data() const { return m_buffer.is_valid(); }
ByteString const& mime_type() const { return m_mime_type; }
HashMap<ByteString, ByteString> const& metadata() const { return m_metadata; }
u8 const* data() const
{
if (!has_data())
return nullptr;
return m_buffer.data<u8>();
}
size_t data_size() const
{
if (has_data())
return m_data_size;
return 0;
}
void set_data(Core::AnonymousBuffer, ByteString const& mime_type, HashMap<ByteString, ByteString> const& metadata);
Function<void()> on_content_change;
Core::AnonymousBuffer const& buffer() const { return m_buffer; }
private:
Storage() = default;
ByteString m_mime_type;
Core::AnonymousBuffer m_buffer;
size_t m_data_size { 0 };
HashMap<ByteString, ByteString> m_metadata;
};
}