diff --git a/bin/test/data/FileManagerTestSuite/src/e.ü b/bin/test/data/FileManagerTestSuite/src/e.ü new file mode 100644 index 00000000..e69de29b diff --git a/src/lib/component/controller/IDECommunicationController.cpp b/src/lib/component/controller/IDECommunicationController.cpp index d00913d1..722adbc1 100644 --- a/src/lib/component/controller/IDECommunicationController.cpp +++ b/src/lib/component/controller/IDECommunicationController.cpp @@ -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); diff --git a/src/lib/component/controller/IDECommunicationController.h b/src/lib/component/controller/IDECommunicationController.h index 4ef29b31..f5844aee 100644 --- a/src/lib/component/controller/IDECommunicationController.h +++ b/src/lib/component/controller/IDECommunicationController.h @@ -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; diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 68a5d7ec..2154e85c 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -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; } diff --git a/src/lib/component/controller/helper/NetworkProtocolHelper.cpp b/src/lib/component/controller/helper/NetworkProtocolHelper.cpp index bb505c42..8454019f 100644 --- a/src/lib/component/controller/helper/NetworkProtocolHelper.cpp +++ b/src/lib/component/controller/helper/NetworkProtocolHelper.cpp @@ -6,35 +6,36 @@ #include #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 = ""; -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""; +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 subMessages = divideMessage(message); + std::vector 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 subMessages = divideMessage(message); + std::vector 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 subMessages = divideMessage(message); + std::vector 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 subMessages = divideMessage(message); + std::vector 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 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 subMessages = divideMessage(message); + std::vector 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 NetworkProtocolHelper::divideMessage(const std::string& message) +std::vector NetworkProtocolHelper::divideMessage(const std::wstring& message) { - std::vector result; + std::vector 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 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); } diff --git a/src/lib/component/controller/helper/NetworkProtocolHelper.h b/src/lib/component/controller/helper/NetworkProtocolHelper.h index 9bc5d740..72d51768 100644 --- a/src/lib/component/controller/helper/NetworkProtocolHelper.h +++ b/src/lib/component/controller/helper/NetworkProtocolHelper.h @@ -4,6 +4,8 @@ #include #include +#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 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 divideMessage(const std::string& message); + static std::vector 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 \ No newline at end of file diff --git a/src/lib/component/view/StatusBarView.h b/src/lib/component/view/StatusBarView.h index d26a80e5..72a05c33 100644 --- a/src/lib/component/view/StatusBarView.h +++ b/src/lib/component/view/StatusBarView.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(); diff --git a/src/lib/settings/SourceGroupSettings.cpp b/src/lib/settings/SourceGroupSettings.cpp index 214b0751..f9abed8a 100644 --- a/src/lib/settings/SourceGroupSettings.cpp +++ b/src/lib/settings/SourceGroupSettings.cpp @@ -13,7 +13,7 @@ SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType , m_standard("") , m_sourcePaths(std::vector()) , m_excludePaths(std::vector()) - , m_sourceExtensions(std::vector()) + , m_sourceExtensions(std::vector()) { } @@ -35,7 +35,7 @@ void SourceGroupSettings::load(std::shared_ptr config) setStandard(getValue(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(), config)); + setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector(), config)); } void SourceGroupSettings::save(std::shared_ptr config) @@ -158,7 +158,7 @@ void SourceGroupSettings::setExcludePaths(const std::vector& excludePa m_excludePaths = excludePaths; } -std::vector SourceGroupSettings::getSourceExtensions() const +std::vector SourceGroupSettings::getSourceExtensions() const { if (m_sourceExtensions.empty()) { @@ -167,7 +167,7 @@ std::vector SourceGroupSettings::getSourceExtensions() const return m_sourceExtensions; } -void SourceGroupSettings::setSourceExtensions(const std::vector& sourceExtensions) +void SourceGroupSettings::setSourceExtensions(const std::vector& sourceExtensions) { m_sourceExtensions = sourceExtensions; } diff --git a/src/lib/settings/SourceGroupSettings.h b/src/lib/settings/SourceGroupSettings.h index 9a406e5e..0744bd43 100644 --- a/src/lib/settings/SourceGroupSettings.h +++ b/src/lib/settings/SourceGroupSettings.h @@ -50,8 +50,8 @@ public: std::vector getExcludePathsExpandedAndAbsolute() const; void setExcludePaths(const std::vector& excludePaths); - std::vector getSourceExtensions() const; - void setSourceExtensions(const std::vector& sourceExtensions); + std::vector getSourceExtensions() const; + void setSourceExtensions(const std::vector& sourceExtensions); protected: template @@ -73,7 +73,7 @@ protected: const ProjectSettings* m_projectSettings; private: - virtual std::vector getDefaultSourceExtensions() const = 0; + virtual std::vector getDefaultSourceExtensions() const = 0; virtual std::string getDefaultStandard() const = 0; std::string m_id; @@ -84,7 +84,7 @@ private: std::string m_standard; std::vector m_sourcePaths; std::vector m_excludePaths; - std::vector m_sourceExtensions; + std::vector m_sourceExtensions; }; template diff --git a/src/lib/settings/SourceGroupSettingsCxx.cpp b/src/lib/settings/SourceGroupSettingsCxx.cpp index 872f4801..0c95b582 100644 --- a/src/lib/settings/SourceGroupSettingsCxx.cpp +++ b/src/lib/settings/SourceGroupSettingsCxx.cpp @@ -143,19 +143,19 @@ void SourceGroupSettingsCxx::setCompilerFlags(const std::vector& co m_compilerFlags = compilerFlags; } -std::vector SourceGroupSettingsCxx::getDefaultSourceExtensions() const +std::vector SourceGroupSettingsCxx::getDefaultSourceExtensions() const { - std::vector defaultValues; + std::vector 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: diff --git a/src/lib/settings/SourceGroupSettingsCxx.h b/src/lib/settings/SourceGroupSettingsCxx.h index cd795755..242f8c33 100644 --- a/src/lib/settings/SourceGroupSettingsCxx.h +++ b/src/lib/settings/SourceGroupSettingsCxx.h @@ -29,7 +29,7 @@ public: void setCompilerFlags(const std::vector& compilerFlags); private: - virtual std::vector getDefaultSourceExtensions() const override; + virtual std::vector getDefaultSourceExtensions() const override; virtual std::string getDefaultStandard() const override; std::vector m_headerSearchPaths; diff --git a/src/lib/settings/SourceGroupSettingsJava.cpp b/src/lib/settings/SourceGroupSettingsJava.cpp index ce361aeb..987ba4a6 100644 --- a/src/lib/settings/SourceGroupSettingsJava.cpp +++ b/src/lib/settings/SourceGroupSettingsJava.cpp @@ -74,9 +74,9 @@ void SourceGroupSettingsJava::setClasspath(const std::vector& classpat { m_classpath = classpath; } -std::vector SourceGroupSettingsJava::getDefaultSourceExtensions() const +std::vector SourceGroupSettingsJava::getDefaultSourceExtensions() const { - return std::vector(1, ".java"); + return { L".java" }; } std::string SourceGroupSettingsJava::getDefaultStandard() const diff --git a/src/lib/settings/SourceGroupSettingsJava.h b/src/lib/settings/SourceGroupSettingsJava.h index fe084b36..a34fd130 100644 --- a/src/lib/settings/SourceGroupSettingsJava.h +++ b/src/lib/settings/SourceGroupSettingsJava.h @@ -28,7 +28,7 @@ public: void setClasspath(const std::vector& classpath); private: - virtual std::vector getDefaultSourceExtensions() const override; + virtual std::vector getDefaultSourceExtensions() const override; virtual std::string getDefaultStandard() const override; bool m_useJreSystemLibrary; diff --git a/src/lib/utility/file/FileManager.cpp b/src/lib/utility/file/FileManager.cpp index 09d73eca..70a3b01e 100644 --- a/src/lib/utility/file/FileManager.cpp +++ b/src/lib/utility/file/FileManager.cpp @@ -16,7 +16,7 @@ FileManager::~FileManager() void FileManager::update( const std::vector& sourcePaths, const std::vector& excludePaths, - const std::vector& sourceExtensions + const std::vector& sourceExtensions ){ m_sourcePaths = sourcePaths; m_excludePaths = makeCanonical(excludePaths); diff --git a/src/lib/utility/file/FileManager.h b/src/lib/utility/file/FileManager.h index b027eda7..73db43fe 100644 --- a/src/lib/utility/file/FileManager.h +++ b/src/lib/utility/file/FileManager.h @@ -17,7 +17,7 @@ public: void update( const std::vector& sourcePaths, const std::vector& excludePaths, - const std::vector& sourceExtensions + const std::vector& sourceExtensions ); // returns a list of source paths (can be directories) specified in the project settings @@ -36,7 +36,7 @@ private: std::vector m_sourcePaths; std::vector m_excludePaths; - std::vector m_sourceExtensions; + std::vector m_sourceExtensions; std::set m_allSourceFilePaths; }; diff --git a/src/lib/utility/file/FilePath.cpp b/src/lib/utility/file/FilePath.cpp index 730f0c5e..32dd3b3a 100644 --- a/src/lib/utility/file/FilePath.cpp +++ b/src/lib/utility/file/FilePath.cpp @@ -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()); diff --git a/src/lib/utility/file/FilePath.h b/src/lib/utility/file/FilePath.h index d93f61ca..054b41b1 100644 --- a/src/lib/utility/file/FilePath.h +++ b/src/lib/utility/file/FilePath.h @@ -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& extensions) const; diff --git a/src/lib/utility/file/FileSystem.cpp b/src/lib/utility/file/FileSystem.cpp index a4162eea..a33d6db6 100644 --- a/src/lib/utility/file/FileSystem.cpp +++ b/src/lib/utility/file/FileSystem.cpp @@ -50,10 +50,10 @@ FileInfo FileSystem::getFileInfoForPath(const FilePath& filePath) } std::vector FileSystem::getFileInfosFromPaths( - const std::vector& paths, const std::vector& fileExtensions, bool followSymLinks + const std::vector& paths, const std::vector& fileExtensions, bool followSymLinks ){ - std::set ext; - for (const std::string& e : fileExtensions) + std::set ext; + for (const std::wstring& e : fileExtensions) { ext.insert(utility::toLowerCase(e)); } @@ -103,7 +103,7 @@ std::vector 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 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(); diff --git a/src/lib/utility/file/FileSystem.h b/src/lib/utility/file/FileSystem.h index 6c5fbd75..180cae97 100644 --- a/src/lib/utility/file/FileSystem.h +++ b/src/lib/utility/file/FileSystem.h @@ -17,7 +17,7 @@ public: static FileInfo getFileInfoForPath(const FilePath& filePath); static std::vector getFileInfosFromPaths( - const std::vector& paths, const std::vector& fileExtensions, bool followSymLinks = true); + const std::vector& paths, const std::vector& fileExtensions, bool followSymLinks = true); static std::set getSymLinkedDirectories(const std::vector& paths); diff --git a/src/lib/utility/messaging/type/MessageMoveIDECursor.h b/src/lib/utility/messaging/type/MessageMoveIDECursor.h index 044f507d..e4dda306 100644 --- a/src/lib/utility/messaging/type/MessageMoveIDECursor.h +++ b/src/lib/utility/messaging/type/MessageMoveIDECursor.h @@ -7,10 +7,10 @@ class MessageMoveIDECursor : public Message { 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 \ No newline at end of file diff --git a/src/lib/utility/messaging/type/MessagePingReceived.h b/src/lib/utility/messaging/type/MessagePingReceived.h index 5fce1118..931c0448 100644 --- a/src/lib/utility/messaging/type/MessagePingReceived.h +++ b/src/lib/utility/messaging/type/MessagePingReceived.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 \ No newline at end of file diff --git a/src/lib/utility/messaging/type/MessageProjectNew.h b/src/lib/utility/messaging/type/MessageProjectNew.h index 4de09c38..f2c0f0d4 100644 --- a/src/lib/utility/messaging/type/MessageProjectNew.h +++ b/src/lib/utility/messaging/type/MessageProjectNew.h @@ -7,9 +7,8 @@ class MessageProjectNew : public Message { public: - MessageProjectNew(const std::string cdbPath, const std::vector headerPaths) + MessageProjectNew(const FilePath& cdbPath) : cdbPath(cdbPath) - , headerPaths(headerPaths) { } @@ -18,8 +17,7 @@ public: return "MessageProjectNew"; } - const std::string cdbPath; - const std::vector headerPaths; + const FilePath cdbPath; }; #endif // MESSAGE_PROJECT_NEW_H diff --git a/src/lib/utility/utilityString.cpp b/src/lib/utility/utilityString.cpp index 4559b7f6..fa825150 100644 --- a/src/lib/utility/utilityString.cpp +++ b/src/lib/utility/utilityString.cpp @@ -10,7 +10,7 @@ namespace { template - 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) diff --git a/src/lib/utility/utilityString.h b/src/lib/utility/utilityString.h index e920a962..463d97a4 100644 --- a/src/lib/utility/utilityString.h +++ b/src/lib/utility/utilityString.h @@ -14,6 +14,9 @@ namespace utility template ContainerType split(const std::string& str, const std::string& delimiter); + template + ContainerType split(const std::wstring& str, const std::wstring& delimiter); + std::deque split(const std::string& str, char delimiter); std::deque split(const std::string& str, const std::string& delimiter); std::vector 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 + 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; } diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index 59adce83..4b1f53ef 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -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 QtDirectoryListBox::getList() { - std::vector strList = getStringList(); std::vector 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& list, bool readOnly) { - std::vector strList; + std::vector strList; for (const FilePath& path : list) { - strList.push_back(path.str()); + strList.push_back(path.wstr()); } - setStringList(strList, readOnly); + setWStringList(strList, readOnly); } -std::vector QtDirectoryListBox::getStringList() +std::vector QtDirectoryListBox::getWStringList() { - std::vector list; + std::vector list; for (int i = 0; i < m_list->count(); ++i) { QtListItemWidget* widget = dynamic_cast(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& list, bool readOnly) +void QtDirectoryListBox::setWStringList(const std::vector& 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& list, boo m_relativeRootDirectory = root; } +std::vector QtDirectoryListBox::getStringList() +{ + std::vector list; + for (std::wstring s: getWStringList()) + { + list.push_back(utility::encodeToUtf8(s)); + } + return list; +} + +void QtDirectoryListBox::setStringList(const std::vector& list, bool readOnly) +{ + std::vector wlist; + for (std::string s : list) + { + wlist.push_back(utility::decodeFromUtf8(s)); + } + setWStringList(wlist); +} + QtListItemWidget* QtDirectoryListBox::addListBoxItemWithText(const QString& text) { QtListItemWidget* widget = addListBoxItem(); diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.h b/src/lib_gui/qt/element/QtDirectoryListBox.h index 2874b3b6..e948368f 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.h +++ b/src/lib_gui/qt/element/QtDirectoryListBox.h @@ -59,6 +59,9 @@ public: std::vector getList(); void setList(const std::vector& list, bool readOnly = false); + std::vector getWStringList(); + void setWStringList(const std::vector& list, bool readOnly = false); + std::vector getStringList(); void setStringList(const std::vector& list, bool readOnly = false); diff --git a/src/lib_gui/qt/element/QtStatusBar.cpp b/src/lib_gui/qt/element/QtStatusBar.cpp index c6a51c91..0c794068 100644 --- a/src/lib_gui/qt/element/QtStatusBar.cpp +++ b/src/lib_gui/qt/element/QtStatusBar.cpp @@ -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) diff --git a/src/lib_gui/qt/element/QtStatusBar.h b/src/lib_gui/qt/element/QtStatusBar.h index a6bded23..562fe940 100644 --- a/src/lib_gui/qt/element/QtStatusBar.h +++ b/src/lib_gui/qt/element/QtStatusBar.h @@ -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); diff --git a/src/lib_gui/qt/network/QtIDECommunicationController.cpp b/src/lib_gui/qt/network/QtIDECommunicationController.cpp index 3e6977c2..1f6a33f4 100644 --- a/src/lib_gui/qt/network/QtIDECommunicationController.cpp +++ b/src/lib_gui/qt/network/QtIDECommunicationController.cpp @@ -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); } diff --git a/src/lib_gui/qt/network/QtIDECommunicationController.h b/src/lib_gui/qt/network/QtIDECommunicationController.h index f5be08ed..72f17db9 100644 --- a/src/lib_gui/qt/network/QtIDECommunicationController.h +++ b/src/lib_gui/qt/network/QtIDECommunicationController.h @@ -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; diff --git a/src/lib_gui/qt/network/QtTcpWrapper.cpp b/src/lib_gui/qt/network/QtTcpWrapper.cpp index 5696da67..dab967a8 100644 --- a/src/lib_gui/qt/network/QtTcpWrapper.cpp +++ b/src/lib_gui/qt/network/QtTcpWrapper.cpp @@ -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& callback) +void QtTcpWrapper::setReadCallback(const std::function& 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 }; diff --git a/src/lib_gui/qt/network/QtTcpWrapper.h b/src/lib_gui/qt/network/QtTcpWrapper.h index b01d6ab7..d549464b 100644 --- a/src/lib_gui/qt/network/QtTcpWrapper.h +++ b/src/lib_gui/qt/network/QtTcpWrapper.h @@ -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& callback); + void setReadCallback(const std::function& callback); quint16 getServerPort() const; void setServerPort(const quint16 serverPort); @@ -42,7 +42,7 @@ private: quint16 m_clientPort; std::string m_ip; - std::function m_readCallback; + std::function m_readCallback; QTcpServer* m_tcpServer; QTcpSocket* m_tcpClient; diff --git a/src/lib_gui/qt/view/QtMainView.cpp b/src/lib_gui/qt/view/QtMainView.cpp index fc104b3a..a88a736e 100644 --- a/src/lib_gui/qt/view/QtMainView.cpp +++ b/src/lib_gui/qt/view/QtMainView.cpp @@ -189,13 +189,12 @@ void QtMainView::handleMessage(MessageProjectEdit* message) void QtMainView::handleMessage(MessageProjectNew* message) { - std::string cdbPath = message->cdbPath; - std::vector headerPaths = message->headerPaths; + FilePath cdbPath = message->cdbPath; m_onQtThread( [=]() { - m_window->newProjectFromCDB(cdbPath, headerPaths); + m_window->newProjectFromCDB(cdbPath); } ); } diff --git a/src/lib_gui/qt/view/QtStatusBarView.cpp b/src/lib_gui/qt/view/QtStatusBarView.cpp index 3297dd0b..0b378cb2 100644 --- a/src/lib_gui/qt/view/QtStatusBarView.cpp +++ b/src/lib_gui/qt/view/QtStatusBarView.cpp @@ -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( [=]() diff --git a/src/lib_gui/qt/view/QtStatusBarView.h b/src/lib_gui/qt/view/QtStatusBarView.h index 71913745..238ffc5a 100644 --- a/src/lib_gui/qt/view/QtStatusBarView.h +++ b/src/lib_gui/qt/view/QtStatusBarView.h @@ -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; diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index fe1b128b..41ff5e99 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -565,7 +565,7 @@ void QtMainWindow::newProject() wizzard->newProject(); } -void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector& headerPaths) +void QtMainWindow::newProjectFromCDB(const FilePath& filePath) { QtProjectWizzard* wizzard = dynamic_cast(m_windowStack.getTopWindow()); if (!wizzard) @@ -573,13 +573,7 @@ void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vec wizzard = createWindow(); } - std::vector headerFilePaths; - for (const std::string& s: headerPaths) - { - headerFilePaths.push_back(FilePath(s)); - } - - wizzard->newProjectFromCDB(FilePath(filePath), headerFilePaths); + wizzard->newProjectFromCDB(filePath); } void QtMainWindow::openProject() diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h index 19ad7b0f..aac84846 100644 --- a/src/lib_gui/qt/window/QtMainWindow.h +++ b/src/lib_gui/qt/window/QtMainWindow.h @@ -115,7 +115,7 @@ public slots: void hideStartScreen(); void newProject(); - void newProjectFromCDB(const std::string& filePath, const std::vector& headerPaths); + void newProjectFromCDB(const FilePath& filePath); void openProject(); void editProject(); diff --git a/src/lib_gui/qt/window/QtTextEditDialog.cpp b/src/lib_gui/qt/window/QtTextEditDialog.cpp index 9168a5d9..8f59c12a 100644 --- a/src/lib_gui/qt/window/QtTextEditDialog.cpp +++ b/src/lib_gui/qt/window/QtTextEditDialog.cpp @@ -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); diff --git a/src/lib_gui/qt/window/QtTextEditDialog.h b/src/lib_gui/qt/window/QtTextEditDialog.h index c2fe7add..6d846a70 100644 --- a/src/lib_gui/qt/window/QtTextEditDialog.h +++ b/src/lib_gui/qt/window/QtTextEditDialog.h @@ -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: diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 27dc23ab..a146443b 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -65,7 +65,7 @@ void QtProjectWizzard::newProject() setup(); } -void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::vector& 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 sourceGroupSettings = std::make_shared(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 settings = std::make_shared(settingsPath); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h index 6f096341..83cedf92 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h @@ -29,8 +29,7 @@ public: public slots: void newProject(); - void newProjectFromCDB(const FilePath& filePath, const std::vector& 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 settings); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp index 68fe6bf7..473dd04b 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp @@ -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()); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index f6da7b07..fc9c94a3 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -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 detectedPaths = utility::splitToVector(m_filesDialog->getText(), "\n"); + const std::vector detectedPaths = utility::split>(m_filesDialog->getWText(), L"\n"); closedFilesDialog(); - std::vector headerSearchPaths = m_list->getStringList(); + std::vector 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() diff --git a/src/test/FileManagerTestSuite.h b/src/test/FileManagerTestSuite.h index 539d57a2..989d939b 100644 --- a/src/test/FileManagerTestSuite.h +++ b/src/test/FileManagerTestSuite.h @@ -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 headerPaths; std::vector excludePaths; - std::vector sourceExtensions; - sourceExtensions.push_back(".cpp"); - sourceExtensions.push_back(".c"); + const wchar_t specialCharacter(252); + std::wstring specialExtension = L"."; + specialExtension += specialCharacter; + std::vector sourceExtensions = { L".cpp", L".c", specialExtension }; FileManager fm; fm.update(sourcePaths, excludePaths, sourceExtensions); - std::set filePaths = fm.getAllSourceFilePaths(); + std::vector filePaths = utility::toVector(fm.getAllSourceFilePaths()); - TS_ASSERT_EQUALS(filePaths.size(), 2); + TS_ASSERT_EQUALS(filePaths.size(), 3); + TS_ASSERT(utility::containsElement(filePaths, FilePath(L"./data/FileManagerTestSuite/src/a.cpp"))); + TS_ASSERT(utility::containsElement(filePaths, FilePath(L"./data/FileManagerTestSuite/src/d.c"))); + TS_ASSERT(utility::containsElement(filePaths, FilePath(L"./data/FileManagerTestSuite/src/e" + specialExtension))); + int ee = 0; } }; diff --git a/src/test/FileSystemTestSuite.h b/src/test/FileSystemTestSuite.h index 4d218cdb..8e9d6cf9 100644 --- a/src/test/FileSystemTestSuite.h +++ b/src/test/FileSystemTestSuite.h @@ -6,6 +6,7 @@ #include #include "utility/file/FileSystem.h" +#include "utility/utility.h" class FileSystemTestSuite: public CxxTest::TestSuite { diff --git a/src/test/NetworkProtocolHelperTestSuite.h b/src/test/NetworkProtocolHelperTestSuite.h index f3a2b554..d6a49a23 100644 --- a/src/test/NetworkProtocolHelperTestSuite.h +++ b/src/test/NetworkProtocolHelperTestSuite.h @@ -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 = ""; + 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""; 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);