docs
Loading...
Searching...
No Matches
ClipboardDataabstract

#include <Ultralight/ClipboardData.h>

Overview

Clipboard contents, stored as multiple type representations of the same data.

Clipboard data is stored in multiple formats, keyed by MIME type (eg, text/plain, text/html) or an application-defined type string.

Building a Payload

Use ClipboardData::Create() to create a payload, then call Set() to add entries. Set() is chainable, so you can build a multi-format payload in one expression:

// Create a payload with a single text/plain entry.
auto data = ClipboardData::Create("hello world");
// Add a text/html entry to the same payload.
data->Set("text/html", "<b>hello world</b>");
static RefPtr< ClipboardData > Create()
Create an empty payload.

Entry order is preserved: when you build a payload yourself you should add the richest format first (the order the OS clipboard will advertise them in).

Note
Use bare MIME types (text/plain, not text/plain;charset=utf-8)– the library normalizes charset-suffixes at its own boundaries.
Inheritance diagram for ClipboardData:
RefCounted

Static Public Member Functions

static RefPtr< ClipboardData > Create ()
 Create an empty payload.
static RefPtr< ClipboardData > Create (const String &text)
 Create a payload holding a single text/plain entry.

Public Member Functions

virtual ClipboardData & Set (const String &type, const ClipboardValue &value)=0
 Set the value for a type (replaces any existing entry with the same type).
virtual ClipboardData & Remove (const String &type)=0
 Remove the entry for a type (does nothing if no such entry exists).
virtual bool Has (const String &type) const =0
 Whether or not an entry exists for a type.
virtual ClipboardValue Get (const String &type) const =0
 Get the value for a type (an empty value when no such entry exists).
virtual String AsText () const =0
 Get the text/plain entry's text (an empty string when there is none, or when that entry holds bytes).
virtual String AsHTML () const =0
 Get the text/html entry's text (an empty string when there is none, or when that entry holds bytes).
virtual size_t size () const =0
 Get the number of entries.
virtual String type_at (size_t index) const =0
 Get the type of the entry at a certain index, in insertion order (an empty string when index is out of range).
virtual String source_url () const =0
 Get the URL of the document this payload came from (can be empty).
virtual void set_source_url (const String &url)=0
 Set the URL of the document this payload came from.
Public Member Functions inherited from RefCounted
virtual void AddRef () const =0
 Increment the reference count (thread-safe).
virtual void Release () const =0
 Decrement the reference count (thread-safe).
virtual int ref_count () const =0
 Get the current reference count.
virtual WeakControlBlock * weak_control_block () const
 Get the control block used to track weak references to this object.

Protected Member Functions

 ClipboardData ()
virtual ~ClipboardData ()
 ClipboardData (const ClipboardData &)
void operator= (const ClipboardData &)
Protected Member Functions inherited from RefCounted
virtual ~RefCounted ()

Constructor & Destructor Documentation

◆ ClipboardData() [1/2]

ClipboardData ( )
protected

◆ ~ClipboardData()

virtual ~ClipboardData ( )
protectedvirtual

◆ ClipboardData() [2/2]

ClipboardData ( const ClipboardData & )
protected

Member Function Documentation

◆ AsHTML()

virtual String AsHTML ( ) const
nodiscardpure virtual

Get the text/html entry's text (an empty string when there is none, or when that entry holds bytes).

◆ AsText()

virtual String AsText ( ) const
nodiscardpure virtual

Get the text/plain entry's text (an empty string when there is none, or when that entry holds bytes).

◆ Create() [1/2]

RefPtr< ClipboardData > Create ( )
static

Create an empty payload.

Returns
Returns a ref-pointer to a new ClipboardData instance.

◆ Create() [2/2]

RefPtr< ClipboardData > Create ( const String & text)
static

Create a payload holding a single text/plain entry.

Returns
Returns a ref-pointer to a new ClipboardData instance.

◆ Get()

virtual ClipboardValue Get ( const String & type) const
nodiscardpure virtual

Get the value for a type (an empty value when no such entry exists).

◆ Has()

virtual bool Has ( const String & type) const
nodiscardpure virtual

Whether or not an entry exists for a type.

◆ operator=()

void operator= ( const ClipboardData & )
protected

◆ Remove()

virtual ClipboardData & Remove ( const String & type)
pure virtual

Remove the entry for a type (does nothing if no such entry exists).

Returns
Returns this ClipboardData so you can chain further calls.

◆ Set()

virtual ClipboardData & Set ( const String & type,
const ClipboardValue & value )
pure virtual

Set the value for a type (replaces any existing entry with the same type).

Parameters
typeThe entry's type (a bare MIME type or an application-defined string).
valueThe value to store (text or bytes; converts implicitly from String, C-string, and RefPtr<Buffer>).
Returns
Returns this ClipboardData so you can chain further calls.

◆ set_source_url()

virtual void set_source_url ( const String & url)
pure virtual

Set the URL of the document this payload came from.

The library sets this when copying page content; on Windows it becomes the HTML clipboard format's SourceURL.

◆ size()

virtual size_t size ( ) const
nodiscardpure virtual

Get the number of entries.

◆ source_url()

virtual String source_url ( ) const
nodiscardpure virtual

Get the URL of the document this payload came from (can be empty).

◆ type_at()

virtual String type_at ( size_t index) const
nodiscardpure virtual

Get the type of the entry at a certain index, in insertion order (an empty string when index is out of range).


The documentation for this class was generated from the following file: