nostalgia/src/turbine/clipboard.hpp

33 lines
796 B
C++

/*
* Copyright 2016 - 2023 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 {
ox::String getClipboardText(class Context &ctx) noexcept;
void setClipboardText(class Context &ctx, ox::CRStringView text) noexcept;
template<typename T>
void setClipboardObject([[maybe_unused]] class Context &ctx, [[maybe_unused]] ox::UniquePtr<T> obj) noexcept {
ctx.clipboard = std::move(obj);
}
template<typename T>
ox::Result<T*> getClipboardObject([[maybe_unused]] class Context &ctx) noexcept {
if (ctx.clipboard && ctx.clipboard->typeMatch(T::TypeName, T::TypeVersion)) {
return static_cast<T*>(ctx.clipboard.get());
}
return OxError(1);
}
}