logic: more wstring usages
* removed header paths from VS Project setup message since VS doesn't send these anymore * implemented using wstring in IDE communication * fixed retrieving filepaths from QtDirectoryListbox that contain special characters * use wstring for source extensions * added special character as file extension to FileManagerTestSuite
This commit is contained in:
@@ -26,7 +26,7 @@ void IDECommunicationController::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void IDECommunicationController::handleIncomingMessage(const std::string& message)
|
||||
void IDECommunicationController::handleIncomingMessage(const std::wstring& message)
|
||||
{
|
||||
if (m_enabled == false)
|
||||
{
|
||||
@@ -70,10 +70,7 @@ void IDECommunicationController::setEnabled(const bool enabled)
|
||||
void IDECommunicationController::sendUpdatePing()
|
||||
{
|
||||
// first reset connection status
|
||||
MessagePingReceived msg;
|
||||
msg.ideId = "";
|
||||
msg.ideName = "";
|
||||
msg.dispatch();
|
||||
MessagePingReceived().dispatch();
|
||||
|
||||
// send ping to update connection status
|
||||
sendMessage(NetworkProtocolHelper::buildPingMessage());
|
||||
@@ -87,7 +84,7 @@ void IDECommunicationController::handleSetActiveTokenMessage(
|
||||
{
|
||||
const unsigned int cursorColumn = message.column;
|
||||
|
||||
const FilePath filePath = FilePath(message.fileLocation).makeCanonical();
|
||||
const FilePath filePath = message.filePath.getCanonical();
|
||||
|
||||
if (FileSystem::getFileInfoForPath(filePath).lastWriteTime
|
||||
== m_storageAccess->getFileInfoForFilePath(filePath).lastWriteTime)
|
||||
@@ -152,7 +149,7 @@ void IDECommunicationController::handleCreateCDBProjectMessage(const NetworkProt
|
||||
{
|
||||
if (message.valid)
|
||||
{
|
||||
MessageProjectNew(message.cdbFileLocation, message.headerPaths).dispatch();
|
||||
MessageProjectNew(message.cdbFileLocation).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,10 +166,10 @@ void IDECommunicationController::handlePing(const NetworkProtocolHelper::PingMes
|
||||
|
||||
if (msg.ideName.empty())
|
||||
{
|
||||
msg.ideName = "unknown IDE";
|
||||
msg.ideName = L"unknown IDE";
|
||||
}
|
||||
|
||||
LOG_INFO(msg.ideName + " instance detected via plugin port");
|
||||
LOG_INFO(msg.ideName + L" instance detected via plugin port");
|
||||
msg.dispatch();
|
||||
}
|
||||
else
|
||||
@@ -191,7 +188,7 @@ void IDECommunicationController::handleMessage(MessageWindowFocus* message)
|
||||
|
||||
void IDECommunicationController::handleMessage(MessageIDECreateCDB* message)
|
||||
{
|
||||
std::string networkMessage = NetworkProtocolHelper::buildCreateCDBMessage();
|
||||
std::wstring networkMessage = NetworkProtocolHelper::buildCreateCDBMessage();
|
||||
|
||||
MessageStatus(L"Requesting IDE to create Compilation Database via plug-in.").dispatch();
|
||||
|
||||
@@ -200,13 +197,13 @@ void IDECommunicationController::handleMessage(MessageIDECreateCDB* message)
|
||||
|
||||
void IDECommunicationController::handleMessage(MessageMoveIDECursor* message)
|
||||
{
|
||||
std::string networkMessage = NetworkProtocolHelper::buildSetIDECursorMessage(
|
||||
message->FilePosition.str(), message->Row, message->Column
|
||||
std::wstring networkMessage = NetworkProtocolHelper::buildSetIDECursorMessage(
|
||||
message->filePath, message->row, message->column
|
||||
);
|
||||
|
||||
MessageStatus(
|
||||
L"Jump to source location via plug-in: " + message->FilePosition.wstr() + L", row: " +
|
||||
std::to_wstring(message->Row) + L", col: " + std::to_wstring(message->Column)
|
||||
L"Jump to source location via plug-in: " + message->filePath.wstr() + L", row: " +
|
||||
std::to_wstring(message->row) + L", col: " + std::to_wstring(message->column)
|
||||
).dispatch();
|
||||
|
||||
sendMessage(networkMessage);
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
virtual void stopListening() = 0;
|
||||
virtual bool isListening() const = 0;
|
||||
|
||||
void handleIncomingMessage(const std::string& message);
|
||||
void handleIncomingMessage(const std::wstring& message);
|
||||
|
||||
bool getEnabled() const;
|
||||
void setEnabled(const bool enabled);
|
||||
@@ -49,7 +49,7 @@ private:
|
||||
virtual void handleMessage(MessageIDECreateCDB* message);
|
||||
virtual void handleMessage(MessageMoveIDECursor* message);
|
||||
virtual void handleMessage(MessagePluginPortChange* message);
|
||||
virtual void sendMessage(const std::string& message) const = 0;
|
||||
virtual void sendMessage(const std::wstring& message) const = 0;
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
|
||||
void StatusBarController::handleMessage(MessagePingReceived* message)
|
||||
{
|
||||
std::string status = "No IDE connected";
|
||||
std::wstring status = L"No IDE connected";
|
||||
|
||||
if (message->ideName.length() > 0)
|
||||
if (!message->ideName.empty())
|
||||
{
|
||||
status = "Connected to ";
|
||||
status = L"Connected to ";
|
||||
status += message->ideName;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,35 +6,36 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::string NetworkProtocolHelper::m_divider = ">>";
|
||||
std::string NetworkProtocolHelper::m_setActiveTokenPrefix = "setActiveToken";
|
||||
std::string NetworkProtocolHelper::m_moveCursorPrefix = "moveCursor";
|
||||
std::string NetworkProtocolHelper::m_endOfMessageToken = "<EOM>";
|
||||
std::string NetworkProtocolHelper::m_createProjectPrefix = "createProject";
|
||||
std::string NetworkProtocolHelper::m_createCDBProjectPrefix = "createCDBProject";
|
||||
std::string NetworkProtocolHelper::m_createCDBPrefix = "createCDB";
|
||||
std::string NetworkProtocolHelper::m_pingPrefix = "ping";
|
||||
std::wstring NetworkProtocolHelper::s_divider = L">>";
|
||||
std::wstring NetworkProtocolHelper::s_setActiveTokenPrefix = L"setActiveToken";
|
||||
std::wstring NetworkProtocolHelper::s_moveCursorPrefix = L"moveCursor";
|
||||
std::wstring NetworkProtocolHelper::s_endOfMessageToken = L"<EOM>";
|
||||
std::wstring NetworkProtocolHelper::s_createProjectPrefix = L"createProject";
|
||||
std::wstring NetworkProtocolHelper::s_createCDBProjectPrefix = L"createCDBProject";
|
||||
std::wstring NetworkProtocolHelper::s_createCDBPrefix = L"createCDB";
|
||||
std::wstring NetworkProtocolHelper::s_pingPrefix = L"ping";
|
||||
|
||||
NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const std::string& message)
|
||||
NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const std::wstring& message)
|
||||
{
|
||||
std::vector<std::string> subMessages = divideMessage(message);
|
||||
std::vector<std::wstring> subMessages = divideMessage(message);
|
||||
|
||||
if (subMessages.size() > 0)
|
||||
if (!subMessages.empty())
|
||||
{
|
||||
if (subMessages[0] == m_setActiveTokenPrefix)
|
||||
if (subMessages[0] == s_setActiveTokenPrefix)
|
||||
{
|
||||
return MESSAGE_TYPE::SET_ACTIVE_TOKEN;
|
||||
}
|
||||
else if (subMessages[0] == m_createProjectPrefix)
|
||||
else if (subMessages[0] == s_createProjectPrefix)
|
||||
{
|
||||
return MESSAGE_TYPE::CREATE_PROJECT;
|
||||
}
|
||||
else if (subMessages[0] == m_createCDBProjectPrefix)
|
||||
else if (subMessages[0] == s_createCDBProjectPrefix)
|
||||
{
|
||||
return MESSAGE_TYPE::CREATE_CDB_MESSAGE;
|
||||
}
|
||||
else if (subMessages[0] == m_pingPrefix)
|
||||
else if (subMessages[0] == s_pingPrefix)
|
||||
{
|
||||
return MESSAGE_TYPE::PING;
|
||||
}
|
||||
@@ -47,34 +48,34 @@ NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const
|
||||
return MESSAGE_TYPE::UNKNOWN;
|
||||
}
|
||||
|
||||
NetworkProtocolHelper::SetActiveTokenMessage NetworkProtocolHelper::parseSetActiveTokenMessage(const std::string& message)
|
||||
NetworkProtocolHelper::SetActiveTokenMessage NetworkProtocolHelper::parseSetActiveTokenMessage(const std::wstring& message)
|
||||
{
|
||||
std::vector<std::string> subMessages = divideMessage(message);
|
||||
std::vector<std::wstring> subMessages = divideMessage(message);
|
||||
|
||||
SetActiveTokenMessage networkMessage;
|
||||
|
||||
if (subMessages.size() > 0)
|
||||
if (!subMessages.empty())
|
||||
{
|
||||
if (subMessages[0] == m_setActiveTokenPrefix)
|
||||
if (subMessages[0] == s_setActiveTokenPrefix)
|
||||
{
|
||||
if (subMessages.size() != 5)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse setActiveToken message, invalid token count");
|
||||
LOG_ERROR("Failed to parse setActiveToken message, invalid token count");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fileLocation = subMessages[1];
|
||||
std::string row = subMessages[2];
|
||||
std::string column = subMessages[3];
|
||||
const std::wstring filePath = subMessages[1];
|
||||
const std::wstring row = subMessages[2];
|
||||
const std::wstring column = subMessages[3];
|
||||
|
||||
if(
|
||||
fileLocation.length() > 0
|
||||
&& row.length() > 0
|
||||
&& column.length() > 0
|
||||
!filePath.empty()
|
||||
&& !row.empty()
|
||||
&& !column.empty()
|
||||
&& isDigits(row)
|
||||
&& isDigits(column)
|
||||
){
|
||||
networkMessage.fileLocation = fileLocation;
|
||||
networkMessage.filePath = FilePath(filePath);
|
||||
networkMessage.row = std::stoi(row);
|
||||
networkMessage.column = std::stoi(column);
|
||||
networkMessage.valid = true;
|
||||
@@ -83,110 +84,79 @@ NetworkProtocolHelper::SetActiveTokenMessage NetworkProtocolHelper::parseSetActi
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_setActiveTokenPrefix);
|
||||
LOG_ERROR(L"Failed to parse message, invalid type token: " + subMessages[0] + L". Expected " + s_setActiveTokenPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return networkMessage;
|
||||
}
|
||||
|
||||
NetworkProtocolHelper::CreateProjectMessage NetworkProtocolHelper::parseCreateProjectMessage(const std::string& message)
|
||||
NetworkProtocolHelper::CreateProjectMessage NetworkProtocolHelper::parseCreateProjectMessage(const std::wstring& message)
|
||||
{
|
||||
std::vector<std::string> subMessages = divideMessage(message);
|
||||
std::vector<std::wstring> subMessages = divideMessage(message);
|
||||
|
||||
NetworkProtocolHelper::CreateProjectMessage networkMessage;
|
||||
|
||||
if (subMessages.size() > 0)
|
||||
if (!subMessages.empty())
|
||||
{
|
||||
if (subMessages[0] == m_createProjectPrefix)
|
||||
if (subMessages[0] == s_createProjectPrefix)
|
||||
{
|
||||
if (subMessages.size() != 4)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse createProject message, invalid token count");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fileLocation = subMessages[1];
|
||||
std::string ideId = subMessages[2];
|
||||
if (fileLocation.length() > 0
|
||||
&& ideId.length() > 0)
|
||||
{
|
||||
networkMessage.solutionFileLocation = fileLocation;
|
||||
|
||||
std::string nonConstId = ideId;
|
||||
boost::algorithm::to_lower(nonConstId);
|
||||
|
||||
networkMessage.ideId = nonConstId;
|
||||
|
||||
networkMessage.valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Failed to parse ide ID string. Is " << ideId);
|
||||
}
|
||||
LOG_ERROR("Failed to parse createProject message, invalid token count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_createProjectPrefix);
|
||||
LOG_ERROR(L"Failed to parse message, invalid type token: " + subMessages[0] + L". Expected " + s_createProjectPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return networkMessage;
|
||||
}
|
||||
|
||||
NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreateCDBProjectMessage(const std::string& message)
|
||||
NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreateCDBProjectMessage(const std::wstring& message)
|
||||
{
|
||||
std::vector<std::string> subMessages = divideMessage(message);
|
||||
std::vector<std::wstring> subMessages = divideMessage(message);
|
||||
|
||||
NetworkProtocolHelper::CreateCDBProjectMessage networkMessage;
|
||||
|
||||
if (subMessages.size() > 0)
|
||||
if (!subMessages.empty())
|
||||
{
|
||||
if (subMessages[0] == m_createCDBProjectPrefix)
|
||||
if (subMessages[0] == s_createCDBProjectPrefix)
|
||||
{
|
||||
if (subMessages.size() < 4)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse createCDBProject message, too few tokens");
|
||||
LOG_ERROR("Failed to parse createCDBProject message, too few tokens");
|
||||
}
|
||||
else
|
||||
{
|
||||
int subMessageCount = subMessages.size();
|
||||
const int subMessageCount = subMessages.size();
|
||||
|
||||
std::string cdbPath = subMessages[1];
|
||||
if (cdbPath.length() > 0)
|
||||
const std::wstring cdbPath = subMessages[1];
|
||||
if (!cdbPath.empty())
|
||||
{
|
||||
networkMessage.cdbFileLocation = cdbPath;
|
||||
networkMessage.cdbFileLocation = FilePath(cdbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "CDB file path is not set.");
|
||||
LOG_WARNING("CDB file path is not set.");
|
||||
}
|
||||
|
||||
std::vector<std::string> headerPaths;
|
||||
for (int i = 2; i < subMessageCount - 2; i++)
|
||||
const std::wstring ideId = subMessages[subMessageCount - 2];
|
||||
if (!ideId.empty())
|
||||
{
|
||||
if (subMessages[i].length() > 0)
|
||||
{
|
||||
headerPaths.push_back(subMessages[i]);
|
||||
}
|
||||
}
|
||||
networkMessage.headerPaths = headerPaths;
|
||||
|
||||
std::string ideId = subMessages[subMessageCount - 2];
|
||||
if (ideId.length() > 0)
|
||||
{
|
||||
std::string nonConstId = ideId;
|
||||
std::wstring nonConstId = ideId;
|
||||
boost::algorithm::to_lower(nonConstId);
|
||||
|
||||
networkMessage.ideId = nonConstId;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Failed to parse ide ID string. Is " << ideId);
|
||||
LOG_WARNING(L"Failed to parse ide ID string. Is " + ideId);
|
||||
}
|
||||
|
||||
if (networkMessage.cdbFileLocation.length() > 0 && networkMessage.ideId.length() > 0)
|
||||
if (!networkMessage.cdbFileLocation.empty() && !networkMessage.ideId.empty())
|
||||
{
|
||||
networkMessage.valid = true;
|
||||
}
|
||||
@@ -194,22 +164,22 @@ NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreat
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_createCDBProjectPrefix);
|
||||
LOG_ERROR(L"Failed to parse message, invalid type token: " + subMessages[0] + L". Expected " + s_createCDBProjectPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return networkMessage;
|
||||
}
|
||||
|
||||
NetworkProtocolHelper::PingMessage NetworkProtocolHelper::parsePingMessage(const std::string& message)
|
||||
NetworkProtocolHelper::PingMessage NetworkProtocolHelper::parsePingMessage(const std::wstring& message)
|
||||
{
|
||||
std::vector<std::string> subMessages = divideMessage(message);
|
||||
std::vector<std::wstring> subMessages = divideMessage(message);
|
||||
|
||||
NetworkProtocolHelper::PingMessage pingMessage;
|
||||
|
||||
if (subMessages.size() > 0)
|
||||
if (!subMessages.empty())
|
||||
{
|
||||
if (subMessages[0] == m_pingPrefix)
|
||||
if (subMessages[0] == s_pingPrefix)
|
||||
{
|
||||
if (subMessages.size() < 2)
|
||||
{
|
||||
@@ -217,11 +187,11 @@ NetworkProtocolHelper::PingMessage NetworkProtocolHelper::parsePingMessage(const
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string ideId = subMessages[1];
|
||||
std::wstring ideId = subMessages[1];
|
||||
|
||||
if (ideId.length() > 0)
|
||||
if (!ideId.empty())
|
||||
{
|
||||
std::string nonConstId = ideId;
|
||||
std::wstring nonConstId = ideId;
|
||||
boost::algorithm::to_lower(nonConstId);
|
||||
|
||||
pingMessage.ideId = ideId;
|
||||
@@ -230,78 +200,78 @@ NetworkProtocolHelper::PingMessage NetworkProtocolHelper::parsePingMessage(const
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Failed to parse ide ID string. Is " << ideId);
|
||||
LOG_WARNING(L"Failed to parse ide ID string: " + ideId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_pingPrefix);
|
||||
LOG_ERROR(L"Failed to parse message, invalid type token: " + subMessages[0] + L". Expected " + s_pingPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return pingMessage;
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::buildSetIDECursorMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column)
|
||||
std::wstring NetworkProtocolHelper::buildSetIDECursorMessage(const FilePath& fileLocation, const unsigned int row, const unsigned int column)
|
||||
{
|
||||
std::stringstream messageStream;
|
||||
std::wstringstream messageStream;
|
||||
|
||||
messageStream << m_moveCursorPrefix;
|
||||
messageStream << m_divider;
|
||||
messageStream << fileLocation;
|
||||
messageStream << m_divider;
|
||||
messageStream << s_moveCursorPrefix;
|
||||
messageStream << s_divider;
|
||||
messageStream << fileLocation.wstr();
|
||||
messageStream << s_divider;
|
||||
messageStream << row;
|
||||
messageStream << m_divider;
|
||||
messageStream << s_divider;
|
||||
messageStream << column;
|
||||
messageStream << m_endOfMessageToken;
|
||||
messageStream << s_endOfMessageToken;
|
||||
|
||||
return messageStream.str();
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::buildCreateCDBMessage()
|
||||
std::wstring NetworkProtocolHelper::buildCreateCDBMessage()
|
||||
{
|
||||
std::stringstream messageStream;
|
||||
std::wstringstream messageStream;
|
||||
|
||||
messageStream << m_createCDBPrefix;
|
||||
messageStream << m_endOfMessageToken;
|
||||
messageStream << s_createCDBPrefix;
|
||||
messageStream << s_endOfMessageToken;
|
||||
|
||||
return messageStream.str();
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::buildPingMessage()
|
||||
std::wstring NetworkProtocolHelper::buildPingMessage()
|
||||
{
|
||||
std::stringstream messageStream;
|
||||
std::wstringstream messageStream;
|
||||
|
||||
messageStream << m_pingPrefix;
|
||||
messageStream << m_divider;
|
||||
messageStream << s_pingPrefix;
|
||||
messageStream << s_divider;
|
||||
messageStream << "sourcetrail";
|
||||
messageStream << m_endOfMessageToken;
|
||||
messageStream << s_endOfMessageToken;
|
||||
|
||||
return messageStream.str();
|
||||
}
|
||||
|
||||
std::vector<std::string> NetworkProtocolHelper::divideMessage(const std::string& message)
|
||||
std::vector<std::wstring> NetworkProtocolHelper::divideMessage(const std::wstring& message)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
std::vector<std::wstring> result;
|
||||
|
||||
std::string msg = message;
|
||||
size_t pos = msg.find(m_divider);
|
||||
std::wstring msg = message;
|
||||
size_t pos = msg.find(s_divider);
|
||||
|
||||
while (pos != std::string::npos)
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
std::string subMessage = msg.substr(0, pos);
|
||||
std::wstring subMessage = msg.substr(0, pos);
|
||||
result.push_back(subMessage);
|
||||
msg = msg.substr(pos + m_divider.size());
|
||||
pos = msg.find(m_divider);
|
||||
msg = msg.substr(pos + s_divider.size());
|
||||
pos = msg.find(s_divider);
|
||||
}
|
||||
|
||||
if (msg.size() > 0)
|
||||
{
|
||||
pos = msg.find(m_endOfMessageToken);
|
||||
if (pos != std::string::npos)
|
||||
pos = msg.find(s_endOfMessageToken);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::string subMessage = msg.substr(0, pos);
|
||||
std::wstring subMessage = msg.substr(0, pos);
|
||||
result.push_back(subMessage);
|
||||
msg = msg.substr(pos);
|
||||
result.push_back(msg);
|
||||
@@ -311,35 +281,7 @@ std::vector<std::string> NetworkProtocolHelper::divideMessage(const std::string&
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::removeEndOfMessageToken(const std::string& message)
|
||||
bool NetworkProtocolHelper::isDigits(const std::wstring& text)
|
||||
{
|
||||
size_t pos = message.find(m_endOfMessageToken);
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
return message.substr(0, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::getSubstringAfterString(const std::string& message, const std::string& searchString, std::string& subMessage)
|
||||
{
|
||||
std::string result = "";
|
||||
|
||||
size_t pos = message.find(searchString);
|
||||
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
result = message.substr(0, pos);
|
||||
subMessage = message.substr(pos + searchString.length());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool NetworkProtocolHelper::isDigits(const std::string& text)
|
||||
{
|
||||
return (text.find_first_not_of("0123456789") == std::string::npos);
|
||||
return (text.find_first_not_of(L"0123456789") == std::wstring::npos);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class NetworkProtocolHelper
|
||||
{
|
||||
public:
|
||||
@@ -11,13 +13,13 @@ public:
|
||||
{
|
||||
public:
|
||||
SetActiveTokenMessage()
|
||||
: fileLocation("")
|
||||
: filePath(L"")
|
||||
, row(0)
|
||||
, column(0)
|
||||
, valid(false)
|
||||
{}
|
||||
|
||||
std::string fileLocation;
|
||||
FilePath filePath;
|
||||
unsigned int row;
|
||||
unsigned int column;
|
||||
bool valid;
|
||||
@@ -25,31 +27,19 @@ public:
|
||||
|
||||
struct CreateProjectMessage
|
||||
{
|
||||
public:
|
||||
CreateProjectMessage()
|
||||
: solutionFileLocation("")
|
||||
, ideId("")
|
||||
, valid(false)
|
||||
{}
|
||||
|
||||
std::string solutionFileLocation;
|
||||
std::string ideId;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
struct CreateCDBProjectMessage
|
||||
{
|
||||
public:
|
||||
CreateCDBProjectMessage()
|
||||
: cdbFileLocation("")
|
||||
, headerPaths()
|
||||
, ideId("")
|
||||
: cdbFileLocation(L"")
|
||||
, ideId(L"")
|
||||
, valid(false)
|
||||
{}
|
||||
|
||||
std::string cdbFileLocation;
|
||||
std::vector<std::string> headerPaths;
|
||||
std::string ideId;
|
||||
FilePath cdbFileLocation;
|
||||
std::wstring ideId;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
@@ -57,11 +47,11 @@ public:
|
||||
{
|
||||
public:
|
||||
PingMessage()
|
||||
: ideId("")
|
||||
: ideId(L"")
|
||||
, valid(false)
|
||||
{}
|
||||
|
||||
std::string ideId;
|
||||
std::wstring ideId;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
@@ -74,33 +64,29 @@ public:
|
||||
PING
|
||||
};
|
||||
|
||||
static MESSAGE_TYPE getMessageType(const std::string& message);
|
||||
static MESSAGE_TYPE getMessageType(const std::wstring& message);
|
||||
|
||||
static SetActiveTokenMessage parseSetActiveTokenMessage(const std::string& message);
|
||||
static CreateProjectMessage parseCreateProjectMessage(const std::string& message);
|
||||
static CreateCDBProjectMessage parseCreateCDBProjectMessage(const std::string& message);
|
||||
static PingMessage parsePingMessage(const std::string& message);
|
||||
static SetActiveTokenMessage parseSetActiveTokenMessage(const std::wstring& message);
|
||||
static CreateProjectMessage parseCreateProjectMessage(const std::wstring& message);
|
||||
static CreateCDBProjectMessage parseCreateCDBProjectMessage(const std::wstring& message);
|
||||
static PingMessage parsePingMessage(const std::wstring& message);
|
||||
|
||||
static std::string buildSetIDECursorMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column);
|
||||
static std::string buildCreateCDBMessage();
|
||||
static std::string buildPingMessage();
|
||||
static std::wstring buildSetIDECursorMessage(const FilePath& fileLocation, const unsigned int row, const unsigned int column);
|
||||
static std::wstring buildCreateCDBMessage();
|
||||
static std::wstring buildPingMessage();
|
||||
|
||||
private:
|
||||
static std::vector<std::string> divideMessage(const std::string& message);
|
||||
static std::vector<std::wstring> divideMessage(const std::wstring& message);
|
||||
static bool isDigits(const std::wstring& text);
|
||||
|
||||
static std::string removeEndOfMessageToken(const std::string& message);
|
||||
|
||||
static std::string getSubstringAfterString(const std::string& message, const std::string& searchString, std::string& subMessage);
|
||||
static bool isDigits(const std::string& text);
|
||||
|
||||
static std::string m_divider;
|
||||
static std::string m_setActiveTokenPrefix;
|
||||
static std::string m_moveCursorPrefix;
|
||||
static std::string m_endOfMessageToken;
|
||||
static std::string m_createProjectPrefix;
|
||||
static std::string m_createCDBProjectPrefix;
|
||||
static std::string m_createCDBPrefix;
|
||||
static std::string m_pingPrefix;
|
||||
static std::wstring s_divider;
|
||||
static std::wstring s_setActiveTokenPrefix;
|
||||
static std::wstring s_moveCursorPrefix;
|
||||
static std::wstring s_endOfMessageToken;
|
||||
static std::wstring s_createProjectPrefix;
|
||||
static std::wstring s_createCDBProjectPrefix;
|
||||
static std::wstring s_createCDBPrefix;
|
||||
static std::wstring s_pingPrefix;
|
||||
};
|
||||
|
||||
#endif // NETWORK_PROTOCOL_HELPER_H
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
virtual void showMessage(const std::wstring& message, bool isError, bool showLoader) = 0;
|
||||
virtual void setErrorCount(ErrorCountInfo errorCount) = 0;
|
||||
|
||||
virtual void showIdeStatus(const std::string& message) = 0;
|
||||
virtual void showIdeStatus(const std::wstring& message) = 0;
|
||||
|
||||
protected:
|
||||
StatusBarController* getController();
|
||||
|
||||
@@ -13,7 +13,7 @@ SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType
|
||||
, m_standard("")
|
||||
, m_sourcePaths(std::vector<FilePath>())
|
||||
, m_excludePaths(std::vector<FilePath>())
|
||||
, m_sourceExtensions(std::vector<std::string>())
|
||||
, m_sourceExtensions(std::vector<std::wstring>())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void SourceGroupSettings::load(std::shared_ptr<const ConfigManager> config)
|
||||
setStandard(getValue<std::string>(key + "/standard", "", config));
|
||||
setSourcePaths(getPathValues(key + "/source_paths/source_path", config));
|
||||
setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path", config));
|
||||
setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::string>(), config));
|
||||
setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::wstring>(), config));
|
||||
}
|
||||
|
||||
void SourceGroupSettings::save(std::shared_ptr<ConfigManager> config)
|
||||
@@ -158,7 +158,7 @@ void SourceGroupSettings::setExcludePaths(const std::vector<FilePath>& excludePa
|
||||
m_excludePaths = excludePaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettings::getSourceExtensions() const
|
||||
std::vector<std::wstring> SourceGroupSettings::getSourceExtensions() const
|
||||
{
|
||||
if (m_sourceExtensions.empty())
|
||||
{
|
||||
@@ -167,7 +167,7 @@ std::vector<std::string> SourceGroupSettings::getSourceExtensions() const
|
||||
return m_sourceExtensions;
|
||||
}
|
||||
|
||||
void SourceGroupSettings::setSourceExtensions(const std::vector<std::string>& sourceExtensions)
|
||||
void SourceGroupSettings::setSourceExtensions(const std::vector<std::wstring>& sourceExtensions)
|
||||
{
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
std::vector<FilePath> getExcludePathsExpandedAndAbsolute() const;
|
||||
void setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
void setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
std::vector<std::wstring> getSourceExtensions() const;
|
||||
void setSourceExtensions(const std::vector<std::wstring>& sourceExtensions);
|
||||
|
||||
protected:
|
||||
template<typename T>
|
||||
@@ -73,7 +73,7 @@ protected:
|
||||
const ProjectSettings* m_projectSettings;
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const = 0;
|
||||
virtual std::vector<std::wstring> getDefaultSourceExtensions() const = 0;
|
||||
virtual std::string getDefaultStandard() const = 0;
|
||||
|
||||
std::string m_id;
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
std::string m_standard;
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
std::vector<std::wstring> m_sourceExtensions;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -143,19 +143,19 @@ void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::string>& co
|
||||
m_compilerFlags = compilerFlags;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getDefaultSourceExtensions() const
|
||||
std::vector<std::wstring> SourceGroupSettingsCxx::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
std::vector<std::wstring> defaultValues;
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
defaultValues.push_back(L".cpp");
|
||||
defaultValues.push_back(L".cxx");
|
||||
defaultValues.push_back(L".cc");
|
||||
break;
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
defaultValues.push_back(".c");
|
||||
defaultValues.push_back(L".c");
|
||||
break;
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
default:
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
void setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const override;
|
||||
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
|
||||
virtual std::string getDefaultStandard() const override;
|
||||
|
||||
std::vector<FilePath> m_headerSearchPaths;
|
||||
|
||||
@@ -74,9 +74,9 @@ void SourceGroupSettingsJava::setClasspath(const std::vector<FilePath>& classpat
|
||||
{
|
||||
m_classpath = classpath;
|
||||
}
|
||||
std::vector<std::string> SourceGroupSettingsJava::getDefaultSourceExtensions() const
|
||||
std::vector<std::wstring> SourceGroupSettingsJava::getDefaultSourceExtensions() const
|
||||
{
|
||||
return std::vector<std::string>(1, ".java");
|
||||
return { L".java" };
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsJava::getDefaultStandard() const
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
void setClasspath(const std::vector<FilePath>& classpath);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const override;
|
||||
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
|
||||
virtual std::string getDefaultStandard() const override;
|
||||
|
||||
bool m_useJreSystemLibrary;
|
||||
|
||||
@@ -16,7 +16,7 @@ FileManager::~FileManager()
|
||||
void FileManager::update(
|
||||
const std::vector<FilePath>& sourcePaths,
|
||||
const std::vector<FilePath>& excludePaths,
|
||||
const std::vector<std::string>& sourceExtensions
|
||||
const std::vector<std::wstring>& sourceExtensions
|
||||
){
|
||||
m_sourcePaths = sourcePaths;
|
||||
m_excludePaths = makeCanonical(excludePaths);
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
void update(
|
||||
const std::vector<FilePath>& sourcePaths,
|
||||
const std::vector<FilePath>& excludePaths,
|
||||
const std::vector<std::string>& sourceExtensions
|
||||
const std::vector<std::wstring>& sourceExtensions
|
||||
);
|
||||
|
||||
// returns a list of source paths (can be directories) specified in the project settings
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
std::vector<std::wstring> m_sourceExtensions;
|
||||
|
||||
std::set<FilePath> m_allSourceFilePaths;
|
||||
};
|
||||
|
||||
@@ -396,6 +396,11 @@ std::string FilePath::extension() const
|
||||
return m_path->extension().generic_string();
|
||||
}
|
||||
|
||||
std::wstring FilePath::wExtension() const
|
||||
{
|
||||
return m_path->extension().generic_wstring();
|
||||
}
|
||||
|
||||
FilePath FilePath::withoutExtension() const
|
||||
{
|
||||
return FilePath(getPath().replace_extension().wstring());
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
std::wstring wFileName() const;
|
||||
|
||||
std::string extension() const;
|
||||
std::wstring wExtension() const;
|
||||
FilePath withoutExtension() const;
|
||||
FilePath replaceExtension(const std::string& extension) const;
|
||||
bool hasExtension(const std::vector<std::string>& extensions) const;
|
||||
|
||||
@@ -50,10 +50,10 @@ FileInfo FileSystem::getFileInfoForPath(const FilePath& filePath)
|
||||
}
|
||||
|
||||
std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
const std::vector<FilePath>& paths, const std::vector<std::string>& fileExtensions, bool followSymLinks
|
||||
const std::vector<FilePath>& paths, const std::vector<std::wstring>& fileExtensions, bool followSymLinks
|
||||
){
|
||||
std::set<std::string> ext;
|
||||
for (const std::string& e : fileExtensions)
|
||||
std::set<std::wstring> ext;
|
||||
for (const std::wstring& e : fileExtensions)
|
||||
{
|
||||
ext.insert(utility::toLowerCase(e));
|
||||
}
|
||||
@@ -103,7 +103,7 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
}
|
||||
|
||||
if (boost::filesystem::is_regular_file(*it) &&
|
||||
(!ext.size() || ext.find(utility::toLowerCase(it->path().extension().string())) != ext.end()))
|
||||
(ext.empty() || ext.find(utility::toLowerCase(it->path().extension().wstring())) != ext.end()))
|
||||
{
|
||||
boost::filesystem::path p = boost::filesystem::canonical(it->path());
|
||||
if (filePaths.find(p) != filePaths.end())
|
||||
@@ -115,7 +115,7 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (path.exists() && (!ext.size() || ext.find(utility::toLowerCase(path.extension())) != ext.end()))
|
||||
else if (path.exists() && (ext.empty() || ext.find(utility::toLowerCase(path.wExtension())) != ext.end()))
|
||||
{
|
||||
const FilePath canonicalPath = path.getCanonical();
|
||||
boost::filesystem::path p = canonicalPath.getPath();
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
static FileInfo getFileInfoForPath(const FilePath& filePath);
|
||||
|
||||
static std::vector<FileInfo> getFileInfosFromPaths(
|
||||
const std::vector<FilePath>& paths, const std::vector<std::string>& fileExtensions, bool followSymLinks = true);
|
||||
const std::vector<FilePath>& paths, const std::vector<std::wstring>& fileExtensions, bool followSymLinks = true);
|
||||
|
||||
static std::set<FilePath> getSymLinkedDirectories(const std::vector<FilePath>& paths);
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
class MessageMoveIDECursor : public Message<MessageMoveIDECursor>
|
||||
{
|
||||
public:
|
||||
MessageMoveIDECursor(const FilePath& FilePos, const unsigned int Row, const unsigned int Column)
|
||||
: FilePosition(FilePos)
|
||||
, Row(Row)
|
||||
, Column(Column)
|
||||
MessageMoveIDECursor(const FilePath& filePath, const unsigned int row, const unsigned int column)
|
||||
: filePath(filePath)
|
||||
, row(row)
|
||||
, column(column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ public:
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << FilePosition.str() << ":" << Row << ":" << Column;
|
||||
os << filePath.str() << ":" << row << ":" << column;
|
||||
}
|
||||
|
||||
const FilePath FilePosition;
|
||||
const unsigned int Row;
|
||||
const unsigned int Column;
|
||||
const FilePath filePath;
|
||||
const unsigned int row;
|
||||
const unsigned int column;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_MOVE_IDE_CURSOR_H
|
||||
@@ -8,8 +8,7 @@ class MessagePingReceived
|
||||
{
|
||||
public:
|
||||
MessagePingReceived()
|
||||
: ideId("")
|
||||
, ideName("")
|
||||
: ideName(L"")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,8 +17,7 @@ public:
|
||||
return "MessagePingReceived";
|
||||
}
|
||||
|
||||
std::string ideId;
|
||||
std::string ideName;
|
||||
std::wstring ideName;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_PING_RECEIVED_H
|
||||
@@ -7,9 +7,8 @@ class MessageProjectNew
|
||||
: public Message<MessageProjectNew>
|
||||
{
|
||||
public:
|
||||
MessageProjectNew(const std::string cdbPath, const std::vector<std::string> headerPaths)
|
||||
MessageProjectNew(const FilePath& cdbPath)
|
||||
: cdbPath(cdbPath)
|
||||
, headerPaths(headerPaths)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,8 +17,7 @@ public:
|
||||
return "MessageProjectNew";
|
||||
}
|
||||
|
||||
const std::string cdbPath;
|
||||
const std::vector<std::string> headerPaths;
|
||||
const FilePath cdbPath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_PROJECT_NEW_H
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace
|
||||
{
|
||||
template <typename StringType>
|
||||
StringType doRreplace(StringType str, const StringType& from, const StringType& to)
|
||||
StringType doReplace(StringType str, const StringType& from, const StringType& to)
|
||||
{
|
||||
size_t pos = 0;
|
||||
|
||||
@@ -215,6 +215,13 @@ namespace utility
|
||||
return out;
|
||||
}
|
||||
|
||||
std::wstring toLowerCase(const std::wstring& in)
|
||||
{
|
||||
std::wstring out;
|
||||
std::transform(in.begin(), in.end(), std::back_inserter(out), tolower);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b)
|
||||
{
|
||||
if (a.size() == b.size())
|
||||
@@ -233,12 +240,12 @@ namespace utility
|
||||
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to)
|
||||
{
|
||||
return doRreplace(str, from, to);
|
||||
return doReplace(str, from, to);
|
||||
}
|
||||
|
||||
std::wstring replace(std::wstring str, const std::wstring& from, const std::wstring& to)
|
||||
{
|
||||
return doRreplace(str, from, to);
|
||||
return doReplace(str, from, to);
|
||||
}
|
||||
|
||||
std::string replaceBetween(const std::string& str, char startDelimiter, char endDelimiter, const std::string& to)
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace utility
|
||||
template <typename ContainerType>
|
||||
ContainerType split(const std::string& str, const std::string& delimiter);
|
||||
|
||||
template <typename ContainerType>
|
||||
ContainerType split(const std::wstring& str, const std::wstring& delimiter);
|
||||
|
||||
std::deque<std::string> split(const std::string& str, char delimiter);
|
||||
std::deque<std::string> split(const std::string& str, const std::string& delimiter);
|
||||
std::vector<std::string> splitToVector(const std::string& str, char delimiter);
|
||||
@@ -45,6 +48,7 @@ namespace utility
|
||||
|
||||
std::string toUpperCase(const std::string& in);
|
||||
std::string toLowerCase(const std::string& in);
|
||||
std::wstring toLowerCase(const std::wstring& in);
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b);
|
||||
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||
@@ -80,8 +84,24 @@ namespace utility
|
||||
pos = str.find(delimiter, oldPos);
|
||||
c.push_back(str.substr(oldPos, pos - oldPos));
|
||||
oldPos = pos + delimiter.size();
|
||||
}
|
||||
while (pos != std::string::npos);
|
||||
} while (pos != std::string::npos);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
template <typename ContainerType>
|
||||
ContainerType split(const std::wstring& str, const std::wstring& delimiter)
|
||||
{
|
||||
size_t pos = 0;
|
||||
size_t oldPos = 0;
|
||||
ContainerType c;
|
||||
|
||||
do
|
||||
{
|
||||
pos = str.find(delimiter, oldPos);
|
||||
c.push_back(str.substr(oldPos, pos - oldPos));
|
||||
oldPos = pos + delimiter.size();
|
||||
} while (pos != std::wstring::npos);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user