Skip to content

Commit

Permalink
Merge pull request #66 from JesseMckinzie/fix_compiler_warnings_v2
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
sameeul authored Mar 1, 2024
2 parents 0af9670 + eba8d1d commit b7a50e3
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 58 deletions.
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<scm>
Expand Down
5 changes: 1 addition & 4 deletions src/filepattern/cpp/external/external_filepattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ExternalFilePattern::~ExternalFilePattern(){


void ExternalFilePattern::printFiles(){
bool after = false;

vector<Tuple> files;

while(true){
Expand All @@ -66,7 +66,6 @@ void ExternalFilePattern::printFiles(){
cout << endl;
}

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

}
Expand All @@ -93,7 +92,6 @@ void ExternalFilePattern::matchFilesOneDir(){
string file;
smatch sm;

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

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

}
Expand Down
32 changes: 17 additions & 15 deletions src/filepattern/cpp/external/external_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ void ExternalPattern::getMatchingInit(const vector<tuple<string, vector<Types>>>

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

if (!created) {
std::cerr << "WARNING: temporary directory " << this->fp_tmpdir_ << " could not be created.";
}

fs::permissions(this->fp_tmpdir_, fs::perms::all);

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

std::vector<std::pair<std::vector<std::pair<std::string, Types>> , std::vector<Tuple>>> temp_group;
int group_idx;

vector<Tuple> temp_vec;
vector<std::pair<std::string, Types>> grouped_variables;
string group_by;
//for(const auto& group_by: this->group){

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

group_idx = 0;

for(auto& vec: this->current_group_){


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

Types current_value = get<0>(vec.second[0])[group_by]; // get the value of variable
vector<Tuple> empty_vec;
int i = 0;
unsigned int i = 0;
int group_ptr = 0;

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

}

Tuple ExternalPattern::getItem(int key){
Tuple ExternalPattern::getItem(unsigned int key){

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

if(s::is_number(key0) && key1 == "None" && key2 == "None"){
int i = stoi(key0);
unsigned int i = stoi(key0);

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

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

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

// A start, stop, and step is provided
if(s::is_number(key0) && s::is_number(key1) && s::is_number(key2)){
int i = stoi(key0);
int j = stoi(key1);
unsigned int i = stoi(key0);
unsigned int j = stoi(key1);

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

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

int j = this->stream_.getValidFilesSize();
unsigned int j = this->stream_.getValidFilesSize();
int step = stoi(key2);
return this->stream_.getValidFilesSlice(i, j, step);
}
Expand Down
2 changes: 1 addition & 1 deletion src/filepattern/cpp/external/external_pattern.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class ExternalPattern : public Pattern {

void sortFiles();

Tuple getItem(int key);
Tuple getItem(unsigned int key);

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

Expand Down
2 changes: 0 additions & 2 deletions src/filepattern/cpp/external/external_stringpattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void ExternalStringPattern::matchFiles(){
string file;
smatch sm;

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

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

if(regex_match(file, sm, pattern_regex)){
this->stream_.writeValidFiles(getVariableMap(file, sm)); // write to txt file
++count;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/filepattern/cpp/external/external_stringpattern.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class ExternalStringPattern : public ExternalPattern {
fs::directory_iterator iterator_; // File iterator for given path
fs::recursive_directory_iterator recursive_iterator_; // Recursive iterator
bool end_of_file_; // True if end of temp file is reached
bool recursive_; // True if recursive iterator through subdirectories
int total_files_; // Total number of matched files (will be deleted)


Expand Down
7 changes: 0 additions & 7 deletions src/filepattern/cpp/internal/filepattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,11 @@ FilePatternObject::FilePatternObject(const string& path, const string& file_patt
this->sortFiles();
}

void FilePatternObject::printFiles(){
for(const auto& file: this->iterator_){
//cout << file << endl;
}
}

void FilePatternObject::matchFilesOneDir(){

Map mapping;
vector<string> parsed_regex;

int i, j;
string s;
string file, file_path;
Tuple member;
Expand Down
6 changes: 0 additions & 6 deletions src/filepattern/cpp/internal/filepattern.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ class FilePatternObject : public InternalPattern {
*/
void matchFiles();

/**
* @brief Print the valid files to the console.
*
*/
void printFiles();

private:
//std::string path; // path to directory
fs::directory_iterator iterator_; // File iterator for given path
Expand Down
11 changes: 5 additions & 6 deletions src/filepattern/cpp/internal/internal_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ void InternalPattern::nextGroup() {}
void InternalPattern::groupByHelper(const vector<string>& groups){

std::vector<std::pair<std::vector<std::pair<std::string, Types>> , std::vector<Tuple>>> temp;
int group_idx;
vector<Tuple> temp_vec;
vector<std::pair<std::string, Types>> grouped_variables;
for(const auto& group_by: groups){

group_idx = 0;
for(const auto& group_by: groups){

for(auto& vec: this->valid_grouped_files_){

grouped_variables.clear();
for(auto& g: vec.first) grouped_variables.push_back(g);
// Sort the matched files by the group_by parameter
Expand All @@ -26,7 +25,7 @@ void InternalPattern::groupByHelper(const vector<string>& groups){

Types current_value = get<0>(vec.second[0])[group_by]; // get the value of variable
vector<Tuple> empty_vec;
int i = 0;
unsigned int i = 0;
int group_ptr = 0;

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

vector<Tuple> empty_vec;
int i = 0;
unsigned int i = 0;
int group_ptr = 0;

//group files into vectors based on group_by variable
Expand Down Expand Up @@ -222,7 +221,7 @@ void InternalPattern::sortFiles(){
});
}

Tuple InternalPattern::getItem(int key){
Tuple InternalPattern::getItem(unsigned int key){
if(key < 0) {
if(this->valid_files_.size() + key < 0) throw out_of_range("Index " + std::to_string(key) + " is out of range.");
return this->valid_files_[this->valid_files_.size()+key];
Expand Down
2 changes: 1 addition & 1 deletion src/filepattern/cpp/internal/internal_pattern.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class InternalPattern : public Pattern {
*/
std::string outputName(std::vector<Tuple>& vec);

Tuple getItem(int key);
Tuple getItem(unsigned int key);

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

Expand Down
11 changes: 5 additions & 6 deletions src/filepattern/cpp/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ tuple<string, vector<string>, vector<string>> Pattern::getRegex(string& pattern,
std::smatch sm, m; // regex matches

string temp;
wchar_t last;
// extract bracket expressions from pattern and store regex
while (regex_search(patternCopy, m, e)){
temp = m[0];
Expand Down Expand Up @@ -158,16 +157,16 @@ Tuple Pattern::getVariableMapMultDir(const string& filePath, const smatch& sm){
string basename;
string file = s::getBaseName(filePath);
// iterate over matched files, checking if filename already exists
for(int i = 0; i < this->valid_files_.size(); i++){
for (auto& valid_file: this->valid_files_) {
#ifdef JAVA_BINDING
basename = s::getBaseName(s::to_string(get<1>(this->valid_files_[i])[0])); // store the basename
basename = s::getBaseName(s::to_string(get<1>(valid_file)[0])); // store the basename
#else
basename = s::getBaseName(get<1>(this->valid_files_[i])[0].string()); // store the basename
basename = s::getBaseName(get<1>(valid_file)[0].string()); // store the basename
#endif
// if the filename is found, add the filepath to the vector in the second member of the tuple
if(basename == file){
matched = true;
get<1>(this->valid_files_[i]).push_back(filePath); // Add path to existing mapping
get<1>(valid_file).push_back(filePath); // Add path to existing mapping
break;
}
}
Expand All @@ -188,7 +187,7 @@ Tuple Pattern::getVariableMap(const string& filePath, const smatch& sm){

string str;
// Extract capture groups from filename and store in mapping
for(int i = 1; i < sm.size(); ++i){
for(unsigned int i = 1; i < sm.size(); ++i){

str = sm[i];

Expand Down
4 changes: 2 additions & 2 deletions src/filepattern/cpp/pattern_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ class PatternObject {

virtual std::vector<Tuple> getMatchingBlock() = 0;

virtual Tuple getItem(int key) = 0;
virtual Tuple getItem(unsigned int key) = 0;

virtual std::vector<Tuple> getItemList(std::vector<int>& key) = 0;

size_t length() const {return valid_files_.size();};

const std::pair<std::vector<std::pair<std::string, Types>> , std::vector<Tuple>>& get_grouped_file_by_idx(int idx) {
const std::pair<std::vector<std::pair<std::string, Types>> , std::vector<Tuple>>& get_grouped_file_by_idx(unsigned int idx) {

if (idx < 0 || idx >= this->valid_grouped_files_.size()) {

Expand Down
2 changes: 1 addition & 1 deletion src/filepattern/cpp/util/fs_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Tuple FilesystemStream::getFileByIndex(int i) {
return temp;
}

int FilesystemStream::getValidFilesSize(){
unsigned int FilesystemStream::getValidFilesSize(){
return this->valid_files_size_;
}

Expand Down
6 changes: 3 additions & 3 deletions src/filepattern/cpp/util/fs_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FilesystemStream {

public:
int counter_; // for debugging (to be removed)
int map_size_; // size of maps in stream
unsigned int map_size_; // size of maps in stream

/**
* @brief Construct a new Filesystem Stream object.
Expand Down Expand Up @@ -145,7 +145,7 @@ class FilesystemStream {

Tuple getFileByIndex(int i);

int getValidFilesSize();
unsigned int getValidFilesSize();

std::vector<Tuple> getValidFilesSlice(int i, int j, int step);

Expand All @@ -170,7 +170,7 @@ class FilesystemStream {
bool empty_; // no more files remaining
bool valid_files_empty_; // no more matched files
long double block_size_; // max amount of memory to use
int valid_files_size_;
unsigned int valid_files_size_;

/**
* @brief Updates the amount of memory being used
Expand Down
6 changes: 3 additions & 3 deletions src/filepattern/cpp/util/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ namespace m {
* @return true The end of the file has not been reached and the map is modified
* @return false The end of the file has been reached and the mao is not modified
*/
inline bool getMap(std::ifstream& infile, Tuple& member, int map_size) {
inline bool getMap(std::ifstream& infile, Tuple& member, long unsigned int map_size) {

std::string str;
Map map;
Expand Down Expand Up @@ -523,7 +523,7 @@ namespace d {
if (s::endsWith(path_to_dir, ".txt")) path_to_dir = path_to_dir.substr(0, path_to_dir.find_last_of('/'));
fs::path path = path_to_dir;
try {
uintmax_t n = fs::remove_all(path);
fs::remove_all(path);
}
catch (fs::filesystem_error& e) {}
}
Expand Down Expand Up @@ -562,7 +562,7 @@ namespace f {

file.seekg(std::ios::beg);

for(int i=0; i < num - 1; ++i){
for(unsigned int i=0; i < num - 1; ++i){
file.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
}

Expand Down

0 comments on commit b7a50e3

Please sign in to comment.