38 std::string::size_type pos1 = fullpath.find_last_of(
"/\\");
39 pos1 = (pos1 == std::string::npos) ? 0U : (pos1 + 1U);
40 std::string::size_type pos2 = fullpath.rfind(
'.');
42 pos2 = std::string::npos;
43 if (pos2 != std::string::npos)
45 return fullpath.substr(pos1,pos2);
48 void AnalyzerInformation::writeFilesTxt(
const std::string &buildDir,
const std::list<std::string> &sourcefiles,
const std::string &userDefines,
const std::list<FileSettings> &fileSettings)
50 std::map<std::string, unsigned int> fileCount;
52 const std::string filesTxt(buildDir +
"/files.txt");
53 std::ofstream fout(filesTxt);
54 for (
const std::string &f : sourcefiles) {
57 if (!userDefines.empty())
62 const std::string afile =
getFilename(fs.filename());
76 static bool skipAnalysis(
const std::string &analyzerInfoFile, std::size_t hash, std::list<ErrorMessage> &errors)
78 tinyxml2::XMLDocument doc;
79 const tinyxml2::XMLError
error = doc.LoadFile(analyzerInfoFile.c_str());
80 if (
error != tinyxml2::XML_SUCCESS)
83 const tinyxml2::XMLElement *
const rootNode = doc.FirstChildElement();
84 if (rootNode ==
nullptr)
87 const char *attr = rootNode->Attribute(
"hash");
88 if (!attr || attr != std::to_string(hash))
91 for (
const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) {
92 if (std::strcmp(e->Name(),
"error") == 0)
93 errors.emplace_back(e);
103 while (std::getline(filesTxt,line)) {
104 if (line.size() <= end.size() + 2U)
106 if (!
endsWith(line, end.c_str(), end.size()))
108 return line.substr(0,line.find(
':'));
115 std::ifstream fin(
Path::join(buildDir,
"files.txt"));
122 const std::string::size_type pos = sourcefile.rfind(
'/');
123 std::string filename;
124 if (pos == std::string::npos)
125 filename = sourcefile;
127 filename = sourcefile.substr(pos + 1);
128 return Path::join(buildDir, filename) +
".analyzerinfo";
133 if (buildDir.empty() || sourcefile.empty())
162 mOutputStream <<
" <FileInfo check=\"" << check <<
"\">\n" << fileInfo <<
" </FileInfo>\n";
static bool skipAnalysis(const std::string &analyzerInfoFile, std::size_t hash, std::list< ErrorMessage > &errors)
static std::string getFilename(const std::string &fullpath)
Wrapper for error messages, provided by reportErr()
std::string toXML() const
Format the error message in XML format.
static std::string simplifyPath(std::string originalPath)
Simplify path "foo/bar/.." => "foo".
static std::string join(const std::string &path1, const std::string &path2)
join 2 paths with '/' separators
static std::string fromNativeSeparators(std::string path)
Convert path to use internal path separators.
@ error
Programming error.
static std::string cfg(const std::vector< std::string > &configs, const std::string &userDefines)
bool endsWith(const std::string &str, char c)