-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFileList.h
66 lines (56 loc) · 1.5 KB
/
FileList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _FILELIST_H_
#define _FILELIST_H_
#include <vector>
#include "SourceFile.h"
#include "TextFile.h"
class FileList {
private:
std::vector<SourceFile> m_sourceFiles;
unsigned m_nFiles;
unsigned m_maxLinesPerFile;
unsigned m_locsTotal;
unsigned m_minChars;
bool m_ignorePrepStuff;
public:
FileList(const TextFile& listOfFiles, unsigned minChars, bool ignorePrepStuff) :
m_nFiles(0),
m_maxLinesPerFile(0),
m_locsTotal(0),
m_minChars(minChars),
m_ignorePrepStuff(ignorePrepStuff)
{
std::vector<std::string> lines;
listOfFiles.readLines(lines, true);
// Create vector with all source files
for (unsigned i=0; i<lines.size(); i++) {
addFile(lines[i]);
}
}
unsigned getNFiles() const {
return m_nFiles;
}
unsigned getMaxLinesPerFile() const {
return m_maxLinesPerFile;
}
unsigned getLOCsTotal() const {
return m_locsTotal;
}
const std::vector<SourceFile>& getSourceFilesRaw() const {
return m_sourceFiles;
}
void addFile(const std::string& fname) {
if (fname.size() > 5) {
SourceFile pSourceFile(fname, m_minChars, m_ignorePrepStuff);
const unsigned numLines = pSourceFile.getNumOfLines();
if (numLines > 0) {
++m_nFiles;
m_sourceFiles.push_back(pSourceFile);
m_locsTotal += numLines;
if (m_maxLinesPerFile < numLines) {
m_maxLinesPerFile = numLines;
}
}
}
}
};
#endif