From 46204ba517821d02d368db75b1ba2688f16bcaa9 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Sat, 1 Jul 2017 15:39:51 +0800 Subject: [PATCH] Move clipboard functions to SDLSystem --- SDLWrapper/SDLSystem.cpp | 29 +++++++++++++++++++++++++++++ SDLWrapper/SDLSystem.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/SDLWrapper/SDLSystem.cpp b/SDLWrapper/SDLSystem.cpp index b84d86e..f0d309f 100644 --- a/SDLWrapper/SDLSystem.cpp +++ b/SDLWrapper/SDLSystem.cpp @@ -244,4 +244,33 @@ int SDLSystem::GetSystemRAM() { return SDL_GetSystemRAM(); } + +//static +int SDLSystem::SetClipboardText(const std::string& str) +{ + return SDL_SetClipboardText(str.c_str()); +} + +//static +std::string SDLSystem::GetClipboardText() +{ + char* pstr=SDL_GetClipboardText(); + if(pstr==nullptr) + { + return std::string(); + } + else + { + std::string s(pstr); + SDL_free(pstr); + return s; + } +} + +//static +bool SDLSystem::HasClipboardText() +{ + return SDL_HasClipboardText()==SDL_TRUE; +} + #include "end_code.h" diff --git a/SDLWrapper/SDLSystem.h b/SDLWrapper/SDLSystem.h index 79d704b..6d16477 100644 --- a/SDLWrapper/SDLSystem.h +++ b/SDLWrapper/SDLSystem.h @@ -52,6 +52,10 @@ public: /// RAM is calculated in MB. static int GetSystemRAM(); + static int SetClipboardText(const std::string& str); + static std::string GetClipboardText(); + static bool HasClipboardText(); + class Android { public: