logic: use wstring in symbol and bookmark names

* use wstring in symbol and bookmark names
* fixed setting apppath in windows includes
* regard utf8 encoding in shared indexer commands
* regard utf8 encoding in shared indexer status
This commit is contained in:
mlangkabel
2018-02-05 17:17:33 +01:00
parent c99e79364f
commit 9e041c1f0a
155 changed files with 1955 additions and 1864 deletions
@@ -25,13 +25,13 @@ void InterprocessIndexer::work()
{
try
{
LOG_INFO_STREAM(<< m_processId << " starting up indexer");
LOG_INFO(std::to_wstring(m_processId) + L" starting up indexer");
std::shared_ptr<IndexerBase> indexer = IndexerFactory::getInstance()->createCompositeIndexerForAllRegisteredModules();
while (std::shared_ptr<IndexerCommand> indexerCommand = m_interprocessIndexerCommandManager.popIndexerCommand())
{
LOG_INFO_STREAM(<< m_processId << " fetched indexer command for \"" << indexerCommand->getSourceFilePath().str() << "\"");
LOG_INFO_STREAM(<< m_processId << " indexer commands left: " << (m_interprocessIndexerCommandManager.indexerCommandCount() + 1));
LOG_INFO(std::to_wstring(m_processId) + L" fetched indexer command for \"" + indexerCommand->getSourceFilePath().wstr() + L"\"");
LOG_INFO(std::to_wstring(m_processId) + L" indexer commands left: " + std::to_wstring(m_interprocessIndexerCommandManager.indexerCommandCount() + 1));
while (true)
{
@@ -1,6 +1,7 @@
#include "InterprocessIndexingStatusManager.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
const char* InterprocessIndexingStatusManager::s_sharedMemoryNamePrefix = "ists_";
@@ -28,7 +29,7 @@ void InterprocessIndexingStatusManager::startIndexingSourceFile(const FilePath&
if (indexingFilesPtr)
{
SharedMemory::String fileStr(access.getAllocator());
fileStr = filePath.str().c_str();
fileStr = utility::encodeToUtf8(filePath.wstr()).c_str();
indexingFilesPtr->push_back(fileStr);
}
@@ -71,7 +72,7 @@ void InterprocessIndexingStatusManager::startIndexingSourceFile(const FilePath&
}
SharedMemory::String str(access.getAllocator());
str = filePath.str().c_str();
str = utility::encodeToUtf8(filePath.wstr()).c_str();
it = currentFilesPtr->insert(std::pair<Id, SharedMemory::String>(getProcessId(), str)).first;
it->second = str;
@@ -125,7 +126,7 @@ std::vector<FilePath> InterprocessIndexingStatusManager::getCurrentlyIndexedSour
{
while (indexingFilesPtr->size())
{
indexingFiles.push_back(FilePath(indexingFilesPtr->front().c_str()));
indexingFiles.push_back(FilePath(utility::decodeFromUtf8(indexingFilesPtr->front().c_str())));
indexingFilesPtr->pop_front();
}
}
@@ -146,7 +147,7 @@ std::vector<FilePath> InterprocessIndexingStatusManager::getCrashedSourceFilePat
{
for (size_t i = 0; i < crashedFilesPtr->size(); i++)
{
crashedFiles.push_back(FilePath(crashedFilesPtr->at(i).c_str()));
crashedFiles.push_back(FilePath(utility::decodeFromUtf8(crashedFilesPtr->at(i).c_str())));
}
}
@@ -156,7 +157,7 @@ std::vector<FilePath> InterprocessIndexingStatusManager::getCrashedSourceFilePat
{
for (SharedMemory::Map<Id, SharedMemory::String>::iterator it = currentFilesPtr->begin(); it != currentFilesPtr->end(); it++)
{
crashedFiles.push_back(FilePath(it->second.c_str()));
crashedFiles.push_back(FilePath(utility::decodeFromUtf8(it->second.c_str())));
}
}
@@ -178,7 +179,7 @@ std::set<FilePath> InterprocessIndexingStatusManager::getIndexedFiles()
for (auto& file : *files)
{
result.insert(FilePath(file.c_str()));
result.insert(FilePath(utility::decodeFromUtf8(file.c_str())));
}
return result;
@@ -206,9 +207,9 @@ void InterprocessIndexingStatusManager::addIndexedFiles(std::set<FilePath> fileP
std::set<std::string> newFiles;
for (const FilePath& filePath : filePaths)
{
if (oldFiles.find(filePath.str()) == oldFiles.end())
if (oldFiles.find(utility::encodeToUtf8(filePath.wstr())) == oldFiles.end())
{
newFiles.insert(filePath.str());
newFiles.insert(utility::encodeToUtf8(filePath.wstr()));
}
}
@@ -5,6 +5,7 @@
#include "data/indexer/IndexerCommandJava.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
void SharedIndexerCommand::fromLocal(IndexerCommand* indexerCommand)
{
@@ -118,12 +119,12 @@ SharedIndexerCommand::~SharedIndexerCommand()
FilePath SharedIndexerCommand::getSourceFilePath() const
{
return FilePath(m_sourceFilePath.c_str());
return FilePath(utility::decodeFromUtf8(m_sourceFilePath.c_str()));
}
void SharedIndexerCommand::setSourceFilePath(const FilePath& filePath)
{
m_sourceFilePath = filePath.str().c_str();
m_sourceFilePath = utility::encodeToUtf8(filePath.wstr()).c_str();
}
std::set<FilePath> SharedIndexerCommand::getIndexedPaths() const
@@ -132,7 +133,7 @@ std::set<FilePath> SharedIndexerCommand::getIndexedPaths() const
for (unsigned int i = 0; i < m_indexedPaths.size(); i++)
{
result.insert(FilePath(m_indexedPaths[i].c_str()));
result.insert(FilePath(utility::decodeFromUtf8(m_indexedPaths[i].c_str())));
}
return result;
@@ -142,10 +143,10 @@ void SharedIndexerCommand::setIndexedPaths(const std::set<FilePath>& indexedPath
{
m_indexedPaths.clear();
for (std::set<FilePath>::iterator it = indexedPaths.begin(); it != indexedPaths.end(); it++)
for (const FilePath& indexedPath: indexedPaths)
{
SharedMemory::String path(m_indexedPaths.get_allocator());
path = (*it).str().c_str();
path = utility::encodeToUtf8(indexedPath.wstr()).c_str();
m_indexedPaths.push_back(path);
}
}
@@ -156,7 +157,7 @@ std::set<FilePath> SharedIndexerCommand::getExcludedPaths() const
for (unsigned int i = 0; i < m_excludedPaths.size(); i++)
{
result.insert(FilePath(m_excludedPaths[i].c_str()));
result.insert(FilePath(utility::decodeFromUtf8(m_excludedPaths[i].c_str())));
}
return result;
@@ -166,22 +167,22 @@ void SharedIndexerCommand::setExcludedPaths(const std::set<FilePath>& excludedPa
{
m_excludedPaths.clear();
for (std::set<FilePath>::iterator it = excludedPaths.begin(); it != excludedPaths.end(); it++)
for (const FilePath& excludedPath : excludedPaths)
{
SharedMemory::String path(m_excludedPaths.get_allocator());
path = (*it).str().c_str();
path = utility::encodeToUtf8(excludedPath.wstr()).c_str();
m_excludedPaths.push_back(path);
}
}
FilePath SharedIndexerCommand::getWorkingDirectory() const
{
return FilePath(m_workingDirectory.c_str());
return FilePath(utility::decodeFromUtf8(m_workingDirectory.c_str()));
}
void SharedIndexerCommand::setWorkingDirectory(const FilePath& workingDirectory)
{
m_workingDirectory = workingDirectory.str().c_str();
m_workingDirectory = utility::encodeToUtf8(workingDirectory.wstr()).c_str();
}
std::string SharedIndexerCommand::getLanguageStandard() const
@@ -212,10 +213,10 @@ void SharedIndexerCommand::setCompilerFlags(const std::vector<std::string>& comp
m_compilerFlags.clear();
m_compilerFlags.reserve(compilerFlags.size());
for (unsigned int i = 0; i < compilerFlags.size(); i++)
for (const std::string& compilerFlag : compilerFlags)
{
SharedMemory::String path(m_compilerFlags.get_allocator());
path = compilerFlags[i].c_str();
path = compilerFlag.c_str();
m_compilerFlags.push_back(path);
}
}
@@ -227,7 +228,7 @@ std::vector<FilePath> SharedIndexerCommand::getSystemHeaderSearchPaths() const
for (unsigned int i = 0; i < m_systemHeaderSearchPaths.size(); i++)
{
result.push_back(FilePath(m_systemHeaderSearchPaths[i].c_str()));
result.push_back(FilePath(utility::decodeFromUtf8(m_systemHeaderSearchPaths[i].c_str())));
}
return result;
@@ -238,10 +239,10 @@ void SharedIndexerCommand::setSystemHeaderSearchPaths(const std::vector<FilePath
m_systemHeaderSearchPaths.clear();
m_systemHeaderSearchPaths.reserve(filePaths.size());
for (unsigned int i = 0; i < filePaths.size(); i++)
for (const FilePath& filePath : filePaths)
{
SharedMemory::String path(m_systemHeaderSearchPaths.get_allocator());
path = filePaths[i].str().c_str();
path = utility::encodeToUtf8(filePath.wstr()).c_str();
m_systemHeaderSearchPaths.push_back(path);
}
}
@@ -253,7 +254,7 @@ std::vector<FilePath> SharedIndexerCommand::getFrameworkSearchhPaths() const
for (unsigned int i = 0; i < m_frameworkSearchPaths.size(); i++)
{
result.push_back(FilePath(m_frameworkSearchPaths[i].c_str()));
result.push_back(FilePath(utility::decodeFromUtf8(m_frameworkSearchPaths[i].c_str())));
}
return result;
@@ -264,10 +265,10 @@ void SharedIndexerCommand::setFrameworkSearchhPaths(const std::vector<FilePath>&
m_frameworkSearchPaths.clear();
m_frameworkSearchPaths.reserve(searchPaths.size());
for (unsigned int i = 0; i < searchPaths.size(); i++)
for (const FilePath& searchPath : searchPaths)
{
SharedMemory::String path(m_frameworkSearchPaths.get_allocator());
path = searchPaths[i].str().c_str();
path = utility::encodeToUtf8(searchPath.wstr()).c_str();
m_frameworkSearchPaths.push_back(path);
}
}
@@ -279,7 +280,7 @@ std::vector<FilePath> SharedIndexerCommand::getClassPaths() const
for (unsigned int i = 0; i < m_classPaths.size(); i++)
{
result.push_back(FilePath(m_classPaths[i].c_str()));
result.push_back(FilePath(utility::decodeFromUtf8(m_classPaths[i].c_str())));
}
return result;
@@ -290,10 +291,10 @@ void SharedIndexerCommand::setClassPaths(const std::vector<FilePath>& classPaths
m_classPaths.clear();
m_classPaths.reserve(classPaths.size());
for (unsigned int i = 0; i < classPaths.size(); i++)
for (const FilePath& classPath : classPaths)
{
SharedMemory::String path(m_classPaths.get_allocator());
path = classPaths[i].str().c_str();
path = utility::encodeToUtf8(classPath.wstr()).c_str();
m_classPaths.push_back(path);
}
}
@@ -13,6 +13,7 @@
#include "data/storage/type/StorageSymbol.h"
#include "utility/types.h"
#include "utility/interprocess/SharedMemory.h"
#include "utility/utilityString.h"
// macro creating SharedStorageType from StorageType
// - arguments: StorageType & SharedStorageType
@@ -54,12 +55,12 @@ struct SharedStorageNode
inline SharedStorageNode toShared(const StorageNode& node, SharedMemory::Allocator* allocator)
{
return SharedStorageNode(node.id, node.type, node.serializedName, allocator);
return SharedStorageNode(node.id, node.type, utility::encodeToUtf8(node.serializedName), allocator);
}
inline StorageNode fromShared(const SharedStorageNode& node)
{
return StorageNode(node.id, node.type, node.serializedName.c_str());
return StorageNode(node.id, node.type, utility::decodeFromUtf8(node.serializedName.c_str()));
}
@@ -82,12 +83,12 @@ struct SharedStorageFile
inline SharedStorageFile toShared(const StorageFile& file, SharedMemory::Allocator* allocator)
{
return SharedStorageFile(file.id, file.filePath, file.modificationTime, file.complete, allocator);
return SharedStorageFile(file.id, utility::encodeToUtf8(file.filePath), file.modificationTime, file.complete, allocator);
}
inline StorageFile fromShared(const SharedStorageFile& file)
{
return StorageFile(file.id, file.filePath.c_str(), file.modificationTime.c_str(), file.complete);
return StorageFile(file.id, utility::decodeFromUtf8(file.filePath.c_str()), file.modificationTime.c_str(), file.complete);
}
@@ -104,12 +105,12 @@ struct SharedStorageLocalSymbol
inline SharedStorageLocalSymbol toShared(const StorageLocalSymbol& symbol, SharedMemory::Allocator* allocator)
{
return SharedStorageLocalSymbol(symbol.id, symbol.name, allocator);
return SharedStorageLocalSymbol(symbol.id, utility::encodeToUtf8(symbol.name), allocator);
}
inline StorageLocalSymbol fromShared(const SharedStorageLocalSymbol& symbol)
{
return StorageLocalSymbol(symbol.id, symbol.name.c_str());
return StorageLocalSymbol(symbol.id, utility::decodeFromUtf8(symbol.name.c_str()));
}
@@ -145,15 +146,25 @@ struct SharedStorageErrorData
inline SharedStorageErrorData toShared(const StorageErrorData& error, SharedMemory::Allocator* allocator)
{
return SharedStorageErrorData(
error.message, error.filePath.str(),
error.lineNumber, error.columnNumber, error.fatal, error.indexed, allocator);
utility::encodeToUtf8(error.message),
utility::encodeToUtf8(error.filePath),
error.lineNumber,
error.columnNumber,
error.fatal,
error.indexed, allocator
);
}
inline StorageErrorData fromShared(const SharedStorageErrorData& error)
{
return StorageErrorData(
error.message.c_str(), FilePath(error.filePath.c_str()),
error.lineNumber, error.columnNumber, error.fatal, error.indexed);
utility::decodeFromUtf8(error.message.c_str()),
utility::decodeFromUtf8(error.filePath.c_str()),
error.lineNumber,
error.columnNumber,
error.fatal,
error.indexed
);
}
#endif // SHARED_STORAGE_TYPES_H