summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/arch/Arch.h4
-rw-r--r--src/lib/arch/ArchDaemonNone.h3
-rw-r--r--src/lib/arch/IArchDaemon.h4
-rw-r--r--src/lib/arch/IArchTaskBarReceiver.h6
-rw-r--r--src/lib/arch/XArch.h6
-rw-r--r--src/lib/arch/unix/ArchInternetUnix.cpp16
-rw-r--r--src/lib/arch/unix/ArchInternetUnix.h6
-rw-r--r--src/lib/arch/unix/ArchMultithreadPosix.cpp13
-rw-r--r--src/lib/arch/unix/ArchNetworkBSD.cpp1
-rw-r--r--src/lib/arch/unix/XArchUnix.h2
-rw-r--r--src/lib/arch/win32/ArchInternetWindows.cpp36
-rw-r--r--src/lib/arch/win32/ArchInternetWindows.h6
-rw-r--r--src/lib/arch/win32/ArchMiscWindows.cpp7
-rw-r--r--src/lib/arch/win32/ArchMiscWindows.h3
-rw-r--r--src/lib/arch/win32/XArchWindows.cpp4
-rw-r--r--src/lib/arch/win32/XArchWindows.h4
-rw-r--r--src/lib/barrier/ClientApp.cpp4
-rw-r--r--src/lib/barrier/PlatformScreen.h2
-rw-r--r--src/lib/barrier/ProtocolUtil.cpp3
-rw-r--r--src/lib/barrier/ProtocolUtil.h6
-rw-r--r--src/lib/barrier/ServerApp.cpp13
-rw-r--r--src/lib/barrier/StreamChunker.cpp2
-rw-r--r--src/lib/barrier/XBarrier.cpp30
-rw-r--r--src/lib/barrier/XBarrier.h34
-rw-r--r--src/lib/barrier/XScreen.cpp11
-rw-r--r--src/lib/barrier/XScreen.h4
-rw-r--r--src/lib/barrier/win32/DaemonApp.cpp5
-rw-r--r--src/lib/base/EventQueue.cpp9
-rw-r--r--src/lib/base/EventQueue.h6
-rw-r--r--src/lib/base/EventTypes.cpp1
-rw-r--r--src/lib/base/EventTypes.h9
-rw-r--r--src/lib/base/IEventQueue.h11
-rw-r--r--src/lib/base/Log.cpp1
-rw-r--r--src/lib/base/String.cpp62
-rw-r--r--src/lib/base/String.h40
-rw-r--r--src/lib/base/Unicode.cpp81
-rw-r--r--src/lib/base/Unicode.h42
-rw-r--r--src/lib/base/XBase.cpp11
-rw-r--r--src/lib/base/XBase.h41
-rw-r--r--src/lib/base/log_outputters.cpp5
-rw-r--r--src/lib/base/log_outputters.h4
-rw-r--r--src/lib/client/Client.cpp20
-rw-r--r--src/lib/client/Client.h20
-rw-r--r--src/lib/client/ServerProxy.cpp10
-rw-r--r--src/lib/client/ServerProxy.h1
-rw-r--r--src/lib/common/stdexcept.h23
-rw-r--r--src/lib/io/XIO.cpp9
-rw-r--r--src/lib/ipc/IpcClientProxy.cpp4
-rw-r--r--src/lib/ipc/IpcLogOutputter.cpp10
-rw-r--r--src/lib/ipc/IpcLogOutputter.h7
-rw-r--r--src/lib/ipc/IpcMessage.cpp14
-rw-r--r--src/lib/ipc/IpcMessage.h14
-rw-r--r--src/lib/ipc/IpcServerProxy.cpp4
-rw-r--r--src/lib/mt/XMT.cpp3
-rw-r--r--src/lib/net/IDataSocket.h4
-rw-r--r--src/lib/net/NetworkAddress.cpp5
-rw-r--r--src/lib/net/NetworkAddress.h7
-rw-r--r--src/lib/net/SecureListenSocket.cpp3
-rw-r--r--src/lib/net/SecureSocket.cpp24
-rw-r--r--src/lib/net/SecureSocket.h18
-rw-r--r--src/lib/net/TCPSocket.cpp25
-rw-r--r--src/lib/net/TCPSocket.h3
-rw-r--r--src/lib/net/XSocket.cpp27
-rw-r--r--src/lib/net/XSocket.h15
-rw-r--r--src/lib/platform/MSWindowsClipboard.cpp9
-rw-r--r--src/lib/platform/MSWindowsClipboard.h14
-rw-r--r--src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp24
-rw-r--r--src/lib/platform/MSWindowsClipboardAnyTextConverter.h14
-rw-r--r--src/lib/platform/MSWindowsClipboardBitmapConverter.cpp12
-rw-r--r--src/lib/platform/MSWindowsClipboardBitmapConverter.h4
-rw-r--r--src/lib/platform/MSWindowsClipboardHTMLConverter.cpp41
-rw-r--r--src/lib/platform/MSWindowsClipboardHTMLConverter.h6
-rw-r--r--src/lib/platform/MSWindowsClipboardTextConverter.cpp12
-rw-r--r--src/lib/platform/MSWindowsClipboardTextConverter.h4
-rw-r--r--src/lib/platform/MSWindowsClipboardUTF16Converter.cpp12
-rw-r--r--src/lib/platform/MSWindowsClipboardUTF16Converter.h4
-rw-r--r--src/lib/platform/MSWindowsDesks.cpp12
-rw-r--r--src/lib/platform/MSWindowsDesks.h12
-rw-r--r--src/lib/platform/MSWindowsEventQueueBuffer.cpp16
-rw-r--r--src/lib/platform/MSWindowsEventQueueBuffer.h1
-rw-r--r--src/lib/platform/MSWindowsKeyState.h1
-rw-r--r--src/lib/platform/MSWindowsScreen.cpp13
-rw-r--r--src/lib/platform/MSWindowsScreen.h9
-rw-r--r--src/lib/platform/MSWindowsScreenSaver.h1
-rw-r--r--src/lib/platform/MSWindowsSession.cpp5
-rw-r--r--src/lib/platform/MSWindowsSession.h4
-rw-r--r--src/lib/platform/MSWindowsUtil.cpp17
-rw-r--r--src/lib/platform/MSWindowsUtil.h6
-rw-r--r--src/lib/platform/MSWindowsWatchdog.cpp7
-rw-r--r--src/lib/platform/MSWindowsWatchdog.h8
-rw-r--r--src/lib/platform/OSXClipboard.cpp12
-rw-r--r--src/lib/platform/OSXClipboard.h12
-rw-r--r--src/lib/platform/OSXClipboardAnyBitmapConverter.cpp6
-rw-r--r--src/lib/platform/OSXClipboardAnyBitmapConverter.h8
-rw-r--r--src/lib/platform/OSXClipboardAnyTextConverter.cpp16
-rw-r--r--src/lib/platform/OSXClipboardAnyTextConverter.h15
-rw-r--r--src/lib/platform/OSXClipboardBMPConverter.cpp12
-rw-r--r--src/lib/platform/OSXClipboardBMPConverter.h9
-rw-r--r--src/lib/platform/OSXClipboardHTMLConverter.cpp20
-rw-r--r--src/lib/platform/OSXClipboardHTMLConverter.h9
-rw-r--r--src/lib/platform/OSXClipboardTextConverter.cpp20
-rw-r--r--src/lib/platform/OSXClipboardTextConverter.h9
-rw-r--r--src/lib/platform/OSXClipboardUTF16Converter.cpp6
-rw-r--r--src/lib/platform/OSXClipboardUTF16Converter.h4
-rw-r--r--src/lib/platform/OSXDragView.m4
-rw-r--r--src/lib/platform/OSXKeyState.cpp12
-rw-r--r--src/lib/platform/OSXScreen.h6
-rw-r--r--src/lib/platform/XWindowsClipboard.cpp50
-rw-r--r--src/lib/platform/XWindowsClipboard.h30
-rw-r--r--src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp16
-rw-r--r--src/lib/platform/XWindowsClipboardAnyBitmapConverter.h14
-rw-r--r--src/lib/platform/XWindowsClipboardBMPConverter.cpp12
-rw-r--r--src/lib/platform/XWindowsClipboardBMPConverter.h4
-rw-r--r--src/lib/platform/XWindowsClipboardHTMLConverter.cpp6
-rw-r--r--src/lib/platform/XWindowsClipboardHTMLConverter.h4
-rw-r--r--src/lib/platform/XWindowsClipboardTextConverter.cpp8
-rw-r--r--src/lib/platform/XWindowsClipboardTextConverter.h4
-rw-r--r--src/lib/platform/XWindowsClipboardUCS2Converter.cpp6
-rw-r--r--src/lib/platform/XWindowsClipboardUCS2Converter.h4
-rw-r--r--src/lib/platform/XWindowsClipboardUTF8Converter.cpp6
-rw-r--r--src/lib/platform/XWindowsClipboardUTF8Converter.h4
-rw-r--r--src/lib/platform/XWindowsEventQueueBuffer.cpp15
-rw-r--r--src/lib/platform/XWindowsEventQueueBuffer.h2
-rw-r--r--src/lib/platform/XWindowsKeyState.cpp1
-rw-r--r--src/lib/platform/XWindowsKeyState.h2
-rw-r--r--src/lib/platform/XWindowsScreen.cpp1
-rw-r--r--src/lib/platform/XWindowsUtil.cpp24
-rw-r--r--src/lib/platform/XWindowsUtil.h24
-rw-r--r--src/lib/server/BaseClientProxy.cpp5
-rw-r--r--src/lib/server/BaseClientProxy.h7
-rw-r--r--src/lib/server/ClientProxy.cpp2
-rw-r--r--src/lib/server/ClientProxy.h3
-rw-r--r--src/lib/server/ClientProxy1_0.cpp3
-rw-r--r--src/lib/server/ClientProxy1_0.h2
-rw-r--r--src/lib/server/ClientProxy1_1.cpp3
-rw-r--r--src/lib/server/ClientProxy1_1.h2
-rw-r--r--src/lib/server/ClientProxy1_2.cpp3
-rw-r--r--src/lib/server/ClientProxy1_2.h2
-rw-r--r--src/lib/server/ClientProxy1_3.cpp3
-rw-r--r--src/lib/server/ClientProxy1_3.h2
-rw-r--r--src/lib/server/ClientProxy1_4.cpp3
-rw-r--r--src/lib/server/ClientProxy1_4.h3
-rw-r--r--src/lib/server/ClientProxy1_5.cpp9
-rw-r--r--src/lib/server/ClientProxy1_5.h3
-rw-r--r--src/lib/server/ClientProxy1_6.cpp7
-rw-r--r--src/lib/server/ClientProxy1_6.h3
-rw-r--r--src/lib/server/ClientProxyUnknown.cpp3
-rw-r--r--src/lib/server/Config.cpp349
-rw-r--r--src/lib/server/Config.h167
-rw-r--r--src/lib/server/InputFilter.cpp93
-rw-r--r--src/lib/server/InputFilter.h57
-rw-r--r--src/lib/server/PrimaryClient.cpp2
-rw-r--r--src/lib/server/PrimaryClient.h2
-rw-r--r--src/lib/server/Server.cpp56
-rw-r--r--src/lib/server/Server.h29
155 files changed, 1086 insertions, 1250 deletions
diff --git a/src/lib/arch/Arch.h b/src/lib/arch/Arch.h
index c062d6f..940a2e3 100644
--- a/src/lib/arch/Arch.h
+++ b/src/lib/arch/Arch.h
@@ -54,9 +54,7 @@
# include "arch/unix/ArchConsoleUnix.h"
# include "arch/unix/ArchDaemonUnix.h"
# include "arch/unix/ArchLogUnix.h"
-# if HAVE_PTHREAD
-# include "arch/unix/ArchMultithreadPosix.h"
-# endif
+# include "arch/unix/ArchMultithreadPosix.h"
# include "arch/unix/ArchNetworkBSD.h"
# include "arch/unix/ArchSleepUnix.h"
# include "arch/unix/ArchStringUnix.h"
diff --git a/src/lib/arch/ArchDaemonNone.h b/src/lib/arch/ArchDaemonNone.h
index fd59758..e02405f 100644
--- a/src/lib/arch/ArchDaemonNone.h
+++ b/src/lib/arch/ArchDaemonNone.h
@@ -19,6 +19,7 @@
#pragma once
#include "arch/IArchDaemon.h"
+#include <string>
#define ARCH_DAEMON ArchDaemonNone
@@ -46,5 +47,5 @@ public:
virtual bool isDaemonInstalled(const char* name);
virtual void installDaemon();
virtual void uninstallDaemon();
- virtual std::string commandLine() const;
+ virtual std::string commandLine() const;
};
diff --git a/src/lib/arch/IArchDaemon.h b/src/lib/arch/IArchDaemon.h
index a4983d3..23a34f2 100644
--- a/src/lib/arch/IArchDaemon.h
+++ b/src/lib/arch/IArchDaemon.h
@@ -19,7 +19,7 @@
#pragma once
#include "common/IInterface.h"
-#include "base/String.h"
+#include <string>
//! Interface for architecture dependent daemonizing
/*!
@@ -122,7 +122,7 @@ public:
/*!
Gets the command line with which the application was started.
*/
- virtual std::string commandLine() const = 0;
+ virtual std::string commandLine() const = 0;
//@}
};
diff --git a/src/lib/arch/IArchTaskBarReceiver.h b/src/lib/arch/IArchTaskBarReceiver.h
index 8a925b4..997c8ae 100644
--- a/src/lib/arch/IArchTaskBarReceiver.h
+++ b/src/lib/arch/IArchTaskBarReceiver.h
@@ -18,8 +18,8 @@
#pragma once
-#include "base/String.h"
#include "common/IInterface.h"
+#include <string>
class IScreen;
class INode;
@@ -88,9 +88,9 @@ public:
to set the tooltip is left to sublclasses. Getting and setting
the icon must be thread safe.
*/
- virtual std::string getToolTip() const = 0;
+ virtual std::string getToolTip() const = 0;
- virtual void updateStatus(INode*, const String& errorMsg) = 0;
+ virtual void updateStatus(INode*, const std::string& errorMsg) = 0;
virtual void cleanup() {}
diff --git a/src/lib/arch/XArch.h b/src/lib/arch/XArch.h
index 457c620..8484d06 100644
--- a/src/lib/arch/XArch.h
+++ b/src/lib/arch/XArch.h
@@ -20,7 +20,7 @@
#include "common/common.h"
#include "common/stdstring.h"
-#include "common/stdexcept.h"
+#include <stdexcept>
//! Generic thread exception
/*!
@@ -56,7 +56,7 @@ string for that error code.
class XArchEval {
public:
XArchEval() { }
- virtual ~XArchEval() _NOEXCEPT { }
+ virtual ~XArchEval() noexcept { }
virtual std::string eval() const = 0;
};
@@ -66,7 +66,7 @@ class XArch : public std::runtime_error {
public:
XArch(XArchEval* adopted) : std::runtime_error(adopted->eval()) { delete adopted; }
XArch(const std::string& msg) : std::runtime_error(msg) { }
- virtual ~XArch() _NOEXCEPT { }
+ virtual ~XArch() noexcept { }
};
// Macro to declare XArch derived types
diff --git a/src/lib/arch/unix/ArchInternetUnix.cpp b/src/lib/arch/unix/ArchInternetUnix.cpp
index fd1e135..76966dc 100644
--- a/src/lib/arch/unix/ArchInternetUnix.cpp
+++ b/src/lib/arch/unix/ArchInternetUnix.cpp
@@ -28,8 +28,8 @@ class CurlFacade {
public:
CurlFacade();
~CurlFacade();
- String get(const String& url);
- String urlEncode(const String& url);
+ std::string get(const std::string& url);
+ std::string urlEncode(const std::string& url);
private:
CURL* m_curl;
@@ -39,15 +39,13 @@ private:
// ArchInternetUnix
//
-String
-ArchInternetUnix::get(const String& url)
+std::string ArchInternetUnix::get(const std::string& url)
{
CurlFacade curl;
return curl.get(url);
}
-String
-ArchInternetUnix::urlEncode(const String& url)
+std::string ArchInternetUnix::urlEncode(const std::string& url)
{
CurlFacade curl;
return curl.urlEncode(url);
@@ -87,8 +85,7 @@ CurlFacade::~CurlFacade()
curl_global_cleanup();
}
-String
-CurlFacade::get(const String& url)
+std::string CurlFacade::get(const std::string& url)
{
curl_easy_setopt(m_curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, curlWriteCallback);
@@ -110,8 +107,7 @@ CurlFacade::get(const String& url)
return result;
}
-String
-CurlFacade::urlEncode(const String& url)
+std::string CurlFacade::urlEncode(const std::string& url)
{
char* resultCStr = curl_easy_escape(m_curl, url.c_str(), 0);
diff --git a/src/lib/arch/unix/ArchInternetUnix.h b/src/lib/arch/unix/ArchInternetUnix.h
index 2413d8f..66de656 100644
--- a/src/lib/arch/unix/ArchInternetUnix.h
+++ b/src/lib/arch/unix/ArchInternetUnix.h
@@ -19,10 +19,10 @@
#define ARCH_INTERNET ArchInternetUnix
-#include "base/String.h"
+#include <string>
class ArchInternetUnix {
public:
- String get(const String& url);
- String urlEncode(const String& url);
+ std::string get(const std::string& url);
+ std::string urlEncode(const std::string& url);
};
diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp
index c9ddc6c..4866edc 100644
--- a/src/lib/arch/unix/ArchMultithreadPosix.cpp
+++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp
@@ -36,17 +36,6 @@
#define SIGWAKEUP SIGUSR1
-#if !HAVE_PTHREAD_SIGNAL
- // boy, is this platform broken. forget about pthread signal
- // handling and let signals through to every process. barrier
- // will not terminate cleanly when it gets SIGTERM or SIGINT.
-# define pthread_sigmask sigprocmask
-# define pthread_kill(tid_, sig_) kill(0, (sig_))
-# define sigwait(set_, sig_)
-# undef HAVE_POSIX_SIGWAIT
-# define HAVE_POSIX_SIGWAIT 1
-#endif
-
static
void
setSignalSet(sigset_t* sigset)
@@ -344,9 +333,7 @@ ArchMultithreadPosix::newThread(ThreadFunc func, void* data)
// can't tell the difference.
if (!m_newThreadCalled) {
m_newThreadCalled = true;
-#if HAVE_PTHREAD_SIGNAL
startSignalHandler();
-#endif
}
// note that the child thread will wait until we release this mutex
diff --git a/src/lib/arch/unix/ArchNetworkBSD.cpp b/src/lib/arch/unix/ArchNetworkBSD.cpp
index 2a9259c..496c988 100644
--- a/src/lib/arch/unix/ArchNetworkBSD.cpp
+++ b/src/lib/arch/unix/ArchNetworkBSD.cpp
@@ -690,7 +690,6 @@ ArchNetworkBSD::nameToAddr(const std::string& name)
// allocate address
ArchNetAddressImpl* addr = new ArchNetAddressImpl;
- char ipstr[INET6_ADDRSTRLEN];
struct addrinfo hints;
struct addrinfo *p;
int ret;
diff --git a/src/lib/arch/unix/XArchUnix.h b/src/lib/arch/unix/XArchUnix.h
index ae62f4c..93d6d62 100644
--- a/src/lib/arch/unix/XArchUnix.h
+++ b/src/lib/arch/unix/XArchUnix.h
@@ -24,7 +24,7 @@
class XArchEvalUnix : public XArchEval {
public:
XArchEvalUnix(int error) : m_error(error) { }
- virtual ~XArchEvalUnix() _NOEXCEPT { }
+ virtual ~XArchEvalUnix() noexcept { }
virtual std::string eval() const;
diff --git a/src/lib/arch/win32/ArchInternetWindows.cpp b/src/lib/arch/win32/ArchInternetWindows.cpp
index 7f69c7f..8a28fde 100644
--- a/src/lib/arch/win32/ArchInternetWindows.cpp
+++ b/src/lib/arch/win32/ArchInternetWindows.cpp
@@ -18,6 +18,7 @@
#include "arch/win32/ArchInternetWindows.h"
#include "arch/win32/XArchWindows.h"
#include "arch/Arch.h"
+#include "base/String.h"
#include "common/Version.h"
#include <sstream>
@@ -25,19 +26,19 @@
#include <Shlwapi.h>
struct WinINetUrl {
- String m_scheme;
- String m_host;
- String m_path;
+ std::string m_scheme;
+ std::string m_host;
+ std::string m_path;
INTERNET_PORT m_port;
DWORD m_flags;
};
class WinINetRequest {
public:
- WinINetRequest(const String& url);
+ WinINetRequest(const std::string& url);
~WinINetRequest();
- String send();
+ std::string send();
void openSession();
void connect();
void openRequest();
@@ -54,15 +55,13 @@ private:
// ArchInternetWindows
//
-String
-ArchInternetWindows::get(const String& url)
+std::string ArchInternetWindows::get(const std::string& url)
{
WinINetRequest request(url);
return request.send();
}
-String
-ArchInternetWindows::urlEncode(const String& url)
+std::string ArchInternetWindows::urlEncode(const std::string& url)
{
TCHAR buffer[1024];
DWORD bufferSize = sizeof(buffer);
@@ -71,7 +70,7 @@ ArchInternetWindows::urlEncode(const String& url)
throw XArch(new XArchEvalWindows());
}
- String result(buffer);
+ std::string result(buffer);
// the win32 url encoding funcitons are pretty useless (to us) and only
// escape "unsafe" chars, but not + or =, so we need to replace these
@@ -86,9 +85,9 @@ ArchInternetWindows::urlEncode(const String& url)
// WinINetRequest
//
-static WinINetUrl parseUrl(const String& url);
+static WinINetUrl parseUrl(const std::string& url);
-WinINetRequest::WinINetRequest(const String& url) :
+WinINetRequest::WinINetRequest(const std::string& url) :
m_session(NULL),
m_connect(NULL),
m_request(NULL),
@@ -112,8 +111,7 @@ WinINetRequest::~WinINetRequest()
}
}
-String
-WinINetRequest::send()
+std::string WinINetRequest::send()
{
if (m_used) {
throw XArch("class is one time use.");
@@ -124,7 +122,7 @@ WinINetRequest::send()
connect();
openRequest();
- String headers("Content-Type: text/html");
+ std::string headers("Content-Type: text/html");
if (!HttpSendRequest(m_request, headers.c_str(), (DWORD)headers.length(), NULL, NULL)) {
throw XArch(new XArchEvalWindows());
}
@@ -142,8 +140,7 @@ WinINetRequest::send()
return result.str();
}
-void
-WinINetRequest::openSession()
+void WinINetRequest::openSession()
{
std::stringstream userAgent;
userAgent << "Barrier ";
@@ -200,8 +197,7 @@ WinINetRequest::openRequest()
// nb: i tried to use InternetCrackUrl here, but couldn't quite get that to
// work. here's some (less robust) code to split the url into components.
// this works fine with simple urls, but doesn't consider the full url spec.
-static WinINetUrl
-parseUrl(const String& url)
+static WinINetUrl parseUrl(const std::string& url)
{
WinINetUrl parsed;
@@ -215,7 +211,7 @@ parseUrl(const String& url)
parsed.m_port = INTERNET_DEFAULT_HTTP_PORT;
parsed.m_flags = 0;
- if (parsed.m_scheme.find("https") != String::npos) {
+ if (parsed.m_scheme.find("https") != std::string::npos) {
parsed.m_port = INTERNET_DEFAULT_HTTPS_PORT;
parsed.m_flags = INTERNET_FLAG_SECURE;
}
diff --git a/src/lib/arch/win32/ArchInternetWindows.h b/src/lib/arch/win32/ArchInternetWindows.h
index bab8d3c..3ef5747 100644
--- a/src/lib/arch/win32/ArchInternetWindows.h
+++ b/src/lib/arch/win32/ArchInternetWindows.h
@@ -19,10 +19,10 @@
#define ARCH_INTERNET ArchInternetWindows
-#include "base/String.h"
+#include <string>
class ArchInternetWindows {
public:
- String get(const String& url);
- String urlEncode(const String& url);
+ std::string get(const std::string& url);
+ std::string urlEncode(const std::string& url);
};
diff --git a/src/lib/arch/win32/ArchMiscWindows.cpp b/src/lib/arch/win32/ArchMiscWindows.cpp
index 924afa2..2c022b1 100644
--- a/src/lib/arch/win32/ArchMiscWindows.cpp
+++ b/src/lib/arch/win32/ArchMiscWindows.cpp
@@ -431,7 +431,7 @@ ArchMiscWindows::wakeupDisplay()
bool
ArchMiscWindows::wasLaunchedAsService()
{
- String name;
+ std::string name;
if (!getParentProcessName(name)) {
LOG((CLOG_ERR "cannot determine if process was launched as service"));
return false;
@@ -440,8 +440,7 @@ ArchMiscWindows::wasLaunchedAsService()
return (name == SERVICE_LAUNCHER);
}
-bool
-ArchMiscWindows::getParentProcessName(String &name)
+bool ArchMiscWindows::getParentProcessName(std::string &name)
{
PROCESSENTRY32 parentEntry;
if (!getParentProcessEntry(parentEntry)){
@@ -521,4 +520,4 @@ ArchMiscWindows::setInstanceWin32(HINSTANCE instance)
{
assert(instance != NULL);
s_instanceWin32 = instance;
-} \ No newline at end of file
+}
diff --git a/src/lib/arch/win32/ArchMiscWindows.h b/src/lib/arch/win32/ArchMiscWindows.h
index 0ecd79d..91cd8f5 100644
--- a/src/lib/arch/win32/ArchMiscWindows.h
+++ b/src/lib/arch/win32/ArchMiscWindows.h
@@ -21,7 +21,6 @@
#include "common/common.h"
#include "common/stdstring.h"
#include "common/stdset.h"
-#include "base/String.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
@@ -163,7 +162,7 @@ public:
static bool wasLaunchedAsService();
//! Returns true if we got the parent process name.
- static bool getParentProcessName(String &name);
+ static bool getParentProcessName(std::string &name);
static HINSTANCE instanceWin32();
diff --git a/src/lib/arch/win32/XArchWindows.cpp b/src/lib/arch/win32/XArchWindows.cpp
index eeec0e1..e116eda 100644
--- a/src/lib/arch/win32/XArchWindows.cpp
+++ b/src/lib/arch/win32/XArchWindows.cpp
@@ -25,7 +25,7 @@
//
std::string
-XArchEvalWindows::eval() const throw()
+XArchEvalWindows::eval() const noexcept
{
char* cmsg;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
@@ -51,7 +51,7 @@ XArchEvalWindows::eval() const throw()
//
std::string
-XArchEvalWinsock::eval() const throw()
+XArchEvalWinsock::eval() const noexcept
{
// built-in windows function for looking up error message strings
// may not look up network error messages correctly. we'll have
diff --git a/src/lib/arch/win32/XArchWindows.h b/src/lib/arch/win32/XArchWindows.h
index 10106b1..4fb2a23 100644
--- a/src/lib/arch/win32/XArchWindows.h
+++ b/src/lib/arch/win32/XArchWindows.h
@@ -30,7 +30,7 @@ public:
XArchEvalWindows(DWORD error) : m_error(error) { }
virtual ~XArchEvalWindows() { }
- virtual std::string eval() const;
+ virtual std::string eval() const noexcept;
private:
DWORD m_error;
@@ -42,7 +42,7 @@ public:
XArchEvalWinsock(int error) : m_error(error) { }
virtual ~XArchEvalWinsock() { }
- virtual std::string eval() const;
+ virtual std::string eval() const noexcept;
private:
int m_error;
diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp
index a91312d..b1a7661 100644
--- a/src/lib/barrier/ClientApp.cpp
+++ b/src/lib/barrier/ClientApp.cpp
@@ -282,7 +282,9 @@ ClientApp::scheduleClientRestart(double retryTime)
void
ClientApp::handleClientConnected(const Event&, void*)
{
- LOG((CLOG_NOTE "connected to server"));
+ // using CLOG_PRINT here allows the GUI to see that the client is connected
+ // regardless of which log level is set
+ LOG((CLOG_PRINT "connected to server"));
resetRestartTimeout();
updateStatus();
}
diff --git a/src/lib/barrier/PlatformScreen.h b/src/lib/barrier/PlatformScreen.h
index 82cbfaa..38bf8de 100644
--- a/src/lib/barrier/PlatformScreen.h
+++ b/src/lib/barrier/PlatformScreen.h
@@ -20,7 +20,7 @@
#include "barrier/IPlatformScreen.h"
#include "barrier/DragInformation.h"
-#include "common/stdexcept.h"
+#include <stdexcept>
//! Base screen implementation
/*!
diff --git a/src/lib/barrier/ProtocolUtil.cpp b/src/lib/barrier/ProtocolUtil.cpp
index 42fe69c..e742687 100644
--- a/src/lib/barrier/ProtocolUtil.cpp
+++ b/src/lib/barrier/ProtocolUtil.cpp
@@ -20,6 +20,7 @@
#include "io/IStream.h"
#include "base/Log.h"
#include "common/stdvector.h"
+#include "base/String.h"
#include <cctype>
#include <cstring>
@@ -538,7 +539,7 @@ ProtocolUtil::read(barrier::IStream* stream, void* vbuffer, UInt32 count)
//
String
-XIOReadMismatch::getWhat() const throw()
+XIOReadMismatch::getWhat() const noexcept
{
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
}
diff --git a/src/lib/barrier/ProtocolUtil.h b/src/lib/barrier/ProtocolUtil.h
index 78bb5ca..9930cfc 100644
--- a/src/lib/barrier/ProtocolUtil.h
+++ b/src/lib/barrier/ProtocolUtil.h
@@ -47,7 +47,7 @@ public:
- \%1I -- converts std::vector<UInt8>* to 1 byte integers
- \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO
- \%4I -- converts std::vector<UInt32>* to 4 byte integers in NBO
- - \%s -- converts String* to stream of bytes
+ - \%s -- converts std::string* to stream of bytes
- \%S -- converts integer N and const UInt8* to stream of N bytes
*/
static void writef(barrier::IStream*,
@@ -67,7 +67,7 @@ public:
- \%1I -- reads 1 byte integers; arg is std::vector<UInt8>*
- \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>*
- \%4I -- reads NBO 4 byte integers; arg is std::vector<UInt32>*
- - \%s -- reads bytes; argument must be a String*, \b not a char*
+ - \%s -- reads bytes; argument must be a std::string*, \b not a char*
*/
static bool readf(barrier::IStream*,
const char* fmt, ...);
@@ -92,5 +92,5 @@ match the format.
class XIOReadMismatch : public XIO {
public:
// XBase overrides
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
};
diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp
index 318673c..18cf935 100644
--- a/src/lib/barrier/ServerApp.cpp
+++ b/src/lib/barrier/ServerApp.cpp
@@ -555,15 +555,18 @@ ServerApp::startServer()
m_server->setListener(listener);
m_listener = listener;
updateStatus();
- LOG((CLOG_NOTE "started server (%s), waiting for clients", family));
+
+ // using CLOG_PRINT here allows the GUI to see that the server is started
+ // regardless of which log level is set
+ LOG((CLOG_PRINT "started server (%s), waiting for clients", family));
m_serverState = kStarted;
return true;
}
catch (XSocketAddressInUse& e) {
- LOG((CLOG_WARN "cannot listen for clients: %s", e.what()));
+ LOG((CLOG_ERR "cannot listen for clients: %s", e.what()));
closeClientListener(listener);
updateStatus(String("cannot listen for clients: ") + e.what());
- retryTime = 10.0;
+ retryTime = 1.0;
}
catch (XBase& e) {
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
@@ -684,9 +687,9 @@ ServerApp::handleNoClients(const Event&, void*)
void
ServerApp::handleScreenSwitched(const Event& e, void*)
{
- Server::SwitchToScreenInfo* info = (Server::SwitchToScreenInfo*)(e.getData());
-
#ifdef WINAPI_XWINDOWS
+ Server::SwitchToScreenInfo* info = (Server::SwitchToScreenInfo*)(e.getData());
+
if (!args().m_screenChangeScript.empty()) {
LOG((CLOG_INFO "Running shell script for screen \"%s\"", info->m_screen));
diff --git a/src/lib/barrier/StreamChunker.cpp b/src/lib/barrier/StreamChunker.cpp
index 8b8971c..579d02f 100644
--- a/src/lib/barrier/StreamChunker.cpp
+++ b/src/lib/barrier/StreamChunker.cpp
@@ -29,9 +29,9 @@
#include "base/Log.h"
#include "base/Stopwatch.h"
#include "base/String.h"
-#include "common/stdexcept.h"
#include <fstream>
+#include <stdexcept>
using namespace std;
diff --git a/src/lib/barrier/XBarrier.cpp b/src/lib/barrier/XBarrier.cpp
index 49a015e..7fe3577 100644
--- a/src/lib/barrier/XBarrier.cpp
+++ b/src/lib/barrier/XBarrier.cpp
@@ -23,8 +23,7 @@
// XBadClient
//
-String
-XBadClient::getWhat() const throw()
+String XBadClient::getWhat() const noexcept
{
return "XBadClient";
}
@@ -41,20 +40,17 @@ XIncompatibleClient::XIncompatibleClient(int major, int minor) :
// do nothing
}
-int
-XIncompatibleClient::getMajor() const throw()
+int XIncompatibleClient::getMajor() const noexcept
{
return m_major;
}
-int
-XIncompatibleClient::getMinor() const throw()
+int XIncompatibleClient::getMinor() const noexcept
{
return m_minor;
}
-String
-XIncompatibleClient::getWhat() const throw()
+String XIncompatibleClient::getWhat() const noexcept
{
return format("XIncompatibleClient", "incompatible client %{1}.%{2}",
barrier::string::sprintf("%d", m_major).c_str(),
@@ -72,14 +68,12 @@ XDuplicateClient::XDuplicateClient(const String& name) :
// do nothing
}
-const String&
-XDuplicateClient::getName() const throw()
+const String& XDuplicateClient::getName() const noexcept
{
return m_name;
}
-String
-XDuplicateClient::getWhat() const throw()
+String XDuplicateClient::getWhat() const noexcept
{
return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str());
}
@@ -95,14 +89,12 @@ XUnknownClient::XUnknownClient(const String& name) :
// do nothing
}
-const String&
-XUnknownClient::getName() const throw()
+const String& XUnknownClient::getName() const noexcept
{
return m_name;
}
-String
-XUnknownClient::getWhat() const throw()
+String XUnknownClient::getWhat() const noexcept
{
return format("XUnknownClient", "unknown client %{1}", m_name.c_str());
}
@@ -118,14 +110,12 @@ XExitApp::XExitApp(int code) :
// do nothing
}
-int
-XExitApp::getCode() const throw()
+int XExitApp::getCode() const noexcept
{
return m_code;
}
-String
-XExitApp::getWhat() const throw()
+String XExitApp::getWhat() const noexcept
{
return format(
"XExitApp", "exiting with code %{1}",
diff --git a/src/lib/barrier/XBarrier.h b/src/lib/barrier/XBarrier.h
index fdf5213..fef931e 100644
--- a/src/lib/barrier/XBarrier.h
+++ b/src/lib/barrier/XBarrier.h
@@ -47,14 +47,14 @@ public:
//@{
//! Get client's major version number
- int getMajor() const throw();
+ int getMajor() const noexcept;
//! Get client's minor version number
- int getMinor() const throw();
+ int getMinor() const noexcept;
//@}
protected:
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
int m_major;
@@ -68,23 +68,22 @@ a client that is already connected.
*/
class XDuplicateClient : public XBarrier {
public:
- XDuplicateClient(const String& name);
- virtual ~XDuplicateClient() _NOEXCEPT { }
+ XDuplicateClient(const std::string& name);
+ virtual ~XDuplicateClient() noexcept { }
//! @name accessors
//@{
//! Get client's name
- virtual const String&
- getName() const throw();
+ virtual const std::string& getName() const noexcept;
//@}
protected:
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
- String m_name;
+ std::string m_name;
};
//! Client not in map exception
@@ -94,23 +93,22 @@ unknown to the server.
*/
class XUnknownClient : public XBarrier {
public:
- XUnknownClient(const String& name);
- virtual ~XUnknownClient() _NOEXCEPT { }
+ XUnknownClient(const std::string& name);
+ virtual ~XUnknownClient() noexcept { }
//! @name accessors
//@{
//! Get the client's name
- virtual const String&
- getName() const throw();
+ virtual const std::string& getName() const noexcept;
//@}
protected:
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
- String m_name;
+ std::string m_name;
};
//! Generic exit eception
@@ -122,13 +120,13 @@ exit(int).
class XExitApp : public XBarrier {
public:
XExitApp(int code);
- virtual ~XExitApp() _NOEXCEPT { }
+ virtual ~XExitApp() noexcept { }
//! Get the exit code
- int getCode() const throw();
+ int getCode() const noexcept;
protected:
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
int m_code;
diff --git a/src/lib/barrier/XScreen.cpp b/src/lib/barrier/XScreen.cpp
index a202240..3398423 100644
--- a/src/lib/barrier/XScreen.cpp
+++ b/src/lib/barrier/XScreen.cpp
@@ -22,8 +22,7 @@
// XScreenOpenFailure
//
-String
-XScreenOpenFailure::getWhat() const throw()
+std::string XScreenOpenFailure::getWhat() const noexcept
{
return format("XScreenOpenFailure", "unable to open screen");
}
@@ -33,8 +32,7 @@ XScreenOpenFailure::getWhat() const throw()
// XScreenXInputFailure
//
-String
-XScreenXInputFailure::getWhat() const throw()
+std::string XScreenXInputFailure::getWhat() const noexcept
{
return "";
}
@@ -50,7 +48,7 @@ XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) :
// do nothing
}
-XScreenUnavailable::~XScreenUnavailable() _NOEXCEPT
+XScreenUnavailable::~XScreenUnavailable() noexcept
{
// do nothing
}
@@ -61,8 +59,7 @@ XScreenUnavailable::getRetryTime() const
return m_timeUntilRetry;
}
-String
-XScreenUnavailable::getWhat() const throw()
+std::string XScreenUnavailable::getWhat() const noexcept
{
return format("XScreenUnavailable", "unable to open screen");
}
diff --git a/src/lib/barrier/XScreen.h b/src/lib/barrier/XScreen.h
index 0cb511e..f8fe7a7 100644
--- a/src/lib/barrier/XScreen.h
+++ b/src/lib/barrier/XScreen.h
@@ -47,7 +47,7 @@ public:
trying to open the screen again.
*/
XScreenUnavailable(double timeUntilRetry);
- virtual ~XScreenUnavailable() _NOEXCEPT;
+ virtual ~XScreenUnavailable() noexcept;
//! @name manipulators
//@{
@@ -61,7 +61,7 @@ public:
//@}
protected:
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
double m_timeUntilRetry;
diff --git a/src/lib/barrier/win32/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp
index eafd893..482c465 100644
--- a/src/lib/barrier/win32/DaemonApp.cpp
+++ b/src/lib/barrier/win32/DaemonApp.cpp
@@ -353,7 +353,10 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
LOG((CLOG_DEBUG "ipc hello, type=%s", type.c_str()));
const char * serverstatus = m_watchdog->isProcessActive() ? "active" : "not active";
- LOG((CLOG_INFO "server status: %s", serverstatus));
+
+ // using CLOG_PRINT here allows the GUI to see that the server status
+ // regardless of which log level is set
+ LOG((CLOG_PRINT "server status: %s", serverstatus));
m_ipcLogOutputter->notifyBuffer();
break;
diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp
index fe8cff5..2429522 100644
--- a/src/lib/base/EventQueue.cpp
+++ b/src/lib/base/EventQueue.cpp
@@ -436,12 +436,6 @@ EventQueue::removeHandlers(void* target)
}
}
-bool
-EventQueue::isEmpty() const
-{
- return (m_buffer->isEmpty() && getNextTimerTimeout() != 0.0);
-}
-
IEventJob*
EventQueue::getHandler(Event::Type type, void* target) const
{
@@ -553,8 +547,7 @@ EventQueue::getNextTimerTimeout() const
return m_timerQueue.top();
}
-Event::Type
-EventQueue::getRegisteredType(const String& name) const
+Event::Type EventQueue::getRegisteredType(const std::string& name) const
{
NameMap::const_iterator found = m_nameMap.find(name);
if (found != m_nameMap.end())
diff --git a/src/lib/base/EventQueue.h b/src/lib/base/EventQueue.h
index 0a2179b..842c5ca 100644
--- a/src/lib/base/EventQueue.h
+++ b/src/lib/base/EventQueue.h
@@ -58,11 +58,9 @@ public:
virtual void removeHandlers(void* target);
virtual Event::Type
registerTypeOnce(Event::Type& type, const char* name);
- virtual bool isEmpty() const;
virtual IEventJob* getHandler(Event::Type type, void* target) const;
virtual const char* getTypeName(Event::Type type);
- virtual Event::Type
- getRegisteredType(const String& name) const;
+ virtual Event::Type getRegisteredType(const std::string& name) const;
void* getSystemTarget();
virtual void waitForReady() const;
@@ -108,7 +106,7 @@ private:
typedef std::map<UInt32, Event> EventTable;
typedef std::vector<UInt32> EventIDList;
typedef std::map<Event::Type, const char*> TypeMap;
- typedef std::map<String, Event::Type> NameMap;
+ typedef std::map<std::string, Event::Type> NameMap;
typedef std::map<Event::Type, IEventJob*> TypeHandlerTable;
typedef std::map<void*, TypeHandlerTable> HandlerTable;
diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp
index 9a3e46c..2ba2077 100644
--- a/src/lib/base/EventTypes.cpp
+++ b/src/lib/base/EventTypes.cpp
@@ -133,6 +133,7 @@ REGISTER_EVENT(Server, error)
REGISTER_EVENT(Server, connected)
REGISTER_EVENT(Server, disconnected)
REGISTER_EVENT(Server, switchToScreen)
+REGISTER_EVENT(Server, toggleScreen)
REGISTER_EVENT(Server, switchInDirection)
REGISTER_EVENT(Server, keyboardBroadcast)
REGISTER_EVENT(Server, lockCursorToScreen)
diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h
index d044c86..f81617e 100644
--- a/src/lib/base/EventTypes.h
+++ b/src/lib/base/EventTypes.h
@@ -432,6 +432,7 @@ public:
m_connected(Event::kUnknown),
m_disconnected(Event::kUnknown),
m_switchToScreen(Event::kUnknown),
+ m_toggleScreen(Event::kUnknown),
m_switchInDirection(Event::kUnknown),
m_keyboardBroadcast(Event::kUnknown),
m_lockCursorToScreen(Event::kUnknown),
@@ -470,6 +471,13 @@ public:
*/
Event::Type switchToScreen();
+ //! Get toggle screen event type
+ /*!
+ Returns the toggle screen event type. The server responds to this
+ by toggling screens. These is no event data.
+ */
+ Event::Type toggleScreen();
+
//! Get switch in direction event type
/*!
Returns the switch in direction event type. The server responds to this
@@ -508,6 +516,7 @@ private:
Event::Type m_connected;
Event::Type m_disconnected;
Event::Type m_switchToScreen;
+ Event::Type m_toggleScreen;
Event::Type m_switchInDirection;
Event::Type m_keyboardBroadcast;
Event::Type m_lockCursorToScreen;
diff --git a/src/lib/base/IEventQueue.h b/src/lib/base/IEventQueue.h
index cd4f0b3..150595c 100644
--- a/src/lib/base/IEventQueue.h
+++ b/src/lib/base/IEventQueue.h
@@ -20,7 +20,7 @@
#include "common/IInterface.h"
#include "base/Event.h"
-#include "base/String.h"
+#include <string>
class IEventJob;
class IEventQueueBuffer;
@@ -189,13 +189,6 @@ public:
//! @name accessors
//@{
- //! Test if queue is empty
- /*!
- Returns true iff the queue has no events in it, including timer
- events.
- */
- virtual bool isEmpty() const = 0;
-
//! Get an event handler
/*!
Finds and returns the event handler for the \p type, \p target pair
@@ -214,7 +207,7 @@ public:
/*!
Returns the registered type for an event for a given name.
*/
- virtual Event::Type getRegisteredType(const String& name) const = 0;
+ virtual Event::Type getRegisteredType(const std::string& name) const = 0;
//! Get the system event type target
/*!
diff --git a/src/lib/base/Log.cpp b/src/lib/base/Log.cpp
index 1252ed9..a3b328d 100644
--- a/src/lib/base/Log.cpp
+++ b/src/lib/base/Log.cpp
@@ -19,7 +19,6 @@
#include "arch/Arch.h"
#include "arch/XArch.h"
#include "base/Log.h"
-#include "base/String.h"
#include "base/log_outputters.h"
#include "common/Version.h"
diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp
index 97b8997..1ab3623 100644
--- a/src/lib/base/String.cpp
+++ b/src/lib/base/String.cpp
@@ -35,17 +35,17 @@
namespace barrier {
namespace string {
-String
+std::string
format(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
- String result = vformat(fmt, args);
+ std::string result = vformat(fmt, args);
va_end(args);
return result;
}
-String
+std::string
vformat(const char* fmt, va_list args)
{
// find highest indexed substitution and the locations of substitutions
@@ -111,7 +111,7 @@ vformat(const char* fmt, va_list args)
}
// substitute
- String result;
+ std::string result;
result.reserve(resultLength);
size_t src = 0;
for (int i = 0; i < n; ++i) {
@@ -124,13 +124,13 @@ vformat(const char* fmt, va_list args)
return result;
}
-String
+std::string
sprintf(const char* fmt, ...)
{
char tmp[1024];
char* buffer = tmp;
int len = (int)(sizeof(tmp) / sizeof(tmp[0]));
- String result;
+ std::string result;
while (buffer != NULL) {
// try printing into the buffer
va_list args;
@@ -162,23 +162,23 @@ sprintf(const char* fmt, ...)
void
findReplaceAll(
- String& subject,
- const String& find,
- const String& replace)
+ std::string& subject,
+ const std::string& find,
+ const std::string& replace)
{
size_t pos = 0;
- while ((pos = subject.find(find, pos)) != String::npos) {
+ while ((pos = subject.find(find, pos)) != std::string::npos) {
subject.replace(pos, find.length(), replace);
pos += replace.length();
}
}
-String
-removeFileExt(String filename)
+std::string
+removeFileExt(std::string filename)
{
size_t dot = filename.find_last_of('.');
- if (dot == String::npos) {
+ if (dot == std::string::npos) {
return filename;
}
@@ -186,7 +186,7 @@ removeFileExt(String filename)
}
void
-toHex(String& subject, int width, const char fill)
+toHex(std::string& subject, int width, const char fill)
{
std::stringstream ss;
ss << std::hex;
@@ -198,18 +198,18 @@ toHex(String& subject, int width, const char fill)
}
void
-uppercase(String& subject)
+uppercase(std::string& subject)
{
std::transform(subject.begin(), subject.end(), subject.begin(), ::toupper);
}
void
-removeChar(String& subject, const char c)
+removeChar(std::string& subject, const char c)
{
subject.erase(std::remove(subject.begin(), subject.end(), c), subject.end());
}
-String
+std::string
sizeTypeToString(size_t n)
{
std::stringstream ss;
@@ -218,7 +218,7 @@ sizeTypeToString(size_t n)
}
size_t
-stringToSizeType(String string)
+stringToSizeType(std::string string)
{
std::istringstream iss(string);
size_t value;
@@ -226,14 +226,14 @@ stringToSizeType(String string)
return value;
}
-std::vector<String>
-splitString(String string, const char c)
+std::vector<std::string>
+splitString(std::string string, const char c)
{
- std::vector<String> results;
+ std::vector<std::string> results;
size_t head = 0;
size_t separator = string.find(c);
- while (separator != String::npos) {
+ while (separator != std::string::npos) {
if (head!=separator) {
results.push_back(string.substr(head, separator - head));
}
@@ -252,26 +252,22 @@ splitString(String string, const char c)
// CaselessCmp
//
-bool
-CaselessCmp::cmpEqual(
- const String::value_type& a,
- const String::value_type& b)
+bool CaselessCmp::cmpEqual(const std::string::value_type& a,
+ const std::string::value_type& b)
{
// should use std::tolower but not in all versions of libstdc++ have it
return tolower(a) == tolower(b);
}
-bool
-CaselessCmp::cmpLess(
- const String::value_type& a,
- const String::value_type& b)
+bool CaselessCmp::cmpLess(const std::string::value_type& a,
+ const std::string::value_type& b)
{
// should use std::tolower but not in all versions of libstdc++ have it
return tolower(a) < tolower(b);
}
bool
-CaselessCmp::less(const String& a, const String& b)
+CaselessCmp::less(const std::string& a, const std::string& b)
{
return std::lexicographical_compare(
a.begin(), a.end(),
@@ -280,13 +276,13 @@ CaselessCmp::less(const String& a, const String& b)
}
bool
-CaselessCmp::equal(const String& a, const String& b)
+CaselessCmp::equal(const std::string& a, const std::string& b)
{
return !(less(a, b) || less(b, a));
}
bool
-CaselessCmp::operator()(const String& a, const String& b) const
+CaselessCmp::operator()(const std::string& a, const std::string& b) const
{
return less(a, b);
}
diff --git a/src/lib/base/String.h b/src/lib/base/String.h
index 3661461..73526b4 100644
--- a/src/lib/base/String.h
+++ b/src/lib/base/String.h
@@ -29,7 +29,7 @@ typedef std::string String;
namespace barrier {
-//! String utilities
+//! std::string utilities
/*!
Provides functions for string manipulation.
*/
@@ -45,67 +45,67 @@ characters and conversion specifications introduced by `\%':
All arguments in the variable list are const char*. Positional
elements are indexed from 1.
*/
-String format(const char* fmt, ...);
+std::string format(const char* fmt, ...);
//! Format positional arguments
/*!
Same as format() except takes va_list.
*/
-String vformat(const char* fmt, va_list);
+std::string vformat(const char* fmt, va_list);
//! Print a string using sprintf-style formatting
/*!
-Equivalent to sprintf() except the result is returned as a String.
+Equivalent to sprintf() except the result is returned as a std::string.
*/
-String sprintf(const char* fmt, ...);
+std::string sprintf(const char* fmt, ...);
//! Find and replace all
/*!
Finds \c find inside \c subject and replaces it with \c replace
*/
-void findReplaceAll(String& subject, const String& find, const String& replace);
+void findReplaceAll(std::string& subject, const std::string& find, const std::string& replace);
//! Remove file extension
/*!
Finds the last dot and remove all characters from the dot to the end
*/
-String removeFileExt(String filename);
+std::string removeFileExt(std::string filename);
//! Convert into hexdecimal
/*!
Convert each character in \c subject into hexdecimal form with \c width
*/
-void toHex(String& subject, int width, const char fill = '0');
+void toHex(std::string& subject, int width, const char fill = '0');
//! Convert to all uppercase
/*!
Convert each character in \c subject to uppercase
*/
-void uppercase(String& subject);
+void uppercase(std::string& subject);
//! Remove all specific char in suject
/*!
Remove all specific \c c in \c suject
*/
-void removeChar(String& subject, const char c);
+void removeChar(std::string& subject, const char c);
//! Convert a size type to a string
/*!
Convert an size type to a string
*/
-String sizeTypeToString(size_t n);
+std::string sizeTypeToString(size_t n);
//! Convert a string to a size type
/*!
Convert an a \c string to an size type
*/
-size_t stringToSizeType(String string);
+size_t stringToSizeType(std::string string);
//! Split a string into substrings
/*!
Split a \c string that separated by a \c c into substrings
*/
-std::vector<String> splitString(String string, const char c);
+std::vector<std::string> splitString(std::string string, const char c);
//! Case-insensitive comparisons
/*!
@@ -114,21 +114,21 @@ This class provides case-insensitve comparison functions.
class CaselessCmp {
public:
//! Same as less()
- bool operator()(const String& a, const String& b) const;
+ bool operator()(const std::string& a, const std::string& b) const;
//! Returns true iff \c a is lexicographically less than \c b
- static bool less(const String& a, const String& b);
+ static bool less(const std::string& a, const std::string& b);
//! Returns true iff \c a is lexicographically equal to \c b
- static bool equal(const String& a, const String& b);
+ static bool equal(const std::string& a, const std::string& b);
//! Returns true iff \c a is lexicographically less than \c b
- static bool cmpLess(const String::value_type& a,
- const String::value_type& b);
+ static bool cmpLess(const std::string::value_type& a,
+ const std::string::value_type& b);
//! Returns true iff \c a is lexicographically equal to \c b
- static bool cmpEqual(const String::value_type& a,
- const String::value_type& b);
+ static bool cmpEqual(const std::string::value_type& a,
+ const std::string::value_type& b);
};
}
diff --git a/src/lib/base/Unicode.cpp b/src/lib/base/Unicode.cpp
index 90a166f..05b0212 100644
--- a/src/lib/base/Unicode.cpp
+++ b/src/lib/base/Unicode.cpp
@@ -98,7 +98,7 @@ UInt32 Unicode::s_invalid = 0x0000ffff;
UInt32 Unicode::s_replacement = 0x0000fffd;
bool
-Unicode::isUTF8(const String& src)
+Unicode::isUTF8(const std::string& src)
{
// convert and test each character
const UInt8* data = reinterpret_cast<const UInt8*>(src.c_str());
@@ -110,15 +110,14 @@ Unicode::isUTF8(const String& src)
return true;
}
-String
-Unicode::UTF8ToUCS2(const String& src, bool* errors)
+std::string Unicode::UTF8ToUCS2(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
- String dst;
+ std::string dst;
dst.reserve(2 * n);
// convert each character
@@ -139,15 +138,15 @@ Unicode::UTF8ToUCS2(const String& src, bool* errors)
return dst;
}
-String
-Unicode::UTF8ToUCS4(const String& src, bool* errors)
+std::string
+Unicode::UTF8ToUCS4(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
- String dst;
+ std::string dst;
dst.reserve(4 * n);
// convert each character
@@ -163,15 +162,15 @@ Unicode::UTF8ToUCS4(const String& src, bool* errors)
return dst;
}
-String
-Unicode::UTF8ToUTF16(const String& src, bool* errors)
+std::string
+Unicode::UTF8ToUTF16(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
- String dst;
+ std::string dst;
dst.reserve(2 * n);
// convert each character
@@ -201,15 +200,15 @@ Unicode::UTF8ToUTF16(const String& src, bool* errors)
return dst;
}
-String
-Unicode::UTF8ToUTF32(const String& src, bool* errors)
+std::string
+Unicode::UTF8ToUTF32(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
- String dst;
+ std::string dst;
dst.reserve(4 * n);
// convert each character
@@ -229,8 +228,8 @@ Unicode::UTF8ToUTF32(const String& src, bool* errors)
return dst;
}
-String
-Unicode::UTF8ToText(const String& src, bool* errors)
+std::string
+Unicode::UTF8ToText(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
@@ -243,7 +242,7 @@ Unicode::UTF8ToText(const String& src, bool* errors)
int len = ARCH->convStringWCToMB(NULL, tmp, size, errors);
char* mbs = new char[len + 1];
ARCH->convStringWCToMB(mbs, tmp, size, errors);
- String text(mbs, len);
+ std::string text(mbs, len);
// clean up
delete[] mbs;
@@ -252,8 +251,8 @@ Unicode::UTF8ToText(const String& src, bool* errors)
return text;
}
-String
-Unicode::UCS2ToUTF8(const String& src, bool* errors)
+std::string
+Unicode::UCS2ToUTF8(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
@@ -263,8 +262,8 @@ Unicode::UCS2ToUTF8(const String& src, bool* errors)
return doUCS2ToUTF8(reinterpret_cast<const UInt8*>(src.data()), n, errors);
}
-String
-Unicode::UCS4ToUTF8(const String& src, bool* errors)
+std::string
+Unicode::UCS4ToUTF8(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
@@ -274,8 +273,8 @@ Unicode::UCS4ToUTF8(const String& src, bool* errors)
return doUCS4ToUTF8(reinterpret_cast<const UInt8*>(src.data()), n, errors);
}
-String
-Unicode::UTF16ToUTF8(const String& src, bool* errors)
+std::string
+Unicode::UTF16ToUTF8(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
@@ -285,8 +284,8 @@ Unicode::UTF16ToUTF8(const String& src, bool* errors)
return doUTF16ToUTF8(reinterpret_cast<const UInt8*>(src.data()), n, errors);
}
-String
-Unicode::UTF32ToUTF8(const String& src, bool* errors)
+std::string
+Unicode::UTF32ToUTF8(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
@@ -296,8 +295,8 @@ Unicode::UTF32ToUTF8(const String& src, bool* errors)
return doUTF32ToUTF8(reinterpret_cast<const UInt8*>(src.data()), n, errors);
}
-String
-Unicode::textToUTF8(const String& src, bool* errors)
+std::string
+Unicode::textToUTF8(const std::string& src, bool* errors)
{
// default to success
resetError(errors);
@@ -309,7 +308,7 @@ Unicode::textToUTF8(const String& src, bool* errors)
ARCH->convStringMBToWC(wcs, src.c_str(), n, errors);
// convert to UTF8
- String utf8 = wideCharToUTF8(wcs, len, errors);
+ std::string utf8 = wideCharToUTF8(wcs, len, errors);
// clean up
delete[] wcs;
@@ -318,10 +317,10 @@ Unicode::textToUTF8(const String& src, bool* errors)
}
wchar_t*
-Unicode::UTF8ToWideChar(const String& src, UInt32& size, bool* errors)
+Unicode::UTF8ToWideChar(const std::string& src, UInt32& size, bool* errors)
{
// convert to platform's wide character encoding
- String tmp;
+ std::string tmp;
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
tmp = UTF8ToUCS2(src, errors);
@@ -353,12 +352,12 @@ Unicode::UTF8ToWideChar(const String& src, UInt32& size, bool* errors)
return dst;
}
-String
+std::string
Unicode::wideCharToUTF8(const wchar_t* src, UInt32 size, bool* errors)
{
// convert from platform's wide character encoding.
// note -- this must include a wide nul character (independent of
- // the String's nul character).
+ // the std::string's nul character).
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
return doUCS2ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
@@ -374,15 +373,15 @@ Unicode::wideCharToUTF8(const wchar_t* src, UInt32 size, bool* errors)
default:
assert(0 && "unknown wide character encoding");
- return String();
+ return std::string();
}
}
-String
+std::string
Unicode::doUCS2ToUTF8(const UInt8* data, UInt32 n, bool* errors)
{
// make some space
- String dst;
+ std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@@ -414,11 +413,11 @@ Unicode::doUCS2ToUTF8(const UInt8* data, UInt32 n, bool* errors)
return dst;
}
-String
+std::string
Unicode::doUCS4ToUTF8(const UInt8* data, UInt32 n, bool* errors)
{
// make some space
- String dst;
+ std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@@ -450,11 +449,11 @@ Unicode::doUCS4ToUTF8(const UInt8* data, UInt32 n, bool* errors)
return dst;
}
-String
+std::string
Unicode::doUTF16ToUTF8(const UInt8* data, UInt32 n, bool* errors)
{
// make some space
- String dst;
+ std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@@ -512,11 +511,11 @@ Unicode::doUTF16ToUTF8(const UInt8* data, UInt32 n, bool* errors)
return dst;
}
-String
+std::string
Unicode::doUTF32ToUTF8(const UInt8* data, UInt32 n, bool* errors)
{
// make some space
- String dst;
+ std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@@ -728,7 +727,7 @@ Unicode::fromUTF8(const UInt8*& data, UInt32& n)
}
void
-Unicode::toUTF8(String& dst, UInt32 c, bool* errors)
+Unicode::toUTF8(std::string& dst, UInt32 c, bool* errors)
{
UInt8 data[6];
diff --git a/src/lib/base/Unicode.h b/src/lib/base/Unicode.h
index 1391c1e..9bf83ae 100644
--- a/src/lib/base/Unicode.h
+++ b/src/lib/base/Unicode.h
@@ -18,8 +18,8 @@
#pragma once
-#include "base/String.h"
#include "common/basic_types.h"
+#include <string>
//! Unicode utility functions
/*!
@@ -36,7 +36,7 @@ public:
Returns true iff the string contains a valid sequence of UTF-8
encoded characters.
*/
- static bool isUTF8(const String&);
+ static bool isUTF8(const std::string&);
//! Convert from UTF-8 to UCS-2 encoding
/*!
@@ -44,7 +44,7 @@ public:
is set to true iff any character could not be encoded in UCS-2.
Decoding errors do not set *errors.
*/
- static String UTF8ToUCS2(const String&, bool* errors = NULL);
+ static std::string UTF8ToUCS2(const std::string&, bool* errors = NULL);
//! Convert from UTF-8 to UCS-4 encoding
/*!
@@ -52,7 +52,7 @@ public:
is set to true iff any character could not be encoded in UCS-4.
Decoding errors do not set *errors.
*/
- static String UTF8ToUCS4(const String&, bool* errors = NULL);
+ static std::string UTF8ToUCS4(const std::string&, bool* errors = NULL);
//! Convert from UTF-8 to UTF-16 encoding
/*!
@@ -60,7 +60,7 @@ public:
is set to true iff any character could not be encoded in UTF-16.
Decoding errors do not set *errors.
*/
- static String UTF8ToUTF16(const String&, bool* errors = NULL);
+ static std::string UTF8ToUTF16(const std::string&, bool* errors = NULL);
//! Convert from UTF-8 to UTF-32 encoding
/*!
@@ -68,7 +68,7 @@ public:
is set to true iff any character could not be encoded in UTF-32.
Decoding errors do not set *errors.
*/
- static String UTF8ToUTF32(const String&, bool* errors = NULL);
+ static std::string UTF8ToUTF32(const std::string&, bool* errors = NULL);
//! Convert from UTF-8 to the current locale encoding
/*!
@@ -76,42 +76,42 @@ public:
NULL then *errors is set to true iff any character could not be encoded.
Decoding errors do not set *errors.
*/
- static String UTF8ToText(const String&, bool* errors = NULL);
+ static std::string UTF8ToText(const std::string&, bool* errors = NULL);
//! Convert from UCS-2 to UTF-8
/*!
Convert from UCS-2 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
- static String UCS2ToUTF8(const String&, bool* errors = NULL);
+ static std::string UCS2ToUTF8(const std::string&, bool* errors = NULL);
//! Convert from UCS-4 to UTF-8
/*!
Convert from UCS-4 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
- static String UCS4ToUTF8(const String&, bool* errors = NULL);
+ static std::string UCS4ToUTF8(const std::string&, bool* errors = NULL);
//! Convert from UTF-16 to UTF-8
/*!
Convert from UTF-16 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
- static String UTF16ToUTF8(const String&, bool* errors = NULL);
+ static std::string UTF16ToUTF8(const std::string&, bool* errors = NULL);
//! Convert from UTF-32 to UTF-8
/*!
Convert from UTF-32 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
- static String UTF32ToUTF8(const String&, bool* errors = NULL);
+ static std::string UTF32ToUTF8(const std::string&, bool* errors = NULL);
//! Convert from the current locale encoding to UTF-8
/*!
Convert from the current locale encoding to UTF-8. If errors is not
NULL then *errors is set to true iff any character could not be decoded.
*/
- static String textToUTF8(const String&, bool* errors = NULL);
+ static std::string textToUTF8(const std::string&, bool* errors = NULL);
//@}
@@ -120,23 +120,21 @@ private:
// to the platform). caller must delete[] the returned string. the
// string is *not* nul terminated; the length (in characters) is
// returned in size.
- static wchar_t* UTF8ToWideChar(const String&,
- UInt32& size, bool* errors);
+ static wchar_t* UTF8ToWideChar(const std::string&, UInt32& size, bool* errors);
// convert nul terminated wchar_t string (in platform's native
// encoding) to UTF8.
- static String wideCharToUTF8(const wchar_t*,
- UInt32 size, bool* errors);
+ static std::string wideCharToUTF8(const wchar_t*, UInt32 size, bool* errors);
// internal conversion to UTF8
- static String doUCS2ToUTF8(const UInt8* src, UInt32 n, bool* errors);
- static String doUCS4ToUTF8(const UInt8* src, UInt32 n, bool* errors);
- static String doUTF16ToUTF8(const UInt8* src, UInt32 n, bool* errors);
- static String doUTF32ToUTF8(const UInt8* src, UInt32 n, bool* errors);
+ static std::string doUCS2ToUTF8(const UInt8* src, UInt32 n, bool* errors);
+ static std::string doUCS4ToUTF8(const UInt8* src, UInt32 n, bool* errors);
+ static std::string doUTF16ToUTF8(const UInt8* src, UInt32 n, bool* errors);
+ static std::string doUTF32ToUTF8(const UInt8* src, UInt32 n, bool* errors);
// convert characters to/from UTF8
- static UInt32 fromUTF8(const UInt8*& src, UInt32& size);
- static void toUTF8(String& dst, UInt32 c, bool* errors);
+ static UInt32 fromUTF8(const UInt8*& src, UInt32& size);
+ static void toUTF8(std::string& dst, UInt32 c, bool* errors);
private:
static UInt32 s_invalid;
diff --git a/src/lib/base/XBase.cpp b/src/lib/base/XBase.cpp
index 29ae927..cb0db2e 100644
--- a/src/lib/base/XBase.cpp
+++ b/src/lib/base/XBase.cpp
@@ -32,19 +32,19 @@ XBase::XBase() :
// do nothing
}
-XBase::XBase(const String& msg) :
+XBase::XBase(const std::string& msg) :
std::runtime_error(msg)
{
// do nothing
}
-XBase::~XBase() _NOEXCEPT
+XBase::~XBase() noexcept
{
// do nothing
}
const char*
-XBase::what() const _NOEXCEPT
+XBase::what() const noexcept
{
const char* what = std::runtime_error::what();
if (strlen(what) == 0) {
@@ -54,14 +54,13 @@ XBase::what() const _NOEXCEPT
return what;
}
-String
-XBase::format(const char* /*id*/, const char* fmt, ...) const throw()
+std::string XBase::format(const char* /*id*/, const char* fmt, ...) const noexcept
{
// FIXME -- lookup message string using id as an index. set
// fmt to that string if it exists.
// format
- String result;
+ std::string result;
va_list args;
va_start(args, fmt);
try {
diff --git a/src/lib/base/XBase.h b/src/lib/base/XBase.h
index 3064b6c..59b700e 100644
--- a/src/lib/base/XBase.h
+++ b/src/lib/base/XBase.h
@@ -18,8 +18,8 @@
#pragma once
-#include "base/String.h"
-#include "common/stdexcept.h"
+#include <stdexcept>
+#include <string>
//! Exception base class
/*!
@@ -30,15 +30,15 @@ public:
//! Use getWhat() as the result of what()
XBase();
//! Use \c msg as the result of what()
- XBase(const String& msg);
- virtual ~XBase() _NOEXCEPT;
+ XBase(const std::string& msg);
+ virtual ~XBase() noexcept;
//! Reason for exception
- virtual const char* what() const _NOEXCEPT;
+ virtual const char* what() const noexcept;
protected:
//! Get a human readable string describing the exception
- virtual String getWhat() const throw() { return ""; }
+ virtual std::string getWhat() const noexcept { return ""; }
//! Format a string
/*!
@@ -46,47 +46,46 @@ protected:
no format can be found, then replaces positional parameters in
the format string and returns the result.
*/
- virtual String format(const char* id,
- const char* defaultFormat, ...) const throw();
+ virtual std::string format(const char* id, const char* defaultFormat, ...) const noexcept;
private:
- mutable String m_what;
+ mutable std::string m_what;
};
/*!
\def XBASE_SUBCLASS
Convenience macro to subclass from XBase (or a subclass of it),
-providing the c'tor taking a const String&. getWhat() is not
+providing the c'tor taking a const std::string&. getWhat() is not
declared.
*/
#define XBASE_SUBCLASS(name_, super_) \
class name_ : public super_ { \
public: \
name_() : super_() { } \
- name_(const String& msg) : super_(msg) { } \
- virtual ~name_() _NOEXCEPT { } \
+ name_(const std::string& msg) : super_(msg) { } \
+ virtual ~name_() noexcept { } \
}
/*!
\def XBASE_SUBCLASS
Convenience macro to subclass from XBase (or a subclass of it),
-providing the c'tor taking a const String&. getWhat() must be
+providing the c'tor taking a const std::string&. getWhat() must be
implemented.
*/
#define XBASE_SUBCLASS_WHAT(name_, super_) \
class name_ : public super_ { \
public: \
name_() : super_() { } \
- name_(const String& msg) : super_(msg) { } \
- virtual ~name_() _NOEXCEPT { } \
+ name_(const std::string& msg) : super_(msg) { } \
+ virtual ~name_() noexcept { } \
\
protected: \
- virtual String getWhat() const throw(); \
+ virtual std::string getWhat() const noexcept; \
}
/*!
\def XBASE_SUBCLASS_FORMAT
Convenience macro to subclass from XBase (or a subclass of it),
-providing the c'tor taking a const String&. what() is overridden
+providing the c'tor taking a const std::string&. what() is overridden
to call getWhat() when first called; getWhat() can format the
error message and can call what() to get the message passed to the
c'tor.
@@ -98,10 +97,10 @@ private: \
\
public: \
name_() : super_(), m_state(kDone) { } \
- name_(const String& msg) : super_(msg), m_state(kFirst) { } \
- virtual ~name_() _NOEXCEPT { } \
+ name_(const std::string& msg) : super_(msg), m_state(kFirst) { } \
+ virtual ~name_() noexcept { } \
\
- virtual const char* what() const _NOEXCEPT \
+ virtual const char* what() const noexcept \
{ \
if (m_state == kFirst) { \
m_state = kFormat; \
@@ -117,7 +116,7 @@ public: \
} \
\
protected: \
- virtual String getWhat() const throw(); \
+ virtual std::string getWhat() const noexcept; \
\
private: \
mutable EState m_state; \
diff --git a/src/lib/base/log_outputters.cpp b/src/lib/base/log_outputters.cpp
index 8e56c26..af53192 100644
--- a/src/lib/base/log_outputters.cpp
+++ b/src/lib/base/log_outputters.cpp
@@ -19,6 +19,7 @@
#include "base/log_outputters.h"
#include "base/TMethodJob.h"
#include "arch/Arch.h"
+#include "base/String.h"
#include <fstream>
@@ -228,7 +229,7 @@ BufferedLogOutputter::write(ELevel, const char* message)
while (m_buffer.size() >= m_maxBufferSize) {
m_buffer.pop_front();
}
- m_buffer.push_back(String(message));
+ m_buffer.push_back(std::string(message));
return true;
}
@@ -272,7 +273,7 @@ FileLogOutputter::write(ELevel level, const char *message)
m_handle.close();
if (moveFile) {
- String oldLogFilename = barrier::string::sprintf("%s.1", m_fileName.c_str());
+ std::string oldLogFilename = barrier::string::sprintf("%s.1", m_fileName.c_str());
remove(oldLogFilename.c_str());
rename(m_fileName.c_str(), oldLogFilename.c_str());
}
diff --git a/src/lib/base/log_outputters.h b/src/lib/base/log_outputters.h
index c4940aa..15f1e7a 100644
--- a/src/lib/base/log_outputters.h
+++ b/src/lib/base/log_outputters.h
@@ -20,12 +20,12 @@
#include "mt/Thread.h"
#include "base/ILogOutputter.h"
-#include "base/String.h"
#include "common/basic_types.h"
#include "common/stddeque.h"
#include <list>
#include <fstream>
+#include <string>
//! Stop traversing log chain outputter
/*!
@@ -126,7 +126,7 @@ This outputter records the last N log messages.
*/
class BufferedLogOutputter : public ILogOutputter {
private:
- typedef std::deque<String> Buffer;
+ typedef std::deque<std::string> Buffer;
public:
typedef Buffer::const_iterator const_iterator;
diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp
index 2158ee2..96d2c67 100644
--- a/src/lib/client/Client.cpp
+++ b/src/lib/client/Client.cpp
@@ -38,23 +38,21 @@
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
-#include "common/stdexcept.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
+#include <stdexcept>
#include <fstream>
//
// Client
//
-Client::Client(
- IEventQueue* events,
- const String& name, const NetworkAddress& address,
- ISocketFactory* socketFactory,
- barrier::Screen* screen,
- ClientArgs const& args) :
+Client::Client(IEventQueue* events, const std::string& name, const NetworkAddress& address,
+ ISocketFactory* socketFactory,
+ barrier::Screen* screen,
+ ClientArgs const& args) :
m_mock(false),
m_name(name),
m_serverAddress(address),
@@ -373,7 +371,7 @@ Client::setOptions(const OptionsList& options)
m_screen->setOptions(options);
}
-String
+std::string
Client::getName() const
{
return m_name;
@@ -403,7 +401,7 @@ Client::sendClipboard(ClipboardID id)
m_timeClipboard[id] = clipboard.getTime();
// marshall the data
- String data = clipboard.marshall();
+ std::string data = clipboard.marshall();
// save and send data if different or not yet sent
if (!m_sentClipboard[id] || data != m_dataClipboard[id]) {
@@ -783,7 +781,7 @@ Client::writeToDropDirThread(void*)
}
void
-Client::dragInfoReceived(UInt32 fileNum, String data)
+Client::dragInfoReceived(UInt32 fileNum, std::string data)
{
// TODO: fix duplicate function from CServer
if (!m_args.m_enableDragDrop) {
@@ -830,7 +828,7 @@ Client::sendFileThread(void* filename)
}
void
-Client::sendDragInfo(UInt32 fileCount, String& info, size_t size)
+Client::sendDragInfo(UInt32 fileCount, std::string& info, size_t size)
{
m_server->sendDragInfo(fileCount, info.c_str(), size);
}
diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h
index 7ac515d..7e566be 100644
--- a/src/lib/client/Client.h
+++ b/src/lib/client/Client.h
@@ -48,7 +48,7 @@ public:
public:
FailInfo(const char* what) : m_retry(false), m_what(what) { }
bool m_retry;
- String m_what;
+ std::string m_what;
};
public:
@@ -57,7 +57,7 @@ public:
as its name and \p address as the server's address and \p factory
to create the socket. \p screen is the local screen.
*/
- Client(IEventQueue* events, const String& name,
+ Client(IEventQueue* events, const std::string& name,
const NetworkAddress& address, ISocketFactory* socketFactory,
barrier::Screen* screen, ClientArgs const& args);
@@ -86,13 +86,13 @@ public:
virtual void handshakeComplete();
//! Received drag information
- void dragInfoReceived(UInt32 fileNum, String data);
+ void dragInfoReceived(UInt32 fileNum, std::string data);
//! Create a new thread and use it to send file to Server
void sendFileToServer(const char* filename);
//! Send dragging file information back to server
- void sendDragInfo(UInt32 fileCount, String& info, size_t size);
+ void sendDragInfo(UInt32 fileCount, std::string& info, size_t size);
//@}
@@ -126,7 +126,7 @@ public:
size_t& getExpectedFileSize() { return m_expectedFileSize; }
//! Return received file data
- String& getReceivedFileData() { return m_receivedFileData; }
+ std::string& getReceivedFileData() { return m_receivedFileData; }
//! Return drag file list
DragFileList getDragFileList() { return m_dragFileList; }
@@ -160,7 +160,7 @@ public:
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const OptionsList& options);
- virtual String getName() const;
+ virtual std::string getName() const;
private:
void sendClipboard(ClipboardID);
@@ -198,7 +198,7 @@ public:
bool m_mock;
private:
- String m_name;
+ std::string m_name;
NetworkAddress m_serverAddress;
ISocketFactory* m_socketFactory;
barrier::Screen* m_screen;
@@ -212,12 +212,12 @@ private:
bool m_ownClipboard[kClipboardEnd];
bool m_sentClipboard[kClipboardEnd];
IClipboard::Time m_timeClipboard[kClipboardEnd];
- String m_dataClipboard[kClipboardEnd];
+ std::string m_dataClipboard[kClipboardEnd];
IEventQueue* m_events;
std::size_t m_expectedFileSize;
- String m_receivedFileData;
+ std::string m_receivedFileData;
DragFileList m_dragFileList;
- String m_dragFileExt;
+ std::string m_dragFileExt;
Thread* m_sendFileThread;
Thread* m_writeToDropDirThread;
TCPSocket* m_socket;
diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp
index 4fbf76a..c067f13 100644
--- a/src/lib/client/ServerProxy.cpp
+++ b/src/lib/client/ServerProxy.cpp
@@ -361,7 +361,7 @@ ServerProxy::onGrabClipboard(ClipboardID id)
void
ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard* clipboard)
{
- String data = IClipboard::marshall(clipboard);
+ std::string data = IClipboard::marshall(clipboard);
LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum));
StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
@@ -550,7 +550,7 @@ void
ServerProxy::setClipboard()
{
// parse
- static String dataCached;
+ static std::string dataCached;
ClipboardID id;
UInt32 seq;
@@ -872,7 +872,7 @@ ServerProxy::fileChunkReceived()
}
else if (result == kStart) {
if (m_client->getDragFileList().size() > 0) {
- String filename = m_client->getDragFileList().at(0).getFilename();
+ std::string filename = m_client->getDragFileList().at(0).getFilename();
LOG((CLOG_DEBUG "start receiving %s", filename.c_str()));
}
}
@@ -883,7 +883,7 @@ ServerProxy::dragInfoReceived()
{
// parse
UInt32 fileNum = 0;
- String content;
+ std::string content;
ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);
m_client->dragInfoReceived(fileNum, content);
@@ -904,6 +904,6 @@ ServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
void
ServerProxy::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
{
- String data(info, size);
+ std::string data(info, size);
ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data);
}
diff --git a/src/lib/client/ServerProxy.h b/src/lib/client/ServerProxy.h
index 2ad711a..abca4c3 100644
--- a/src/lib/client/ServerProxy.h
+++ b/src/lib/client/ServerProxy.h
@@ -22,7 +22,6 @@
#include "barrier/key_types.h"
#include "base/Event.h"
#include "base/Stopwatch.h"
-#include "base/String.h"
class Client;
class ClientInfo;
diff --git a/src/lib/common/stdexcept.h b/src/lib/common/stdexcept.h
deleted file mode 100644
index 2bd96b3..0000000
--- a/src/lib/common/stdexcept.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * barrier -- mouse and keyboard sharing utility
- * Copyright (C) 2014-2016 Symless Ltd.
- *
- * This package is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * found in the file LICENSE that should have accompanied this file.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdexcept>
-
-// apple declares _NOEXCEPT
-#ifndef _NOEXCEPT
-# define _NOEXCEPT throw()
-#endif
diff --git a/src/lib/io/XIO.cpp b/src/lib/io/XIO.cpp
index 1299d23..911fa87 100644
--- a/src/lib/io/XIO.cpp
+++ b/src/lib/io/XIO.cpp
@@ -22,8 +22,7 @@
// XIOClosed
//
-String
-XIOClosed::getWhat() const throw()
+std::string XIOClosed::getWhat() const noexcept
{
return format("XIOClosed", "already closed");
}
@@ -33,8 +32,7 @@ XIOClosed::getWhat() const throw()
// XIOEndOfStream
//
-String
-XIOEndOfStream::getWhat() const throw()
+std::string XIOEndOfStream::getWhat() const noexcept
{
return format("XIOEndOfStream", "reached end of stream");
}
@@ -44,8 +42,7 @@ XIOEndOfStream::getWhat() const throw()
// XIOWouldBlock
//
-String
-XIOWouldBlock::getWhat() const throw()
+std::string XIOWouldBlock::getWhat() const noexcept
{
return format("XIOWouldBlock", "stream operation would block");
}
diff --git a/src/lib/ipc/IpcClientProxy.cpp b/src/lib/ipc/IpcClientProxy.cpp
index 5104277..432cc8c 100644
--- a/src/lib/ipc/IpcClientProxy.cpp
+++ b/src/lib/ipc/IpcClientProxy.cpp
@@ -141,7 +141,7 @@ IpcClientProxy::send(const IpcMessage& message)
switch (message.type()) {
case kIpcLogLine: {
const IpcLogLineMessage& llm = static_cast<const IpcLogLineMessage&>(message);
- const String logLine = llm.logLine();
+ const std::string logLine = llm.logLine();
ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine);
break;
}
@@ -171,7 +171,7 @@ IpcClientProxy::parseHello()
IpcCommandMessage*
IpcClientProxy::parseCommand()
{
- String command;
+ std::string command;
UInt8 elevate;
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp
index b62c76a..44ecdba 100644
--- a/src/lib/ipc/IpcLogOutputter.cpp
+++ b/src/lib/ipc/IpcLogOutputter.cpp
@@ -44,8 +44,8 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType
m_running(false),
m_notifyCond(ARCH->newCondVar()),
m_notifyMutex(ARCH->newMutex()),
- m_bufferThreadId(0),
m_bufferWaiting(false),
+ m_bufferThreadId(0),
m_bufferMaxSize(kBufferMaxSize),
m_bufferRateWriteLimit(kBufferRateWriteLimit),
m_bufferRateTimeLimit(kBufferRateTimeLimit),
@@ -109,8 +109,7 @@ IpcLogOutputter::write(ELevel, const char* text)
return true;
}
-void
-IpcLogOutputter::appendBuffer(const String& text)
+void IpcLogOutputter::appendBuffer(const std::string& text)
{
std::lock_guard<std::mutex> lock(m_bufferMutex);
@@ -173,8 +172,7 @@ IpcLogOutputter::notifyBuffer()
ARCH->broadcastCondVar(m_notifyCond);
}
-String
-IpcLogOutputter::getChunk(size_t count)
+std::string IpcLogOutputter::getChunk(size_t count)
{
std::lock_guard<std::mutex> lock(m_bufferMutex);
@@ -182,7 +180,7 @@ IpcLogOutputter::getChunk(size_t count)
count = m_buffer.size();
}
- String chunk;
+ std::string chunk;
for (size_t i = 0; i < count; i++) {
chunk.append(m_buffer.front());
chunk.append("\n");
diff --git a/src/lib/ipc/IpcLogOutputter.h b/src/lib/ipc/IpcLogOutputter.h
index 2f1b98c..cc7b2fe 100644
--- a/src/lib/ipc/IpcLogOutputter.h
+++ b/src/lib/ipc/IpcLogOutputter.h
@@ -21,6 +21,7 @@
#include "arch/Arch.h"
#include "arch/IArchMultithread.h"
#include "base/ILogOutputter.h"
+#include "base/String.h"
#include "ipc/Ipc.h"
#include <deque>
@@ -92,12 +93,12 @@ public:
private:
void init();
void bufferThread(void*);
- String getChunk(size_t count);
- void appendBuffer(const String& text);
+ std::string getChunk(size_t count);
+ void appendBuffer(const std::string& text);
bool isRunning();
private:
- typedef std::deque<String> Buffer;
+ typedef std::deque<std::string> Buffer;
IpcServer& m_ipcServer;
Buffer m_buffer;
diff --git a/src/lib/ipc/IpcMessage.cpp b/src/lib/ipc/IpcMessage.cpp
index deef22d..9c321cb 100644
--- a/src/lib/ipc/IpcMessage.cpp
+++ b/src/lib/ipc/IpcMessage.cpp
@@ -47,9 +47,9 @@ IpcShutdownMessage::~IpcShutdownMessage()
{
}
-IpcLogLineMessage::IpcLogLineMessage(const String& logLine) :
-IpcMessage(kIpcLogLine),
-m_logLine(logLine)
+IpcLogLineMessage::IpcLogLineMessage(const std::string& logLine) :
+ IpcMessage(kIpcLogLine),
+ m_logLine(logLine)
{
}
@@ -57,10 +57,10 @@ IpcLogLineMessage::~IpcLogLineMessage()
{
}
-IpcCommandMessage::IpcCommandMessage(const String& command, bool elevate) :
-IpcMessage(kIpcCommand),
-m_command(command),
-m_elevate(elevate)
+IpcCommandMessage::IpcCommandMessage(const std::string& command, bool elevate) :
+ IpcMessage(kIpcCommand),
+ m_command(command),
+ m_elevate(elevate)
{
}
diff --git a/src/lib/ipc/IpcMessage.h b/src/lib/ipc/IpcMessage.h
index 5cc3d79..d37ebc3 100644
--- a/src/lib/ipc/IpcMessage.h
+++ b/src/lib/ipc/IpcMessage.h
@@ -20,8 +20,8 @@
#include "ipc/Ipc.h"
#include "base/EventTypes.h"
-#include "base/String.h"
#include "base/Event.h"
+#include <string>
class IpcMessage : public EventData {
public:
@@ -58,28 +58,28 @@ public:
class IpcLogLineMessage : public IpcMessage {
public:
- IpcLogLineMessage(const String& logLine);
+ IpcLogLineMessage(const std::string& logLine);
virtual ~IpcLogLineMessage();
//! Gets the log line.
- String logLine() const { return m_logLine; }
+ std::string logLine() const { return m_logLine; }
private:
- String m_logLine;
+ std::string m_logLine;
};
class IpcCommandMessage : public IpcMessage {
public:
- IpcCommandMessage(const String& command, bool elevate);
+ IpcCommandMessage(const std::string& command, bool elevate);
virtual ~IpcCommandMessage();
//! Gets the command.
- String command() const { return m_command; }
+ std::string command() const { return m_command; }
//! Gets whether or not the process should be elevated on MS Windows.
bool elevate() const { return m_elevate; }
private:
- String m_command;
+ std::string m_command;
bool m_elevate;
};
diff --git a/src/lib/ipc/IpcServerProxy.cpp b/src/lib/ipc/IpcServerProxy.cpp
index 820e1ab..49b3e00 100644
--- a/src/lib/ipc/IpcServerProxy.cpp
+++ b/src/lib/ipc/IpcServerProxy.cpp
@@ -94,7 +94,7 @@ IpcServerProxy::send(const IpcMessage& message)
case kIpcCommand: {
const IpcCommandMessage& cm = static_cast<const IpcCommandMessage&>(message);
- const String command = cm.command();
+ std::string command = cm.command();
ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command);
break;
}
@@ -108,7 +108,7 @@ IpcServerProxy::send(const IpcMessage& message)
IpcLogLineMessage*
IpcServerProxy::parseLogLine()
{
- String logLine;
+ std::string logLine;
ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine);
// must be deleted by event handler.
diff --git a/src/lib/mt/XMT.cpp b/src/lib/mt/XMT.cpp
index 9aa5852..2274a6b 100644
--- a/src/lib/mt/XMT.cpp
+++ b/src/lib/mt/XMT.cpp
@@ -22,8 +22,7 @@
// XMTThreadUnavailable
//
-String
-XMTThreadUnavailable::getWhat() const throw()
+std::string XMTThreadUnavailable::getWhat() const noexcept
{
return format("XMTThreadUnavailable", "cannot create thread");
}
diff --git a/src/lib/net/IDataSocket.h b/src/lib/net/IDataSocket.h
index dc07df5..c77a99c 100644
--- a/src/lib/net/IDataSocket.h
+++ b/src/lib/net/IDataSocket.h
@@ -20,8 +20,8 @@
#include "net/ISocket.h"
#include "io/IStream.h"
-#include "base/String.h"
#include "base/EventTypes.h"
+#include <string>
//! Data stream socket interface
/*!
@@ -33,7 +33,7 @@ public:
class ConnectionFailedInfo {
public:
ConnectionFailedInfo(const char* what) : m_what(what) { }
- String m_what;
+ std::string m_what;
};
IDataSocket(IEventQueue* events) { }
diff --git a/src/lib/net/NetworkAddress.cpp b/src/lib/net/NetworkAddress.cpp
index 8d60567..c8ea9c6 100644
--- a/src/lib/net/NetworkAddress.cpp
+++ b/src/lib/net/NetworkAddress.cpp
@@ -96,7 +96,7 @@ NetworkAddress::NetworkAddress(const NetworkAddress& addr) :
// do nothing
}
-NetworkAddress::NetworkAddress(const String& hostname, int port) :
+NetworkAddress::NetworkAddress(const std::string& hostname, int port) :
m_address(NULL),
m_hostname(hostname),
m_port(port)
@@ -196,8 +196,7 @@ NetworkAddress::getPort() const
return m_port;
}
-String
-NetworkAddress::getHostname() const
+std::string NetworkAddress::getHostname() const
{
return m_hostname;
}
diff --git a/src/lib/net/NetworkAddress.h b/src/lib/net/NetworkAddress.h
index cbd15f5..87dc1e4 100644
--- a/src/lib/net/NetworkAddress.h
+++ b/src/lib/net/NetworkAddress.h
@@ -18,7 +18,6 @@
#pragma once
-#include "base/String.h"
#include "base/EventTypes.h"
#include "arch/IArchNetwork.h"
@@ -49,7 +48,7 @@ public:
is thrown with an error of \c XSocketAddress::kBadPort. The hostname
is not resolved by the c'tor; use \c resolve to do that.
*/
- NetworkAddress(const String& hostname, int port);
+ NetworkAddress(const std::string& hostname, int port);
NetworkAddress(const NetworkAddress&);
@@ -109,7 +108,7 @@ public:
/*!
Returns the hostname passed to the c'tor sans any port suffix.
*/
- String getHostname() const;
+ std::string getHostname() const;
//@}
@@ -118,6 +117,6 @@ private:
private:
ArchNetAddress m_address;
- String m_hostname;
+ std::string m_hostname;
int m_port;
};
diff --git a/src/lib/net/SecureListenSocket.cpp b/src/lib/net/SecureListenSocket.cpp
index 7af905e..a137f39 100644
--- a/src/lib/net/SecureListenSocket.cpp
+++ b/src/lib/net/SecureListenSocket.cpp
@@ -23,6 +23,7 @@
#include "net/TSocketMultiplexerMethodJob.h"
#include "arch/XArch.h"
#include "common/DataDirectories.h"
+#include "base/String.h"
static const char s_certificateDir[] = { "SSL" };
static const char s_certificateFilename[] = { "Barrier.pem" };
@@ -54,7 +55,7 @@ SecureListenSocket::accept()
setListeningJob();
}
- String certificateFilename = barrier::string::sprintf("%s/%s/%s",
+ std::string certificateFilename = barrier::string::sprintf("%s/%s/%s",
DataDirectories::profile().c_str(),
s_certificateDir,
s_certificateFilename);
diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp
index 99f626e..855e16b 100644
--- a/src/lib/net/SecureSocket.cpp
+++ b/src/lib/net/SecureSocket.cpp
@@ -23,6 +23,7 @@
#include "mt/Lock.h"
#include "arch/XArch.h"
#include "base/Log.h"
+#include "base/String.h"
#include "common/DataDirectories.h"
#include <openssl/ssl.h>
@@ -328,8 +329,7 @@ SecureSocket::initSsl(bool server)
initContext(server);
}
-bool
-SecureSocket::loadCertificates(String& filename)
+bool SecureSocket::loadCertificates(std::string& filename)
{
if (filename.empty()) {
showError("ssl certificate is not specified");
@@ -341,7 +341,7 @@ SecureSocket::loadCertificates(String& filename)
file.close();
if (!exist) {
- String errorMsg("ssl certificate doesn't exist: ");
+ std::string errorMsg("ssl certificate doesn't exist: ");
errorMsg.append(filename);
showError(errorMsg.c_str());
return false;
@@ -630,14 +630,13 @@ SecureSocket::showError(const char* reason)
LOG((CLOG_ERR "%s", reason));
}
- String error = getError();
+ std::string error = getError();
if (!error.empty()) {
LOG((CLOG_ERR "%s", error.c_str()));
}
}
-String
-SecureSocket::getError()
+std::string SecureSocket::getError()
{
unsigned long e = ERR_get_error();
@@ -659,8 +658,7 @@ SecureSocket::disconnect()
sendEvent(getEvents()->forIStream().inputShutdown());
}
-void
-SecureSocket::formatFingerprint(String& fingerprint, bool hex, bool separator)
+void SecureSocket::formatFingerprint(std::string& fingerprint, bool hex, bool separator)
{
if (hex) {
// to hexidecimal
@@ -696,11 +694,11 @@ SecureSocket::verifyCertFingerprint()
}
// format fingerprint into hexdecimal format with colon separator
- String fingerprint(reinterpret_cast<char*>(tempFingerprint), tempFingerprintLen);
+ std::string fingerprint(reinterpret_cast<char*>(tempFingerprint), tempFingerprintLen);
formatFingerprint(fingerprint);
LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str()));
- String trustedServersFilename;
+ std::string trustedServersFilename;
trustedServersFilename = barrier::string::sprintf(
"%s/%s/%s",
DataDirectories::profile().c_str(),
@@ -711,7 +709,7 @@ SecureSocket::verifyCertFingerprint()
LOG((CLOG_NOTE "trustedServersFilename: %s", trustedServersFilename.c_str() ));
// check if this fingerprint exist
- String fileLine;
+ std::string fileLine;
std::ifstream file;
file.open(trustedServersFilename.c_str());
@@ -761,7 +759,7 @@ MultiplexerJobStatus SecureSocket::serviceConnect(ISocketMultiplexerJob* job,
// If status > 0, success
if (status > 0) {
sendEvent(m_events->forIDataSocket().secureConnected());
- return {true, newJob()};
+ return newJobOrStopServicing();
}
// Retry case
@@ -793,7 +791,7 @@ MultiplexerJobStatus SecureSocket::serviceAccept(ISocketMultiplexerJob* job,
// If status > 0, success
if (status > 0) {
sendEvent(m_events->forClientListener().accepted());
- return {true, newJob()};
+ return newJobOrStopServicing();
}
// Retry case
diff --git a/src/lib/net/SecureSocket.h b/src/lib/net/SecureSocket.h
index 773b508..c602e2d 100644
--- a/src/lib/net/SecureSocket.h
+++ b/src/lib/net/SecureSocket.h
@@ -39,23 +39,23 @@ public:
~SecureSocket();
// ISocket overrides
- void close();
+ void close() override;
// IDataSocket overrides
- virtual void connect(const NetworkAddress&);
+ virtual void connect(const NetworkAddress&) override;
std::unique_ptr<ISocketMultiplexerJob> newJob() override;
- bool isFatal() const { return m_fatal; }
+ bool isFatal() const override { return m_fatal; }
void isFatal(bool b) { m_fatal = b; }
bool isSecureReady();
void secureConnect();
void secureAccept();
int secureRead(void* buffer, int size, int& read);
int secureWrite(const void* buffer, int size, int& wrote);
- EJobResult doRead();
- EJobResult doWrite();
+ EJobResult doRead() override;
+ EJobResult doWrite() override;
void initSsl(bool server);
- bool loadCertificates(String& CertFile);
+ bool loadCertificates(std::string& CertFile);
private:
// SSL
@@ -66,11 +66,9 @@ private:
bool showCertificate();
void checkResult(int n, int& retry);
void showError(const char* reason = NULL);
- String getError();
+ std::string getError();
void disconnect();
- void formatFingerprint(String& fingerprint,
- bool hex = true,
- bool separator = true);
+ void formatFingerprint(std::string& fingerprint, bool hex = true, bool separator = true);
bool verifyCertFingerprint();
MultiplexerJobStatus serviceConnect(ISocketMultiplexerJob*, bool, bool, bool);
diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp
index 4f4251a..09a8f17 100644
--- a/src/lib/net/TCPSocket.cpp
+++ b/src/lib/net/TCPSocket.cpp
@@ -403,6 +403,15 @@ void TCPSocket::setJob(std::unique_ptr<ISocketMultiplexerJob>&& job)
}
}
+MultiplexerJobStatus TCPSocket::newJobOrStopServicing()
+{
+ auto new_job = newJob();
+ if (new_job)
+ return {true, std::move(new_job)};
+ else
+ return {false, {}};
+}
+
std::unique_ptr<ISocketMultiplexerJob> TCPSocket::newJob()
{
// note -- must have m_mutex locked on entry
@@ -519,22 +528,14 @@ MultiplexerJobStatus TCPSocket::serviceConnecting(ISocketMultiplexerJob* job, bo
catch (XArchNetwork& e) {
sendConnectionFailedEvent(e.what());
onDisconnected();
- auto new_job = newJob();
- if (new_job)
- return {true, std::move(new_job)};
- else
- return {false, {}};
+ return newJobOrStopServicing();
}
}
if (write) {
sendEvent(m_events->forIDataSocket().connected());
onConnected();
- auto new_job = newJob();
- if (new_job)
- return {true, std::move(new_job)};
- else
- return {false, {}};
+ return newJobOrStopServicing();
}
return {true, {}};
@@ -548,7 +549,7 @@ MultiplexerJobStatus TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
if (error) {
sendEvent(m_events->forISocket().disconnected());
onDisconnected();
- return {true, newJob()};
+ return newJobOrStopServicing();
}
EJobResult writeResult = kRetry;
@@ -603,7 +604,7 @@ MultiplexerJobStatus TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
if (writeResult == kBreak || readResult == kBreak) {
return {false, {}};
} else if (writeResult == kNew || readResult == kNew) {
- return {true, newJob()};
+ return newJobOrStopServicing();
} else {
return {true, {}};
}
diff --git a/src/lib/net/TCPSocket.h b/src/lib/net/TCPSocket.h
index 2889135..0b98888 100644
--- a/src/lib/net/TCPSocket.h
+++ b/src/lib/net/TCPSocket.h
@@ -76,7 +76,8 @@ protected:
void removeJob();
void setJob(std::unique_ptr<ISocketMultiplexerJob>&& job);
-
+ MultiplexerJobStatus newJobOrStopServicing();
+
bool isReadable() { return m_readable; }
bool isWritable() { return m_writable; }
diff --git a/src/lib/net/XSocket.cpp b/src/lib/net/XSocket.cpp
index 13e0fc3..eed7a26 100644
--- a/src/lib/net/XSocket.cpp
+++ b/src/lib/net/XSocket.cpp
@@ -23,8 +23,7 @@
// XSocketAddress
//
-XSocketAddress::XSocketAddress(EError error,
- const String& hostname, int port) _NOEXCEPT :
+XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int port) noexcept :
m_error(error),
m_hostname(hostname),
m_port(port)
@@ -32,26 +31,22 @@ XSocketAddress::XSocketAddress(EError error,
// do nothing
}
-XSocketAddress::EError
-XSocketAddress::getError() const throw()
+XSocketAddress::EError XSocketAddress::getError() const noexcept
{
return m_error;
}
-String
-XSocketAddress::getHostname() const throw()
+std::string XSocketAddress::getHostname() const noexcept
{
return m_hostname;
}
-int
-XSocketAddress::getPort() const throw()
+int XSocketAddress::getPort() const noexcept
{
return m_port;
}
-String
-XSocketAddress::getWhat() const throw()
+std::string XSocketAddress::getWhat() const noexcept
{
static const char* s_errorID[] = {
"XSocketAddressUnknown",
@@ -77,8 +72,7 @@ XSocketAddress::getWhat() const throw()
// XSocketIOClose
//
-String
-XSocketIOClose::getWhat() const throw()
+std::string XSocketIOClose::getWhat() const noexcept
{
return format("XSocketIOClose", "close: %{1}", what());
}
@@ -88,8 +82,7 @@ XSocketIOClose::getWhat() const throw()
// XSocketBind
//
-String
-XSocketBind::getWhat() const throw()
+std::string XSocketBind::getWhat() const noexcept
{
return format("XSocketBind", "cannot bind address: %{1}", what());
}
@@ -99,8 +92,7 @@ XSocketBind::getWhat() const throw()
// XSocketConnect
//
-String
-XSocketConnect::getWhat() const throw()
+std::string XSocketConnect::getWhat() const noexcept
{
return format("XSocketConnect", "cannot connect socket: %{1}", what());
}
@@ -110,8 +102,7 @@ XSocketConnect::getWhat() const throw()
// XSocketCreate
//
-String
-XSocketCreate::getWhat() const throw()
+std::string XSocketCreate::getWhat() const noexcept
{
return format("XSocketCreate", "cannot create socket: %{1}", what());
}
diff --git a/src/lib/net/XSocket.h b/src/lib/net/XSocket.h
index be02b5b..d12278e 100644
--- a/src/lib/net/XSocket.h
+++ b/src/lib/net/XSocket.h
@@ -20,7 +20,6 @@
#include "io/XIO.h"
#include "base/XBase.h"
-#include "base/String.h"
#include "common/basic_types.h"
//! Generic socket exception
@@ -41,28 +40,28 @@ public:
kBadPort //!< The port is invalid
};
- XSocketAddress(EError, const String& hostname, int port) _NOEXCEPT;
- virtual ~XSocketAddress() _NOEXCEPT { }
+ XSocketAddress(EError, const std::string& hostname, int port) noexcept;
+ virtual ~XSocketAddress() noexcept { }
//! @name accessors
//@{
//! Get the error code
- EError getError() const throw();
+ EError getError() const noexcept;
//! Get the hostname
- String getHostname() const throw();
+ std::string getHostname() const noexcept;
//! Get the port
- int getPort() const throw();
+ int getPort() const noexcept;
//@}
protected:
// XBase overrides
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
EError m_error;
- String m_hostname;
+ std::string m_hostname;
int m_port;
};
diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp
index 8ab50df..20445d4 100644
--- a/src/lib/platform/MSWindowsClipboard.cpp
+++ b/src/lib/platform/MSWindowsClipboard.cpp
@@ -98,7 +98,7 @@ MSWindowsClipboard::empty()
}
void
-MSWindowsClipboard::add(EFormat format, const String& data)
+MSWindowsClipboard::add(EFormat format, const std::string& data)
{
LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format));
@@ -165,8 +165,7 @@ MSWindowsClipboard::has(EFormat format) const
return false;
}
-String
-MSWindowsClipboard::get(EFormat format) const
+std::string MSWindowsClipboard::get(EFormat format) const
{
// find the converter for the first clipboard format we can handle
IMSWindowsClipboardConverter* converter = NULL;
@@ -183,7 +182,7 @@ MSWindowsClipboard::get(EFormat format) const
// if no converter then we don't recognize any formats
if (converter == NULL) {
LOG((CLOG_WARN "no converter for format %d", format));
- return String();
+ return {};
}
// get a handle to the clipboard data
@@ -192,7 +191,7 @@ MSWindowsClipboard::get(EFormat format) const
// nb: can't cause this using integ tests; this is only caused when
// the selected converter returns an invalid format -- which you
// cannot cause using public functions.
- return String();
+ return {};
}
// convert
diff --git a/src/lib/platform/MSWindowsClipboard.h b/src/lib/platform/MSWindowsClipboard.h
index 3e92a39..35ccb56 100644
--- a/src/lib/platform/MSWindowsClipboard.h
+++ b/src/lib/platform/MSWindowsClipboard.h
@@ -55,21 +55,21 @@ public:
// IClipboard overrides
virtual bool empty();
- virtual void add(EFormat, const String& data);
+ virtual void add(EFormat, const std::string& data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
- virtual String get(EFormat) const;
+ virtual std::string get(EFormat) const;
void setFacade(IMSWindowsClipboardFacade& facade);
private:
void clearConverters();
- UINT convertFormatToWin32(EFormat) const;
- HANDLE convertTextToWin32(const String& data) const;
- String convertTextFromWin32(HANDLE) const;
+ UINT convertFormatToWin32(EFormat) const;
+ HANDLE convertTextToWin32(const std::string& data) const;
+ std::string convertTextFromWin32(HANDLE) const;
static UINT getOwnershipFormat();
@@ -105,9 +105,9 @@ public:
// the input data must be in the IClipboard format returned by
// getFormat(). the return data will be in the win32 clipboard
// format returned by getWin32Format(), allocated by GlobalAlloc().
- virtual HANDLE fromIClipboard(const String&) const = 0;
+ virtual HANDLE fromIClipboard(const std::string&) const = 0;
// convert from the win32 clipboard format to the IClipboard format
// (i.e., the reverse of fromIClipboard()).
- virtual String toIClipboard(HANDLE data) const = 0;
+ virtual std::string toIClipboard(HANDLE data) const = 0;
};
diff --git a/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp b/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp
index decbad6..85a7dbe 100644
--- a/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp
+++ b/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp
@@ -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
diff --git a/src/lib/platform/MSWindowsClipboardAnyTextConverter.h b/src/lib/platform/MSWindowsClipboardAnyTextConverter.h
index cabdb0b..622d281 100644
--- a/src/lib/platform/MSWindowsClipboardAnyTextConverter.h
+++ b/src/lib/platform/MSWindowsClipboardAnyTextConverter.h
@@ -31,8 +31,8 @@ public:
virtual IClipboard::EFormat
getFormat() const;
virtual UINT getWin32Format() const = 0;
- virtual HANDLE fromIClipboard(const String&) const;
- virtual String toIClipboard(HANDLE) const;
+ virtual HANDLE fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(HANDLE) const;
protected:
//! Convert from IClipboard format
@@ -40,18 +40,18 @@ protected:
Do UTF-8 conversion only. Memory handle allocation and
linefeed conversion is done by this class. doFromIClipboard()
must include the nul terminator in the returned string (not
- including the String's nul terminator).
+ including the std::string's nul terminator).
*/
- virtual String doFromIClipboard(const String&) const = 0;
+ virtual std::string doFromIClipboard(const std::string&) const = 0;
//! Convert to IClipboard format
/*!
Do UTF-8 conversion only. Memory handle allocation and
linefeed conversion is done by this class.
*/
- virtual String doToIClipboard(const String&) const = 0;
+ virtual std::string doToIClipboard(const std::string&) const = 0;
private:
- String convertLinefeedToWin32(const String&) const;
- String convertLinefeedToUnix(const String&) const;
+ std::string convertLinefeedToWin32(const std::string&) const;
+ std::string convertLinefeedToUnix(const std::string&) const;
};
diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp
index 16bd4bf..7d38fda 100644
--- a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp
+++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp
@@ -46,8 +46,7 @@ MSWindowsClipboardBitmapConverter::getWin32Format() const
return CF_DIB;
}
-HANDLE
-MSWindowsClipboardBitmapConverter::fromIClipboard(const String& data) const
+HANDLE MSWindowsClipboardBitmapConverter::fromIClipboard(const std::string& data) const
{
// copy to memory handle
HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, data.size());
@@ -67,13 +66,12 @@ MSWindowsClipboardBitmapConverter::fromIClipboard(const String& data) const
return gData;
}
-String
-MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
+std::string MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
{
// get datator
LPVOID src = GlobalLock(data);
if (src == NULL) {
- return String();
+ return {};
}
UInt32 srcSize = (UInt32)GlobalSize(data);
@@ -85,7 +83,7 @@ MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
bitmap->bmiHeader.biBitCount == 32) &&
bitmap->bmiHeader.biCompression == BI_RGB) {
// already in canonical form
- String image(static_cast<char const*>(src), srcSize);
+ std::string image(static_cast<char const*>(src), srcSize);
GlobalUnlock(data);
return image;
}
@@ -138,7 +136,7 @@ MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
GdiFlush();
// extract data
- String image((const char*)&info, info.biSize);
+ std::string image((const char*)&info, info.biSize);
image.append((const char*)raw, 4 * w * h);
// clean up GDI
diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.h b/src/lib/platform/MSWindowsClipboardBitmapConverter.h
index 52b5547..2733884 100644
--- a/src/lib/platform/MSWindowsClipboardBitmapConverter.h
+++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.h
@@ -31,6 +31,6 @@ public:
virtual IClipboard::EFormat
getFormat() const;
virtual UINT getWin32Format() const;
- virtual HANDLE fromIClipboard(const String&) const;
- virtual String toIClipboard(HANDLE) const;
+ virtual HANDLE fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(HANDLE) const;
};
diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp
index 347a224..a1f1212 100644
--- a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp
+++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp
@@ -46,15 +46,14 @@ MSWindowsClipboardHTMLConverter::getWin32Format() const
return m_format;
}
-String
-MSWindowsClipboardHTMLConverter::doFromIClipboard(const String& data) const
+std::string MSWindowsClipboardHTMLConverter::doFromIClipboard(const std::string& data) const
{
// prepare to CF_HTML format prefix and suffix
- String prefix("Version:0.9\r\nStartHTML:0000000105\r\n"
+ std::string prefix("Version:0.9\r\nStartHTML:0000000105\r\n"
"EndHTML:ZZZZZZZZZZ\r\n"
"StartFragment:XXXXXXXXXX\r\nEndFragment:YYYYYYYYYY\r\n"
"<!DOCTYPE><HTML><BODY><!--StartFragment-->");
- String suffix("<!--EndFragment--></BODY></HTML>\r\n");
+ std::string suffix("<!--EndFragment--></BODY></HTML>\r\n");
// Get byte offsets for header
UInt32 StartFragment = (UInt32)prefix.size();
@@ -75,45 +74,43 @@ MSWindowsClipboardHTMLConverter::doFromIClipboard(const String& data) const
return prefix;
}
-String
-MSWindowsClipboardHTMLConverter::doToIClipboard(const String& data) const
+std::string MSWindowsClipboardHTMLConverter::doToIClipboard(const std::string& data) const
{
// get fragment start/end args
- String startArg = findArg(data, "StartFragment");
- String endArg = findArg(data, "EndFragment");
+ std::string startArg = findArg(data, "StartFragment");
+ std::string endArg = findArg(data, "EndFragment");
if (startArg.empty() || endArg.empty()) {
- return String();
+ return std::string();
}
// convert args to integers
SInt32 start = (SInt32)atoi(startArg.c_str());
SInt32 end = (SInt32)atoi(endArg.c_str());
if (start <= 0 || end <= 0 || start >= end) {
- return String();
+ return std::string();
}
// extract the fragment
return data.substr(start, end - start);
}
-String
-MSWindowsClipboardHTMLConverter::findArg(
- const String& data, const String& name) const
+std::string MSWindowsClipboardHTMLConverter::findArg(const std::string& data,
+ const std::string& name) const
{
- String::size_type i = data.find(name);
- if (i == String::npos) {
- return String();
+ std::string::size_type i = data.find(name);
+ if (i == std::string::npos) {
+ return std::string();
}
i = data.find_first_of(":\r\n", i);
- if (i == String::npos || data[i] != ':') {
- return String();
+ if (i == std::string::npos || data[i] != ':') {
+ return std::string();
}
i = data.find_first_of("0123456789\r\n", i + 1);
- if (i == String::npos || data[i] == '\r' || data[i] == '\n') {
- return String();
+ if (i == std::string::npos || data[i] == '\r' || data[i] == '\n') {
+ return std::string();
}
- String::size_type j = data.find_first_not_of("0123456789", i);
- if (j == String::npos) {
+ std::string::size_type j = data.find_first_not_of("0123456789", i);
+ if (j == std::string::npos) {
j = data.size();
}
return data.substr(i, j - i);
diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.h b/src/lib/platform/MSWindowsClipboardHTMLConverter.h
index 66c8045..51607a7 100644
--- a/src/lib/platform/MSWindowsClipboardHTMLConverter.h
+++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.h
@@ -34,11 +34,11 @@ public:
protected:
// MSWindowsClipboardAnyTextConverter overrides
- virtual String doFromIClipboard(const String&) const;
- virtual String doToIClipboard(const String&) const;
+ virtual std::string doFromIClipboard(const std::string&) const;
+ virtual std::string doToIClipboard(const std::string&) const;
private:
- String findArg(const String& data, const String& name) const;
+ std::string findArg(const std::string& data, const std::string& name) const;
private:
UINT m_format;
diff --git a/src/lib/platform/MSWindowsClipboardTextConverter.cpp b/src/lib/platform/MSWindowsClipboardTextConverter.cpp
index 360c72c..1500e7e 100644
--- a/src/lib/platform/MSWindowsClipboardTextConverter.cpp
+++ b/src/lib/platform/MSWindowsClipboardTextConverter.cpp
@@ -40,20 +40,18 @@ MSWindowsClipboardTextConverter::getWin32Format() const
return CF_TEXT;
}
-String
-MSWindowsClipboardTextConverter::doFromIClipboard(const String& data) const
+std::string MSWindowsClipboardTextConverter::doFromIClipboard(const std::string& data) const
{
// convert and add nul terminator
return Unicode::UTF8ToText(data) += '\0';
}
-String
-MSWindowsClipboardTextConverter::doToIClipboard(const String& data) const
+std::string MSWindowsClipboardTextConverter::doToIClipboard(const std::string& data) const
{
// convert and truncate at first nul terminator
- String dst = Unicode::textToUTF8(data);
- String::size_type n = dst.find('\0');
- if (n != String::npos) {
+ std::string dst = Unicode::textToUTF8(data);
+ std::string::size_type n = dst.find('\0');
+ if (n != std::string::npos) {
dst.erase(n);
}
return dst;
diff --git a/src/lib/platform/MSWindowsClipboardTextConverter.h b/src/lib/platform/MSWindowsClipboardTextConverter.h
index fb081c3..6e265a2 100644
--- a/src/lib/platform/MSWindowsClipboardTextConverter.h
+++ b/src/lib/platform/MSWindowsClipboardTextConverter.h
@@ -32,6 +32,6 @@ public:
protected:
// MSWindowsClipboardAnyTextConverter overrides
- virtual String doFromIClipboard(const String&) const;
- virtual String doToIClipboard(const String&) const;
+ virtual std::string doFromIClipboard(const std::string&) const;
+ virtual std::string doToIClipboard(const std::string&) const;
};
diff --git a/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp b/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp
index 0f8642a..4b72717 100644
--- a/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp
+++ b/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp
@@ -40,20 +40,18 @@ MSWindowsClipboardUTF16Converter::getWin32Format() const
return CF_UNICODETEXT;
}
-String
-MSWindowsClipboardUTF16Converter::doFromIClipboard(const String& data) const
+std::string MSWindowsClipboardUTF16Converter::doFromIClipboard(const std::string& data) const
{
// convert and add nul terminator
return Unicode::UTF8ToUTF16(data).append(sizeof(wchar_t), 0);
}
-String
-MSWindowsClipboardUTF16Converter::doToIClipboard(const String& data) const
+std::string MSWindowsClipboardUTF16Converter::doToIClipboard(const std::string& data) const
{
// convert and strip nul terminator
- String dst = Unicode::UTF16ToUTF8(data);
- String::size_type n = dst.find('\0');
- if (n != String::npos) {
+ std::string dst = Unicode::UTF16ToUTF8(data);
+ std::string::size_type n = dst.find('\0');
+ if (n != std::string::npos) {
dst.erase(n);
}
return dst;
diff --git a/src/lib/platform/MSWindowsClipboardUTF16Converter.h b/src/lib/platform/MSWindowsClipboardUTF16Converter.h
index e7222bc..1a9d435 100644
--- a/src/lib/platform/MSWindowsClipboardUTF16Converter.h
+++ b/src/lib/platform/MSWindowsClipboardUTF16Converter.h
@@ -32,6 +32,6 @@ public:
protected:
// MSWindowsClipboardAnyTextConverter overrides
- virtual String doFromIClipboard(const String&) const;
- virtual String doToIClipboard(const String&) const;
+ virtual std::string doFromIClipboard(const std::string&) const;
+ virtual std::string doToIClipboard(const std::string&) const;
};
diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp
index e47aeaa..768ccb4 100644
--- a/src/lib/platform/MSWindowsDesks.cpp
+++ b/src/lib/platform/MSWindowsDesks.cpp
@@ -746,8 +746,7 @@ MSWindowsDesks::deskThread(void* vdesk)
}
}
-MSWindowsDesks::Desk*
-MSWindowsDesks::addDesk(const String& name, HDESK hdesk)
+MSWindowsDesks::Desk* MSWindowsDesks::addDesk(const std::string& name, HDESK hdesk)
{
Desk* desk = new Desk;
desk->m_name = name;
@@ -782,7 +781,7 @@ MSWindowsDesks::checkDesk()
// get current desktop. if we already know about it then return.
Desk* desk;
HDESK hdesk = openInputDesktop();
- String name = getDesktopName(hdesk);
+ std::string name = getDesktopName(hdesk);
Desks::const_iterator index = m_desks.find(name);
if (index == m_desks.end()) {
desk = addDesk(name, hdesk);
@@ -900,18 +899,17 @@ MSWindowsDesks::closeDesktop(HDESK desk)
}
}
-String
-MSWindowsDesks::getDesktopName(HDESK desk)
+std::string MSWindowsDesks::getDesktopName(HDESK desk)
{
if (desk == NULL) {
- return String();
+ return {};
}
else {
DWORD size;
GetUserObjectInformation(desk, UOI_NAME, NULL, 0, &size);
TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR));
GetUserObjectInformation(desk, UOI_NAME, name, size, &size);
- String result(name);
+ std::string result(name);
return result;
}
}
diff --git a/src/lib/platform/MSWindowsDesks.h b/src/lib/platform/MSWindowsDesks.h
index da93c34..6e5e709 100644
--- a/src/lib/platform/MSWindowsDesks.h
+++ b/src/lib/platform/MSWindowsDesks.h
@@ -25,8 +25,8 @@
#include "barrier/option_types.h"
#include "mt/CondVar.h"
#include "mt/Mutex.h"
-#include "base/String.h"
#include "common/stdmap.h"
+#include <string>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
@@ -195,7 +195,7 @@ public:
private:
class Desk {
public:
- String m_name;
+ std::string m_name;
Thread* m_thread;
DWORD m_threadID;
DWORD m_targetID;
@@ -204,7 +204,7 @@ private:
HWND m_foregroundWindow;
bool m_lowLevel;
};
- typedef std::map<String, Desk*> Desks;
+ typedef std::map<std::string, Desk*> Desks;
// initialization and shutdown operations
HCURSOR createBlankCursor() const;
@@ -222,7 +222,7 @@ private:
void deskThread(void* vdesk);
// desk switch checking and handling
- Desk* addDesk(const String& name, HDESK hdesk);
+ Desk* addDesk(const std::string& name, HDESK hdesk);
void removeDesks();
void checkDesk();
bool isDeskAccessible(const Desk* desk) const;
@@ -238,7 +238,7 @@ private:
// desk API wrappers
HDESK openInputDesktop();
void closeDesktop(HDESK);
- String getDesktopName(HDESK);
+ std::string getDesktopName(HDESK);
// our desk window procs
static LRESULT CALLBACK primaryDeskProc(HWND, UINT, WPARAM, LPARAM);
@@ -276,7 +276,7 @@ private:
// the current desk and it's name
Desk* m_activeDesk;
- String m_activeDeskName;
+ std::string m_activeDeskName;
// one desk per desktop and a cond var to communicate with it
Mutex m_mutex;
diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.cpp b/src/lib/platform/MSWindowsEventQueueBuffer.cpp
index f6de157..3111367 100644
--- a/src/lib/platform/MSWindowsEventQueueBuffer.cpp
+++ b/src/lib/platform/MSWindowsEventQueueBuffer.cpp
@@ -21,6 +21,7 @@
#include "arch/win32/ArchMiscWindows.h"
#include "mt/Thread.h"
#include "base/IEventQueue.h"
+#include <VersionHelpers.h>
//
// EventQueueTimer
@@ -48,6 +49,15 @@ MSWindowsEventQueueBuffer::MSWindowsEventQueueBuffer(IEventQueue* events) :
// make sure this thread has a message queue
MSG dummy;
PeekMessage(&dummy, NULL, WM_USER, WM_USER, PM_NOREMOVE);
+
+ m_os_supported_message_types = QS_ALLINPUT;
+ if (!IsWindows8OrGreater())
+ {
+ // don't use QS_POINTER, QS_TOUCH
+ // because they can cause GetQueueStatus() to always return 0 and we miss events
+ // since those flags are confusing Windows 7. See QTBUG-29097 for related info
+ m_os_supported_message_types &= ~(QS_TOUCH | QS_POINTER);
+ }
}
MSWindowsEventQueueBuffer::~MSWindowsEventQueueBuffer()
@@ -79,7 +89,7 @@ MSWindowsEventQueueBuffer::waitForEvent(double timeout)
// cancellation but that's okay because we're run in the main
// thread and we never cancel that thread.
HANDLE dummy[1];
- MsgWaitForMultipleObjects(0, dummy, FALSE, t, QS_ALLINPUT);
+ MsgWaitForMultipleObjects(0, dummy, FALSE, t, m_os_supported_message_types);
}
IEventQueueBuffer::Type
@@ -128,9 +138,7 @@ MSWindowsEventQueueBuffer::addEvent(UInt32 dataID)
bool
MSWindowsEventQueueBuffer::isEmpty() const
{
- // don't use QS_POINTER, QS_TOUCH, or any meta-flags that include them (like QS_ALLINPUT)
- // because they can cause GetQueueStatus() to always return 0 and we miss events
- return (HIWORD(GetQueueStatus(QS_POSTMESSAGE)) == 0);
+ return (HIWORD(GetQueueStatus(m_os_supported_message_types)) == 0);
}
EventQueueTimer*
diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.h b/src/lib/platform/MSWindowsEventQueueBuffer.h
index 6a0f9f9..bc9bde1 100644
--- a/src/lib/platform/MSWindowsEventQueueBuffer.h
+++ b/src/lib/platform/MSWindowsEventQueueBuffer.h
@@ -47,4 +47,5 @@ private:
MSG m_event;
UINT m_daemonQuit;
IEventQueue* m_events;
+ UINT m_os_supported_message_types;
};
diff --git a/src/lib/platform/MSWindowsKeyState.h b/src/lib/platform/MSWindowsKeyState.h
index b226d8b..3c5fa40 100644
--- a/src/lib/platform/MSWindowsKeyState.h
+++ b/src/lib/platform/MSWindowsKeyState.h
@@ -19,7 +19,6 @@
#pragma once
#include "barrier/KeyState.h"
-#include "base/String.h"
#include "common/stdvector.h"
#define WIN32_LEAN_AND_MEAN
diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp
index 2717034..df10270 100644
--- a/src/lib/platform/MSWindowsScreen.cpp
+++ b/src/lib/platform/MSWindowsScreen.cpp
@@ -38,7 +38,6 @@
#include "arch/Arch.h"
#include "base/FunctionJob.h"
#include "base/Log.h"
-#include "base/String.h"
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
@@ -150,7 +149,7 @@ MSWindowsScreen::MSWindowsScreen(
// SHGetFolderPath is deprecated in vista, but use it for xp support.
char desktopPath[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) {
- m_desktopPath = String(desktopPath);
+ m_desktopPath = std::string(desktopPath);
LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str()));
}
else {
@@ -378,7 +377,7 @@ MSWindowsScreen::leave()
void
MSWindowsScreen::sendDragThread(void*)
{
- String& draggingFilename = getDraggingFilename();
+ std::string& draggingFilename = getDraggingFilename();
size_t size = draggingFilename.size();
if (draggingFilename.empty() == false) {
@@ -1867,8 +1866,7 @@ MSWindowsScreen::fakeDraggingFiles(DragFileList fileList)
// exception from being thrown.
}
-String&
-MSWindowsScreen::getDraggingFilename()
+std::string& MSWindowsScreen::getDraggingFilename()
{
if (m_draggingStarted) {
m_dropTarget->clearDraggingFilename();
@@ -1894,7 +1892,7 @@ MSWindowsScreen::getDraggingFilename()
fakeKeyUp(1);
fakeMouseButton(kButtonLeft, false);
- String filename;
+ std::string filename;
DOUBLE timeout = ARCH->time() + .5f;
while (ARCH->time() < timeout) {
ARCH->sleep(.05f);
@@ -1923,8 +1921,7 @@ MSWindowsScreen::getDraggingFilename()
return m_draggingFilename;
}
-const String&
-MSWindowsScreen::getDropTarget() const
+const std::string& MSWindowsScreen::getDropTarget() const
{
return m_desktopPath;
}
diff --git a/src/lib/platform/MSWindowsScreen.h b/src/lib/platform/MSWindowsScreen.h
index 14cd505..49e09df 100644
--- a/src/lib/platform/MSWindowsScreen.h
+++ b/src/lib/platform/MSWindowsScreen.h
@@ -25,7 +25,7 @@
#include "platform/synwinhk.h"
#include "mt/CondVar.h"
#include "mt/Mutex.h"
-#include "base/String.h"
+#include <string>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
@@ -118,9 +118,8 @@ public:
virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const;
virtual void fakeDraggingFiles(DragFileList fileList);
- virtual String& getDraggingFilename();
- virtual const String&
- getDropTarget() const;
+ virtual std::string& getDraggingFilename();
+ virtual const std::string& getDropTarget() const;
protected:
// IPlatformScreen overrides
@@ -333,7 +332,7 @@ private:
IEventQueue* m_events;
- String m_desktopPath;
+ std::string m_desktopPath;
MSWindowsDropTarget*
m_dropTarget;
diff --git a/src/lib/platform/MSWindowsScreenSaver.h b/src/lib/platform/MSWindowsScreenSaver.h
index 91df181..a117370 100644
--- a/src/lib/platform/MSWindowsScreenSaver.h
+++ b/src/lib/platform/MSWindowsScreenSaver.h
@@ -19,7 +19,6 @@
#pragma once
#include "barrier/IScreenSaver.h"
-#include "base/String.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
diff --git a/src/lib/platform/MSWindowsSession.cpp b/src/lib/platform/MSWindowsSession.cpp
index 63e8d8f..8d4f8ce 100644
--- a/src/lib/platform/MSWindowsSession.cpp
+++ b/src/lib/platform/MSWindowsSession.cpp
@@ -172,10 +172,9 @@ MSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry)
return gotEntry;
}
-String
-MSWindowsSession::getActiveDesktopName()
+std::string MSWindowsSession::getActiveDesktopName()
{
- String result;
+ std::string result;
try {
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
if (hd != NULL) {
diff --git a/src/lib/platform/MSWindowsSession.h b/src/lib/platform/MSWindowsSession.h
index d777141..e14d7e2 100644
--- a/src/lib/platform/MSWindowsSession.h
+++ b/src/lib/platform/MSWindowsSession.h
@@ -17,7 +17,7 @@
#pragma once
-#include "base/String.h"
+#include <string>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
@@ -42,7 +42,7 @@ public:
void updateActiveSession();
- String getActiveDesktopName();
+ std::string getActiveDesktopName();
private:
BOOL nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry);
diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp
index b657906..b6b809f 100644
--- a/src/lib/platform/MSWindowsUtil.cpp
+++ b/src/lib/platform/MSWindowsUtil.cpp
@@ -18,29 +18,26 @@
#include "platform/MSWindowsUtil.h"
-#include "base/String.h"
-
#include <stdio.h>
+#include "base/String.h"
//
// MSWindowsUtil
//
-String
-MSWindowsUtil::getString(HINSTANCE instance, DWORD id)
+std::string MSWindowsUtil::getString(HINSTANCE instance, DWORD id)
{
char* msg = NULL;
int n = LoadString(instance, id, reinterpret_cast<LPSTR>(&msg), 0);
if (n <= 0) {
- return String();
+ return {};
}
- return String (msg, n);
+ return std::string (msg, n);
}
-String
-MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id)
+std::string MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id)
{
char* buffer;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
@@ -52,12 +49,12 @@ MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id)
(LPTSTR)&buffer,
0,
NULL) == 0) {
- String errorString = barrier::string::sprintf("%d", error);
+ std::string errorString = barrier::string::sprintf("%d", error);
return barrier::string::format(getString(hinstance, id).c_str(),
errorString.c_str());
}
else {
- String result(buffer);
+ std::string result(buffer);
LocalFree(buffer);
return result;
}
diff --git a/src/lib/platform/MSWindowsUtil.h b/src/lib/platform/MSWindowsUtil.h
index 29eef2e..59f2eac 100644
--- a/src/lib/platform/MSWindowsUtil.h
+++ b/src/lib/platform/MSWindowsUtil.h
@@ -18,7 +18,7 @@
#pragma once
-#include "base/String.h"
+#include <string>
#define WINDOWS_LEAN_AND_MEAN
#include <Windows.h>
@@ -29,14 +29,14 @@ public:
/*!
Gets a string for \p id from the string table of \p instance.
*/
- static String getString(HINSTANCE instance, DWORD id);
+ static std::string getString(HINSTANCE instance, DWORD id);
//! Get error string
/*!
Gets a system error message for \p error. If the error cannot be
found return the string for \p id, replacing ${1} with \p error.
*/
- static String getErrorString(HINSTANCE, DWORD error, DWORD id);
+ static std::string getErrorString(HINSTANCE, DWORD error, DWORD id);
//! Create directory
/*!
diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp
index 9856b5d..0aa5505 100644
--- a/src/lib/platform/MSWindowsWatchdog.cpp
+++ b/src/lib/platform/MSWindowsWatchdog.cpp
@@ -327,8 +327,7 @@ MSWindowsWatchdog::startProcess()
}
}
-BOOL
-MSWindowsWatchdog::doStartProcessAsSelf(String& command)
+BOOL MSWindowsWatchdog::doStartProcessAsSelf(std::string& command)
{
DWORD creationFlags =
NORMAL_PRIORITY_CLASS |
@@ -347,8 +346,8 @@ MSWindowsWatchdog::doStartProcessAsSelf(String& command)
return CreateProcess(NULL, LPSTR(command.c_str()), NULL, NULL, FALSE, creationFlags, NULL, NULL, &si, &m_processInfo);
}
-BOOL
-MSWindowsWatchdog::doStartProcessAsUser(String& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
+BOOL MSWindowsWatchdog::doStartProcessAsUser(std::string& command, HANDLE userToken,
+ LPSECURITY_ATTRIBUTES sa)
{
// clear, as we're reusing process info struct
ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION));
diff --git a/src/lib/platform/MSWindowsWatchdog.h b/src/lib/platform/MSWindowsWatchdog.h
index 7a1f661..0a81521 100644
--- a/src/lib/platform/MSWindowsWatchdog.h
+++ b/src/lib/platform/MSWindowsWatchdog.h
@@ -55,8 +55,8 @@ private:
HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security);
HANDLE getUserToken(LPSECURITY_ATTRIBUTES security);
void startProcess();
- BOOL doStartProcessAsUser(String& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa);
- BOOL doStartProcessAsSelf(String& command);
+ BOOL doStartProcessAsUser(std::string& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa);
+ BOOL doStartProcessAsSelf(std::string& command);
private:
Thread* m_thread;
@@ -85,8 +85,8 @@ An error occured in the process watchdog.
*/
class XMSWindowsWatchdogError : public XBarrier {
public:
- XMSWindowsWatchdogError(const String& msg) : XBarrier(msg) { }
+ XMSWindowsWatchdogError(const std::string& msg) : XBarrier(msg) { }
// XBase overrides
- virtual String getWhat() const throw() { return what(); }
+ virtual std::string getWhat() const noexcept { return what(); }
};
diff --git a/src/lib/platform/OSXClipboard.cpp b/src/lib/platform/OSXClipboard.cpp
index 710b471..e55c8e0 100644
--- a/src/lib/platform/OSXClipboard.cpp
+++ b/src/lib/platform/OSXClipboard.cpp
@@ -92,8 +92,7 @@ OSXClipboard::synchronize()
return false;
}
- void
-OSXClipboard::add(EFormat format, const String & data)
+void OSXClipboard::add(EFormat format, const std::string& data)
{
if (m_pboard == NULL)
return;
@@ -116,7 +115,7 @@ OSXClipboard::add(EFormat format, const String & data)
// skip converters for other formats
if (converter->getFormat() == format) {
- String osXData = converter->fromIClipboard(data);
+ std::string osXData = converter->fromIClipboard(data);
CFStringRef flavorType = converter->getOSXFormat();
CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, (UInt8 *)osXData.data(), osXData.size());
PasteboardItemID itemID = 0;
@@ -185,12 +184,11 @@ OSXClipboard::has(EFormat format) const
return false;
}
-String
-OSXClipboard::get(EFormat format) const
+std::string OSXClipboard::get(EFormat format) const
{
CFStringRef type;
PasteboardItemID item;
- String result;
+ std::string result;
if (m_pboard == NULL)
return result;
@@ -229,7 +227,7 @@ OSXClipboard::get(EFormat format) const
throw err;
}
- result = String((char *) CFDataGetBytePtr(buffer), CFDataGetLength(buffer));
+ result = std::string((char *) CFDataGetBytePtr(buffer), CFDataGetLength(buffer));
}
catch (OSStatus err) {
LOG((CLOG_DEBUG "exception thrown in OSXClipboard::get MacError (%d)", err));
diff --git a/src/lib/platform/OSXClipboard.h b/src/lib/platform/OSXClipboard.h
index ba25c32..b1f9801 100644
--- a/src/lib/platform/OSXClipboard.h
+++ b/src/lib/platform/OSXClipboard.h
@@ -21,6 +21,7 @@
#include "barrier/IClipboard.h"
#include <Carbon/Carbon.h>
+#include <string>
#include <vector>
class IOSXClipboardConverter;
@@ -36,12 +37,12 @@ public:
// IClipboard overrides
virtual bool empty();
- virtual void add(EFormat, const String& data);
+ virtual void add(EFormat, const std::string& data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
- virtual String get(EFormat) const;
+ virtual std::string get(EFormat) const;
bool synchronize();
private:
@@ -72,8 +73,7 @@ public:
getFormat() const = 0;
//! returns the scrap flavor type that this object converts from/to
- virtual CFStringRef
- getOSXFormat() const = 0;
+ virtual CFStringRef getOSXFormat() const = 0;
//! Convert from IClipboard format
/*!
@@ -82,14 +82,14 @@ public:
getFormat(). The return data will be in the scrap
format returned by getOSXFormat().
*/
- virtual String fromIClipboard(const String&) const = 0;
+ virtual std::string fromIClipboard(const std::string&) const = 0;
//! Convert to IClipboard format
/*!
Convert from the carbon scrap format to the IClipboard format
(i.e., the reverse of fromIClipboard()).
*/
- virtual String toIClipboard(const String&) const = 0;
+ virtual std::string toIClipboard(const std::string&) const = 0;
//@}
};
diff --git a/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp b/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp
index 73f64c7..8b1b6d4 100644
--- a/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp
+++ b/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp
@@ -35,14 +35,12 @@ OSXClipboardAnyBitmapConverter::getFormat() const
return IClipboard::kBitmap;
}
-String
-OSXClipboardAnyBitmapConverter::fromIClipboard(const String& data) const
+std::string OSXClipboardAnyBitmapConverter::fromIClipboard(const std::string& data) const
{
return doFromIClipboard(data);
}
-String
-OSXClipboardAnyBitmapConverter::toIClipboard(const String& data) const
+std::string OSXClipboardAnyBitmapConverter::toIClipboard(const std::string& data) const
{
return doToIClipboard(data);
}
diff --git a/src/lib/platform/OSXClipboardAnyBitmapConverter.h b/src/lib/platform/OSXClipboardAnyBitmapConverter.h
index 277e75d..78f7809 100644
--- a/src/lib/platform/OSXClipboardAnyBitmapConverter.h
+++ b/src/lib/platform/OSXClipboardAnyBitmapConverter.h
@@ -30,19 +30,19 @@ public:
virtual IClipboard::EFormat
getFormat() const;
virtual CFStringRef getOSXFormat() const = 0;
- virtual String fromIClipboard(const String &) const;
- virtual String toIClipboard(const String &) const;
+ virtual std::string fromIClipboard(const std::string &) const;
+ virtual std::string toIClipboard(const std::string &) const;
protected:
//! Convert from IClipboard format
/*!
Do UTF-8 conversion and linefeed conversion.
*/
- virtual String doFromIClipboard(const String&) const = 0;
+ virtual std::string doFromIClipboard(const std::string&) const = 0;
//! Convert to IClipboard format
/*!
Do UTF-8 conversion and Linefeed conversion.
*/
- virtual String doToIClipboard(const String&) const = 0;
+ virtual std::string doToIClipboard(const std::string&) const = 0;
};
diff --git a/src/lib/platform/OSXClipboardAnyTextConverter.cpp b/src/lib/platform/OSXClipboardAnyTextConverter.cpp
index 7095006..ae8dc4a 100644
--- a/src/lib/platform/OSXClipboardAnyTextConverter.cpp
+++ b/src/lib/platform/OSXClipboardAnyTextConverter.cpp
@@ -40,15 +40,13 @@ OSXClipboardAnyTextConverter::getFormat() const
return IClipboard::kText;
}
-String
-OSXClipboardAnyTextConverter::fromIClipboard(const String& data) const
+std::string OSXClipboardAnyTextConverter::fromIClipboard(const std::string& data) const
{
// convert linefeeds and then convert to desired encoding
return doFromIClipboard(convertLinefeedToMacOS(data));
}
-String
-OSXClipboardAnyTextConverter::toIClipboard(const String& data) const
+std::string OSXClipboardAnyTextConverter::toIClipboard(const std::string& data) const
{
// convert text then newlines
return convertLinefeedToUnix(doToIClipboard(data));
@@ -68,21 +66,19 @@ isCR(char ch)
return (ch == '\r');
}
-String
-OSXClipboardAnyTextConverter::convertLinefeedToMacOS(const String& src)
+std::string OSXClipboardAnyTextConverter::convertLinefeedToMacOS(const std::string& src)
{
// note -- we assume src is a valid UTF-8 string
- String copy = src;
+ std::string copy = src;
std::replace_if(copy.begin(), copy.end(), isLF, '\r');
return copy;
}
-String
-OSXClipboardAnyTextConverter::convertLinefeedToUnix(const String& src)
+std::string OSXClipboardAnyTextConverter::convertLinefeedToUnix(const std::string& src)
{
- String copy = src;
+ std::string copy = src;
std::replace_if(copy.begin(), copy.end(), isCR, '\n');
diff --git a/src/lib/platform/OSXClipboardAnyTextConverter.h b/src/lib/platform/OSXClipboardAnyTextConverter.h
index ea42994..f057bae 100644
--- a/src/lib/platform/OSXClipboardAnyTextConverter.h
+++ b/src/lib/platform/OSXClipboardAnyTextConverter.h
@@ -29,25 +29,24 @@ public:
// IOSXClipboardConverter overrides
virtual IClipboard::EFormat
getFormat() const;
- virtual CFStringRef
- getOSXFormat() const = 0;
- virtual String fromIClipboard(const String &) const;
- virtual String toIClipboard(const String &) const;
+ virtual CFStringRef getOSXFormat() const = 0;
+ virtual std::string fromIClipboard(const std::string &) const;
+ virtual std::string toIClipboard(const std::string &) const;
protected:
//! Convert from IClipboard format
/*!
Do UTF-8 conversion and linefeed conversion.
*/
- virtual String doFromIClipboard(const String&) const = 0;
+ virtual std::string doFromIClipboard(const std::string&) const = 0;
//! Convert to IClipboard format
/*!
Do UTF-8 conversion and Linefeed conversion.
*/
- virtual String doToIClipboard(const String&) const = 0;
+ virtual std::string doToIClipboard(const std::string&) const = 0;
private:
- static String convertLinefeedToMacOS(const String&);
- static String convertLinefeedToUnix(const String&);
+ static std::string convertLinefeedToMacOS(const std::string&);
+ static std::string convertLinefeedToUnix(const std::string&);
};
diff --git a/src/lib/platform/OSXClipboardBMPConverter.cpp b/src/lib/platform/OSXClipboardBMPConverter.cpp
index 51c44ec..ac74fbb 100644
--- a/src/lib/platform/OSXClipboardBMPConverter.cpp
+++ b/src/lib/platform/OSXClipboardBMPConverter.cpp
@@ -91,8 +91,7 @@ OSXClipboardBMPConverter::getOSXFormat() const
return CFSTR("com.microsoft.bmp");
}
-String
-OSXClipboardBMPConverter::fromIClipboard(const String& bmp) const
+std::string OSXClipboardBMPConverter::fromIClipboard(const std::string& bmp) const
{
LOG((CLOG_DEBUG1 "ENTER OSXClipboardBMPConverter::doFromIClipboard()"));
// create BMP image
@@ -104,21 +103,20 @@ OSXClipboardBMPConverter::fromIClipboard(const String& bmp) const
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt32>(14 + 40));
- return String(reinterpret_cast<const char*>(header), 14) + bmp;
+ return std::string(reinterpret_cast<const char*>(header), 14) + bmp;
}
-String
-OSXClipboardBMPConverter::toIClipboard(const String& bmp) const
+std::string OSXClipboardBMPConverter::toIClipboard(const std::string& bmp) const
{
// make sure data is big enough for a BMP file
if (bmp.size() <= 14 + 40) {
- return String();
+ return {};
}
// check BMP file header
const UInt8* rawBMPHeader = reinterpret_cast<const UInt8*>(bmp.data());
if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') {
- return String();
+ return {};
}
// get offset to image data
diff --git a/src/lib/platform/OSXClipboardBMPConverter.h b/src/lib/platform/OSXClipboardBMPConverter.h
index 400831d..f841bee 100644
--- a/src/lib/platform/OSXClipboardBMPConverter.h
+++ b/src/lib/platform/OSXClipboardBMPConverter.h
@@ -34,11 +34,10 @@ public:
getOSXFormat() const;
// OSXClipboardAnyBMPConverter overrides
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
// generic encoding converter
- static String convertString(const String& data,
- CFStringEncoding fromEncoding,
- CFStringEncoding toEncoding);
+ static std::string convertString(const std::string& data, CFStringEncoding fromEncoding,
+ CFStringEncoding toEncoding);
};
diff --git a/src/lib/platform/OSXClipboardHTMLConverter.cpp b/src/lib/platform/OSXClipboardHTMLConverter.cpp
index b5fdb77..46a3d0f 100644
--- a/src/lib/platform/OSXClipboardHTMLConverter.cpp
+++ b/src/lib/platform/OSXClipboardHTMLConverter.cpp
@@ -42,18 +42,16 @@ OSXClipboardHTMLConverter::getOSXFormat() const
return CFSTR("public.html");
}
-String
-OSXClipboardHTMLConverter::convertString(
- const String& data,
- CFStringEncoding fromEncoding,
- CFStringEncoding toEncoding)
+std::string OSXClipboardHTMLConverter::convertString(const std::string& data,
+ CFStringEncoding fromEncoding,
+ CFStringEncoding toEncoding)
{
CFStringRef stringRef = CFStringCreateWithCString(
kCFAllocatorDefault,
data.c_str(), fromEncoding);
if (stringRef == NULL) {
- return String();
+ return {};
}
CFIndex buffSize;
@@ -66,13 +64,13 @@ OSXClipboardHTMLConverter::convertString(
if (buffer == NULL) {
CFRelease(stringRef);
- return String();
+ return {};
}
CFStringGetBytes(stringRef, entireString, toEncoding,
0, false, (UInt8*)buffer, buffSize, NULL);
- String result(buffer, buffSize);
+ std::string result(buffer, buffSize);
delete[] buffer;
CFRelease(stringRef);
@@ -80,15 +78,13 @@ OSXClipboardHTMLConverter::convertString(
return result;
}
-String
-OSXClipboardHTMLConverter::doFromIClipboard(const String& data) const
+std::string OSXClipboardHTMLConverter::doFromIClipboard(const std::string& data) const
{
return convertString(data, kCFStringEncodingUTF8,
CFStringGetSystemEncoding());
}
-String
-OSXClipboardHTMLConverter::doToIClipboard(const String& data) const
+std::string OSXClipboardHTMLConverter::doToIClipboard(const std::string& data) const
{
return convertString(data, CFStringGetSystemEncoding(),
kCFStringEncodingUTF8);
diff --git a/src/lib/platform/OSXClipboardHTMLConverter.h b/src/lib/platform/OSXClipboardHTMLConverter.h
index 21c2b82..a821e25 100644
--- a/src/lib/platform/OSXClipboardHTMLConverter.h
+++ b/src/lib/platform/OSXClipboardHTMLConverter.h
@@ -34,11 +34,10 @@ public:
protected:
// OSXClipboardAnyTextConverter overrides
- virtual String doFromIClipboard(const String&) const;
- virtual String doToIClipboard(const String&) const;
+ virtual std::string doFromIClipboard(const std::string&) const;
+ virtual std::string doToIClipboard(const std::string&) const;
// generic encoding converter
- static String convertString(const String& data,
- CFStringEncoding fromEncoding,
- CFStringEncoding toEncoding);
+ static std::string convertString(const std::string& data, CFStringEncoding fromEncoding,
+ CFStringEncoding toEncoding);
};
diff --git a/src/lib/platform/OSXClipboardTextConverter.cpp b/src/lib/platform/OSXClipboardTextConverter.cpp
index c18ad3f..a68258d 100644
--- a/src/lib/platform/OSXClipboardTextConverter.cpp
+++ b/src/lib/platform/OSXClipboardTextConverter.cpp
@@ -40,18 +40,16 @@ OSXClipboardTextConverter::getOSXFormat() const
return CFSTR("public.plain-text");
}
-String
-OSXClipboardTextConverter::convertString(
- const String& data,
- CFStringEncoding fromEncoding,
- CFStringEncoding toEncoding)
+std::string OSXClipboardTextConverter::convertString(const std::string& data,
+ CFStringEncoding fromEncoding,
+ CFStringEncoding toEncoding)
{
CFStringRef stringRef =
CFStringCreateWithCString(kCFAllocatorDefault,
data.c_str(), fromEncoding);
if (stringRef == NULL) {
- return String();
+ return {};
}
CFIndex buffSize;
@@ -64,13 +62,13 @@ OSXClipboardTextConverter::convertString(
if (buffer == NULL) {
CFRelease(stringRef);
- return String();
+ return {};
}
CFStringGetBytes(stringRef, entireString, toEncoding,
0, false, (UInt8*)buffer, buffSize, NULL);
- String result(buffer, buffSize);
+ std::string result(buffer, buffSize);
delete[] buffer;
CFRelease(stringRef);
@@ -78,15 +76,13 @@ OSXClipboardTextConverter::convertString(
return result;
}
-String
-OSXClipboardTextConverter::doFromIClipboard(const String& data) const
+std::string OSXClipboardTextConverter::doFromIClipboard(const std::string& data) const
{
return convertString(data, kCFStringEncodingUTF8,
CFStringGetSystemEncoding());
}
-String
-OSXClipboardTextConverter::doToIClipboard(const String& data) const
+std::string OSXClipboardTextConverter::doToIClipboard(const std::string& data) const
{
return convertString(data, CFStringGetSystemEncoding(),
kCFStringEncodingUTF8);
diff --git a/src/lib/platform/OSXClipboardTextConverter.h b/src/lib/platform/OSXClipboardTextConverter.h
index 55d82ce..8211f1e 100644
--- a/src/lib/platform/OSXClipboardTextConverter.h
+++ b/src/lib/platform/OSXClipboardTextConverter.h
@@ -32,11 +32,10 @@ public:
protected:
// OSXClipboardAnyTextConverter overrides
- virtual String doFromIClipboard(const String&) const;
- virtual String doToIClipboard(const String&) const;
+ virtual std::string doFromIClipboard(const std::string&) const;
+ virtual std::string doToIClipboard(const std::string&) const;
// generic encoding converter
- static String convertString(const String& data,
- CFStringEncoding fromEncoding,
- CFStringEncoding toEncoding);
+ static std::string convertString(const std::string& data, CFStringEncoding fromEncoding,
+ CFStringEncoding toEncoding);
};
diff --git a/src/lib/platform/OSXClipboardUTF16Converter.cpp b/src/lib/platform/OSXClipboardUTF16Converter.cpp
index 02d8fa3..8411e92 100644
--- a/src/lib/platform/OSXClipboardUTF16Converter.cpp
+++ b/src/lib/platform/OSXClipboardUTF16Converter.cpp
@@ -40,15 +40,13 @@ OSXClipboardUTF16Converter::getOSXFormat() const
return CFSTR("public.utf16-plain-text");
}
-String
-OSXClipboardUTF16Converter::doFromIClipboard(const String& data) const
+std::string OSXClipboardUTF16Converter::doFromIClipboard(const std::string& data) const
{
// convert and add nul terminator
return Unicode::UTF8ToUTF16(data);
}
-String
-OSXClipboardUTF16Converter::doToIClipboard(const String& data) const
+std::string OSXClipboardUTF16Converter::doToIClipboard(const std::string& data) const
{
// convert and strip nul terminator
return Unicode::UTF16ToUTF8(data);
diff --git a/src/lib/platform/OSXClipboardUTF16Converter.h b/src/lib/platform/OSXClipboardUTF16Converter.h
index 10bb595..b279c99 100644
--- a/src/lib/platform/OSXClipboardUTF16Converter.h
+++ b/src/lib/platform/OSXClipboardUTF16Converter.h
@@ -32,6 +32,6 @@ public:
protected:
// OSXClipboardAnyTextConverter overrides
- virtual String doFromIClipboard(const String&) const;
- virtual String doToIClipboard(const String&) const;
+ virtual std::string doFromIClipboard(const std::string&) const;
+ virtual std::string doToIClipboard(const std::string&) const;
};
diff --git a/src/lib/platform/OSXDragView.m b/src/lib/platform/OSXDragView.m
index 9f77499..67dac56 100644
--- a/src/lib/platform/OSXDragView.m
+++ b/src/lib/platform/OSXDragView.m
@@ -129,13 +129,13 @@ draggingSourceOperationMask
- (NSPoint)draggingLocation
{
- NSPoint point;
+ NSPoint point = NSMakePoint(0, 0);
return point;
}
- (NSPoint)draggedImageLocation
{
- NSPoint point;
+ NSPoint point = NSMakePoint(0, 0);
return point;
}
diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp
index 9d8f429..9db3c5d 100644
--- a/src/lib/platform/OSXKeyState.cpp
+++ b/src/lib/platform/OSXKeyState.cpp
@@ -337,26 +337,26 @@ OSXKeyState::fakeMediaKey(KeyID id)
CGEventFlags
OSXKeyState::getModifierStateAsOSXFlags()
{
- CGEventFlags modifiers = 0;
+ CGEventFlags modifiers = CGEventFlags(0);
if (m_shiftPressed) {
- modifiers |= kCGEventFlagMaskShift;
+ modifiers |= CGEventFlags(kCGEventFlagMaskShift);
}
if (m_controlPressed) {
- modifiers |= kCGEventFlagMaskControl;
+ modifiers |= CGEventFlags(kCGEventFlagMaskControl);
}
if (m_altPressed) {
- modifiers |= kCGEventFlagMaskAlternate;
+ modifiers |= CGEventFlags(kCGEventFlagMaskAlternate);
}
if (m_superPressed) {
- modifiers |= kCGEventFlagMaskCommand;
+ modifiers |= CGEventFlags(kCGEventFlagMaskCommand);
}
if (m_capsPressed) {
- modifiers |= kCGEventFlagMaskAlphaShift;
+ modifiers |= CGEventFlags(kCGEventFlagMaskAlphaShift);
}
return modifiers;
diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h
index bbddfb9..68c7c68 100644
--- a/src/lib/platform/OSXScreen.h
+++ b/src/lib/platform/OSXScreen.h
@@ -97,9 +97,9 @@ public:
virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const;
virtual void fakeDraggingFiles(DragFileList fileList);
- virtual String& getDraggingFilename();
+ virtual std::string& getDraggingFilename();
- const String& getDropTarget() const { return m_dropTarget; }
+ const std::string& getDropTarget() const { return m_dropTarget; }
void waitForCarbonLoop() const;
protected:
@@ -338,7 +338,7 @@ private:
IEventQueue* m_events;
Thread* m_getDropTargetThread;
- String m_dropTarget;
+ std::string m_dropTarget;
#if defined(MAC_OS_X_VERSION_10_7)
Mutex* m_carbonLoopMutex;
diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp
index b2c17f9..b0da695 100644
--- a/src/lib/platform/XWindowsClipboard.cpp
+++ b/src/lib/platform/XWindowsClipboard.cpp
@@ -170,7 +170,7 @@ XWindowsClipboard::addSimpleRequest(Window requestor,
}
// handle targets
- String data;
+ std::string data;
Atom type = None;
int format = 0;
if (target == m_atomTargets) {
@@ -303,8 +303,7 @@ XWindowsClipboard::empty()
return true;
}
-void
-XWindowsClipboard::add(EFormat format, const String& data)
+void XWindowsClipboard::add(EFormat format, const std::string& data)
{
assert(m_open);
assert(m_owner);
@@ -387,8 +386,7 @@ XWindowsClipboard::has(EFormat format) const
return m_added[format];
}
-String
-XWindowsClipboard::get(EFormat format) const
+std::string XWindowsClipboard::get(EFormat format) const
{
assert(m_open);
@@ -513,7 +511,7 @@ XWindowsClipboard::icccmFillCache()
// instead of the correct type ATOM; allow either.
const Atom atomTargets = m_atomTargets;
Atom target;
- String data;
+ std::string data;
if (!icccmGetSelection(atomTargets, &target, &data) ||
(target != m_atomAtom && target != m_atomTargets)) {
LOG((CLOG_DEBUG1 "selection doesn't support TARGETS"));
@@ -557,7 +555,7 @@ XWindowsClipboard::icccmFillCache()
// get the data
Atom actualTarget;
- String targetData;
+ std::string targetData;
if (!icccmGetSelection(target, &actualTarget, &targetData)) {
LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str()));
continue;
@@ -573,7 +571,7 @@ XWindowsClipboard::icccmFillCache()
bool
XWindowsClipboard::icccmGetSelection(Atom target,
- Atom* actualTarget, String* data) const
+ Atom* actualTarget, std::string* data) const
{
assert(actualTarget != NULL);
assert(data != NULL);
@@ -597,7 +595,7 @@ IClipboard::Time
XWindowsClipboard::icccmGetTime() const
{
Atom actualTarget;
- String data;
+ std::string data;
if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) &&
actualTarget == m_atomInteger) {
Time time = *reinterpret_cast<const Time*>(data.data());
@@ -668,7 +666,7 @@ XWindowsClipboard::motifOwnsClipboard() const
// get the Motif clipboard header property from the root window
Atom target;
SInt32 format;
- String data;
+ std::string data;
Window root = RootWindow(m_display, DefaultScreen(m_display));
if (!XWindowsUtil::getWindowProperty(m_display, root,
m_atomMotifClipHeader,
@@ -697,7 +695,7 @@ XWindowsClipboard::motifFillCache()
// get the Motif clipboard header property from the root window
Atom target;
SInt32 format;
- String data;
+ std::string data;
Window root = RootWindow(m_display, DefaultScreen(m_display));
if (!XWindowsUtil::getWindowProperty(m_display, root,
m_atomMotifClipHeader,
@@ -741,13 +739,13 @@ XWindowsClipboard::motifFillCache()
static_cast<const char*>(data.data()));
// get the available formats
- typedef std::map<Atom, String> MotifFormatMap;
+ typedef std::map<Atom, std::string> MotifFormatMap;
MotifFormatMap motifFormats;
for (SInt32 i = 0; i < numFormats; ++i) {
// get Motif format property from the root window
sprintf(name, "_MOTIF_CLIP_ITEM_%d", formats[i]);
Atom atomFormat = m_impl->XInternAtom(m_display, name, False);
- String data;
+ std::string data;
if (!XWindowsUtil::getWindowProperty(m_display, root,
atomFormat, &data,
&target, &format, False)) {
@@ -797,7 +795,7 @@ XWindowsClipboard::motifFillCache()
// get the data (finally)
Atom actualTarget;
- String targetData;
+ std::string targetData;
if (!motifGetSelection(&motifFormat, &actualTarget, &targetData)) {
LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str()));
continue;
@@ -813,7 +811,7 @@ XWindowsClipboard::motifFillCache()
bool
XWindowsClipboard::motifGetSelection(const MotifClipFormat* format,
- Atom* actualTarget, String* data) const
+ Atom* actualTarget, std::string* data) const
{
// if the current clipboard owner and the owner indicated by the
// motif clip header are the same then transfer via a property on
@@ -849,7 +847,7 @@ XWindowsClipboard::insertMultipleReply(Window requestor,
// get the requested targets
Atom target;
SInt32 format;
- String data;
+ std::string data;
if (!XWindowsUtil::getWindowProperty(m_display, requestor,
property, &data, &target, &format, False)) {
// can't get the requested targets
@@ -887,7 +885,7 @@ XWindowsClipboard::insertMultipleReply(Window requestor,
// add reply for MULTIPLE request
insertReply(new Reply(requestor, m_atomMultiple,
- time, property, String(), None, 32));
+ time, property, std::string(), None, 32));
return true;
}
@@ -1101,7 +1099,7 @@ XWindowsClipboard::sendReply(Reply* reply)
LOG((CLOG_DEBUG2 "properties of 0x%08x:", reply->m_requestor));
for (int i = 0; i < n; ++i) {
Atom target;
- String data;
+ std::string data;
char* name = m_impl->XGetAtomName(m_display, props[i]);
if (!XWindowsUtil::getWindowProperty(m_display,
reply->m_requestor,
@@ -1112,9 +1110,9 @@ XWindowsClipboard::sendReply(Reply* reply)
// if there are any non-ascii characters in string
// then print the binary data.
static const char* hex = "0123456789abcdef";
- for (String::size_type j = 0; j < data.size(); ++j) {
+ for (std::string::size_type j = 0; j < data.size(); ++j) {
if (data[j] < 32 || data[j] > 126) {
- String tmp;
+ std::string tmp;
tmp.reserve(data.size() * 3);
for (j = 0; j < data.size(); ++j) {
unsigned char v = (unsigned char)data[j];
@@ -1221,8 +1219,7 @@ XWindowsClipboard::wasOwnedAtTime(::Time time) const
return (/*when >= 0 &&*/ when <= duration);
}
-Atom
-XWindowsClipboard::getTargetsData(String& data, int* format) const
+Atom XWindowsClipboard::getTargetsData(std::string& data, int* format) const
{
assert(format != NULL);
@@ -1246,8 +1243,7 @@ XWindowsClipboard::getTargetsData(String& data, int* format) const
return m_atomAtom;
}
-Atom
-XWindowsClipboard::getTimestampData(String& data, int* format) const
+Atom XWindowsClipboard::getTimestampData(std::string& data, int* format) const
{
assert(format != NULL);
@@ -1285,7 +1281,7 @@ XWindowsClipboard::CICCCMGetClipboard::~CICCCMGetClipboard()
bool
XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display,
- Atom selection, Atom target, Atom* actualTarget, String* data)
+ Atom selection, Atom target, Atom* actualTarget, std::string* data)
{
assert(actualTarget != NULL);
assert(data != NULL);
@@ -1430,7 +1426,7 @@ XWindowsClipboard::CICCCMGetClipboard::processEvent(
// get the data from the property
Atom target;
- const String::size_type oldSize = m_data->size();
+ const std::string::size_type oldSize = m_data->size();
if (!XWindowsUtil::getWindowProperty(display, m_requestor,
m_property, m_data, &target, NULL, True)) {
// unable to read property
@@ -1515,7 +1511,7 @@ XWindowsClipboard::Reply::Reply(Window requestor, Atom target, ::Time time) :
}
XWindowsClipboard::Reply::Reply(Window requestor, Atom target, ::Time time,
- Atom property, const String& data, Atom type, int format) :
+ Atom property, const std::string& data, Atom type, int format) :
m_requestor(requestor),
m_target(target),
m_time(time),
diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h
index f00c3fc..091036e 100644
--- a/src/lib/platform/XWindowsClipboard.h
+++ b/src/lib/platform/XWindowsClipboard.h
@@ -90,12 +90,12 @@ public:
// IClipboard overrides
virtual bool empty();
- virtual void add(EFormat, const String& data);
+ virtual void add(EFormat, const std::string& data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
- virtual String get(EFormat) const;
+ virtual std::string get(EFormat) const;
private:
// remove all converters from our list
@@ -148,7 +148,7 @@ private:
// cannot be performed (in which case *actualTarget == None).
bool readClipboard(Display* display,
Atom selection, Atom target,
- Atom* actualTarget, String* data);
+ Atom* actualTarget, std::string* data);
private:
bool processEvent(Display* display, XEvent* event);
@@ -169,7 +169,7 @@ private:
bool m_reading;
// the converted selection data
- String* m_data;
+ std::string* m_data;
// the actual type of the data. if this is None then the
// selection owner cannot convert to the requested type.
@@ -224,8 +224,8 @@ private:
class Reply {
public:
Reply(Window, Atom target, ::Time);
- Reply(Window, Atom target, ::Time, Atom property,
- const String& data, Atom type, int format);
+ Reply(Window, Atom target, ::Time, Atom property, const std::string& data,
+ Atom type, int format);
public:
// information about the request
@@ -241,7 +241,7 @@ private:
bool m_done;
// the data to send and its type and format
- String m_data;
+ std::string m_data;
Atom m_type;
int m_format;
@@ -254,8 +254,7 @@ private:
// ICCCM interoperability methods
void icccmFillCache();
- bool icccmGetSelection(Atom target,
- Atom* actualTarget, String* data) const;
+ bool icccmGetSelection(Atom target, Atom* actualTarget, std::string* data) const;
Time icccmGetTime() const;
// motif interoperability methods
@@ -263,8 +262,7 @@ private:
void motifUnlockClipboard() const;
bool motifOwnsClipboard() const;
void motifFillCache();
- bool motifGetSelection(const MotifClipFormat*,
- Atom* actualTarget, String* data) const;
+ bool motifGetSelection(const MotifClipFormat*, Atom* actualTarget, std::string* data) const;
Time motifGetTime() const;
// reply methods
@@ -281,8 +279,8 @@ private:
bool wasOwnedAtTime(::Time) const;
// data conversion methods
- Atom getTargetsData(String&, int* format) const;
- Atom getTimestampData(String&, int* format) const;
+ Atom getTargetsData(std::string&, int* format) const;
+ Atom getTimestampData(std::string&, int* format) const;
private:
typedef std::vector<IXWindowsClipboardConverter*> ConverterList;
@@ -306,7 +304,7 @@ private:
bool m_cached;
Time m_cacheTime;
bool m_added[kNumFormats];
- String m_data[kNumFormats];
+ std::string m_data[kNumFormats];
// conversion request replies
ReplyMap m_replies;
@@ -368,14 +366,14 @@ public:
getFormat(). The return data will be in the X selection
format returned by getAtom().
*/
- virtual String fromIClipboard(const String&) const = 0;
+ virtual std::string fromIClipboard(const std::string&) const = 0;
//! Convert to IClipboard format
/*!
Convert from the X selection format to the IClipboard format
(i.e., the reverse of fromIClipboard()).
*/
- virtual String toIClipboard(const String&) const = 0;
+ virtual std::string toIClipboard(const std::string&) const = 0;
//@}
};
diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp
index 493b1e8..f6fed1c 100644
--- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp
+++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp
@@ -122,8 +122,7 @@ XWindowsClipboardAnyBitmapConverter::getDataSize() const
return 8;
}
-String
-XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const
+std::string XWindowsClipboardAnyBitmapConverter::fromIClipboard(const std::string& bmp) const
{
// fill BMP info header with native-endian data
CBMPInfoHeader infoHeader;
@@ -145,7 +144,7 @@ XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const
infoHeader.biWidth == 0 || infoHeader.biHeight == 0 ||
infoHeader.biPlanes != 0 || infoHeader.biCompression != 0 ||
(infoHeader.biBitCount != 24 && infoHeader.biBitCount != 32)) {
- return String();
+ return {};
}
// convert to image format
@@ -160,14 +159,13 @@ XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const
}
}
-String
-XWindowsClipboardAnyBitmapConverter::toIClipboard(const String& image) const
+std::string XWindowsClipboardAnyBitmapConverter::toIClipboard(const std::string& image) const
{
// convert to raw BMP data
UInt32 w, h, depth;
- String rawBMP = doToIClipboard(image, w, h, depth);
+ std::string rawBMP = doToIClipboard(image, w, h, depth);
if (rawBMP.empty() || w == 0 || h == 0 || (depth != 24 && depth != 32)) {
- return String();
+ return {};
}
// fill BMP info header with little-endian data
@@ -186,6 +184,6 @@ XWindowsClipboardAnyBitmapConverter::toIClipboard(const String& image) const
toLE(dst, static_cast<UInt32>(0));
// construct image
- return String(reinterpret_cast<const char*>(infoHeader),
- sizeof(infoHeader)) + rawBMP;
+ return std::string(reinterpret_cast<const char*>(infoHeader),
+ sizeof(infoHeader)) + rawBMP;
}
diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h
index d723a33..861b1b6 100644
--- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h
+++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h
@@ -32,29 +32,27 @@ public:
getFormat() const;
virtual Atom getAtom() const = 0;
virtual int getDataSize() const;
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
protected:
//! Convert from IClipboard format
/*!
Convert raw BGR pixel data to another image format.
*/
- virtual String doBGRFromIClipboard(const UInt8* bgrData,
- UInt32 w, UInt32 h) const = 0;
+ virtual std::string doBGRFromIClipboard(const UInt8* bgrData, UInt32 w, UInt32 h) const = 0;
//! Convert from IClipboard format
/*!
Convert raw BGRA pixel data to another image format.
*/
- virtual String doBGRAFromIClipboard(const UInt8* bgrData,
- UInt32 w, UInt32 h) const = 0;
+ virtual std::string doBGRAFromIClipboard(const UInt8* bgrData, UInt32 w, UInt32 h) const = 0;
//! Convert to IClipboard format
/*!
Convert an image into raw BGR or BGRA image data and store the
width, height, and image depth (24 or 32).
*/
- virtual String doToIClipboard(const String&,
- UInt32& w, UInt32& h, UInt32& depth) const = 0;
+ virtual std::string doToIClipboard(const std::string&, UInt32& w, UInt32& h,
+ UInt32& depth) const = 0;
};
diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.cpp b/src/lib/platform/XWindowsClipboardBMPConverter.cpp
index b4def5b..fcfdc69 100644
--- a/src/lib/platform/XWindowsClipboardBMPConverter.cpp
+++ b/src/lib/platform/XWindowsClipboardBMPConverter.cpp
@@ -101,8 +101,7 @@ XWindowsClipboardBMPConverter::getDataSize() const
return 8;
}
-String
-XWindowsClipboardBMPConverter::fromIClipboard(const String& bmp) const
+std::string XWindowsClipboardBMPConverter::fromIClipboard(const std::string& bmp) const
{
// create BMP image
UInt8 header[14];
@@ -113,21 +112,20 @@ XWindowsClipboardBMPConverter::fromIClipboard(const String& bmp) const
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt32>(14 + 40));
- return String(reinterpret_cast<const char*>(header), 14) + bmp;
+ return std::string(reinterpret_cast<const char*>(header), 14) + bmp;
}
-String
-XWindowsClipboardBMPConverter::toIClipboard(const String& bmp) const
+std::string XWindowsClipboardBMPConverter::toIClipboard(const std::string& bmp) const
{
// make sure data is big enough for a BMP file
if (bmp.size() <= 14 + 40) {
- return String();
+ return {};
}
// check BMP file header
const UInt8* rawBMPHeader = reinterpret_cast<const UInt8*>(bmp.data());
if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') {
- return String();
+ return {};
}
// get offset to image data
diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.h b/src/lib/platform/XWindowsClipboardBMPConverter.h
index d7813a0..4afa788 100644
--- a/src/lib/platform/XWindowsClipboardBMPConverter.h
+++ b/src/lib/platform/XWindowsClipboardBMPConverter.h
@@ -32,8 +32,8 @@ public:
getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
private:
Atom m_atom;
diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp
index 32db724..6ae98a7 100644
--- a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp
+++ b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp
@@ -54,14 +54,12 @@ XWindowsClipboardHTMLConverter::getDataSize() const
return 8;
}
-String
-XWindowsClipboardHTMLConverter::fromIClipboard(const String& data) const
+std::string XWindowsClipboardHTMLConverter::fromIClipboard(const std::string& data) const
{
return Unicode::UTF8ToUTF16(data);
}
-String
-XWindowsClipboardHTMLConverter::toIClipboard(const String& data) const
+std::string XWindowsClipboardHTMLConverter::toIClipboard(const std::string& data) const
{
return Unicode::UTF16ToUTF8(data);
}
diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.h b/src/lib/platform/XWindowsClipboardHTMLConverter.h
index 013aa99..9a4ce61 100644
--- a/src/lib/platform/XWindowsClipboardHTMLConverter.h
+++ b/src/lib/platform/XWindowsClipboardHTMLConverter.h
@@ -34,8 +34,8 @@ public:
getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
private:
Atom m_atom;
diff --git a/src/lib/platform/XWindowsClipboardTextConverter.cpp b/src/lib/platform/XWindowsClipboardTextConverter.cpp
index 71b7a84..2e18d91 100644
--- a/src/lib/platform/XWindowsClipboardTextConverter.cpp
+++ b/src/lib/platform/XWindowsClipboardTextConverter.cpp
@@ -54,18 +54,16 @@ XWindowsClipboardTextConverter::getDataSize() const
return 8;
}
-String
-XWindowsClipboardTextConverter::fromIClipboard(const String& data) const
+std::string XWindowsClipboardTextConverter::fromIClipboard(const std::string& data) const
{
return Unicode::UTF8ToText(data);
}
-String
-XWindowsClipboardTextConverter::toIClipboard(const String& data) const
+std::string XWindowsClipboardTextConverter::toIClipboard(const std::string& data) const
{
// convert to UTF-8
bool errors;
- String utf8 = Unicode::textToUTF8(data, &errors);
+ std::string utf8 = Unicode::textToUTF8(data, &errors);
// if there were decoding errors then, to support old applications
// that don't understand UTF-8 but can report the exact binary
diff --git a/src/lib/platform/XWindowsClipboardTextConverter.h b/src/lib/platform/XWindowsClipboardTextConverter.h
index 0e6d598..99cdbcb 100644
--- a/src/lib/platform/XWindowsClipboardTextConverter.h
+++ b/src/lib/platform/XWindowsClipboardTextConverter.h
@@ -34,8 +34,8 @@ public:
getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
private:
Atom m_atom;
diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp
index 988b909..d3d5e04 100644
--- a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp
+++ b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp
@@ -54,14 +54,12 @@ XWindowsClipboardUCS2Converter::getDataSize() const
return 16;
}
-String
-XWindowsClipboardUCS2Converter::fromIClipboard(const String& data) const
+std::string XWindowsClipboardUCS2Converter::fromIClipboard(const std::string& data) const
{
return Unicode::UTF8ToUCS2(data);
}
-String
-XWindowsClipboardUCS2Converter::toIClipboard(const String& data) const
+std::string XWindowsClipboardUCS2Converter::toIClipboard(const std::string& data) const
{
return Unicode::UCS2ToUTF8(data);
}
diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.h b/src/lib/platform/XWindowsClipboardUCS2Converter.h
index 6491408..16d880a 100644
--- a/src/lib/platform/XWindowsClipboardUCS2Converter.h
+++ b/src/lib/platform/XWindowsClipboardUCS2Converter.h
@@ -34,8 +34,8 @@ public:
getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
private:
Atom m_atom;
diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp
index 0e43cce..f470cf1 100644
--- a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp
+++ b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp
@@ -52,14 +52,12 @@ XWindowsClipboardUTF8Converter::getDataSize() const
return 8;
}
-String
-XWindowsClipboardUTF8Converter::fromIClipboard(const String& data) const
+std::string XWindowsClipboardUTF8Converter::fromIClipboard(const std::string& data) const
{
return data;
}
-String
-XWindowsClipboardUTF8Converter::toIClipboard(const String& data) const
+std::string XWindowsClipboardUTF8Converter::toIClipboard(const std::string& data) const
{
return data;
}
diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.h b/src/lib/platform/XWindowsClipboardUTF8Converter.h
index e3eeca0..2219ed2 100644
--- a/src/lib/platform/XWindowsClipboardUTF8Converter.h
+++ b/src/lib/platform/XWindowsClipboardUTF8Converter.h
@@ -34,8 +34,8 @@ public:
getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
- virtual String fromIClipboard(const String&) const;
- virtual String toIClipboard(const String&) const;
+ virtual std::string fromIClipboard(const std::string&) const;
+ virtual std::string toIClipboard(const std::string&) const;
private:
Atom m_atom;
diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp
index 78f0e5a..8b8c3b5 100644
--- a/src/lib/platform/XWindowsEventQueueBuffer.cpp
+++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp
@@ -82,6 +82,19 @@ XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer()
close(m_pipefd[1]);
}
+int XWindowsEventQueueBuffer::getPendingCountLocked()
+{
+ Lock lock(&m_mutex);
+ // work around a bug in old libx11 which causes the first XPending not to read events under
+ // certain conditions. The issue happens when libx11 has not yet received replies for all
+ // flushed events. In that case, internally XPending will not try to process received events
+ // as the reply for the last event was not found. As a result, XPending will return the number
+ // of pending events without regard to the events it has just read.
+ // https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/1 fixes this on libx11 side.
+ m_impl->XPending(m_display);
+ return m_impl->XPending(m_display);
+}
+
void
XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
{
@@ -163,7 +176,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
// we want to give the cpu a chance s owe up this to 25ms
#define TIMEOUT_DELAY 25
- while (((dtimeout < 0.0) || (remaining > 0)) && QLength(m_display)==0 && retval==0){
+ while (((dtimeout < 0.0) || (remaining > 0)) && getPendingCountLocked() == 0 && retval == 0) {
#if HAVE_POLL
retval = poll(pfds, 2, TIMEOUT_DELAY); //16ms = 60hz, but we make it > to play nicely with the cpu
if (pfds[1].revents & POLLIN) {
diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h
index e49b282..13f6b16 100644
--- a/src/lib/platform/XWindowsEventQueueBuffer.h
+++ b/src/lib/platform/XWindowsEventQueueBuffer.h
@@ -51,6 +51,8 @@ public:
private:
void flush();
+ int getPendingCountLocked();
+
private:
typedef std::vector<XEvent> EventList;
IXWindowsImpl* m_impl;
diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp
index 37fd5e8..9fb71ca 100644
--- a/src/lib/platform/XWindowsKeyState.cpp
+++ b/src/lib/platform/XWindowsKeyState.cpp
@@ -20,7 +20,6 @@
#include "platform/XWindowsUtil.h"
#include "base/Log.h"
-#include "base/String.h"
#include "common/stdmap.h"
#include <cstddef>
diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h
index f42f7ac..f790390 100644
--- a/src/lib/platform/XWindowsKeyState.h
+++ b/src/lib/platform/XWindowsKeyState.h
@@ -173,6 +173,6 @@ private:
public:
SInt32 group() const { return m_group; }
void group(const SInt32& group) { m_group = group; }
- KeyModifierMaskList modifierFromX() const { return m_modifierFromX; }
+ KeyModifierMaskList& modifierFromX() { return m_modifierFromX; }
#endif
};
diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp
index e5db1a3..5f1724c 100644
--- a/src/lib/platform/XWindowsScreen.cpp
+++ b/src/lib/platform/XWindowsScreen.cpp
@@ -30,7 +30,6 @@
#include "arch/Arch.h"
#include "base/Log.h"
#include "base/Stopwatch.h"
-#include "base/String.h"
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
diff --git a/src/lib/platform/XWindowsUtil.cpp b/src/lib/platform/XWindowsUtil.cpp
index 65448e8..3c90bd6 100644
--- a/src/lib/platform/XWindowsUtil.cpp
+++ b/src/lib/platform/XWindowsUtil.cpp
@@ -1294,7 +1294,7 @@ XWindowsUtil::KeySymMap XWindowsUtil::s_keySymToUCS4;
bool
XWindowsUtil::getWindowProperty(Display* display, Window window,
- Atom property, String* data, Atom* type,
+ Atom property, std::string* data, Atom* type,
SInt32* format, bool deleteProperty)
{
assert(display != NULL);
@@ -1608,8 +1608,7 @@ XWindowsUtil::getModifierBitForKeySym(KeySym keysym)
}
}
-String
-XWindowsUtil::atomToString(Display* display, Atom atom)
+std::string XWindowsUtil::atomToString(Display* display, Atom atom)
{
if (atom == 0) {
return "None";
@@ -1622,20 +1621,19 @@ XWindowsUtil::atomToString(Display* display, Atom atom)
return barrier::string::sprintf("<UNKNOWN> (%d)", (int)atom);
}
else {
- String msg = barrier::string::sprintf("%s (%d)", name, (int)atom);
+ std::string msg = barrier::string::sprintf("%s (%d)", name, (int)atom);
XFree(name);
return msg;
}
}
-String
-XWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num)
+std::string XWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num)
{
char** names = new char*[num];
bool error = false;
XWindowsUtil::ErrorLock lock(display, &error);
XGetAtomNames(display, const_cast<Atom*>(atom), (int)num, names);
- String msg;
+ std::string msg;
if (error) {
for (UInt32 i = 0; i < num; ++i) {
msg += barrier::string::sprintf("<UNKNOWN> (%d), ", (int)atom[i]);
@@ -1654,8 +1652,7 @@ XWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num)
return msg;
}
-void
-XWindowsUtil::convertAtomProperty(String& data)
+void XWindowsUtil::convertAtomProperty(std::string& data)
{
// as best i can tell, 64-bit systems don't pack Atoms into properties
// as 32-bit numbers but rather as the 64-bit numbers they are. that
@@ -1669,22 +1666,19 @@ XWindowsUtil::convertAtomProperty(String& data)
}
}
-void
-XWindowsUtil::appendAtomData(String& data, Atom atom)
+void XWindowsUtil::appendAtomData(std::string& data, Atom atom)
{
data.append(reinterpret_cast<char*>(&atom), sizeof(Atom));
}
-void
-XWindowsUtil::replaceAtomData(String& data, UInt32 index, Atom atom)
+void XWindowsUtil::replaceAtomData(std::string& data, UInt32 index, Atom atom)
{
data.replace(index * sizeof(Atom), sizeof(Atom),
reinterpret_cast<const char*>(&atom),
sizeof(Atom));
}
-void
-XWindowsUtil::appendTimeData(String& data, Time time)
+void XWindowsUtil::appendTimeData(std::string& data, Time time)
{
data.append(reinterpret_cast<char*>(&time), sizeof(Time));
}
diff --git a/src/lib/platform/XWindowsUtil.h b/src/lib/platform/XWindowsUtil.h
index 4df888f..f5b3ea8 100644
--- a/src/lib/platform/XWindowsUtil.h
+++ b/src/lib/platform/XWindowsUtil.h
@@ -18,7 +18,6 @@
#pragma once
-#include "base/String.h"
#include "base/EventTypes.h"
#include "common/stdmap.h"
#include "common/stdvector.h"
@@ -29,6 +28,8 @@
# include <X11/Xlib.h>
#endif
+#include <string>
+
//! X11 utility functions
class XWindowsUtil {
public:
@@ -42,10 +43,9 @@ public:
if \c format is not NULL. If \c deleteProperty is true then the
property is deleted after being read.
*/
- static bool getWindowProperty(Display*,
- Window window, Atom property,
- String* data, Atom* type,
- SInt32* format, bool deleteProperty);
+ static bool getWindowProperty(Display*, Window window, Atom property,
+ std::string* data, Atom* type,
+ SInt32* format, bool deleteProperty);
//! Set property
/*!
@@ -81,44 +81,42 @@ public:
/*!
Converts \p atom to its string representation.
*/
- static String atomToString(Display*, Atom atom);
+ static std::string atomToString(Display*, Atom atom);
//! Convert several Atoms to a string
/*!
Converts each atom in \p atoms to its string representation and
concatenates the results.
*/
- static String atomsToString(Display* display,
- const Atom* atom, UInt32 num);
+ static std::string atomsToString(Display* display, const Atom* atom, UInt32 num);
//! Prepare a property of atoms for use
/*!
64-bit systems may need to modify a property's data if it's a
list of Atoms before using it.
*/
- static void convertAtomProperty(String& data);
+ static void convertAtomProperty(std::string& data);
//! Append an Atom to property data
/*!
Converts \p atom to a 32-bit on-the-wire format and appends it to
\p data.
*/
- static void appendAtomData(String& data, Atom atom);
+ static void appendAtomData(std::string& data, Atom atom);
//! Replace an Atom in property data
/*!
Converts \p atom to a 32-bit on-the-wire format and replaces the atom
at index \p index in \p data.
*/
- static void replaceAtomData(String& data,
- UInt32 index, Atom atom);
+ static void replaceAtomData(std::string& data, UInt32 index, Atom atom);
//! Append an Time to property data
/*!
Converts \p time to a 32-bit on-the-wire format and appends it to
\p data.
*/
- static void appendTimeData(String& data, Time time);
+ static void appendTimeData(std::string& data, Time time);
//! X11 error handler
/*!
diff --git a/src/lib/server/BaseClientProxy.cpp b/src/lib/server/BaseClientProxy.cpp
index b9c5339..6ccd251 100644
--- a/src/lib/server/BaseClientProxy.cpp
+++ b/src/lib/server/BaseClientProxy.cpp
@@ -22,7 +22,7 @@
// BaseClientProxy
//
-BaseClientProxy::BaseClientProxy(const String& name) :
+BaseClientProxy::BaseClientProxy(const std::string& name) :
m_name(name),
m_x(0),
m_y(0)
@@ -49,8 +49,7 @@ BaseClientProxy::getJumpCursorPos(SInt32& x, SInt32& y) const
y = m_y;
}
-String
-BaseClientProxy::getName() const
+std::string BaseClientProxy::getName() const
{
return m_name;
}
diff --git a/src/lib/server/BaseClientProxy.h b/src/lib/server/BaseClientProxy.h
index c7c23ff..a2c9459 100644
--- a/src/lib/server/BaseClientProxy.h
+++ b/src/lib/server/BaseClientProxy.h
@@ -19,7 +19,6 @@
#pragma once
#include "barrier/IClient.h"
-#include "base/String.h"
namespace barrier { class IStream; }
@@ -29,7 +28,7 @@ public:
/*!
\c name is the name of the client.
*/
- BaseClientProxy(const String& name);
+ BaseClientProxy(const std::string& name);
~BaseClientProxy();
//! @name manipulators
@@ -89,11 +88,11 @@ public:
virtual void sendDragInfo(UInt32 fileCount, const char* info,
size_t size) = 0;
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize) = 0;
- virtual String getName() const;
+ virtual std::string getName() const;
virtual barrier::IStream*
getStream() const = 0;
private:
- String m_name;
+ std::string m_name;
SInt32 m_x, m_y;
};
diff --git a/src/lib/server/ClientProxy.cpp b/src/lib/server/ClientProxy.cpp
index 5a28248..d91e186 100644
--- a/src/lib/server/ClientProxy.cpp
+++ b/src/lib/server/ClientProxy.cpp
@@ -27,7 +27,7 @@
// ClientProxy
//
-ClientProxy::ClientProxy(const String& name, barrier::IStream* stream) :
+ClientProxy::ClientProxy(const std::string& name, barrier::IStream* stream) :
BaseClientProxy(name),
m_stream(stream)
{
diff --git a/src/lib/server/ClientProxy.h b/src/lib/server/ClientProxy.h
index 726ded4..a3d87cb 100644
--- a/src/lib/server/ClientProxy.h
+++ b/src/lib/server/ClientProxy.h
@@ -20,7 +20,6 @@
#include "server/BaseClientProxy.h"
#include "base/Event.h"
-#include "base/String.h"
#include "base/EventTypes.h"
namespace barrier { class IStream; }
@@ -31,7 +30,7 @@ public:
/*!
\c name is the name of the client.
*/
- ClientProxy(const String& name, barrier::IStream* adoptedStream);
+ ClientProxy(const std::string& name, barrier::IStream* adoptedStream);
~ClientProxy();
//! @name manipulators
diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp
index ee805c6..5cbaac2 100644
--- a/src/lib/server/ClientProxy1_0.cpp
+++ b/src/lib/server/ClientProxy1_0.cpp
@@ -31,7 +31,8 @@
// ClientProxy1_0
//
-ClientProxy1_0::ClientProxy1_0(const String& name, barrier::IStream* stream, IEventQueue* events) :
+ClientProxy1_0::ClientProxy1_0(const std::string& name, barrier::IStream* stream,
+ IEventQueue* events) :
ClientProxy(name, stream),
m_heartbeatTimer(NULL),
m_parser(&ClientProxy1_0::parseHandshakeMessage),
diff --git a/src/lib/server/ClientProxy1_0.h b/src/lib/server/ClientProxy1_0.h
index 0720232..98c68f3 100644
--- a/src/lib/server/ClientProxy1_0.h
+++ b/src/lib/server/ClientProxy1_0.h
@@ -29,7 +29,7 @@ class IEventQueue;
//! Proxy for client implementing protocol version 1.0
class ClientProxy1_0 : public ClientProxy {
public:
- ClientProxy1_0(const String& name, barrier::IStream* adoptedStream, IEventQueue* events);
+ ClientProxy1_0(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events);
~ClientProxy1_0();
// IScreen
diff --git a/src/lib/server/ClientProxy1_1.cpp b/src/lib/server/ClientProxy1_1.cpp
index b7eb4c4..bb33ac1 100644
--- a/src/lib/server/ClientProxy1_1.cpp
+++ b/src/lib/server/ClientProxy1_1.cpp
@@ -27,7 +27,8 @@
// ClientProxy1_1
//
-ClientProxy1_1::ClientProxy1_1(const String& name, barrier::IStream* stream, IEventQueue* events) :
+ClientProxy1_1::ClientProxy1_1(const std::string& name, barrier::IStream* stream,
+ IEventQueue* events) :
ClientProxy1_0(name, stream, events)
{
// do nothing
diff --git a/src/lib/server/ClientProxy1_1.h b/src/lib/server/ClientProxy1_1.h
index cdb674d..ada4dcc 100644
--- a/src/lib/server/ClientProxy1_1.h
+++ b/src/lib/server/ClientProxy1_1.h
@@ -23,7 +23,7 @@
//! Proxy for client implementing protocol version 1.1
class ClientProxy1_1 : public ClientProxy1_0 {
public:
- ClientProxy1_1(const String& name, barrier::IStream* adoptedStream, IEventQueue* events);
+ ClientProxy1_1(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events);
~ClientProxy1_1();
// IClient overrides
diff --git a/src/lib/server/ClientProxy1_2.cpp b/src/lib/server/ClientProxy1_2.cpp
index 2dd13cf..e9527ef 100644
--- a/src/lib/server/ClientProxy1_2.cpp
+++ b/src/lib/server/ClientProxy1_2.cpp
@@ -25,7 +25,8 @@
// ClientProxy1_1
//
-ClientProxy1_2::ClientProxy1_2(const String& name, barrier::IStream* stream, IEventQueue* events) :
+ClientProxy1_2::ClientProxy1_2(const std::string& name, barrier::IStream* stream,
+ IEventQueue* events) :
ClientProxy1_1(name, stream, events)
{
// do nothing
diff --git a/src/lib/server/ClientProxy1_2.h b/src/lib/server/ClientProxy1_2.h
index f6ffe94..12d6b92 100644
--- a/src/lib/server/ClientProxy1_2.h
+++ b/src/lib/server/ClientProxy1_2.h
@@ -25,7 +25,7 @@ class IEventQueue;
//! Proxy for client implementing protocol version 1.2
class ClientProxy1_2 : public ClientProxy1_1 {
public:
- ClientProxy1_2(const String& name, barrier::IStream* adoptedStream, IEventQueue* events);
+ ClientProxy1_2(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events);
~ClientProxy1_2();
// IClient overrides
diff --git a/src/lib/server/ClientProxy1_3.cpp b/src/lib/server/ClientProxy1_3.cpp
index 34ea0c8..d0031ce 100644
--- a/src/lib/server/ClientProxy1_3.cpp
+++ b/src/lib/server/ClientProxy1_3.cpp
@@ -30,7 +30,8 @@
// ClientProxy1_3
//
-ClientProxy1_3::ClientProxy1_3(const String& name, barrier::IStream* stream, IEventQueue* events) :
+ClientProxy1_3::ClientProxy1_3(const std::string& name, barrier::IStream* stream,
+ IEventQueue* events) :
ClientProxy1_2(name, stream, events),
m_keepAliveRate(kKeepAliveRate),
m_keepAliveTimer(NULL),
diff --git a/src/lib/server/ClientProxy1_3.h b/src/lib/server/ClientProxy1_3.h
index ff2ed0a..ad46cea 100644
--- a/src/lib/server/ClientProxy1_3.h
+++ b/src/lib/server/ClientProxy1_3.h
@@ -23,7 +23,7 @@
//! Proxy for client implementing protocol version 1.3
class ClientProxy1_3 : public ClientProxy1_2 {
public:
- ClientProxy1_3(const String& name, barrier::IStream* adoptedStream, IEventQueue* events);
+ ClientProxy1_3(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events);
~ClientProxy1_3();
// IClient overrides
diff --git a/src/lib/server/ClientProxy1_4.cpp b/src/lib/server/ClientProxy1_4.cpp
index 43c708d..9b12976 100644
--- a/src/lib/server/ClientProxy1_4.cpp
+++ b/src/lib/server/ClientProxy1_4.cpp
@@ -31,7 +31,8 @@
// ClientProxy1_4
//
-ClientProxy1_4::ClientProxy1_4(const String& name, barrier::IStream* stream, Server* server, IEventQueue* events) :
+ClientProxy1_4::ClientProxy1_4(const std::string& name, barrier::IStream* stream, Server* server,
+ IEventQueue* events) :
ClientProxy1_3(name, stream, events), m_server(server)
{
assert(m_server != NULL);
diff --git a/src/lib/server/ClientProxy1_4.h b/src/lib/server/ClientProxy1_4.h
index 6c55965..cda090b 100644
--- a/src/lib/server/ClientProxy1_4.h
+++ b/src/lib/server/ClientProxy1_4.h
@@ -25,7 +25,8 @@ class Server;
//! Proxy for client implementing protocol version 1.4
class ClientProxy1_4 : public ClientProxy1_3 {
public:
- ClientProxy1_4(const String& name, barrier::IStream* adoptedStream, Server* server, IEventQueue* events);
+ ClientProxy1_4(const std::string& name, barrier::IStream* adoptedStream, Server* server,
+ IEventQueue* events);
~ClientProxy1_4();
//! @name accessors
diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp
index 43fd0b7..40bba08 100644
--- a/src/lib/server/ClientProxy1_5.cpp
+++ b/src/lib/server/ClientProxy1_5.cpp
@@ -31,7 +31,8 @@
// ClientProxy1_5
//
-ClientProxy1_5::ClientProxy1_5(const String& name, barrier::IStream* stream, Server* server, IEventQueue* events) :
+ClientProxy1_5::ClientProxy1_5(const std::string& name, barrier::IStream* stream, Server* server,
+ IEventQueue* events) :
ClientProxy1_4(name, stream, server, events),
m_events(events)
{
@@ -50,7 +51,7 @@ ClientProxy1_5::~ClientProxy1_5()
void
ClientProxy1_5::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
{
- String data(info, size);
+ std::string data(info, size);
ProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &data);
}
@@ -92,7 +93,7 @@ ClientProxy1_5::fileChunkReceived()
}
else if (result == kStart) {
if (server->getFakeDragFileList().size() > 0) {
- String filename = server->getFakeDragFileList().at(0).getFilename();
+ std::string filename = server->getFakeDragFileList().at(0).getFilename();
LOG((CLOG_DEBUG "start receiving %s", filename.c_str()));
}
}
@@ -103,7 +104,7 @@ ClientProxy1_5::dragInfoReceived()
{
// parse
UInt32 fileNum = 0;
- String content;
+ std::string content;
ProtocolUtil::readf(getStream(), kMsgDDragInfo + 4, &fileNum, &content);
m_server->dragInfoReceived(fileNum, content);
diff --git a/src/lib/server/ClientProxy1_5.h b/src/lib/server/ClientProxy1_5.h
index 776de03..4087730 100644
--- a/src/lib/server/ClientProxy1_5.h
+++ b/src/lib/server/ClientProxy1_5.h
@@ -27,7 +27,8 @@ class IEventQueue;
//! Proxy for client implementing protocol version 1.5
class ClientProxy1_5 : public ClientProxy1_4 {
public:
- ClientProxy1_5(const String& name, barrier::IStream* adoptedStream, Server* server, IEventQueue* events);
+ ClientProxy1_5(const std::string& name, barrier::IStream* adoptedStream, Server* server,
+ IEventQueue* events);
~ClientProxy1_5();
virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp
index a0d2621..c829e84 100644
--- a/src/lib/server/ClientProxy1_6.cpp
+++ b/src/lib/server/ClientProxy1_6.cpp
@@ -29,7 +29,8 @@
// ClientProxy1_6
//
-ClientProxy1_6::ClientProxy1_6(const String& name, barrier::IStream* stream, Server* server, IEventQueue* events) :
+ClientProxy1_6::ClientProxy1_6(const std::string& name, barrier::IStream* stream, Server* server,
+ IEventQueue* events) :
ClientProxy1_5(name, stream, server, events),
m_events(events)
{
@@ -52,7 +53,7 @@ ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard* clipboard)
m_clipboard[id].m_dirty = false;
Clipboard::copy(&m_clipboard[id].m_clipboard, clipboard);
- String data = m_clipboard[id].m_clipboard.marshall();
+ std::string data = m_clipboard[id].m_clipboard.marshall();
size_t size = data.size();
LOG((CLOG_DEBUG "sending clipboard %d to \"%s\"", id, getName().c_str()));
@@ -71,7 +72,7 @@ bool
ClientProxy1_6::recvClipboard()
{
// parse message
- static String dataCached;
+ static std::string dataCached;
ClipboardID id;
UInt32 seq;
diff --git a/src/lib/server/ClientProxy1_6.h b/src/lib/server/ClientProxy1_6.h
index 838cb02..830696a 100644
--- a/src/lib/server/ClientProxy1_6.h
+++ b/src/lib/server/ClientProxy1_6.h
@@ -25,7 +25,8 @@ class IEventQueue;
//! Proxy for client implementing protocol version 1.6
class ClientProxy1_6 : public ClientProxy1_5 {
public:
- ClientProxy1_6(const String& name, barrier::IStream* adoptedStream, Server* server, IEventQueue* events);
+ ClientProxy1_6(const std::string& name, barrier::IStream* adoptedStream, Server* server,
+ IEventQueue* events);
~ClientProxy1_6();
virtual void setClipboard(ClipboardID id, const IClipboard* clipboard);
diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp
index f929108..dc79da7 100644
--- a/src/lib/server/ClientProxyUnknown.cpp
+++ b/src/lib/server/ClientProxyUnknown.cpp
@@ -32,7 +32,6 @@
#include "io/IStream.h"
#include "io/XIO.h"
#include "base/Log.h"
-#include "base/String.h"
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
@@ -176,7 +175,7 @@ ClientProxyUnknown::handleData(const Event&, void*)
{
LOG((CLOG_DEBUG1 "parsing hello reply"));
- String name("<unknown>");
+ std::string name("<unknown>");
try {
// limit the maximum length of the hello
UInt32 n = m_stream->getSize();
diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp
index 3cf60a5..a47a391 100644
--- a/src/lib/server/Config.cpp
+++ b/src/lib/server/Config.cpp
@@ -48,7 +48,7 @@ Config::~Config()
}
bool
-Config::addScreen(const String& name)
+Config::addScreen(const std::string& name)
{
// alias name must not exist
if (m_nameToCanonicalName.find(name) != m_nameToCanonicalName.end()) {
@@ -64,12 +64,10 @@ Config::addScreen(const String& name)
return true;
}
-bool
-Config::renameScreen(const String& oldName,
- const String& newName)
+bool Config::renameScreen(const std::string& oldName, const std::string& newName)
{
// get canonical name and find cell
- String oldCanonical = getCanonicalName(oldName);
+ std::string oldCanonical = getCanonicalName(oldName);
CellMap::iterator index = m_map.find(oldCanonical);
if (index == m_map.end()) {
return false;
@@ -111,11 +109,10 @@ Config::renameScreen(const String& oldName,
return true;
}
-void
-Config::removeScreen(const String& name)
+void Config::removeScreen(const std::string& name)
{
// get canonical name and find cell
- String canonical = getCanonicalName(name);
+ std::string canonical = getCanonicalName(name);
CellMap::iterator index = m_map.find(canonical);
if (index == m_map.end()) {
return;
@@ -149,8 +146,7 @@ Config::removeAllScreens()
m_nameToCanonicalName.clear();
}
-bool
-Config::addAlias(const String& canonical, const String& alias)
+bool Config::addAlias(const std::string& canonical, const std::string& alias)
{
// alias name must not exist
if (m_nameToCanonicalName.find(alias) != m_nameToCanonicalName.end()) {
@@ -168,8 +164,7 @@ Config::addAlias(const String& canonical, const String& alias)
return true;
}
-bool
-Config::removeAlias(const String& alias)
+bool Config::removeAlias(const std::string& alias)
{
// must not be a canonical name
if (m_map.find(alias) != m_map.end()) {
@@ -188,8 +183,7 @@ Config::removeAlias(const String& alias)
return true;
}
-bool
-Config::removeAliases(const String& canonical)
+bool Config::removeAliases(const std::string& canonical)
{
// must be a canonical name
if (m_map.find(canonical) == m_map.end()) {
@@ -224,12 +218,9 @@ Config::removeAllAliases()
}
}
-bool
-Config::connect(const String& srcName,
- EDirection srcSide,
- float srcStart, float srcEnd,
- const String& dstName,
- float dstStart, float dstEnd)
+bool Config::connect(const std::string& srcName, EDirection srcSide,
+ float srcStart, float srcEnd, const std::string& dstName,
+ float dstStart, float dstEnd)
{
assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);
@@ -245,8 +236,7 @@ Config::connect(const String& srcName,
return index->second.add(srcEdge, dstEdge);
}
-bool
-Config::disconnect(const String& srcName, EDirection srcSide)
+bool Config::disconnect(const std::string& srcName, EDirection srcSide)
{
assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);
@@ -262,8 +252,7 @@ Config::disconnect(const String& srcName, EDirection srcSide)
return true;
}
-bool
-Config::disconnect(const String& srcName, EDirection srcSide, float position)
+bool Config::disconnect(const std::string& srcName, EDirection srcSide, float position)
{
assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);
@@ -285,8 +274,7 @@ Config::setBarrierAddress(const NetworkAddress& addr)
m_barrierAddress = addr;
}
-bool
-Config::addOption(const String& name, OptionID option, OptionValue value)
+bool Config::addOption(const std::string& name, OptionID option, OptionValue value)
{
// find options
ScreenOptions* options = NULL;
@@ -308,8 +296,7 @@ Config::addOption(const String& name, OptionID option, OptionValue value)
return true;
}
-bool
-Config::removeOption(const String& name, OptionID option)
+bool Config::removeOption(const std::string& name, OptionID option)
{
// find options
ScreenOptions* options = NULL;
@@ -331,8 +318,7 @@ Config::removeOption(const String& name, OptionID option)
return true;
}
-bool
-Config::removeOptions(const String& name)
+bool Config::removeOptions(const std::string& name)
{
// find options
ScreenOptions* options = NULL;
@@ -354,8 +340,7 @@ Config::removeOptions(const String& name)
return true;
}
-bool
-Config::isValidScreenName(const String& name) const
+bool Config::isValidScreenName(const std::string& name) const
{
// name is valid if matches validname
// name ::= [_A-Za-z0-9] | [_A-Za-z0-9][-_A-Za-z0-9]*[_A-Za-z0-9]
@@ -370,7 +355,7 @@ Config::isValidScreenName(const String& name) const
}
// check each dot separated part
- String::size_type b = 0;
+ std::string::size_type b = 0;
for (;;) {
// accept trailing .
if (b == name.size()) {
@@ -378,8 +363,8 @@ Config::isValidScreenName(const String& name) const
}
// find end of part
- String::size_type e = name.find('.', b);
- if (e == String::npos) {
+ std::string::size_type e = name.find('.', b);
+ if (e == std::string::npos) {
e = name.size();
}
@@ -395,7 +380,7 @@ Config::isValidScreenName(const String& name) const
}
// check interior characters
- for (String::size_type i = b; i < e; ++i) {
+ for (std::string::size_type i = b; i < e; ++i) {
if (!isalnum(name[i]) && name[i] != '_' && name[i] != '-') {
return false;
}
@@ -437,40 +422,38 @@ Config::endAll() const
}
bool
-Config::isScreen(const String& name) const
+Config::isScreen(const std::string& name) const
{
return (m_nameToCanonicalName.count(name) > 0);
}
bool
-Config::isCanonicalName(const String& name) const
+Config::isCanonicalName(const std::string& name) const
{
return (!name.empty() &&
CaselessCmp::equal(getCanonicalName(name), name));
}
-String
-Config::getCanonicalName(const String& name) const
+std::string Config::getCanonicalName(const std::string& name) const
{
NameMap::const_iterator index = m_nameToCanonicalName.find(name);
if (index == m_nameToCanonicalName.end()) {
- return String();
+ return std::string();
}
else {
return index->second;
}
}
-String
-Config::getNeighbor(const String& srcName, EDirection srcSide,
- float position, float* positionOut) const
+std::string Config::getNeighbor(const std::string& srcName, EDirection srcSide,
+ float position, float* positionOut) const
{
assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);
// find source cell
CellMap::const_iterator index = m_map.find(getCanonicalName(srcName));
if (index == m_map.end()) {
- return String();
+ return std::string();
}
// find edge
@@ -491,15 +474,13 @@ Config::getNeighbor(const String& srcName, EDirection srcSide,
}
}
-bool
-Config::hasNeighbor(const String& srcName, EDirection srcSide) const
+bool Config::hasNeighbor(const std::string& srcName, EDirection srcSide) const
{
return hasNeighbor(srcName, srcSide, 0.0f, 1.0f);
}
-bool
-Config::hasNeighbor(const String& srcName, EDirection srcSide,
- float start, float end) const
+bool Config::hasNeighbor(const std::string& srcName, EDirection srcSide,
+ float start, float end) const
{
assert(srcSide >= kFirstDirection && srcSide <= kLastDirection);
@@ -512,16 +493,14 @@ Config::hasNeighbor(const String& srcName, EDirection srcSide,
return index->second.overlaps(CellEdge(srcSide, Interval(start, end)));
}
-Config::link_const_iterator
-Config::beginNeighbor(const String& srcName) const
+Config::link_const_iterator Config::beginNeighbor(const std::string& srcName) const
{
CellMap::const_iterator index = m_map.find(getCanonicalName(srcName));
assert(index != m_map.end());
return index->second.begin();
}
-Config::link_const_iterator
-Config::endNeighbor(const String& srcName) const
+Config::link_const_iterator Config::endNeighbor(const std::string& srcName) const
{
CellMap::const_iterator index = m_map.find(getCanonicalName(srcName));
assert(index != m_map.end());
@@ -534,8 +513,7 @@ Config::getBarrierAddress() const
return m_barrierAddress;
}
-const Config::ScreenOptions*
-Config::getOptions(const String& name) const
+const Config::ScreenOptions* Config::getOptions(const std::string& name) const
{
// find options
const ScreenOptions* options = NULL;
@@ -641,8 +619,7 @@ Config::getInputFilter()
return &m_inputFilter;
}
-String
-Config::formatInterval(const Interval& x)
+std::string Config::formatInterval(const Interval& x)
{
if (x.first == 0.0f && x.second == 1.0f) {
return "";
@@ -660,7 +637,7 @@ Config::readSection(ConfigReadContext& s)
static const char s_links[] = "links";
static const char s_aliases[] = "aliases";
- String line;
+ std::string line;
if (!s.readLine(line)) {
// no more sections
return;
@@ -672,13 +649,13 @@ Config::readSection(ConfigReadContext& s)
}
// get section name
- String::size_type i = line.find_first_not_of(" \t", sizeof(s_section) - 1);
- if (i == String::npos) {
+ std::string::size_type i = line.find_first_not_of(" \t", sizeof(s_section) - 1);
+ if (i == std::string::npos) {
throw XConfigRead(s, "section name is missing");
}
- String name = line.substr(i);
+ std::string name = line.substr(i);
i = name.find_first_of(" \t");
- if (i != String::npos) {
+ if (i != std::string::npos) {
throw XConfigRead(s, "unexpected data after section name");
}
@@ -703,7 +680,7 @@ Config::readSection(ConfigReadContext& s)
void
Config::readSectionOptions(ConfigReadContext& s)
{
- String line;
+ std::string line;
while (s.readLine(line)) {
// check for end of section
if (line == "end") {
@@ -714,8 +691,8 @@ Config::readSectionOptions(ConfigReadContext& s)
// nameAndArgs := <name>[(arg[,...])]
// values := valueAndArgs[,valueAndArgs]...
// valueAndArgs := <value>[(arg[,...])]
- String::size_type i = 0;
- String name, value;
+ std::string::size_type i = 0;
+ std::string name, value;
ConfigReadContext::ArgList nameArgs, valueArgs;
s.parseNameWithArgs("name", line, "=", i, name, nameArgs);
++i;
@@ -728,8 +705,7 @@ Config::readSectionOptions(ConfigReadContext& s)
m_barrierAddress.resolve();
}
catch (XSocketAddress& e) {
- throw XConfigRead(s,
- String("invalid address argument ") + e.what());
+ throw XConfigRead(s, std::string("invalid address argument ") + e.what());
}
}
else if (name == "heartbeat") {
@@ -799,7 +775,7 @@ Config::readSectionOptions(ConfigReadContext& s)
if (i < line.length() && line[i] == ';') {
// allow trailing ';'
i = line.find_first_not_of(" \t", i + 1);
- if (i == String::npos) {
+ if (i == std::string::npos) {
i = line.length();
}
else {
@@ -825,9 +801,9 @@ Config::readSectionOptions(ConfigReadContext& s)
void
Config::readSectionScreens(ConfigReadContext& s)
{
- String line;
- String screen;
- while (s.readLine(line)) {
+ std::string line;
+ std::string screen;
+ while (s.readLine(line)) {
// check for end of section
if (line == "end") {
return;
@@ -853,21 +829,21 @@ Config::readSectionScreens(ConfigReadContext& s)
}
else {
// parse argument: `<name>=<value>'
- String::size_type i = line.find_first_of(" \t=");
+ std::string::size_type i = line.find_first_of(" \t=");
if (i == 0) {
throw XConfigRead(s, "missing argument name");
}
- if (i == String::npos) {
+ if (i == std::string::npos) {
throw XConfigRead(s, "missing =");
}
- String name = line.substr(0, i);
+ std::string name = line.substr(0, i);
i = line.find_first_not_of(" \t", i);
- if (i == String::npos || line[i] != '=') {
+ if (i == std::string::npos || line[i] != '=') {
throw XConfigRead(s, "missing =");
}
i = line.find_first_not_of(" \t", i + 1);
- String value;
- if (i != String::npos) {
+ std::string value;
+ if (i != std::string::npos) {
value = line.substr(i);
}
@@ -936,8 +912,8 @@ Config::readSectionScreens(ConfigReadContext& s)
void
Config::readSectionLinks(ConfigReadContext& s)
{
- String line;
- String screen;
+ std::string line;
+ std::string screen;
while (s.readLine(line)) {
// check for end of section
if (line == "end") {
@@ -965,8 +941,8 @@ Config::readSectionLinks(ConfigReadContext& s)
// the stuff in brackets is optional. interval values must be
// in the range [0,100] and start < end. if not given the
// interval is taken to be (0,100).
- String::size_type i = 0;
- String side, dstScreen, srcArgString, dstArgString;
+ std::string::size_type i = 0;
+ std::string side, dstScreen, srcArgString, dstArgString;
ConfigReadContext::ArgList srcArgs, dstArgs;
s.parseNameWithArgs("link", line, "=", i, side, srcArgs);
++i;
@@ -1009,8 +985,8 @@ Config::readSectionLinks(ConfigReadContext& s)
void
Config::readSectionAliases(ConfigReadContext& s)
{
- String line;
- String screen;
+ std::string line;
+ std::string screen;
while (s.readLine(line)) {
// check for end of section
if (line == "end") {
@@ -1049,9 +1025,8 @@ Config::readSectionAliases(ConfigReadContext& s)
}
-InputFilter::Condition*
-Config::parseCondition(ConfigReadContext& s,
- const String& name, const std::vector<String>& args)
+InputFilter::Condition* Config::parseCondition(ConfigReadContext& s, const std::string& name,
+ const std::vector<std::string>& args)
{
if (name == "keystroke") {
if (args.size() != 1) {
@@ -1078,7 +1053,7 @@ Config::parseCondition(ConfigReadContext& s,
throw XConfigRead(s, "syntax for condition: connect([screen])");
}
- String screen = args[0];
+ std::string screen = args[0];
if (isScreen(screen)) {
screen = getCanonicalName(screen);
}
@@ -1092,10 +1067,9 @@ Config::parseCondition(ConfigReadContext& s,
throw XConfigRead(s, "unknown argument \"%{1}\"", name);
}
-void
-Config::parseAction(ConfigReadContext& s,
- const String& name, const std::vector<String>& args,
- InputFilter::Rule& rule, bool activate)
+void Config::parseAction(ConfigReadContext& s, const std::string& name,
+ const std::vector<std::string>& args,
+ InputFilter::Rule& rule, bool activate)
{
InputFilter::Action* action;
@@ -1109,7 +1083,7 @@ Config::parseAction(ConfigReadContext& s,
keyInfo = s.parseKeystroke(args[0]);
}
else {
- std::set<String> screens;
+ std::set<std::string> screens;
parseScreens(s, args[1], screens);
keyInfo = s.parseKeystroke(args[0], screens);
}
@@ -1171,7 +1145,7 @@ Config::parseAction(ConfigReadContext& s,
throw XConfigRead(s, "syntax for action: switchToScreen(name)");
}
- String screen = args[0];
+ std::string screen = args[0];
if (isScreen(screen)) {
screen = getCanonicalName(screen);
}
@@ -1182,6 +1156,10 @@ Config::parseAction(ConfigReadContext& s,
action = new InputFilter::SwitchToScreenAction(m_events, screen);
}
+ else if (name == "toggleScreen") {
+ action = new InputFilter::ToggleScreenAction(m_events);
+ }
+
else if (name == "switchInDirection") {
if (args.size() != 1) {
throw XConfigRead(s, "syntax for action: switchInDirection(<left|right|up|down>)");
@@ -1258,7 +1236,7 @@ Config::parseAction(ConfigReadContext& s,
}
}
- std::set<String> screens;
+ std::set<std::string> screens;
if (args.size() >= 2) {
parseScreens(s, args[1], screens);
}
@@ -1273,22 +1251,21 @@ Config::parseAction(ConfigReadContext& s,
rule.adoptAction(action, activate);
}
-void
-Config::parseScreens(ConfigReadContext& c,
- const String& s, std::set<String>& screens) const
+void Config::parseScreens(ConfigReadContext& c, const std::string& s,
+ std::set<std::string>& screens) const
{
screens.clear();
- String::size_type i = 0;
+ std::string::size_type i = 0;
while (i < s.size()) {
// find end of next screen name
- String::size_type j = s.find(':', i);
- if (j == String::npos) {
+ std::string::size_type j = s.find(':', i);
+ if (j == std::string::npos) {
j = s.size();
}
// extract name
- String rawName;
+ std::string rawName;
i = s.find_first_not_of(" \t", i);
if (i < j) {
rawName = s.substr(i, s.find_last_not_of(" \t", j - 1) - i + 1);
@@ -1299,7 +1276,7 @@ Config::parseScreens(ConfigReadContext& c,
screens.insert("*");
}
else if (!rawName.empty()) {
- String name = getCanonicalName(rawName);
+ std::string name = getCanonicalName(rawName);
if (name.empty()) {
throw XConfigRead(c, "unknown screen name \"%{1}\"", rawName);
}
@@ -1386,8 +1363,7 @@ Config::getOptionName(OptionID id)
return NULL;
}
-String
-Config::getOptionValue(OptionID id, OptionValue value)
+std::string Config::getOptionValue(OptionID id, OptionValue value)
{
if (id == kOptionHalfDuplexCapsLock ||
id == kOptionHalfDuplexNumLock ||
@@ -1463,17 +1439,16 @@ Config::getOptionValue(OptionID id, OptionValue value)
// Config::Name
//
-Config::Name::Name(Config* config, const String& name) :
+Config::Name::Name(Config* config, const std::string& name) :
m_config(config),
m_name(config->getCanonicalName(name))
{
// do nothing
}
-bool
-Config::Name::operator==(const String& name) const
+bool Config::Name::operator==(const std::string& name) const
{
- String canonical = m_config->getCanonicalName(name);
+ std::string canonical = m_config->getCanonicalName(name);
return CaselessCmp::equal(canonical, m_name);
}
@@ -1496,8 +1471,7 @@ Config::CellEdge::CellEdge(EDirection side, const Interval& interval)
init("", side, interval);
}
-Config::CellEdge::CellEdge(const String& name,
- EDirection side, const Interval& interval)
+Config::CellEdge::CellEdge(const std::string& name, EDirection side, const Interval& interval)
{
assert(interval.first >= 0.0f);
assert(interval.second <= 1.0f);
@@ -1511,9 +1485,7 @@ Config::CellEdge::~CellEdge()
// do nothing
}
-void
-Config::CellEdge::init(const String& name, EDirection side,
- const Interval& interval)
+void Config::CellEdge::init(const std::string& name, EDirection side, const Interval& interval)
{
assert(side != kNoDirection);
@@ -1528,14 +1500,12 @@ Config::CellEdge::getInterval() const
return m_interval;
}
-void
-Config::CellEdge::setName(const String& newName)
+void Config::CellEdge::setName(const std::string& newName)
{
m_name = newName;
}
-String
-Config::CellEdge::getName() const
+std::string Config::CellEdge::getName() const
{
return m_name;
}
@@ -1662,8 +1632,7 @@ Config::Cell::remove(const Name& name)
}
}
-void
-Config::Cell::rename(const Name& oldName, const String& newName)
+void Config::Cell::rename(const Name& oldName, const std::string& newName)
{
for (EdgeLinks::iterator j = m_neighbors.begin();
j != m_neighbors.end(); ++j) {
@@ -1789,8 +1758,7 @@ operator<<(std::ostream& s, const Config& config)
option = options->begin();
option != options->end(); ++option) {
const char* name = Config::getOptionName(option->first);
- String value = Config::getOptionValue(option->first,
- option->second);
+ std::string value = Config::getOptionValue(option->first, option->second);
if (name != NULL && !value.empty()) {
s << "\t\t" << name << " = " << value << std::endl;
}
@@ -1800,7 +1768,7 @@ operator<<(std::ostream& s, const Config& config)
s << "end" << std::endl;
// links section
- String neighbor;
+ std::string neighbor;
s << "section: links" << std::endl;
for (Config::const_iterator screen = config.begin();
screen != config.end(); ++screen) {
@@ -1821,8 +1789,7 @@ operator<<(std::ostream& s, const Config& config)
// aliases section (if there are any)
if (config.m_map.size() != config.m_nameToCanonicalName.size()) {
// map canonical to alias
- typedef std::multimap<String, String,
- CaselessCmp> CMNameMap;
+ typedef std::multimap<std::string, std::string, CaselessCmp> CMNameMap;
CMNameMap aliases;
for (Config::NameMap::const_iterator
index = config.m_nameToCanonicalName.begin();
@@ -1834,7 +1801,7 @@ operator<<(std::ostream& s, const Config& config)
}
// dump it
- String screen;
+ std::string screen;
s << "section: aliases" << std::endl;
for (CMNameMap::const_iterator index = aliases.begin();
index != aliases.end(); ++index) {
@@ -1855,8 +1822,7 @@ operator<<(std::ostream& s, const Config& config)
option = options->begin();
option != options->end(); ++option) {
const char* name = Config::getOptionName(option->first);
- String value = Config::getOptionValue(option->first,
- option->second);
+ std::string value = Config::getOptionValue(option->first, option->second);
if (name != NULL && !value.empty()) {
s << "\t" << name << " = " << value << std::endl;
}
@@ -1889,24 +1855,23 @@ ConfigReadContext::~ConfigReadContext()
// do nothing
}
-bool
-ConfigReadContext::readLine(String& line)
+bool ConfigReadContext::readLine(std::string& line)
{
++m_line;
while (std::getline(m_stream, line)) {
// strip leading whitespace
- String::size_type i = line.find_first_not_of(" \t");
- if (i != String::npos) {
- line.erase(0, i);
+ std::string::size_type i = line.find_first_not_of(" \t");
+ if (i != std::string::npos) {
+ line.erase(0, i);
}
// strip comments and then trailing whitespace
i = line.find('#');
- if (i != String::npos) {
+ if (i != std::string::npos) {
line.erase(i);
}
i = line.find_last_not_of(" \r\t");
- if (i != String::npos) {
+ if (i != std::string::npos) {
line.erase(i + 1);
}
@@ -1942,8 +1907,7 @@ ConfigReadContext::operator!() const
return !m_stream;
}
-OptionValue
-ConfigReadContext::parseBoolean(const String& arg) const
+OptionValue ConfigReadContext::parseBoolean(const std::string& arg) const
{
if (CaselessCmp::equal(arg, "true")) {
return static_cast<OptionValue>(true);
@@ -1954,8 +1918,7 @@ ConfigReadContext::parseBoolean(const String& arg) const
throw XConfigRead(*this, "invalid boolean argument \"%{1}\"", arg);
}
-OptionValue
-ConfigReadContext::parseInt(const String& arg) const
+OptionValue ConfigReadContext::parseInt(const std::string& arg) const
{
const char* s = arg.c_str();
char* end;
@@ -1972,8 +1935,7 @@ ConfigReadContext::parseInt(const String& arg) const
return value;
}
-OptionValue
-ConfigReadContext::parseModifierKey(const String& arg) const
+OptionValue ConfigReadContext::parseModifierKey(const std::string& arg) const
{
if (CaselessCmp::equal(arg, "shift")) {
return static_cast<OptionValue>(kKeyModifierIDShift);
@@ -1999,8 +1961,7 @@ ConfigReadContext::parseModifierKey(const String& arg) const
throw XConfigRead(*this, "invalid argument \"%{1}\"", arg);
}
-OptionValue
-ConfigReadContext::parseCorner(const String& arg) const
+OptionValue ConfigReadContext::parseCorner(const std::string& arg) const
{
if (CaselessCmp::equal(arg, "left")) {
return kTopLeftMask | kBottomLeftMask;
@@ -2035,22 +1996,21 @@ ConfigReadContext::parseCorner(const String& arg) const
throw XConfigRead(*this, "invalid argument \"%{1}\"", arg);
}
-OptionValue
-ConfigReadContext::parseCorners(const String& args) const
+OptionValue ConfigReadContext::parseCorners(const std::string& args) const
{
// find first token
- String::size_type i = args.find_first_not_of(" \t", 0);
- if (i == String::npos) {
+ std::string::size_type i = args.find_first_not_of(" \t", 0);
+ if (i == std::string::npos) {
throw XConfigRead(*this, "missing corner argument");
}
- String::size_type j = args.find_first_of(" \t", i);
+ std::string::size_type j = args.find_first_of(" \t", i);
// parse first corner token
OptionValue corners = parseCorner(args.substr(i, j - i));
// get +/-
i = args.find_first_not_of(" \t", j);
- while (i != String::npos) {
+ while (i != std::string::npos) {
// parse +/-
bool add;
if (args[i] == '-') {
@@ -2060,15 +2020,14 @@ ConfigReadContext::parseCorners(const String& args) const
add = true;
}
else {
- throw XConfigRead(*this,
- "invalid corner operator \"%{1}\"",
- String(args.c_str() + i, 1));
+ throw XConfigRead(*this, "invalid corner operator \"%{1}\"",
+ std::string(args.c_str() + i, 1));
}
// get next corner token
i = args.find_first_not_of(" \t", i + 1);
j = args.find_first_of(" \t", i);
- if (i == String::npos) {
+ if (i == std::string::npos) {
throw XConfigRead(*this, "missing corner argument");
}
@@ -2114,21 +2073,19 @@ ConfigReadContext::parseInterval(const ArgList& args) const
return Config::Interval(startValue / 100.0f, endValue / 100.0f);
}
-void
-ConfigReadContext::parseNameWithArgs(
- const String& type, const String& line,
- const String& delim, String::size_type& index,
- String& name, ArgList& args) const
+void ConfigReadContext::parseNameWithArgs(const std::string& type, const std::string& line,
+ const std::string& delim, std::string::size_type& index,
+ std::string& name, ArgList& args) const
{
// skip leading whitespace
- String::size_type i = line.find_first_not_of(" \t", index);
- if (i == String::npos) {
- throw XConfigRead(*this, String("missing ") + type);
+ std::string::size_type i = line.find_first_not_of(" \t", index);
+ if (i == std::string::npos) {
+ throw XConfigRead(*this, std::string("missing ") + type);
}
// find end of name
- String::size_type j = line.find_first_of(" \t(" + delim, i);
- if (j == String::npos) {
+ std::string::size_type j = line.find_first_of(" \t(" + delim, i);
+ if (j == std::string::npos) {
j = line.length();
}
@@ -2137,15 +2094,15 @@ ConfigReadContext::parseNameWithArgs(
args.clear();
// is it okay to not find a delimiter?
- bool needDelim = (!delim.empty() && delim.find('\n') == String::npos);
+ bool needDelim = (!delim.empty() && delim.find('\n') == std::string::npos);
// skip whitespace
i = line.find_first_not_of(" \t", j);
- if (i == String::npos && needDelim) {
+ if (i == std::string::npos && needDelim) {
// expected delimiter but didn't find it
- throw XConfigRead(*this, String("missing ") + delim[0]);
+ throw XConfigRead(*this, std::string("missing ") + delim[0]);
}
- if (i == String::npos) {
+ if (i == std::string::npos) {
// no arguments
index = line.length();
return;
@@ -2161,18 +2118,18 @@ ConfigReadContext::parseNameWithArgs(
// parse arguments
j = line.find_first_of(",)", i);
- while (j != String::npos) {
+ while (j != std::string::npos) {
// extract arg
- String arg(line.substr(i, j - i));
+ std::string arg(line.substr(i, j - i));
i = j;
// trim whitespace
j = arg.find_first_not_of(" \t");
- if (j != String::npos) {
+ if (j != std::string::npos) {
arg.erase(0, j);
}
j = arg.find_last_not_of(" \t");
- if (j != String::npos) {
+ if (j != std::string::npos) {
arg.erase(j + 1);
}
@@ -2192,7 +2149,7 @@ ConfigReadContext::parseNameWithArgs(
}
// verify ')'
- if (j == String::npos) {
+ if (j == std::string::npos) {
// expected )
throw XConfigRead(*this, "missing )");
}
@@ -2202,17 +2159,17 @@ ConfigReadContext::parseNameWithArgs(
// skip whitespace
j = line.find_first_not_of(" \t", i);
- if (j == String::npos && needDelim) {
+ if (j == std::string::npos && needDelim) {
// expected delimiter but didn't find it
- throw XConfigRead(*this, String("missing ") + delim[0]);
+ throw XConfigRead(*this, std::string("missing ") + delim[0]);
}
// verify delimiter
- if (needDelim && delim.find(line[j]) == String::npos) {
- throw XConfigRead(*this, String("expected ") + delim[0]);
+ if (needDelim && delim.find(line[j]) == std::string::npos) {
+ throw XConfigRead(*this, std::string("expected ") + delim[0]);
}
- if (j == String::npos) {
+ if (j == std::string::npos) {
j = line.length();
}
@@ -2220,17 +2177,15 @@ ConfigReadContext::parseNameWithArgs(
return;
}
-IPlatformScreen::KeyInfo*
-ConfigReadContext::parseKeystroke(const String& keystroke) const
+IPlatformScreen::KeyInfo* ConfigReadContext::parseKeystroke(const std::string& keystroke) const
{
- return parseKeystroke(keystroke, std::set<String>());
+ return parseKeystroke(keystroke, std::set<std::string>());
}
-IPlatformScreen::KeyInfo*
-ConfigReadContext::parseKeystroke(const String& keystroke,
- const std::set<String>& screens) const
+IPlatformScreen::KeyInfo* ConfigReadContext::parseKeystroke(const std::string& keystroke,
+ const std::set<std::string>& screens) const
{
- String s = keystroke;
+ std::string s = keystroke;
KeyModifierMask mask;
if (!barrier::KeyMap::parseModifiers(s, mask)) {
@@ -2250,9 +2205,9 @@ ConfigReadContext::parseKeystroke(const String& keystroke,
}
IPlatformScreen::ButtonInfo*
-ConfigReadContext::parseMouse(const String& mouse) const
+ConfigReadContext::parseMouse(const std::string& mouse) const
{
- String s = mouse;
+ std::string s = mouse;
KeyModifierMask mask;
if (!barrier::KeyMap::parseModifiers(s, mask)) {
@@ -2271,10 +2226,9 @@ ConfigReadContext::parseMouse(const String& mouse) const
return IPlatformScreen::ButtonInfo::alloc(button, mask);
}
-KeyModifierMask
-ConfigReadContext::parseModifier(const String& modifiers) const
+KeyModifierMask ConfigReadContext::parseModifier(const std::string& modifiers) const
{
- String s = modifiers;
+ std::string s = modifiers;
KeyModifierMask mask;
if (!barrier::KeyMap::parseModifiers(s, mask)) {
@@ -2288,10 +2242,9 @@ ConfigReadContext::parseModifier(const String& modifiers) const
return mask;
}
-String
-ConfigReadContext::concatArgs(const ArgList& args)
+std::string ConfigReadContext::concatArgs(const ArgList& args)
{
- String s("(");
+ std::string s("(");
for (size_t i = 0; i < args.size(); ++i) {
if (i != 0) {
s += ",";
@@ -2307,29 +2260,27 @@ ConfigReadContext::concatArgs(const ArgList& args)
// Config I/O exceptions
//
-XConfigRead::XConfigRead(const ConfigReadContext& context,
- const String& error) :
+XConfigRead::XConfigRead(const ConfigReadContext& context, const std::string& error) :
m_error(barrier::string::sprintf("line %d: %s",
context.getLineNumber(), error.c_str()))
{
// do nothing
}
-XConfigRead::XConfigRead(const ConfigReadContext& context,
- const char* errorFmt, const String& arg) :
+XConfigRead::XConfigRead(const ConfigReadContext& context, const char* errorFmt,
+ const std::string& arg) :
m_error(barrier::string::sprintf("line %d: ", context.getLineNumber()) +
barrier::string::format(errorFmt, arg.c_str()))
{
// do nothing
}
-XConfigRead::~XConfigRead() _NOEXCEPT
+XConfigRead::~XConfigRead() noexcept
{
// do nothing
}
-String
-XConfigRead::getWhat() const throw()
+std::string XConfigRead::getWhat() const noexcept
{
return format("XConfigRead", "read error: %{1}", m_error.c_str());
}
diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h
index 69b01c4..c459393 100644
--- a/src/lib/server/Config.h
+++ b/src/lib/server/Config.h
@@ -23,7 +23,6 @@
#include "barrier/protocol_types.h"
#include "barrier/IPlatformScreen.h"
#include "net/NetworkAddress.h"
-#include "base/String.h"
#include "base/XBase.h"
#include "common/stdmap.h"
#include "common/stdset.h"
@@ -37,11 +36,11 @@ class IEventQueue;
namespace std {
template <>
struct iterator_traits<Config> {
- typedef String value_type;
+ typedef std::string value_type;
typedef ptrdiff_t difference_type;
typedef bidirectional_iterator_tag iterator_category;
- typedef String* pointer;
- typedef String& reference;
+ typedef std::string* pointer;
+ typedef std::string& reference;
};
};
@@ -64,12 +63,12 @@ public:
public:
CellEdge(EDirection side, float position);
CellEdge(EDirection side, const Interval&);
- CellEdge(const String& name, EDirection side, const Interval&);
+ CellEdge(const std::string& name, EDirection side, const Interval&);
~CellEdge();
Interval getInterval() const;
- void setName(const String& newName);
- String getName() const;
+ void setName(const std::string& newName);
+ std::string getName() const;
EDirection getSide() const;
bool overlaps(const CellEdge&) const;
bool isInside(float x) const;
@@ -88,11 +87,10 @@ public:
bool operator!=(const CellEdge&) const;
private:
- void init(const String& name, EDirection side,
- const Interval&);
+ void init(const std::string& name, EDirection side, const Interval&);
private:
- String m_name;
+ std::string m_name;
EDirection m_side;
Interval m_interval;
};
@@ -100,13 +98,13 @@ public:
private:
class Name {
public:
- Name(Config*, const String& name);
+ Name(Config*, const std::string& name);
- bool operator==(const String& name) const;
+ bool operator==(const std::string& name) const;
private:
Config* m_config;
- String m_name;
+ std::string m_name;
};
class Cell {
@@ -120,7 +118,7 @@ private:
void remove(EDirection side);
void remove(EDirection side, float position);
void remove(const Name& destinationName);
- void rename(const Name& oldName, const String& newName);
+ void rename(const Name& oldName, const std::string& newName);
bool hasEdge(const CellEdge&) const;
bool overlaps(const CellEdge&) const;
@@ -140,8 +138,8 @@ private:
public:
ScreenOptions m_options;
};
- typedef std::map<String, Cell, barrier::string::CaselessCmp> CellMap;
- typedef std::map<String, String, barrier::string::CaselessCmp> NameMap;
+ typedef std::map<std::string, Cell, barrier::string::CaselessCmp> CellMap;
+ typedef std::map<std::string, std::string, barrier::string::CaselessCmp> NameMap;
public:
typedef Cell::const_iterator link_const_iterator;
@@ -156,8 +154,8 @@ public:
m_i = i.m_i;
return *this;
}
- String operator*() { return m_i->first; }
- const String* operator->() { return &(m_i->first); }
+ std::string operator*() { return m_i->first; }
+ const std::string* operator->() { return &(m_i->first); }
const_iterator& operator++() { ++m_i; return *this; }
const_iterator operator++(int) { return const_iterator(m_i++); }
const_iterator& operator--() { --m_i; return *this; }
@@ -188,15 +186,14 @@ public:
Adds a screen, returning true iff successful. If a screen or
alias with the given name exists then it fails.
*/
- bool addScreen(const String& name);
+ bool addScreen(const std::string& name);
//! Rename screen
/*!
Renames a screen. All references to the name are updated.
Returns true iff successful.
*/
- bool renameScreen(const String& oldName,
- const String& newName);
+ bool renameScreen(const std::string& oldName, const std::string& newName);
//! Remove screen
/*!
@@ -204,7 +201,7 @@ public:
disconnects any connections to the screen. \c name may be an
alias.
*/
- void removeScreen(const String& name);
+ void removeScreen(const std::string& name);
//! Remove all screens
/*!
@@ -219,22 +216,21 @@ public:
Returns false if the alias name already exists or the canonical
name is unknown, otherwise returns true.
*/
- bool addAlias(const String& canonical,
- const String& alias);
+ bool addAlias(const std::string& canonical, const std::string& alias);
//! Remove alias
/*!
Removes an alias for a screen name. It returns false if the
alias is unknown or a canonical name, otherwise returns true.
*/
- bool removeAlias(const String& alias);
+ bool removeAlias(const std::string& alias);
//! Remove aliases
/*!
Removes all aliases for a canonical screen name. It returns false
if the canonical name is unknown, otherwise returns true.
*/
- bool removeAliases(const String& canonical);
+ bool removeAliases(const std::string& canonical);
//! Remove all aliases
/*!
@@ -258,19 +254,15 @@ public:
and all of \c srcStart, \c srcEnd, \c dstStart, or \c dstEnd must
be inside the range [0,1].
*/
- bool connect(const String& srcName,
- EDirection srcSide,
- float srcStart, float srcEnd,
- const String& dstName,
- float dstStart, float dstEnd);
+ bool connect(const std::string& srcName, EDirection srcSide, float srcStart, float srcEnd,
+ const std::string& dstName, float dstStart, float dstEnd);
//! Disconnect screens
/*!
Removes all connections created by connect() on side \c srcSide.
Returns false if \c srcName is unknown.
*/
- bool disconnect(const String& srcName,
- EDirection srcSide);
+ bool disconnect(const std::string& srcName, EDirection srcSide);
//! Disconnect screens
/*!
@@ -278,8 +270,7 @@ public:
covering position \c position. Returns false if \c srcName is
unknown.
*/
- bool disconnect(const String& srcName,
- EDirection srcSide, float position);
+ bool disconnect(const std::string& srcName, EDirection srcSide, float position);
//! Set server address
/*!
@@ -294,8 +285,7 @@ public:
existing option's value if there is one. Returns true iff \c name
is a known screen.
*/
- bool addOption(const String& name,
- OptionID option, OptionValue value);
+ bool addOption(const std::string& name, OptionID option, OptionValue value);
//! Remove a screen option
/*!
@@ -303,14 +293,14 @@ public:
nothing if the option doesn't exist on the screen. Returns true
iff \c name is a known screen.
*/
- bool removeOption(const String& name, OptionID option);
+ bool removeOption(const std::string& name, OptionID option);
//! Remove a screen options
/*!
Removes all options and values from the named screen. Returns true
iff \c name is a known screen.
*/
- bool removeOptions(const String& name);
+ bool removeOptions(const std::string& name);
//! Get the hot key input filter
/*!
@@ -328,7 +318,7 @@ public:
/*!
Returns true iff \c name is a valid screen name.
*/
- bool isValidScreenName(const String& name) const;
+ bool isValidScreenName(const std::string& name) const;
//! Get beginning (canonical) screen name iterator
const_iterator begin() const;
@@ -344,20 +334,20 @@ public:
/*!
Returns true iff \c name names a screen.
*/
- virtual bool isScreen(const String& name) const;
+ virtual bool isScreen(const std::string& name) const;
//! Test for canonical screen name
/*!
Returns true iff \c name is the canonical name of a screen.
*/
- bool isCanonicalName(const String& name) const;
+ bool isCanonicalName(const std::string& name) const;
//! Get canonical name
/*!
Returns the canonical name of a screen or the empty string if
the name is unknown. Returns the canonical name if one is given.
*/
- String getCanonicalName(const String& name) const;
+ std::string getCanonicalName(const std::string& name) const;
//! Get neighbor
/*!
@@ -367,7 +357,7 @@ public:
saves the position on the neighbor in \c positionOut if it's not
\c NULL.
*/
- String getNeighbor(const String&, EDirection,
+ std::string getNeighbor(const std::string&, EDirection,
float position, float* positionOut) const;
//! Check for neighbor
@@ -375,20 +365,19 @@ public:
Returns \c true if the screen has a neighbor anywhere along the edge
given by the direction.
*/
- bool hasNeighbor(const String&, EDirection) const;
+ bool hasNeighbor(const std::string&, EDirection) const;
//! Check for neighbor
/*!
Returns \c true if the screen has a neighbor in the given range along
the edge given by the direction.
*/
- bool hasNeighbor(const String&, EDirection,
- float start, float end) const;
+ bool hasNeighbor(const std::string&, EDirection, float start, float end) const;
//! Get beginning neighbor iterator
- link_const_iterator beginNeighbor(const String&) const;
+ link_const_iterator beginNeighbor(const std::string&) const;
//! Get ending neighbor iterator
- link_const_iterator endNeighbor(const String&) const;
+ link_const_iterator endNeighbor(const std::string&) const;
//! Get the server address
const NetworkAddress&
@@ -400,8 +389,7 @@ public:
if the screen is unknown and an empty collection if there are no
options.
*/
- const ScreenOptions*
- getOptions(const String& name) const;
+ const ScreenOptions* getOptions(const std::string& name) const;
//! Check for lock to screen action
/*!
@@ -446,7 +434,7 @@ public:
/*!
Returns an interval as a parseable string.
*/
- static String formatInterval(const Interval&);
+ static std::string formatInterval(const Interval&);
//@}
@@ -457,19 +445,16 @@ private:
void readSectionLinks(ConfigReadContext&);
void readSectionAliases(ConfigReadContext&);
- InputFilter::Condition*
- parseCondition(ConfigReadContext&,
- const String& condition,
- const std::vector<String>& args);
- void parseAction(ConfigReadContext&,
- const String& action,
- const std::vector<String>& args,
- InputFilter::Rule&, bool activate);
-
- void parseScreens(ConfigReadContext&, const String&,
- std::set<String>& screens) const;
+ InputFilter::Condition* parseCondition(ConfigReadContext&, const std::string& condition,
+ const std::vector<std::string>& args);
+
+ void parseAction(ConfigReadContext&, const std::string& action,
+ const std::vector<std::string>& args, InputFilter::Rule&, bool activate);
+
+ void parseScreens(ConfigReadContext&, const std::string&, std::set<std::string>& screens) const;
+
static const char* getOptionName(OptionID);
- static String getOptionValue(OptionID, OptionValue);
+ static std::string getOptionValue(OptionID, OptionValue);
private:
CellMap m_map;
@@ -487,42 +472,41 @@ Maintains a context when reading a configuration from a stream.
*/
class ConfigReadContext {
public:
- typedef std::vector<String> ArgList;
+ typedef std::vector<std::string> ArgList;
ConfigReadContext(std::istream&, SInt32 firstLine = 1);
~ConfigReadContext();
- bool readLine(String&);
+ bool readLine(std::string&);
UInt32 getLineNumber() const;
bool operator!() const;
- OptionValue parseBoolean(const String&) const;
- OptionValue parseInt(const String&) const;
- OptionValue parseModifierKey(const String&) const;
- OptionValue parseCorner(const String&) const;
- OptionValue parseCorners(const String&) const;
- Config::Interval
- parseInterval(const ArgList& args) const;
- void parseNameWithArgs(
- const String& type, const String& line,
- const String& delim, String::size_type& index,
- String& name, ArgList& args) const;
- IPlatformScreen::KeyInfo*
- parseKeystroke(const String& keystroke) const;
- IPlatformScreen::KeyInfo*
- parseKeystroke(const String& keystroke,
- const std::set<String>& screens) const;
- IPlatformScreen::ButtonInfo*
- parseMouse(const String& mouse) const;
- KeyModifierMask parseModifier(const String& modifiers) const;
+ OptionValue parseBoolean(const std::string&) const;
+ OptionValue parseInt(const std::string&) const;
+ OptionValue parseModifierKey(const std::string&) const;
+ OptionValue parseCorner(const std::string&) const;
+ OptionValue parseCorners(const std::string&) const;
+
+ Config::Interval parseInterval(const ArgList& args) const;
+
+ void parseNameWithArgs(const std::string& type, const std::string& line,
+ const std::string& delim, std::string::size_type& index,
+ std::string& name, ArgList& args) const;
+
+ IPlatformScreen::KeyInfo* parseKeystroke(const std::string& keystroke) const;
+ IPlatformScreen::KeyInfo* parseKeystroke(const std::string& keystroke,
+ const std::set<std::string>& screens) const;
+ IPlatformScreen::ButtonInfo* parseMouse(const std::string& mouse) const;
+ KeyModifierMask parseModifier(const std::string& modifiers) const;
+
std::istream& getStream() const { return m_stream; };
private:
// not implemented
ConfigReadContext& operator=(const ConfigReadContext&);
- static String concatArgs(const ArgList& args);
+ static std::string concatArgs(const ArgList& args);
private:
std::istream& m_stream;
@@ -535,15 +519,14 @@ Thrown when a configuration stream cannot be parsed.
*/
class XConfigRead : public XBase {
public:
- XConfigRead(const ConfigReadContext& context, const String&);
- XConfigRead(const ConfigReadContext& context,
- const char* errorFmt, const String& arg);
- virtual ~XConfigRead() _NOEXCEPT;
+ XConfigRead(const ConfigReadContext& context, const std::string&);
+ XConfigRead(const ConfigReadContext& contex, const char* errorFmt, const std::string& arg);
+ virtual ~XConfigRead() noexcept;
protected:
// XBase overrides
- virtual String getWhat() const throw();
+ virtual std::string getWhat() const noexcept;
private:
- String m_error;
+ std::string m_error;
};
diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp
index 9e73f45..38d9a84 100644
--- a/src/lib/server/InputFilter.cpp
+++ b/src/lib/server/InputFilter.cpp
@@ -95,8 +95,7 @@ InputFilter::KeystrokeCondition::clone() const
return new KeystrokeCondition(m_events, m_key, m_mask);
}
-String
-InputFilter::KeystrokeCondition::format() const
+std::string InputFilter::KeystrokeCondition::format() const
{
return barrier::string::sprintf("keystroke(%s)",
barrier::KeyMap::formatKey(m_key, m_mask).c_str());
@@ -183,10 +182,9 @@ InputFilter::MouseButtonCondition::clone() const
return new MouseButtonCondition(m_events, m_button, m_mask);
}
-String
-InputFilter::MouseButtonCondition::format() const
+std::string InputFilter::MouseButtonCondition::format() const
{
- String key = barrier::KeyMap::formatKey(kKeyNone, m_mask);
+ std::string key = barrier::KeyMap::formatKey(kKeyNone, m_mask);
if (!key.empty()) {
key += "+";
}
@@ -226,8 +224,8 @@ InputFilter::MouseButtonCondition::match(const Event& event)
return status;
}
-InputFilter::ScreenConnectedCondition::ScreenConnectedCondition(
- IEventQueue* events, const String& screen) :
+InputFilter::ScreenConnectedCondition::ScreenConnectedCondition(IEventQueue* events,
+ const std::string& screen) :
m_screen(screen),
m_events(events)
{
@@ -245,8 +243,7 @@ InputFilter::ScreenConnectedCondition::clone() const
return new ScreenConnectedCondition(m_events, m_screen);
}
-String
-InputFilter::ScreenConnectedCondition::format() const
+std::string InputFilter::ScreenConnectedCondition::format() const
{
return barrier::string::sprintf("connect(%s)", m_screen.c_str());
}
@@ -298,8 +295,7 @@ InputFilter::LockCursorToScreenAction::clone() const
return new LockCursorToScreenAction(*this);
}
-String
-InputFilter::LockCursorToScreenAction::format() const
+std::string InputFilter::LockCursorToScreenAction::format() const
{
static const char* s_mode[] = { "off", "on", "toggle" };
@@ -323,16 +319,15 @@ InputFilter::LockCursorToScreenAction::perform(const Event& event)
Event::kDeliverImmediately));
}
-InputFilter::SwitchToScreenAction::SwitchToScreenAction(
- IEventQueue* events, const String& screen) :
+InputFilter::SwitchToScreenAction::SwitchToScreenAction(IEventQueue* events,
+ const std::string& screen) :
m_screen(screen),
m_events(events)
{
// do nothing
}
-String
-InputFilter::SwitchToScreenAction::getScreen() const
+std::string InputFilter::SwitchToScreenAction::getScreen() const
{
return m_screen;
}
@@ -343,8 +338,7 @@ InputFilter::SwitchToScreenAction::clone() const
return new SwitchToScreenAction(*this);
}
-String
-InputFilter::SwitchToScreenAction::format() const
+std::string InputFilter::SwitchToScreenAction::format() const
{
return barrier::string::sprintf("switchToScreen(%s)", m_screen.c_str());
}
@@ -354,7 +348,7 @@ InputFilter::SwitchToScreenAction::perform(const Event& event)
{
// pick screen name. if m_screen is empty then use the screen from
// event if it has one.
- String screen = m_screen;
+ std::string screen = m_screen;
if (screen.empty() && event.getType() == m_events->forServer().connected()) {
Server::ScreenConnectedInfo* info =
static_cast<Server::ScreenConnectedInfo*>(event.getData());
@@ -369,6 +363,32 @@ InputFilter::SwitchToScreenAction::perform(const Event& event)
Event::kDeliverImmediately));
}
+InputFilter::ToggleScreenAction::ToggleScreenAction(IEventQueue* events) :
+ m_events(events)
+{
+ // do nothing
+}
+
+InputFilter::Action*
+InputFilter::ToggleScreenAction::clone() const
+{
+ return new ToggleScreenAction(*this);
+}
+
+String
+InputFilter::ToggleScreenAction::format() const
+{
+ return barrier::string::sprintf("toggleScreen");
+}
+
+void
+InputFilter::ToggleScreenAction::perform(const Event& event)
+{
+ m_events->addEvent(Event(m_events->forServer().toggleScreen(),
+ event.getTarget(), NULL,
+ Event::kDeliverImmediately));
+}
+
InputFilter::SwitchInDirectionAction::SwitchInDirectionAction(
IEventQueue* events, EDirection direction) :
m_direction(direction),
@@ -389,8 +409,7 @@ InputFilter::SwitchInDirectionAction::clone() const
return new SwitchInDirectionAction(*this);
}
-String
-InputFilter::SwitchInDirectionAction::format() const
+std::string InputFilter::SwitchInDirectionAction::format() const
{
static const char* s_names[] = {
"",
@@ -421,10 +440,8 @@ InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction(
// do nothing
}
-InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction(
- IEventQueue* events,
- Mode mode,
- const std::set<String>& screens) :
+InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction(IEventQueue* events, Mode mode,
+ const std::set<std::string>& screens) :
m_mode(mode),
m_screens(IKeyState::KeyInfo::join(screens)),
m_events(events)
@@ -438,10 +455,9 @@ InputFilter::KeyboardBroadcastAction::getMode() const
return m_mode;
}
-std::set<String>
-InputFilter::KeyboardBroadcastAction::getScreens() const
+std::set<std::string> InputFilter::KeyboardBroadcastAction::getScreens() const
{
- std::set<String> screens;
+ std::set<std::string> screens;
IKeyState::KeyInfo::split(m_screens.c_str(), screens);
return screens;
}
@@ -452,8 +468,7 @@ InputFilter::KeyboardBroadcastAction::clone() const
return new KeyboardBroadcastAction(*this);
}
-String
-InputFilter::KeyboardBroadcastAction::format() const
+std::string InputFilter::KeyboardBroadcastAction::format() const
{
static const char* s_mode[] = { "off", "on", "toggle" };
static const char* s_name = "keyboardBroadcast";
@@ -525,8 +540,7 @@ InputFilter::KeystrokeAction::clone() const
return new KeystrokeAction(m_events, info, m_press);
}
-String
-InputFilter::KeystrokeAction::format() const
+std::string InputFilter::KeystrokeAction::format() const
{
const char* type = formatName();
@@ -607,12 +621,11 @@ InputFilter::MouseButtonAction::clone() const
return new MouseButtonAction(m_events, info, m_press);
}
-String
-InputFilter::MouseButtonAction::format() const
+std::string InputFilter::MouseButtonAction::format() const
{
const char* type = formatName();
- String key = barrier::KeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask);
+ std::string key = barrier::KeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask);
return barrier::string::sprintf("%s(%s%s%d)", type,
key.c_str(), key.empty() ? "" : "+",
m_buttonInfo->m_button);
@@ -820,10 +833,9 @@ InputFilter::Rule::handleEvent(const Event& event)
return true;
}
-String
-InputFilter::Rule::format() const
+std::string InputFilter::Rule::format() const
{
- String s;
+ std::string s;
if (m_condition != NULL) {
// condition
s += m_condition->format();
@@ -1019,10 +1031,9 @@ InputFilter::setPrimaryClient(PrimaryClient* client)
}
}
-String
-InputFilter::format(const String& linePrefix) const
+std::string InputFilter::format(const std::string& linePrefix) const
{
- String s;
+ std::string s;
for (RuleList::const_iterator i = m_ruleList.begin();
i != m_ruleList.end(); ++i) {
s += linePrefix;
@@ -1048,7 +1059,7 @@ InputFilter::operator==(const InputFilter& x) const
// compare rule lists. the easiest way to do that is to format each
// rule into a string, sort the strings, then compare the results.
- std::vector<String> aList, bList;
+ std::vector<std::string> aList, bList;
for (RuleList::const_iterator i = m_ruleList.begin();
i != m_ruleList.end(); ++i) {
aList.push_back(i->format());
diff --git a/src/lib/server/InputFilter.h b/src/lib/server/InputFilter.h
index 73afe97..0cb99da 100644
--- a/src/lib/server/InputFilter.h
+++ b/src/lib/server/InputFilter.h
@@ -22,7 +22,6 @@
#include "barrier/mouse_types.h"
#include "barrier/protocol_types.h"
#include "barrier/IPlatformScreen.h"
-#include "base/String.h"
#include "common/stdmap.h"
#include "common/stdset.h"
@@ -47,7 +46,7 @@ public:
virtual ~Condition();
virtual Condition* clone() const = 0;
- virtual String format() const = 0;
+ virtual std::string format() const = 0;
virtual EFilterStatus match(const Event&) = 0;
@@ -67,7 +66,7 @@ public:
// Condition overrides
virtual Condition* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual EFilterStatus match(const Event&);
virtual void enablePrimary(PrimaryClient*);
virtual void disablePrimary(PrimaryClient*);
@@ -91,7 +90,7 @@ public:
// Condition overrides
virtual Condition* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual EFilterStatus match(const Event&);
private:
@@ -103,16 +102,16 @@ public:
// ScreenConnectedCondition
class ScreenConnectedCondition : public Condition {
public:
- ScreenConnectedCondition(IEventQueue* events, const String& screen);
+ ScreenConnectedCondition(IEventQueue* events, const std::string& screen);
virtual ~ScreenConnectedCondition();
// Condition overrides
virtual Condition* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual EFilterStatus match(const Event&);
private:
- String m_screen;
+ std::string m_screen;
IEventQueue* m_events;
};
@@ -126,7 +125,7 @@ public:
virtual ~Action();
virtual Action* clone() const = 0;
- virtual String format() const = 0;
+ virtual std::string format() const = 0;
virtual void perform(const Event&) = 0;
};
@@ -142,7 +141,7 @@ public:
// Action overrides
virtual Action* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual void perform(const Event&);
private:
@@ -153,20 +152,34 @@ public:
// SwitchToScreenAction
class SwitchToScreenAction : public Action {
public:
- SwitchToScreenAction(IEventQueue* events, const String& screen);
+ SwitchToScreenAction(IEventQueue* events, const std::string& screen);
- String getScreen() const;
+ std::string getScreen() const;
// Action overrides
virtual Action* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual void perform(const Event&);
private:
- String m_screen;
+ std::string m_screen;
IEventQueue* m_events;
};
+ // ToggleScreenAction
+ class ToggleScreenAction : public Action {
+ public:
+ ToggleScreenAction(IEventQueue* events);
+
+ // Action overrides
+ virtual Action* clone() const;
+ virtual String format() const;
+ virtual void perform(const Event&);
+
+ private:
+ IEventQueue* m_events;
+ };
+
// SwitchInDirectionAction
class SwitchInDirectionAction : public Action {
public:
@@ -176,7 +189,7 @@ public:
// Action overrides
virtual Action* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual void perform(const Event&);
private:
@@ -190,19 +203,19 @@ public:
enum Mode { kOff, kOn, kToggle };
KeyboardBroadcastAction(IEventQueue* events, Mode = kToggle);
- KeyboardBroadcastAction(IEventQueue* events, Mode, const std::set<String>& screens);
+ KeyboardBroadcastAction(IEventQueue* events, Mode, const std::set<std::string>& screens);
Mode getMode() const;
- std::set<String> getScreens() const;
+ std::set<std::string> getScreens() const;
// Action overrides
virtual Action* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual void perform(const Event&);
private:
Mode m_mode;
- String m_screens;
+ std::string m_screens;
IEventQueue* m_events;
};
@@ -219,7 +232,7 @@ public:
// Action overrides
virtual Action* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual void perform(const Event&);
protected:
@@ -245,7 +258,7 @@ public:
// Action overrides
virtual Action* clone() const;
- virtual String format() const;
+ virtual std::string format() const;
virtual void perform(const Event&);
protected:
@@ -287,7 +300,7 @@ public:
bool handleEvent(const Event&);
// convert rule to a string
- String format() const;
+ std::string format() const;
// get the rule's condition
const Condition*
@@ -340,7 +353,7 @@ public:
virtual void setPrimaryClient(PrimaryClient* client);
// convert rules to a string
- String format(const String& linePrefix) const;
+ std::string format(const std::string& linePrefix) const;
// get number of rules
UInt32 getNumRules() const;
diff --git a/src/lib/server/PrimaryClient.cpp b/src/lib/server/PrimaryClient.cpp
index 4c9fe50..04ae86c 100644
--- a/src/lib/server/PrimaryClient.cpp
+++ b/src/lib/server/PrimaryClient.cpp
@@ -26,7 +26,7 @@
// PrimaryClient
//
-PrimaryClient::PrimaryClient(const String& name, barrier::Screen* screen) :
+PrimaryClient::PrimaryClient(const std::string& name, barrier::Screen* screen) :
BaseClientProxy(name),
m_screen(screen),
m_fakeInputCount(0)
diff --git a/src/lib/server/PrimaryClient.h b/src/lib/server/PrimaryClient.h
index 4296aaa..68b91e3 100644
--- a/src/lib/server/PrimaryClient.h
+++ b/src/lib/server/PrimaryClient.h
@@ -34,7 +34,7 @@ public:
/*!
\c name is the name of the server and \p screen is primary screen.
*/
- PrimaryClient(const String& name, barrier::Screen* screen);
+ PrimaryClient(const std::string& name, barrier::Screen* screen);
~PrimaryClient();
#ifdef TEST_ENV
diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp
index 12aedd0..334049c 100644
--- a/src/lib/server/Server.cpp
+++ b/src/lib/server/Server.cpp
@@ -43,14 +43,13 @@
#include "base/IEventQueue.h"
#include "base/Log.h"
#include "base/TMethodEventJob.h"
-#include "common/stdexcept.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <ctime>
-
+#include <stdexcept>
//
// Server
//
@@ -101,7 +100,7 @@ Server::Server(
assert(config.isScreen(primaryClient->getName()));
assert(m_screen != NULL);
- String primaryName = getName(primaryClient);
+ std::string primaryName = getName(primaryClient);
// clear clipboards
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
@@ -163,6 +162,10 @@ Server::Server(
m_inputFilter,
new TMethodEventJob<Server>(this,
&Server::handleSwitchToScreenEvent));
+ m_events->adoptHandler(m_events->forServer().toggleScreen(),
+ m_inputFilter,
+ new TMethodEventJob<Server>(this,
+ &Server::handleToggleScreenEvent));
m_events->adoptHandler(m_events->forServer().switchInDirection(),
m_inputFilter,
new TMethodEventJob<Server>(this,
@@ -370,7 +373,7 @@ Server::getNumClients() const
}
void
-Server::getClients(std::vector<String>& list) const
+Server::getClients(std::vector<std::string>& list) const
{
list.clear();
for (ClientList::const_iterator index = m_clients.begin();
@@ -379,10 +382,9 @@ Server::getClients(std::vector<String>& list) const
}
}
-String
-Server::getName(const BaseClientProxy* client) const
+std::string Server::getName(const BaseClientProxy* client) const
{
- String name = m_config->getCanonicalName(client->getName());
+ std::string name = m_config->getCanonicalName(client->getName());
if (name.empty()) {
name = client->getName();
}
@@ -600,7 +602,7 @@ Server::getNeighbor(BaseClientProxy* src,
assert(src != NULL);
// get source screen name
- String srcName = getName(src);
+ std::string srcName = getName(src);
assert(!srcName.empty());
LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str()));
@@ -610,7 +612,7 @@ Server::getNeighbor(BaseClientProxy* src,
// search for the closest neighbor that exists in direction dir
float tTmp;
for (;;) {
- String dstName(m_config->getNeighbor(srcName, dir, t, &tTmp));
+ std::string dstName(m_config->getNeighbor(srcName, dir, t, &tTmp));
// if nothing in that direction then return NULL. if the
// destination is the source then we can make no more
@@ -755,7 +757,7 @@ Server::avoidJumpZone(BaseClientProxy* dst,
return;
}
- const String dstName(getName(dst));
+ const std::string dstName(getName(dst));
SInt32 dx, dy, dw, dh;
dst->getShape(dx, dy, dw, dh);
float t = mapToFraction(dst, dir, x, y);
@@ -1408,6 +1410,24 @@ Server::handleSwitchToScreenEvent(const Event& event, void*)
}
void
+Server::handleToggleScreenEvent(const Event& event, void*)
+{
+ std::string current = getName(m_active);
+ ClientList::const_iterator index = m_clients.find(current);
+ if (index == m_clients.end()) {
+ LOG((CLOG_DEBUG1 "screen \"%s\" not active", current.c_str()));
+ }
+ else {
+ ++index;
+ if (index == m_clients.end()) {
+ index = m_clients.begin();
+ }
+ jumpToScreen(index->second);
+ }
+}
+
+
+void
Server::handleSwitchInDirectionEvent(const Event& event, void*)
{
SwitchInDirectionInfo* info =
@@ -1533,7 +1553,7 @@ Server::onClipboardChanged(BaseClientProxy* sender,
sender->getClipboard(id, &clipboard.m_clipboard);
// ignore if data hasn't changed
- String data = clipboard.m_clipboard.marshall();
+ std::string data = clipboard.m_clipboard.marshall();
if (data == clipboard.m_clipboardData) {
LOG((CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", clipboard.m_clipboardOwner.c_str(), id));
return;
@@ -1703,7 +1723,7 @@ Server::onMouseUp(ButtonID id)
if (m_args.m_enableDragDrop) {
if (!m_screen->isOnScreen()) {
- String& file = m_screen->getDraggingFilename();
+ std::string& file = m_screen->getDraggingFilename();
if (!file.empty()) {
sendFileToClient(file.c_str());
}
@@ -1829,7 +1849,7 @@ Server::sendDragInfoThread(void* arg)
BaseClientProxy* newScreen = static_cast<BaseClientProxy*>(arg);
m_dragFileList.clear();
- String& dragFileList = m_screen->getDraggingFilename();
+ std::string& dragFileList = m_screen->getDraggingFilename();
if (!dragFileList.empty()) {
DragInformation di;
di.setFilename(dragFileList);
@@ -1856,7 +1876,7 @@ Server::sendDragInfoThread(void* arg)
void
Server::sendDragInfo(BaseClientProxy* newScreen)
{
- String infoString;
+ std::string infoString;
UInt32 fileCount = DragInformation::setupDragInfo(m_dragFileList, infoString);
if (fileCount > 0) {
@@ -2089,7 +2109,7 @@ Server::writeToDropDirThread(void*)
bool
Server::addClient(BaseClientProxy* client)
{
- String name = getName(client);
+ std::string name = getName(client);
if (m_clients.count(name) != 0) {
return false;
}
@@ -2313,7 +2333,7 @@ Server::LockCursorToScreenInfo::alloc(State state)
//
Server::SwitchToScreenInfo*
-Server::SwitchToScreenInfo::alloc(const String& screen)
+Server::SwitchToScreenInfo::alloc(const std::string& screen)
{
SwitchToScreenInfo* info =
(SwitchToScreenInfo*)malloc(sizeof(SwitchToScreenInfo) +
@@ -2351,7 +2371,7 @@ Server::KeyboardBroadcastInfo::alloc(State state)
}
Server::KeyboardBroadcastInfo*
-Server::KeyboardBroadcastInfo::alloc(State state, const String& screens)
+Server::KeyboardBroadcastInfo::alloc(State state, const std::string& screens)
{
KeyboardBroadcastInfo* info =
(KeyboardBroadcastInfo*)malloc(sizeof(KeyboardBroadcastInfo) +
@@ -2396,7 +2416,7 @@ Server::sendFileThread(void* data)
}
void
-Server::dragInfoReceived(UInt32 fileNum, String content)
+Server::dragInfoReceived(UInt32 fileNum, std::string content)
{
if (!m_args.m_enableDragDrop) {
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h
index 609af21..bfd0a7d 100644
--- a/src/lib/server/Server.h
+++ b/src/lib/server/Server.h
@@ -62,7 +62,7 @@ public:
//! Switch to screen data
class SwitchToScreenInfo {
public:
- static SwitchToScreenInfo* alloc(const String& screen);
+ static SwitchToScreenInfo* alloc(const std::string& screen);
public:
// this is a C-string; this type is a variable size structure
@@ -81,10 +81,10 @@ public:
//! Screen connected data
class ScreenConnectedInfo {
public:
- ScreenConnectedInfo(String screen) : m_screen(screen) { }
+ ScreenConnectedInfo(std::string screen) : m_screen(screen) { }
public:
- String m_screen; // was char[1]
+ std::string m_screen;
};
//! Keyboard broadcast data
@@ -94,7 +94,7 @@ public:
static KeyboardBroadcastInfo* alloc(State state = kToggle);
static KeyboardBroadcastInfo* alloc(State state,
- const String& screens);
+ const std::string& screens);
public:
State m_state;
@@ -146,7 +146,7 @@ public:
void sendFileToClient(const char* filename);
//! Received dragging information from client
- void dragInfoReceived(UInt32 fileNum, String content);
+ void dragInfoReceived(UInt32 fileNum, std::string content);
//! Store ClientListener pointer
void setListener(ClientListener* p) { m_clientListener = p; }
@@ -165,7 +165,7 @@ public:
/*!
Set the \c list to the names of the currently connected clients.
*/
- void getClients(std::vector<String>& list) const;
+ void getClients(std::vector<std::string>& list) const;
//! Return true if recieved file size is valid
bool isReceivedFileSizeValid();
@@ -174,7 +174,7 @@ public:
size_t& getExpectedFileSize() { return m_expectedFileSize; }
//! Return received file data
- String& getReceivedFileData() { return m_receivedFileData; }
+ std::string& getReceivedFileData() { return m_receivedFileData; }
//! Return fake drag file list
DragFileList getFakeDragFileList() { return m_fakeDragFileList; }
@@ -183,7 +183,7 @@ public:
private:
// get canonical name of client
- String getName(const BaseClientProxy*) const;
+ std::string getName(const BaseClientProxy*) const;
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
@@ -308,6 +308,7 @@ private:
void handleClientDisconnected(const Event&, void*);
void handleClientCloseTimeout(const Event&, void*);
void handleSwitchToScreenEvent(const Event&, void*);
+ void handleToggleScreenEvent(const Event&, void*);
void handleSwitchInDirectionEvent(const Event&, void*);
void handleKeyboardBroadcastEvent(const Event&,void*);
void handleLockCursorToScreenEvent(const Event&, void*);
@@ -378,8 +379,8 @@ private:
public:
Clipboard m_clipboard;
- String m_clipboardData;
- String m_clipboardOwner;
+ std::string m_clipboardData;
+ std::string m_clipboardOwner;
UInt32 m_clipboardSeqNum;
};
@@ -387,7 +388,7 @@ private:
PrimaryClient* m_primaryClient;
// all clients (including the primary client) indexed by name
- typedef std::map<String, BaseClientProxy*> ClientList;
+ typedef std::map<std::string, BaseClientProxy*> ClientList;
typedef std::set<BaseClientProxy*> ClientSet;
ClientList m_clients;
ClientSet m_clientSet;
@@ -454,7 +455,7 @@ private:
// flag whether or not we have broadcasting enabled and the screens to
// which we should send broadcasted keys.
bool m_keyboardBroadcasting;
- String m_keyboardBroadcastingScreens;
+ std::string m_keyboardBroadcastingScreens;
// screen locking (former scroll lock)
bool m_lockedToScreen;
@@ -466,12 +467,12 @@ private:
// file transfer
size_t m_expectedFileSize;
- String m_receivedFileData;
+ std::string m_receivedFileData;
DragFileList m_dragFileList;
DragFileList m_fakeDragFileList;
Thread* m_sendFileThread;
Thread* m_writeToDropDirThread;
- String m_dragFileExt;
+ std::string m_dragFileExt;
bool m_ignoreFileTransfer;
bool m_enableClipboard;