MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / loadVisualStudioProperties

Function loadVisualStudioProperties

lib/importproject.cpp:834–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834static void loadVisualStudioProperties(const std::string &props, std::map<std::string,std::string,cppcheck::stricmp> &variables, std::string &includePath, const std::string &additionalIncludeDirectories, std::list<ItemDefinitionGroup> &itemDefinitionGroupList)
835{
836 std::string filename(props);
837 // variables can't be resolved
838 if (!simplifyPathWithVariables(filename, variables))
839 return;
840
841 // prepend project dir (if it exists) to transform relative paths into absolute ones
842 if (!Path::isAbsolute(filename) && variables.count("ProjectDir") > 0)
843 filename = Path::getAbsoluteFilePath(variables.at("ProjectDir") + filename);
844
845 tinyxml2::XMLDocument doc;
846 if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS)
847 return;
848 const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();
849 if (rootnode == nullptr)
850 return;
851 for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
852 const char* name = node->Name();
853 if (std::strcmp(name, "ImportGroup") == 0) {
854 const char *labelAttribute = node->Attribute("Label");
855 if (labelAttribute == nullptr || std::strcmp(labelAttribute, "PropertySheets") != 0)
856 continue;
857 for (const tinyxml2::XMLElement *importGroup = node->FirstChildElement(); importGroup; importGroup = importGroup->NextSiblingElement()) {
858 if (std::strcmp(importGroup->Name(), "Import") == 0) {
859 const char *projectAttribute = importGroup->Attribute("Project");
860 if (projectAttribute == nullptr)
861 continue;
862 std::string loadprj(projectAttribute);
863 if (loadprj.find('$') == std::string::npos) {
864 loadprj = Path::getPathFromFilename(filename) + loadprj;
865 }
866 loadVisualStudioProperties(loadprj, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList);
867 }
868 }
869 } else if (std::strcmp(name,"PropertyGroup")==0) {
870 importPropertyGroup(node, variables, includePath);
871 } else if (std::strcmp(name,"ItemDefinitionGroup")==0) {
872 itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories);
873 }
874 }
875}
876
877bool ImportProject::importVcxproj(const std::string &filename,
878 std::map<std::string, std::string, cppcheck::stricmp> &variables,

Callers 1

importVcxprojMethod · 0.85

Calls 9

importPropertyGroupFunction · 0.85
atMethod · 0.80
LoadFileMethod · 0.80
FirstChildElementMethod · 0.80
NextSiblingElementMethod · 0.80
NameMethod · 0.80
AttributeMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected