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

Method importBcb6Prj

lib/importproject.cpp:1130–1396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1128}
1129
1130bool ImportProject::importBcb6Prj(const std::string &projectFilename)
1131{
1132 tinyxml2::XMLDocument doc;
1133 const tinyxml2::XMLError error = doc.LoadFile(projectFilename.c_str());
1134 if (error != tinyxml2::XML_SUCCESS) {
1135 errors.emplace_back(std::string("Borland project file is not a valid XML - ") + tinyxml2::XMLDocument::ErrorIDToName(error));
1136 return false;
1137 }
1138 const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();
1139 if (rootnode == nullptr) {
1140 errors.emplace_back("Borland project file has no XML root node");
1141 return false;
1142 }
1143
1144 const std::string& projectDir = Path::simplifyPath(Path::getPathFromFilename(projectFilename));
1145
1146 std::list<std::string> compileList;
1147 std::string includePath;
1148 std::string userdefines;
1149 std::string sysdefines;
1150 std::string cflag1;
1151
1152 for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
1153 const char* name = node->Name();
1154 if (std::strcmp(name, "FILELIST") == 0) {
1155 for (const tinyxml2::XMLElement *f = node->FirstChildElement(); f; f = f->NextSiblingElement()) {
1156 if (std::strcmp(f->Name(), "FILE") == 0) {
1157 const char *filename = f->Attribute("FILENAME");
1158 if (filename && Path::acceptFile(filename))
1159 compileList.emplace_back(filename);
1160 }
1161 }
1162 } else if (std::strcmp(name, "MACROS") == 0) {
1163 for (const tinyxml2::XMLElement *m = node->FirstChildElement(); m; m = m->NextSiblingElement()) {
1164 const char* mname = m->Name();
1165 if (std::strcmp(mname, "INCLUDEPATH") == 0) {
1166 const char *v = m->Attribute("value");
1167 if (v)
1168 includePath = v;
1169 } else if (std::strcmp(mname, "USERDEFINES") == 0) {
1170 const char *v = m->Attribute("value");
1171 if (v)
1172 userdefines = v;
1173 } else if (std::strcmp(mname, "SYSDEFINES") == 0) {
1174 const char *v = m->Attribute("value");
1175 if (v)
1176 sysdefines = v;
1177 }
1178 }
1179 } else if (std::strcmp(name, "OPTIONS") == 0) {
1180 for (const tinyxml2::XMLElement *m = node->FirstChildElement(); m; m = m->NextSiblingElement()) {
1181 if (std::strcmp(m->Name(), "CFLAG1") == 0) {
1182 const char *v = m->Attribute("value");
1183 if (v)
1184 cflag1 = v;
1185 }
1186 }
1187 }

Callers

nothing calls this directly

Calls 14

simplifyPathFunction · 0.85
acceptFileFunction · 0.85
toStringListFunction · 0.85
LoadFileMethod · 0.80
FirstChildElementMethod · 0.80
NextSiblingElementMethod · 0.80
NameMethod · 0.80
AttributeMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected