/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <ox/claw/claw.hpp>
#include <ox/std/memory.hpp>
#include <ox/std/string.hpp>

#include "context.hpp"

namespace turbine {

class BaseClipboardObject {
	public:
		virtual ~BaseClipboardObject() noexcept = default;

		[[nodiscard]]
		virtual ox::StringView typeId() const noexcept = 0;
};

template<typename T>
class ClipboardObject: public BaseClipboardObject {
	[[nodiscard]]
	ox::StringView typeId() const noexcept final {
		return ox::ModelTypeId_v<T>;
	}
};

ox::String getClipboardText(Context const &ctx) noexcept;

void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept;

void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexcept;

ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringViewCR typeId) noexcept;

template<typename T>
ox::Result<T*> getClipboardObject(Context &ctx) noexcept {
	OX_REQUIRE(p, getClipboardData(ctx, ox::ModelTypeId_v<T>));
	return dynamic_cast<T*>(p);
}

}
