summaryrefslogtreecommitdiff
path: root/Services/Clipboard/Storage.h
diff options
context:
space:
mode:
Diffstat (limited to 'Services/Clipboard/Storage.h')
-rw-r--r--Services/Clipboard/Storage.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/Services/Clipboard/Storage.h b/Services/Clipboard/Storage.h
new file mode 100644
index 0000000000..7f38c3d1db
--- /dev/null
+++ b/Services/Clipboard/Storage.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <AK/Function.h>
+#include <AK/SharedBuffer.h>
+#include <AK/String.h>
+
+namespace Clipboard {
+
+class Storage {
+public:
+ static Storage& the();
+ ~Storage();
+
+ bool has_data() const { return m_shared_buffer; }
+
+ const String& mime_type() const { return m_mime_type; }
+
+ const u8* data() const
+ {
+ if (!has_data())
+ return nullptr;
+ return static_cast<const u8*>(m_shared_buffer->data());
+ }
+
+ size_t data_size() const
+ {
+ if (has_data())
+ return m_data_size;
+ return 0;
+ }
+
+ void set_data(NonnullRefPtr<SharedBuffer>, size_t data_size, const String& mime_type);
+
+ Function<void()> on_content_change;
+
+private:
+ Storage();
+
+ String m_mime_type;
+ RefPtr<SharedBuffer> m_shared_buffer;
+ size_t m_data_size { 0 };
+};
+
+}