mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-09 07:22:21 +08:00
lib/platform: Use std::string directly instead of String typedef
This commit is contained in:
@@ -38,11 +38,10 @@ MSWindowsClipboardAnyTextConverter::getFormat() const
|
||||
return IClipboard::kText;
|
||||
}
|
||||
|
||||
HANDLE
|
||||
MSWindowsClipboardAnyTextConverter::fromIClipboard(const String& data) const
|
||||
HANDLE MSWindowsClipboardAnyTextConverter::fromIClipboard(const std::string& data) const
|
||||
{
|
||||
// convert linefeeds and then convert to desired encoding
|
||||
String text = doFromIClipboard(convertLinefeedToWin32(data));
|
||||
std::string text = doFromIClipboard(convertLinefeedToWin32(data));
|
||||
UInt32 size = (UInt32)text.size();
|
||||
|
||||
// copy to memory handle
|
||||
@@ -63,18 +62,17 @@ MSWindowsClipboardAnyTextConverter::fromIClipboard(const String& data) const
|
||||
return gData;
|
||||
}
|
||||
|
||||
String
|
||||
MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const
|
||||
std::string MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const
|
||||
{
|
||||
// get datator
|
||||
const char* src = (const char*)GlobalLock(data);
|
||||
UInt32 srcSize = (UInt32)GlobalSize(data);
|
||||
if (src == NULL || srcSize <= 1) {
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
// convert text
|
||||
String text = doToIClipboard(String(src, srcSize));
|
||||
std::string text = doToIClipboard(std::string(src, srcSize));
|
||||
|
||||
// release handle
|
||||
GlobalUnlock(data);
|
||||
@@ -83,9 +81,7 @@ MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const
|
||||
return convertLinefeedToUnix(text);
|
||||
}
|
||||
|
||||
String
|
||||
MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32(
|
||||
const String& src) const
|
||||
std::string MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32(const std::string& src) const
|
||||
{
|
||||
// note -- we assume src is a valid UTF-8 string
|
||||
|
||||
@@ -102,7 +98,7 @@ MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32(
|
||||
}
|
||||
|
||||
// allocate new string
|
||||
String dst;
|
||||
std::string dst;
|
||||
dst.reserve(src.size() + numNewlines);
|
||||
|
||||
// copy string, converting newlines
|
||||
@@ -117,9 +113,7 @@ MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32(
|
||||
return dst;
|
||||
}
|
||||
|
||||
String
|
||||
MSWindowsClipboardAnyTextConverter::convertLinefeedToUnix(
|
||||
const String& src) const
|
||||
std::string MSWindowsClipboardAnyTextConverter::convertLinefeedToUnix(const std::string& src) const
|
||||
{
|
||||
// count newlines in string
|
||||
UInt32 numNewlines = 0;
|
||||
@@ -134,7 +128,7 @@ MSWindowsClipboardAnyTextConverter::convertLinefeedToUnix(
|
||||
}
|
||||
|
||||
// allocate new string
|
||||
String dst;
|
||||
std::string dst;
|
||||
dst.reserve(src.size());
|
||||
|
||||
// copy string, converting newlines
|
||||
|
||||
Reference in New Issue
Block a user