Skip to content

Commit

Permalink
Merge pull request #712 from p12tic/use-std-string-4
Browse files Browse the repository at this point in the history
lib/ipc: Use std::string directly instead of String typedef
  • Loading branch information
shymega authored May 30, 2020
2 parents df15e76 + 787f907 commit b02a20b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/lib/ipc/IpcClientProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ IpcClientProxy::parseHello()
IpcCommandMessage*
IpcClientProxy::parseCommand()
{
String command;
std::string command;
UInt8 elevate;
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);

Expand Down
8 changes: 3 additions & 5 deletions src/lib/ipc/IpcLogOutputter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -173,16 +172,15 @@ 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);

if (m_buffer.size() < 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");
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ipc/IpcLogOutputter.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class IpcLogOutputter : public ILogOutputter {
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;
Expand Down
14 changes: 7 additions & 7 deletions src/lib/ipc/IpcMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ IpcShutdownMessage::~IpcShutdownMessage()
{
}

IpcLogLineMessage::IpcLogLineMessage(const String& logLine) :
IpcMessage(kIpcLogLine),
m_logLine(logLine)
IpcLogLineMessage::IpcLogLineMessage(const std::string& logLine) :
IpcMessage(kIpcLogLine),
m_logLine(logLine)
{
}

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)
{
}

Expand Down
14 changes: 7 additions & 7 deletions src/lib/ipc/IpcMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -58,28 +58,28 @@ class IpcShutdownMessage : public IpcMessage {

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;
};
4 changes: 2 additions & 2 deletions src/lib/ipc/IpcServerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.
Expand Down

0 comments on commit b02a20b

Please sign in to comment.