Skip to content

Commit b7a50e3

Browse files
authored
Merge pull request #66 from JesseMckinzie/fix_compiler_warnings_v2
Fix compiler warnings
2 parents 0af9670 + eba8d1d commit b7a50e3

15 files changed

+41
-58
lines changed

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<properties>
1010
<maven.compiler.source>1.7</maven.compiler.source>
1111
<maven.compiler.target>1.7</maven.compiler.target>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1214
</properties>
1315

1416
<scm>

src/filepattern/cpp/external/external_filepattern.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ExternalFilePattern::~ExternalFilePattern(){
4848

4949

5050
void ExternalFilePattern::printFiles(){
51-
bool after = false;
51+
5252
vector<Tuple> files;
5353

5454
while(true){
@@ -66,7 +66,6 @@ void ExternalFilePattern::printFiles(){
6666
cout << endl;
6767
}
6868

69-
after = true;
7069
if (this->stream_.endOfValidFiles()) break;
7170

7271
}
@@ -93,7 +92,6 @@ void ExternalFilePattern::matchFilesOneDir(){
9392
string file;
9493
smatch sm;
9594

96-
int count = 0;
9795
// iterate over files
9896
while(!this->stream_.isEmpty()){
9997
block = this->stream_.getBlock();
@@ -104,7 +102,6 @@ void ExternalFilePattern::matchFilesOneDir(){
104102

105103
if(regex_match(file, sm, pattern_regex)){
106104
this->stream_.writeValidFiles(getVariableMap(file_path, sm)); // write to txt file
107-
++count;
108105
}
109106

110107
}

src/filepattern/cpp/external/external_pattern.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ void ExternalPattern::getMatchingInit(const vector<tuple<string, vector<Types>>>
9696

9797
bool created = fs::create_directory(this->fp_tmpdir_);
9898

99+
if (!created) {
100+
std::cerr << "WARNING: temporary directory " << this->fp_tmpdir_ << " could not be created.";
101+
}
102+
99103
fs::permissions(this->fp_tmpdir_, fs::perms::all);
100104

101105
// create a path to store matching files
@@ -164,17 +168,15 @@ vector<Tuple> ExternalPattern::getMatchingBlock(){
164168
void ExternalPattern::groupByHelper(){
165169

166170
std::vector<std::pair<std::vector<std::pair<std::string, Types>> , std::vector<Tuple>>> temp_group;
167-
int group_idx;
171+
168172
vector<Tuple> temp_vec;
169173
vector<std::pair<std::string, Types>> grouped_variables;
170174
string group_by;
171175
//for(const auto& group_by: this->group){
172176

173-
for(int j = 1; j < this->group_.size(); ++j){
177+
for(unsigned int j = 1; j < this->group_.size(); ++j){
174178
group_by = this->group_[j];
175179

176-
group_idx = 0;
177-
178180
for(auto& vec: this->current_group_){
179181

180182

@@ -189,7 +191,7 @@ void ExternalPattern::groupByHelper(){
189191

190192
Types current_value = get<0>(vec.second[0])[group_by]; // get the value of variable
191193
vector<Tuple> empty_vec;
192-
int i = 0;
194+
unsigned int i = 0;
193195
int group_ptr = 0;
194196

195197
//group files into vectors based on group_by variable
@@ -421,7 +423,7 @@ void ExternalPattern::sortFiles(){
421423

422424
}
423425

424-
Tuple ExternalPattern::getItem(int key){
426+
Tuple ExternalPattern::getItem(unsigned int key){
425427

426428
if(key < 0) {
427429
if(this->stream_.getValidFilesSize() + key < 0) throw out_of_range("Index " + std::to_string(key) + " is out of range.");
@@ -459,18 +461,18 @@ vector<Tuple> ExternalPattern::getSlice(vector<Types>& key){
459461
string key2 = s::to_string(key[2]);
460462

461463
if(s::is_number(key0) && key1 == "None" && key2 == "None"){
462-
int i = stoi(key0);
464+
unsigned int i = stoi(key0);
463465

464466
if(i >= this->stream_.getValidFilesSize()) throw out_of_range("Index " + std::to_string(i) + " is out of range.");
465-
int j = this->stream_.getValidFilesSize();
466-
int step = 1;
467+
unsigned int j = this->stream_.getValidFilesSize();
468+
unsigned int step = 1;
467469
return this->stream_.getValidFilesSlice(i, j, step);
468470
}
469471

470472
// A start and stop index is provided with no step size, i.e. valid_files[i:j]
471473
if(s::is_number(key0) && s::is_number(key1) && key2 == "None"){
472-
int i = stoi(key0);
473-
int j = stoi(key1);
474+
unsigned int i = stoi(key0);
475+
unsigned int j = stoi(key1);
474476

475477
if(i > this->stream_.getValidFilesSize()) throw out_of_range("Index " + std::to_string(i) + " is out of range.");
476478
if(j > this->stream_.getValidFilesSize()) throw out_of_range("Index " + std::to_string(j) + " is out of range.");
@@ -483,8 +485,8 @@ vector<Tuple> ExternalPattern::getSlice(vector<Types>& key){
483485

484486
// A start, stop, and step is provided
485487
if(s::is_number(key0) && s::is_number(key1) && s::is_number(key2)){
486-
int i = stoi(key0);
487-
int j = stoi(key1);
488+
unsigned int i = stoi(key0);
489+
unsigned int j = stoi(key1);
488490

489491
if(i > this->stream_.getValidFilesSize()) throw out_of_range("Index " + std::to_string(i) + " is out of range.");
490492
if(j > this->stream_.getValidFilesSize()) throw out_of_range("Index " + std::to_string(j) + " is out of range.");
@@ -494,10 +496,10 @@ vector<Tuple> ExternalPattern::getSlice(vector<Types>& key){
494496
}
495497

496498
if(s::is_number(key0) && key1 == "None" && s::is_number(key2)){
497-
int i = stoi(key0);
499+
unsigned int i = stoi(key0);
498500
if(i > this->stream_.getValidFilesSize()) throw out_of_range("Index " + std::to_string(i) + " is out of range.");
499501

500-
int j = this->stream_.getValidFilesSize();
502+
unsigned int j = this->stream_.getValidFilesSize();
501503
int step = stoi(key2);
502504
return this->stream_.getValidFilesSlice(i, j, step);
503505
}

src/filepattern/cpp/external/external_pattern.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class ExternalPattern : public Pattern {
230230

231231
void sortFiles();
232232

233-
Tuple getItem(int key);
233+
Tuple getItem(unsigned int key);
234234

235235
std::vector<Tuple> getItemList(std::vector<int>& key);
236236

src/filepattern/cpp/external/external_stringpattern.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void ExternalStringPattern::matchFiles(){
4747
string file;
4848
smatch sm;
4949

50-
int count = 0;
5150
// iterate over files
5251
while(!this->stream_.isEmpty()){
5352

@@ -57,7 +56,6 @@ void ExternalStringPattern::matchFiles(){
5756

5857
if(regex_match(file, sm, pattern_regex)){
5958
this->stream_.writeValidFiles(getVariableMap(file, sm)); // write to txt file
60-
++count;
6159
}
6260
}
6361
}

src/filepattern/cpp/external/external_stringpattern.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class ExternalStringPattern : public ExternalPattern {
5959
fs::directory_iterator iterator_; // File iterator for given path
6060
fs::recursive_directory_iterator recursive_iterator_; // Recursive iterator
6161
bool end_of_file_; // True if end of temp file is reached
62-
bool recursive_; // True if recursive iterator through subdirectories
6362
int total_files_; // Total number of matched files (will be deleted)
6463

6564

src/filepattern/cpp/internal/filepattern.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,11 @@ FilePatternObject::FilePatternObject(const string& path, const string& file_patt
5656
this->sortFiles();
5757
}
5858

59-
void FilePatternObject::printFiles(){
60-
for(const auto& file: this->iterator_){
61-
//cout << file << endl;
62-
}
63-
}
64-
6559
void FilePatternObject::matchFilesOneDir(){
6660

6761
Map mapping;
6862
vector<string> parsed_regex;
6963

70-
int i, j;
7164
string s;
7265
string file, file_path;
7366
Tuple member;

src/filepattern/cpp/internal/filepattern.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ class FilePatternObject : public InternalPattern {
3535
*/
3636
void matchFiles();
3737

38-
/**
39-
* @brief Print the valid files to the console.
40-
*
41-
*/
42-
void printFiles();
43-
4438
private:
4539
//std::string path; // path to directory
4640
fs::directory_iterator iterator_; // File iterator for given path

src/filepattern/cpp/internal/internal_pattern.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ void InternalPattern::nextGroup() {}
99
void InternalPattern::groupByHelper(const vector<string>& groups){
1010

1111
std::vector<std::pair<std::vector<std::pair<std::string, Types>> , std::vector<Tuple>>> temp;
12-
int group_idx;
1312
vector<Tuple> temp_vec;
1413
vector<std::pair<std::string, Types>> grouped_variables;
15-
for(const auto& group_by: groups){
1614

17-
group_idx = 0;
15+
for(const auto& group_by: groups){
1816

1917
for(auto& vec: this->valid_grouped_files_){
18+
2019
grouped_variables.clear();
2120
for(auto& g: vec.first) grouped_variables.push_back(g);
2221
// Sort the matched files by the group_by parameter
@@ -26,7 +25,7 @@ void InternalPattern::groupByHelper(const vector<string>& groups){
2625

2726
Types current_value = get<0>(vec.second[0])[group_by]; // get the value of variable
2827
vector<Tuple> empty_vec;
29-
int i = 0;
28+
unsigned int i = 0;
3029
int group_ptr = 0;
3130

3231
//group files into vectors based on group_by variable
@@ -90,7 +89,7 @@ void InternalPattern::groupBy(vector<string>& groups) {
9089
Types current_value = get<0>(this->valid_files_[0])[group_by]; // get the value of variable
9190

9291
vector<Tuple> empty_vec;
93-
int i = 0;
92+
unsigned int i = 0;
9493
int group_ptr = 0;
9594

9695
//group files into vectors based on group_by variable
@@ -222,7 +221,7 @@ void InternalPattern::sortFiles(){
222221
});
223222
}
224223

225-
Tuple InternalPattern::getItem(int key){
224+
Tuple InternalPattern::getItem(unsigned int key){
226225
if(key < 0) {
227226
if(this->valid_files_.size() + key < 0) throw out_of_range("Index " + std::to_string(key) + " is out of range.");
228227
return this->valid_files_[this->valid_files_.size()+key];

src/filepattern/cpp/internal/internal_pattern.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class InternalPattern : public Pattern {
8383
*/
8484
std::string outputName(std::vector<Tuple>& vec);
8585

86-
Tuple getItem(int key);
86+
Tuple getItem(unsigned int key);
8787

8888
std::vector<Tuple> getItemList(std::vector<int>& key);
8989

0 commit comments

Comments
 (0)