foobar2000 SDK  2015-08-03
Data Structures | Functions
ClipboardHelper Namespace Reference

Data Structures

class  OpenScope
 

Functions

template<typename TArray >
bool GetRaw (UINT format, TArray &out)
 
bool GetString (pfc::string_base &out)
 
bool IsTextAvailable ()
 
void SetRaw (UINT format, const void *data, t_size size)
 
void SetString (const char *in)
 

Function Documentation

template<typename TArray >
bool ClipboardHelper::GetRaw ( UINT  format,
TArray &  out 
)

Definition at line 31 of file clipboard.h.

31  {
33  HANDLE data = GetClipboardData(format);
34  if (data == NULL) return false;
35  CGlobalLockScope lock(data);
36  out.set_size( lock.GetSize() );
37  memcpy(out.get_ptr(), lock.GetPtr(), lock.GetSize() );
38  return true;
39  }
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
bool ClipboardHelper::GetString ( pfc::string_base out)

Definition at line 30 of file clipboard.cpp.

30  {
32  if (!GetRaw(CF_TCHAR,temp)) return false;
33  out = pfc::stringcvt::string_utf8_from_os(reinterpret_cast<const TCHAR*>(temp.get_ptr()),temp.get_size() / sizeof(TCHAR));
34  return true;
35  }
const t_item * get_ptr() const
Definition: array.h:213
bool GetRaw(UINT format, TArray &out)
Definition: clipboard.h:31
string_utf8_from_wide string_utf8_from_os
Definition: string_conv.h:517
t_size get_size() const
Definition: array.h:130
bool ClipboardHelper::IsTextAvailable ( )

Definition at line 36 of file clipboard.cpp.

36  {
37  return IsClipboardFormatAvailable(CF_TCHAR) == TRUE;
38  }
void ClipboardHelper::SetRaw ( UINT  format,
const void *  data,
t_size  size 
)

Definition at line 12 of file clipboard.cpp.

12  {
13  HANDLE buffer = GlobalAlloc(GMEM_DDESHARE,size);
14  if (buffer == NULL) throw std::bad_alloc();
15  try {
16  CGlobalLockScope lock(buffer);
17  PFC_ASSERT(lock.GetSize() == size);
18  memcpy(lock.GetPtr(),data,size);
19  } catch(...) {
20  GlobalFree(buffer); throw;
21  }
22 
23  WIN32_OP(SetClipboardData(format,buffer) != NULL);
24  }
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
void ClipboardHelper::SetString ( const char *  in)

Definition at line 25 of file clipboard.cpp.

25  {
27  SetRaw(CF_TCHAR,temp.get_ptr(),(temp.length() + 1) * sizeof(TCHAR));
28  }
void SetRaw(UINT format, const void *data, t_size size)
Definition: clipboard.cpp:12