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:
mlangkabel
2018-01-30 17:07:51 +01:00
parent 471b1757df
commit c99e79364f
46 changed files with 319 additions and 337 deletions
@@ -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
+1 -1
View File
@@ -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();
+4 -4
View File
@@ -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;
}
+4 -4
View File
@@ -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>
+6 -6
View File
@@ -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:
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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;
};
+5
View File
@@ -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());
+1
View File
@@ -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;
+5 -5
View File
@@ -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();
+1 -1
View File
@@ -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 -3
View File
@@ -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)
+22 -2
View File
@@ -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;
}
+33 -14
View File
@@ -61,9 +61,9 @@ void QtListItemWidget::setText(QString text)
{
const FilePath path(text.toStdWString());
const FilePath relPath = path.getRelativeTo(relativeRoot);
if (relPath.str().size() < path.str().size())
if (relPath.wstr().size() < path.wstr().size())
{
text = QString::fromStdString(relPath.str());
text = QString::fromStdWString(relPath.wstr());
}
}
@@ -239,46 +239,45 @@ void QtDirectoryListBox::dropEvent(QDropEvent *event)
std::vector<FilePath> QtDirectoryListBox::getList()
{
std::vector<std::string> strList = getStringList();
std::vector<FilePath> list;
for (const std::string& str : strList)
for (const std::wstring& s : getWStringList())
{
list.push_back(FilePath(str));
list.push_back(FilePath(s));
}
return list;
}
void QtDirectoryListBox::setList(const std::vector<FilePath>& list, bool readOnly)
{
std::vector<std::string> strList;
std::vector<std::wstring> strList;
for (const FilePath& path : list)
{
strList.push_back(path.str());
strList.push_back(path.wstr());
}
setStringList(strList, readOnly);
setWStringList(strList, readOnly);
}
std::vector<std::string> QtDirectoryListBox::getStringList()
std::vector<std::wstring> QtDirectoryListBox::getWStringList()
{
std::vector<std::string> list;
std::vector<std::wstring> list;
for (int i = 0; i < m_list->count(); ++i)
{
QtListItemWidget* widget = dynamic_cast<QtListItemWidget*>(m_list->itemWidget(m_list->item(i)));
list.push_back(widget->getText().toStdString());
list.push_back(widget->getText().toStdWString());
}
return list;
}
void QtDirectoryListBox::setStringList(const std::vector<std::string>& list, bool readOnly)
void QtDirectoryListBox::setWStringList(const std::vector<std::wstring>& list, bool readOnly)
{
clear();
FilePath root = m_relativeRootDirectory;
m_relativeRootDirectory = FilePath();
for (const std::string& str : list)
for (const std::wstring& str : list)
{
QtListItemWidget* itemWidget = addListBoxItemWithText(QString::fromStdString(str));
QtListItemWidget* itemWidget = addListBoxItemWithText(QString::fromStdWString(str));
itemWidget->setReadOnly(readOnly);
}
@@ -286,6 +285,26 @@ void QtDirectoryListBox::setStringList(const std::vector<std::string>& list, boo
m_relativeRootDirectory = root;
}
std::vector<std::string> QtDirectoryListBox::getStringList()
{
std::vector<std::string> list;
for (std::wstring s: getWStringList())
{
list.push_back(utility::encodeToUtf8(s));
}
return list;
}
void QtDirectoryListBox::setStringList(const std::vector<std::string>& list, bool readOnly)
{
std::vector<std::wstring> wlist;
for (std::string s : list)
{
wlist.push_back(utility::decodeFromUtf8(s));
}
setWStringList(wlist);
}
QtListItemWidget* QtDirectoryListBox::addListBoxItemWithText(const QString& text)
{
QtListItemWidget* widget = addListBoxItem();
@@ -59,6 +59,9 @@ public:
std::vector<FilePath> getList();
void setList(const std::vector<FilePath>& list, bool readOnly = false);
std::vector<std::wstring> getWStringList();
void setWStringList(const std::vector<std::wstring>& list, bool readOnly = false);
std::vector<std::string> getStringList();
void setStringList(const std::vector<std::string>& list, bool readOnly = false);
+2 -2
View File
@@ -101,9 +101,9 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
}
}
void QtStatusBar::setIdeStatus(const std::string& text)
void QtStatusBar::setIdeStatus(const std::wstring& text)
{
m_ideStatusText.setText(text.c_str());
m_ideStatusText.setText(QString::fromStdWString(text));
}
void QtStatusBar::resizeEvent(QResizeEvent* event)
+1 -1
View File
@@ -21,7 +21,7 @@ public:
void setText(const std::wstring& text, bool isError, bool showLoader);
void setErrorCount(ErrorCountInfo errorCount);
void setIdeStatus(const std::string& text);
void setIdeStatus(const std::wstring& text);
protected:
virtual void resizeEvent(QResizeEvent* event);
@@ -45,7 +45,7 @@ bool QtIDECommunicationController::isListening() const
return m_tcpWrapper.isListening();
}
void QtIDECommunicationController::sendMessage(const std::string& message) const
void QtIDECommunicationController::sendMessage(const std::wstring& message) const
{
m_tcpWrapper.sendMessage(message);
}
@@ -23,7 +23,7 @@ public:
virtual bool isListening() const;
private:
virtual void sendMessage(const std::string& message) const;
virtual void sendMessage(const std::wstring& message) const;
QtTcpWrapper m_tcpWrapper;
+5 -7
View File
@@ -43,10 +43,9 @@ QtTcpWrapper::~QtTcpWrapper()
}
}
void QtTcpWrapper::sendMessage(const std::string& message) const
void QtTcpWrapper::sendMessage(const std::wstring& message) const
{
QByteArray data;
data.append(message.c_str());
QByteArray data = QString::fromStdWString(message).toUtf8();
QTcpSocket socket;
socket.connectToHost(QHostAddress::LocalHost, m_clientPort);
@@ -60,7 +59,7 @@ void QtTcpWrapper::sendMessage(const std::string& message) const
}
}
void QtTcpWrapper::setReadCallback(const std::function<void(const std::string&)>& callback)
void QtTcpWrapper::setReadCallback(const std::function<void(const std::wstring&)>& callback)
{
m_readCallback = callback;
}
@@ -110,12 +109,11 @@ void QtTcpWrapper::startRead()
QString string;
stream >> string;*/
QString string = QString::fromUtf8(byteArray);
QString message = QString::fromUtf8(byteArray);
if (m_readCallback != NULL)
{
std::string message = string.toStdString();
m_readCallback(message);
m_readCallback(message.toStdWString());
}
/*char buffer[1024] = { 0 };
+3 -3
View File
@@ -19,9 +19,9 @@ public:
void startListening();
void stopListening();
void sendMessage(const std::string& message) const;
void sendMessage(const std::wstring& message) const;
void setReadCallback(const std::function<void(const std::string&)>& callback);
void setReadCallback(const std::function<void(const std::wstring&)>& callback);
quint16 getServerPort() const;
void setServerPort(const quint16 serverPort);
@@ -42,7 +42,7 @@ private:
quint16 m_clientPort;
std::string m_ip;
std::function<void(const std::string&)> m_readCallback;
std::function<void(const std::wstring&)> m_readCallback;
QTcpServer* m_tcpServer;
QTcpSocket* m_tcpClient;
+2 -3
View File
@@ -189,13 +189,12 @@ void QtMainView::handleMessage(MessageProjectEdit* message)
void QtMainView::handleMessage(MessageProjectNew* message)
{
std::string cdbPath = message->cdbPath;
std::vector<std::string> headerPaths = message->headerPaths;
FilePath cdbPath = message->cdbPath;
m_onQtThread(
[=]()
{
m_window->newProjectFromCDB(cdbPath, headerPaths);
m_window->newProjectFromCDB(cdbPath);
}
);
}
+1 -1
View File
@@ -51,7 +51,7 @@ void QtStatusBarView::setErrorCount(ErrorCountInfo errorCount)
);
}
void QtStatusBarView::showIdeStatus(const std::string& message)
void QtStatusBarView::showIdeStatus(const std::wstring& message)
{
m_onQtThread(
[=]()
+1 -1
View File
@@ -25,7 +25,7 @@ public:
virtual void showMessage(const std::wstring& message, bool isError, bool showLoader);
virtual void setErrorCount(ErrorCountInfo errorCount);
virtual void showIdeStatus(const std::string& message);
virtual void showIdeStatus(const std::wstring& message);
private:
QtThreadedLambdaFunctor m_onQtThread;
+2 -8
View File
@@ -565,7 +565,7 @@ void QtMainWindow::newProject()
wizzard->newProject();
}
void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
void QtMainWindow::newProjectFromCDB(const FilePath& filePath)
{
QtProjectWizzard* wizzard = dynamic_cast<QtProjectWizzard*>(m_windowStack.getTopWindow());
if (!wizzard)
@@ -573,13 +573,7 @@ void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vec
wizzard = createWindow<QtProjectWizzard>();
}
std::vector<FilePath> headerFilePaths;
for (const std::string& s: headerPaths)
{
headerFilePaths.push_back(FilePath(s));
}
wizzard->newProjectFromCDB(FilePath(filePath), headerFilePaths);
wizzard->newProjectFromCDB(filePath);
}
void QtMainWindow::openProject()
+1 -1
View File
@@ -115,7 +115,7 @@ public slots:
void hideStartScreen();
void newProject();
void newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
void newProjectFromCDB(const FilePath& filePath);
void openProject();
void editProject();
@@ -25,6 +25,16 @@ std::string QtTextEditDialog::getText()
return m_text->toPlainText().toStdString();
}
void QtTextEditDialog::setWText(const std::wstring& text)
{
m_text->setPlainText(QString::fromStdWString(text));
}
std::wstring QtTextEditDialog::getWText()
{
return m_text->toPlainText().toStdWString();
}
void QtTextEditDialog::setReadOnly(bool readOnly)
{
m_text->setReadOnly(readOnly);
+3
View File
@@ -18,6 +18,9 @@ public:
void setText(const std::string& text);
std::string getText();
void setWText(const std::wstring& text);
std::wstring getWText();
void setReadOnly(bool readOnly);
protected:
@@ -65,7 +65,7 @@ void QtProjectWizzard::newProject()
setup();
}
void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths)
void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath)
{
if (!m_projectSettings)
{
@@ -91,16 +91,11 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve
std::shared_ptr<SourceGroupSettingsCxxCdb> sourceGroupSettings =
std::make_shared<SourceGroupSettingsCxxCdb>(utility::getUuidString(), m_projectSettings.get());
sourceGroupSettings->setCompilationDatabasePath(filePath);
sourceGroupSettings->setSourcePaths(headerPaths);
m_newSourceGroupSettings = sourceGroupSettings;
emptySourceGroupCDBVS();
}
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
}
void QtProjectWizzard::editProject(const FilePath& settingsPath)
{
std::shared_ptr<ProjectSettings> settings = std::make_shared<ProjectSettings>(settingsPath);
@@ -29,8 +29,7 @@ public:
public slots:
void newProject();
void newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths);
void refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void newProjectFromCDB(const FilePath& filePath);
void editProject(const FilePath& settingsPath);
void editProject(std::shared_ptr<ProjectSettings> settings);
@@ -27,10 +27,10 @@ void QtProjectWizzardContentExtensions::populate(QGridLayout* layout, int& row)
void QtProjectWizzardContentExtensions::load()
{
m_sourceList->setStringList(m_settings->getSourceExtensions());
m_sourceList->setWStringList(m_settings->getSourceExtensions());
}
void QtProjectWizzardContentExtensions::save()
{
m_settings->setSourceExtensions(m_sourceList->getStringList());
m_settings->setSourceExtensions(m_sourceList->getWStringList());
}
@@ -86,7 +86,7 @@ bool QtProjectWizzardContentPaths::check()
{
if (!expandedPath.exists())
{
missingPaths.append((expandedPath.str() + "\n").c_str());
missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n"));
}
else
{
@@ -94,7 +94,7 @@ bool QtProjectWizzardContentPaths::check()
}
}
if (expandedPaths.size() && expandedPaths.size() == existingCount)
if (!expandedPaths.empty() && expandedPaths.size() == existingCount)
{
existingPaths.push_back(path);
}
@@ -648,13 +648,13 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP
void QtProjectWizzardContentPathsHeaderSearch::finishedAcceptDetectedIncludePathsDialog()
{
const std::vector<std::string> detectedPaths = utility::splitToVector(m_filesDialog->getText(), "\n");
const std::vector<std::wstring> detectedPaths = utility::split<std::vector<std::wstring>>(m_filesDialog->getWText(), L"\n");
closedFilesDialog();
std::vector<std::string> headerSearchPaths = m_list->getStringList();
std::vector<std::wstring> headerSearchPaths = m_list->getWStringList();
headerSearchPaths.reserve(headerSearchPaths.size() + detectedPaths.size());
for (const std::string& detectedPath : detectedPaths)
for (const std::wstring& detectedPath : detectedPaths)
{
if (!detectedPath.empty())
{
@@ -662,7 +662,7 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedAcceptDetectedIncludePath
}
}
m_list->setStringList(headerSearchPaths);
m_list->setWStringList(headerSearchPaths);
}
void QtProjectWizzardContentPathsHeaderSearch::closedPathsDialog()
+12 -5
View File
@@ -1,6 +1,8 @@
#include "cxxtest/TestSuite.h"
#include "utility/file/FileManager.h"
#include "utility/file/FilePath.h"
#include "utility/utility.h"
class FileManagerTestSuite : public CxxTest::TestSuite
{
@@ -12,14 +14,19 @@ public:
sourcePaths.push_back(FilePath(L"./data/FileManagerTestSuite/include/"));
std::vector<FilePath> headerPaths;
std::vector<FilePath> excludePaths;
std::vector<std::string> sourceExtensions;
sourceExtensions.push_back(".cpp");
sourceExtensions.push_back(".c");
const wchar_t specialCharacter(252);
std::wstring specialExtension = L".";
specialExtension += specialCharacter;
std::vector<std::wstring> sourceExtensions = { L".cpp", L".c", specialExtension };
FileManager fm;
fm.update(sourcePaths, excludePaths, sourceExtensions);
std::set<FilePath> filePaths = fm.getAllSourceFilePaths();
std::vector<FilePath> filePaths = utility::toVector(fm.getAllSourceFilePaths());
TS_ASSERT_EQUALS(filePaths.size(), 2);
TS_ASSERT_EQUALS(filePaths.size(), 3);
TS_ASSERT(utility::containsElement<FilePath>(filePaths, FilePath(L"./data/FileManagerTestSuite/src/a.cpp")));
TS_ASSERT(utility::containsElement<FilePath>(filePaths, FilePath(L"./data/FileManagerTestSuite/src/d.c")));
TS_ASSERT(utility::containsElement<FilePath>(filePaths, FilePath(L"./data/FileManagerTestSuite/src/e" + specialExtension)));
int ee = 0;
}
};
+1
View File
@@ -6,6 +6,7 @@
#include <vector>
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
class FileSystemTestSuite: public CxxTest::TestSuite
{
+15 -15
View File
@@ -7,60 +7,60 @@ class NetworkProtocolHelperTestSuite : public CxxTest::TestSuite
public:
void test_parse_message(void)
{
std::string type = "setActiveToken";
std::string divider = ">>";
std::string filePath = "C:\\Users\\Manuel\\imporant\\file\\location\\fileName.cpp";
std::string endOfMessageToken = "<EOM>";
std::wstring type = L"setActiveToken";
std::wstring divider = L">>";
std::wstring filePath = L"C:/Users/Manuel/imporant/file/location/fileName.cpp";
std::wstring endOfMessageToken = L"<EOM>";
int row = 1;
int column = 2;
// valid message
std::stringstream message;
std::wstringstream message;
message << type << divider << filePath << divider << row << divider << column << endOfMessageToken;
NetworkProtocolHelper::SetActiveTokenMessage networkMessage = NetworkProtocolHelper::parseSetActiveTokenMessage(message.str());
TS_ASSERT_EQUALS(networkMessage.fileLocation, filePath);
TS_ASSERT_EQUALS(networkMessage.filePath.wstr(), filePath);
TS_ASSERT_EQUALS(networkMessage.row, row);
TS_ASSERT_EQUALS(networkMessage.column, column);
TS_ASSERT_EQUALS(networkMessage.valid, true);
// invalid type
message.str("");
message << "foo" << divider << filePath << divider << row << divider << column << endOfMessageToken;
message.str(L"");
message << L"foo" << divider << filePath << divider << row << divider << column << endOfMessageToken;
networkMessage = NetworkProtocolHelper::parseSetActiveTokenMessage(message.str());
TS_ASSERT_EQUALS(networkMessage.fileLocation, "");
TS_ASSERT_EQUALS(networkMessage.filePath.wstr(), L"");
TS_ASSERT_EQUALS(networkMessage.row, 0);
TS_ASSERT_EQUALS(networkMessage.column, 0);
TS_ASSERT_EQUALS(networkMessage.valid, false);
// missing divider
message.str("");
message.str(L"");
message << type << divider << filePath << row << divider << column << endOfMessageToken;
networkMessage = NetworkProtocolHelper::parseSetActiveTokenMessage(message.str());
TS_ASSERT_EQUALS(networkMessage.fileLocation, "");
TS_ASSERT_EQUALS(networkMessage.filePath.wstr(), L"");
TS_ASSERT_EQUALS(networkMessage.row, 0);
TS_ASSERT_EQUALS(networkMessage.column, 0);
TS_ASSERT_EQUALS(networkMessage.valid, false);
// invalid row
message.str("");
message.str(L"");
message << type << divider << filePath << divider << "potato" << divider << column << endOfMessageToken;
networkMessage = NetworkProtocolHelper::parseSetActiveTokenMessage(message.str());
TS_ASSERT_EQUALS(networkMessage.fileLocation, "");
TS_ASSERT_EQUALS(networkMessage.filePath.wstr(), L"");
TS_ASSERT_EQUALS(networkMessage.row, 0);
TS_ASSERT_EQUALS(networkMessage.column, 0);
TS_ASSERT_EQUALS(networkMessage.valid, false);
// invalid column
message.str("");
message.str(L"");
message << type << divider << filePath << divider << row << divider << "laz0r" << endOfMessageToken;
networkMessage = NetworkProtocolHelper::parseSetActiveTokenMessage(message.str());
TS_ASSERT_EQUALS(networkMessage.fileLocation, "");
TS_ASSERT_EQUALS(networkMessage.filePath.wstr(), L"");
TS_ASSERT_EQUALS(networkMessage.row, 0);
TS_ASSERT_EQUALS(networkMessage.column, 0);
TS_ASSERT_EQUALS(networkMessage.valid, false);