/*
 * Copyright 2016 - 2022 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 nostalgia::core {

ox::String getClipboardText(class Context *ctx) noexcept;

void setClipboardText(class Context *ctx, const ox::String &text) noexcept;

template<typename T>
void setClipboardObject([[maybe_unused]] class Context *ctx, [[maybe_unused]] ox::UniquePtr<T> obj) noexcept {
#ifndef OX_BARE_METAL
	ctx->clipboard = std::move(obj);
#endif
}

template<typename T>
ox::Result<T*> getClipboardObject([[maybe_unused]] class Context *ctx) noexcept {
#ifndef OX_BARE_METAL
	if (ctx->clipboard && ctx->clipboard->typeMatch(T::TypeName, T::TypeVersion)) {
		return static_cast<T*>(ctx->clipboard.get());
	}
#endif
	return OxError(1);
}

}
