src: switch to wstring for printing messages

This commit is contained in:
mlangkabel
2018-02-06 10:03:46 +01:00
parent 1d7fc6e9d4
commit 9da3ac3d3c
36 changed files with 127 additions and 89 deletions
+21
View File
@@ -29,6 +29,27 @@
} \ } \
while(0) while(0)
#define LOG_INFO_BARE(__str__) \
do \
{ \
LogManager::getInstance()->logInfo(__str__, "", "", 0); \
} \
while(0)
#define LOG_WARNING_BARE(__str__) \
do \
{ \
LogManager::getInstance()->logWarning(__str__, "", "", 0); \
} \
while(0)
#define LOG_ERROR_BARE(__str__) \
do \
{ \
LogManager::getInstance()->logError(__str__, "", "", 0); \
} \
while(0)
#define LOG_INFO_STREAM(__s__) \ #define LOG_INFO_STREAM(__s__) \
do \ do \
{ \ { \
+16
View File
@@ -89,6 +89,7 @@ public:
bool operator!=(const VectorBase<U, N>& other) const; bool operator!=(const VectorBase<U, N>& other) const;
std::string toString() const; std::string toString() const;
std::wstring toWString() const;
protected: protected:
T m_values[N]; T m_values[N];
@@ -441,6 +442,21 @@ std::string VectorBase<T, N>::toString() const
return result.str(); return result.str();
} }
template<class T, unsigned int N>
std::wstring VectorBase<T, N>::toWString() const
{
std::wstringstream result;
result << L"[";
for (unsigned int i = 0; i < N - 1; i++)
{
result << m_values[i] << L", ";
}
result << m_values[N - 1] << L"]";
return result.str();
}
template<class T, unsigned int N> template<class T, unsigned int N>
std::ostream& operator<<(std::ostream& ostream, const VectorBase<T, N>& vector) std::ostream& operator<<(std::ostream& ostream, const VectorBase<T, N>& vector)
{ {
+1 -1
View File
@@ -34,7 +34,7 @@ public:
MessageQueue::getInstance()->processMessage(message, true); MessageQueue::getInstance()->processMessage(message, true);
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
} }
}; };
+5 -4
View File
@@ -5,6 +5,7 @@
#include <sstream> #include <sstream>
#include "utility/types.h" #include "utility/types.h"
#include "utility/utilityString.h"
class MessageBase class MessageBase
{ {
@@ -92,12 +93,12 @@ public:
return m_keepContent; return m_keepContent;
} }
virtual void print(std::ostream& os) const = 0; virtual void print(std::wostream& os) const = 0;
std::string str() const std::wstring str() const
{ {
std::stringstream ss; std::wstringstream ss;
ss << getType() << " "; ss << utility::decodeFromUtf8(getType()) << L" ";
print(ss); print(ss);
return ss.str(); return ss.str();
} }
+1 -1
View File
@@ -92,7 +92,7 @@ void MessageQueue::processMessage(std::shared_ptr<MessageBase> message, bool asN
{ {
if (message->isLogged()) if (message->isLogged())
{ {
LOG_INFO_STREAM_BARE(<< "send " << message->str()); LOG_INFO_BARE(L"send " + message->str());
} }
if (m_sendMessagesAsTasks && message->sendAsTask()) if (m_sendMessagesAsTasks && message->sendAsTask())
@@ -34,17 +34,17 @@ public:
return type == Edge::EDGE_AGGREGATION; return type == Edge::EDGE_AGGREGATION;
} }
std::string getFullName() const std::wstring getFullName() const
{ {
std::wstring name = Edge::getReadableTypeString(type) + L":"; std::wstring name = Edge::getReadableTypeString(type) + L":";
name += sourceNameHierarchy.getQualifiedNameWithSignature() + L"->"; name += sourceNameHierarchy.getQualifiedNameWithSignature() + L"->";
name += targetNameHierarchy.getQualifiedNameWithSignature(); name += targetNameHierarchy.getQualifiedNameWithSignature();
return utility::encodeToUtf8(name); return name;
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << tokenId << " - " << getFullName(); os << tokenId << L" - " << getFullName();
} }
const Id tokenId; const Id tokenId;
@@ -18,9 +18,9 @@ public:
return "MessageActivateFile"; return "MessageActivateFile";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << filePath.str(); os << filePath.wstr();
} }
const FilePath filePath; const FilePath filePath;
@@ -27,11 +27,11 @@ public:
return "MessageActivateLocalSymbols"; return "MessageActivateLocalSymbols";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const Id& symbolId : symbolIds) for (const Id& symbolId : symbolIds)
{ {
os << symbolId << " "; os << symbolId << L" ";
} }
} }
@@ -36,11 +36,11 @@ public:
return "MessageActivateNodes"; return "MessageActivateNodes";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const ActiveNode& node : nodes) for (const ActiveNode& node : nodes)
{ {
os << node.nodeId << " "; os << node.nodeId << L" ";
} }
} }
@@ -18,11 +18,11 @@ public:
return "MessageActivateSourceLocations"; return "MessageActivateSourceLocations";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const Id& id : locationIds) for (const Id& id : locationIds)
{ {
os << id << " "; os << id << L" ";
} }
} }
@@ -18,11 +18,11 @@ public:
return "MessageActivateTokenIds"; return "MessageActivateTokenIds";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const Id& id : tokenIds) for (const Id& id : tokenIds)
{ {
os << id << " "; os << id << L" ";
} }
} }
@@ -24,11 +24,11 @@ public:
return "MessageActivateTokens"; return "MessageActivateTokens";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const Id& id : tokenIds) for (const Id& id : tokenIds)
{ {
os << id << " "; os << id << L" ";
} }
} }
@@ -27,17 +27,17 @@ public:
return "MessageActivateTrailEdge"; return "MessageActivateTrailEdge";
} }
std::string getFullName() const std::wstring getFullName() const
{ {
std::wstring name = Edge::getReadableTypeString(type) + L":"; std::wstring name = Edge::getReadableTypeString(type) + L":";
name += sourceNameHierarchy.getQualifiedNameWithSignature() + L"->"; name += sourceNameHierarchy.getQualifiedNameWithSignature() + L"->";
name += targetNameHierarchy.getQualifiedNameWithSignature(); name += targetNameHierarchy.getQualifiedNameWithSignature();
return utility::encodeToUtf8(name); return name;
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << tokenId << " - " << getFullName(); os << tokenId << L" - " << getFullName();
} }
const Id tokenId; const Id tokenId;
@@ -44,27 +44,27 @@ public:
return "MessageChangeFileView"; return "MessageChangeFileView";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << filePath.str(); os << filePath.wstr();
switch (state) switch (state)
{ {
case FILE_MINIMIZED: os << ", minimize"; break; case FILE_MINIMIZED: os << L", minimize"; break;
case FILE_SNIPPETS: os << ", snippets"; break; case FILE_SNIPPETS: os << L", snippets"; break;
case FILE_MAXIMIZED: os << ", maximize"; break; case FILE_MAXIMIZED: os << L", maximize"; break;
} }
switch (viewMode) switch (viewMode)
{ {
case VIEW_LIST: os << ", list"; break; case VIEW_LIST: os << L", list"; break;
case VIEW_SINGLE: os << ", single"; break; case VIEW_SINGLE: os << L", single"; break;
case VIEW_CURRENT: os << ", current"; break; case VIEW_CURRENT: os << L", current"; break;
} }
if (needsData) if (needsData)
{ {
os << ", needs data"; os << L", needs data";
} }
} }
@@ -23,15 +23,15 @@ public:
return "MessageCodeReference"; return "MessageCodeReference";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
if (type == REFERENCE_PREVIOUS) if (type == REFERENCE_PREVIOUS)
{ {
os << "previous"; os << L"previous";
} }
else else
{ {
os << "next"; os << L"next";
} }
} }
@@ -24,11 +24,11 @@ public:
return "MessageFocusIn"; return "MessageFocusIn";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const Id& id : tokenIds) for (const Id& id : tokenIds)
{ {
os << id << " "; os << id << L" ";
} }
} }
@@ -21,11 +21,11 @@ public:
return "MessageFocusOut"; return "MessageFocusOut";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
for (const Id& id : tokenIds) for (const Id& id : tokenIds)
{ {
os << id << " "; os << id << L" ";
} }
} }
@@ -20,7 +20,7 @@ public:
return "MessageGraphNodeBundleSplit"; return "MessageGraphNodeBundleSplit";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << bundleId; os << bundleId;
} }
@@ -20,16 +20,16 @@ public:
return "MessageGraphNodeExpand"; return "MessageGraphNodeExpand";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << tokenId << " "; os << tokenId << L" ";
if (expand) if (expand)
{ {
os << "expand"; os << L"expand";
} }
else else
{ {
os << "collapse"; os << L"collapse";
} }
} }
@@ -18,7 +18,7 @@ public:
return "MessageGraphNodeHide"; return "MessageGraphNodeHide";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << tokenId; os << tokenId;
} }
@@ -20,9 +20,9 @@ public:
return "MessageGraphNodeMove"; return "MessageGraphNodeMove";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << tokenId << " " << delta.toString(); os << tokenId << L" " << delta.toWString();
} }
const Id tokenId; const Id tokenId;
@@ -15,9 +15,9 @@ public:
return "MessageIDECreateCDB"; return "MessageIDECreateCDB";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << "Create CDB from current solution"; os << L"Create CDB from current solution";
} }
}; };
@@ -22,11 +22,11 @@ public:
return "MessageLoadProject"; return "MessageLoadProject";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << projectSettingsFilePath.str(); os << projectSettingsFilePath.wstr();
os << ", settingsChanged: " << std::boolalpha << settingsChanged; os << L", settingsChanged: " << std::boolalpha << settingsChanged;
os << ", refreshMode: " << refreshMode; os << L", refreshMode: " << refreshMode;
} }
const FilePath projectSettingsFilePath; const FilePath projectSettingsFilePath;
@@ -19,9 +19,9 @@ public:
return "MessageMoveIDECursor"; return "MessageMoveIDECursor";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << filePath.str() << ":" << row << ":" << column; os << filePath.wstr() << L":" << row << L":" << column;
} }
const FilePath filePath; const FilePath filePath;
@@ -22,9 +22,9 @@ public:
return "MessageNewErrors"; return "MessageNewErrors";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << errors.size() << " errors"; os << errors.size() << L" errors";
} }
std::vector<ErrorInfo> errors; std::vector<ErrorInfo> errors;
@@ -37,7 +37,7 @@ public:
return *this; return *this;
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
if (uiOnly) if (uiOnly)
{ {
@@ -22,7 +22,7 @@ public:
return "MessageSearch"; return "MessageSearch";
} }
std::string getMatchesAsString() const std::wstring getMatchesAsString() const
{ {
std::stringstream ss; std::stringstream ss;
@@ -43,7 +43,7 @@ public:
} }
} }
return ss.str(); return utility::decodeFromUtf8(ss.str());
} }
const std::vector<SearchMatch>& getMatches() const const std::vector<SearchMatch>& getMatches() const
@@ -67,7 +67,7 @@ public:
return tokenIds; return tokenIds;
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << getMatchesAsString(); os << getMatchesAsString();
} }
@@ -20,19 +20,19 @@ public:
return "MessageSearchAutocomplete"; return "MessageSearchAutocomplete";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << query << "["; os << utility::decodeFromUtf8(query) << L"[";
std::vector<Id> nodeTypeIds = acceptedNodeTypes.getNodeTypeIds(); std::vector<Id> nodeTypeIds = acceptedNodeTypes.getNodeTypeIds();
for (size_t i = 0; i < nodeTypeIds.size(); i++) for (size_t i = 0; i < nodeTypeIds.size(); i++)
{ {
if (i != 0) if (i != 0)
{ {
os << ", "; os << L", ";
} }
os << std::to_string(nodeTypeIds[i]); os << std::to_wstring(nodeTypeIds[i]);
} }
os << "]"; os << L"]";
} }
const std::string query; const std::string query;
@@ -17,9 +17,9 @@ public:
return "MessageSearchFullText"; return "MessageSearchFullText";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << searchTerm; os << utility::decodeFromUtf8(searchTerm);
} }
const std::string searchTerm; const std::string searchTerm;
@@ -21,9 +21,9 @@ public:
return "MessageShowReference"; return "MessageShowReference";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << "index: " << refIndex << " token: " << tokenId << " location: " << locationId; os << L"index: " << refIndex << L" token: " << tokenId << L" location: " << locationId;
} }
const size_t refIndex; const size_t refIndex;
@@ -19,7 +19,7 @@ public:
return "MessageShowScope"; return "MessageShowScope";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << scopeLocationId; os << scopeLocationId;
} }
@@ -48,26 +48,26 @@ std::wstring MessageStatus::status() const
return L""; return L"";
} }
void MessageStatus::print(std::ostream& os) const void MessageStatus::print(std::wostream& os) const
{ {
for (const std::wstring& status : m_stati) for (const std::wstring& status : m_stati)
{ {
os << utility::encodeToUtf8(status); os << status;
if (m_stati.size() > 1) if (m_stati.size() > 1)
{ {
os << " - "; os << L" - ";
} }
} }
if (isError) if (isError)
{ {
os << " - error"; os << L" - error";
} }
if (showLoader) if (showLoader)
{ {
os << " - loading"; os << L" - loading";
} }
} }
@@ -18,7 +18,7 @@ public:
const std::vector<std::wstring>& stati() const; const std::vector<std::wstring>& stati() const;
std::wstring status() const; std::wstring status() const;
virtual void print(std::ostream& os) const; virtual void print(std::wostream& os) const;
const bool isError; const bool isError;
const bool showLoader; const bool showLoader;
@@ -17,9 +17,9 @@ public:
return "MessageSwitchColorScheme"; return "MessageSwitchColorScheme";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
os << colorSchemePath.str(); os << colorSchemePath.wstr();
} }
const FilePath colorSchemePath; const FilePath colorSchemePath;
+3 -3
View File
@@ -17,15 +17,15 @@ public:
return "MessageZoom"; return "MessageZoom";
} }
virtual void print(std::ostream& os) const virtual void print(std::wostream& os) const
{ {
if (zoomIn) if (zoomIn)
{ {
os << "in"; os << L"in";
} }
else else
{ {
os << "out"; os << L"out";
} }
} }
@@ -13,8 +13,8 @@ class CxxDeclName: public CxxName
public: public:
// uncomment this constructor if required, but try to use the one using move constructors for the members // uncomment this constructor if required, but try to use the one using move constructors for the members
//CxxDeclName( //CxxDeclName(
// const std::string& name, // const std::wstring& name,
// const std::vector<std::string>& templateParameterNames // const std::vector<std::wstring>& templateParameterNames
//); //);
CxxDeclName( CxxDeclName(
@@ -24,8 +24,8 @@ public:
// uncomment this constructor if required, but try to use the one using move constructors for the members // uncomment this constructor if required, but try to use the one using move constructors for the members
//CxxDeclName( //CxxDeclName(
// const std::string& name, // const std::wstring& name,
// const std::vector<std::string>& templateParameterNames, // const std::vector<std::wstring>& templateParameterNames,
// std::shared_ptr<CxxName> parent // std::shared_ptr<CxxName> parent
//); //);