mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-23 00:56:21 +03:00
Merge pull request #712 from p12tic/use-std-string-4
lib/ipc: Use std::string directly instead of String typedef
This commit is contained in:
commit
b02a20bd36
@ -141,7 +141,7 @@ IpcClientProxy::send(const IpcMessage& message)
|
|||||||
switch (message.type()) {
|
switch (message.type()) {
|
||||||
case kIpcLogLine: {
|
case kIpcLogLine: {
|
||||||
const IpcLogLineMessage& llm = static_cast<const IpcLogLineMessage&>(message);
|
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);
|
ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ IpcClientProxy::parseHello()
|
|||||||
IpcCommandMessage*
|
IpcCommandMessage*
|
||||||
IpcClientProxy::parseCommand()
|
IpcClientProxy::parseCommand()
|
||||||
{
|
{
|
||||||
String command;
|
std::string command;
|
||||||
UInt8 elevate;
|
UInt8 elevate;
|
||||||
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
|
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
|
||||||
|
|
||||||
|
@ -109,8 +109,7 @@ IpcLogOutputter::write(ELevel, const char* text)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void IpcLogOutputter::appendBuffer(const std::string& text)
|
||||||
IpcLogOutputter::appendBuffer(const String& text)
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
||||||
|
|
||||||
@ -173,8 +172,7 @@ IpcLogOutputter::notifyBuffer()
|
|||||||
ARCH->broadcastCondVar(m_notifyCond);
|
ARCH->broadcastCondVar(m_notifyCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
String
|
std::string IpcLogOutputter::getChunk(size_t count)
|
||||||
IpcLogOutputter::getChunk(size_t count)
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
||||||
|
|
||||||
@ -182,7 +180,7 @@ IpcLogOutputter::getChunk(size_t count)
|
|||||||
count = m_buffer.size();
|
count = m_buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
String chunk;
|
std::string chunk;
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
chunk.append(m_buffer.front());
|
chunk.append(m_buffer.front());
|
||||||
chunk.append("\n");
|
chunk.append("\n");
|
||||||
|
@ -93,12 +93,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void bufferThread(void*);
|
void bufferThread(void*);
|
||||||
String getChunk(size_t count);
|
std::string getChunk(size_t count);
|
||||||
void appendBuffer(const String& text);
|
void appendBuffer(const std::string& text);
|
||||||
bool isRunning();
|
bool isRunning();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::deque<String> Buffer;
|
typedef std::deque<std::string> Buffer;
|
||||||
|
|
||||||
IpcServer& m_ipcServer;
|
IpcServer& m_ipcServer;
|
||||||
Buffer m_buffer;
|
Buffer m_buffer;
|
||||||
|
@ -47,7 +47,7 @@ IpcShutdownMessage::~IpcShutdownMessage()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcLogLineMessage::IpcLogLineMessage(const String& logLine) :
|
IpcLogLineMessage::IpcLogLineMessage(const std::string& logLine) :
|
||||||
IpcMessage(kIpcLogLine),
|
IpcMessage(kIpcLogLine),
|
||||||
m_logLine(logLine)
|
m_logLine(logLine)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ IpcLogLineMessage::~IpcLogLineMessage()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcCommandMessage::IpcCommandMessage(const String& command, bool elevate) :
|
IpcCommandMessage::IpcCommandMessage(const std::string& command, bool elevate) :
|
||||||
IpcMessage(kIpcCommand),
|
IpcMessage(kIpcCommand),
|
||||||
m_command(command),
|
m_command(command),
|
||||||
m_elevate(elevate)
|
m_elevate(elevate)
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
#include "ipc/Ipc.h"
|
#include "ipc/Ipc.h"
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class IpcMessage : public EventData {
|
class IpcMessage : public EventData {
|
||||||
public:
|
public:
|
||||||
@ -58,28 +58,28 @@ public:
|
|||||||
|
|
||||||
class IpcLogLineMessage : public IpcMessage {
|
class IpcLogLineMessage : public IpcMessage {
|
||||||
public:
|
public:
|
||||||
IpcLogLineMessage(const String& logLine);
|
IpcLogLineMessage(const std::string& logLine);
|
||||||
virtual ~IpcLogLineMessage();
|
virtual ~IpcLogLineMessage();
|
||||||
|
|
||||||
//! Gets the log line.
|
//! Gets the log line.
|
||||||
String logLine() const { return m_logLine; }
|
std::string logLine() const { return m_logLine; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_logLine;
|
std::string m_logLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IpcCommandMessage : public IpcMessage {
|
class IpcCommandMessage : public IpcMessage {
|
||||||
public:
|
public:
|
||||||
IpcCommandMessage(const String& command, bool elevate);
|
IpcCommandMessage(const std::string& command, bool elevate);
|
||||||
virtual ~IpcCommandMessage();
|
virtual ~IpcCommandMessage();
|
||||||
|
|
||||||
//! Gets the command.
|
//! 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.
|
//! Gets whether or not the process should be elevated on MS Windows.
|
||||||
bool elevate() const { return m_elevate; }
|
bool elevate() const { return m_elevate; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_command;
|
std::string m_command;
|
||||||
bool m_elevate;
|
bool m_elevate;
|
||||||
};
|
};
|
||||||
|
@ -94,7 +94,7 @@ IpcServerProxy::send(const IpcMessage& message)
|
|||||||
|
|
||||||
case kIpcCommand: {
|
case kIpcCommand: {
|
||||||
const IpcCommandMessage& cm = static_cast<const IpcCommandMessage&>(message);
|
const IpcCommandMessage& cm = static_cast<const IpcCommandMessage&>(message);
|
||||||
const String command = cm.command();
|
std::string command = cm.command();
|
||||||
ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command);
|
ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ IpcServerProxy::send(const IpcMessage& message)
|
|||||||
IpcLogLineMessage*
|
IpcLogLineMessage*
|
||||||
IpcServerProxy::parseLogLine()
|
IpcServerProxy::parseLogLine()
|
||||||
{
|
{
|
||||||
String logLine;
|
std::string logLine;
|
||||||
ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine);
|
ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine);
|
||||||
|
|
||||||
// must be deleted by event handler.
|
// must be deleted by event handler.
|
||||||
|
Loading…
Reference in New Issue
Block a user