From 45652bc20b8a54056a5f68d2e239fb553d7c4500 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sun, 28 Jun 2009 04:58:27 -0400 Subject: [PATCH] ENH: create a "Virtual Folder" in CodeBlocks, which contains all the cmake files of the project, i.e. there is now a "CMake Files" folder additionally to the "Sources", "Headers" and "Others" folders which already existed. Patch by Daniel Teske. Alex --- Source/cmExtraCodeBlocksGenerator.cxx | 192 ++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 772f065f8..cbebf984b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -110,6 +110,146 @@ void cmExtraCodeBlocksGenerator::CreateProjectFile( } +/* Tree is used to create a "Virtual Folder" in CodeBlocks, in which all + CMake files this project depends on will be put. This means additionally + to the "Sources" and "Headers" virtual folders of CodeBlocks, there will + now also be a "CMake Files" virtual folder. + Patch by Daniel Teske (which use C::B project + files in QtCreator).*/ +struct Tree +{ + std::string path; //only one component of the path + std::vector folders; + std::vector files; + void InsertPath(const std::vector& splitted, + std::vector::size_type start, + const std::string& fileName); + void BuildVirtualFolder(std::string& virtualFolders) const; + void BuildVirtualFolderImpl(std::string& virtualFolders, + const std::string& prefix) const; + void BuildUnit(std::string& unitString, const std::string& fsPath) const; + void BuildUnitImpl(std::string& unitString, + const std::string& virtualFolderPath, + const std::string& fsPath) const; +}; + + +void Tree::InsertPath(const std::vector& splitted, + std::vector::size_type start, + const std::string& fileName) +{ + if (start == splitted.size()) + { + files.push_back(fileName); + return; + } + for (std::vector::iterator + it = folders.begin(); + it != folders.end(); + ++it) + { + if ((*it).path == splitted.at(start)) + { + if (start + 1 < splitted.size()) + { + it->InsertPath(splitted, start + 1, fileName); + return; + } + else + { + // last part of splitted + it->files.push_back(fileName); + return; + } + } + } + // Not found in folders, thus insert + Tree newFolder; + newFolder.path = splitted.at(start); + if (start + 1 < splitted.size()) + { + newFolder.InsertPath(splitted, start + 1, fileName); + folders.push_back(newFolder); + return; + } + else + { + // last part of splitted + newFolder.files.push_back(fileName); + folders.push_back(newFolder); + return; + } +} + + +void Tree::BuildVirtualFolder(std::string& virtualFolders) const +{ + virtualFolders += "