Struct DataTransfer¶
Defined in File slint_data_transfer.h
Struct Documentation¶
-
struct DataTransfer¶
DataTransferabstracts over the various ways of transferring data within an application and between applications. The details will depend on the current platform, but the common features are:Each
DataTransfercontains multiple views over the same data in different formats, specified by MIME typeThe
DataTransfermay contain an in-memory representation of the data, which can be sent and received within the current applicationSerializing to a given format may be done eagerly or lazily
Public Functions
-
inline DataTransfer()¶
Default constructor for
DataTransfer
Constructs a
DataTransferwhose plaintext representation is string.
-
inline explicit DataTransfer(const Image &image)¶
Constructs a
DataTransferwhose image representation is image. Conversion to the relevant format is done on-demand.
-
inline ~DataTransfer()¶
Destroys this
DataTransfer, releasing any data it holds.
-
inline DataTransfer(const DataTransfer &other)¶
Creates a new
DataTransferthat shares the data of other.
-
inline DataTransfer &operator=(const DataTransfer &other)¶
Assigns other to this
DataTransferand returns a reference to this.
-
inline DataTransfer(DataTransfer &&other) noexcept¶
Move-constructs a
DataTransferfrom other, leaving other in a default-constructed state.
-
inline DataTransfer &operator=(DataTransfer &&other) noexcept¶
Move-assigns other to this
DataTransferand returns a reference to this.
Sets the plaintext representation of this
DataTransfer. EachDataTransfercan only have a single plaintext representation; calling this again overwrites the previous one.
-
inline void set_image(const Image &image)¶
Sets the image representation of this
DataTransfer. EachDataTransfercan only have a single image representation; calling this again overwrites the previous one.
-
inline bool has_plaintext() const¶
Returns
trueif this data transfer advertises a plaintext representation.
-
inline bool has_image() const¶
Returns
trueif this data transfer advertises an image representation.
-
inline std::optional<SharedString> fetch_plaintext() const¶
Returns the plaintext representation of this
DataTransfer, orstd::nulloptif no plaintext representation is available.
-
inline std::optional<Image> fetch_image() const¶
Returns the image representation of this
DataTransfer, orstd::nulloptif no image representation is available.
-
inline void set_user_data(std::any value)¶
Overload of
set_user_data()for callers that already hold astd::any.
-
inline std::any user_data() const¶
Returns the user data, or an empty
std::anyif none is set. Usestd::any_castto extract the concrete value.
-
inline bool has_user_data() const¶
Returns
trueif thisDataTransferholds user data.
-
inline void clear_user_data()¶
Clears the user data, if any.
Friends
-
inline friend bool operator==(const DataTransfer &a, const DataTransfer &b)¶
Compare two
DataTransfervalues for equality. This will return true ifbis an unmodified clone ofa, but if any modification has been done to either value since cloning then this will return false even if the two values are semantically identical.