Skip to content
Snippets Groups Projects
Commit b44cabef authored by Mathieu Valois's avatar Mathieu Valois
Browse files

move nbline to own file

parent b1c28bdf
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ add_executable(cppack
src/core/Statsgen.cpp
src/core/Policy.cpp
src/core/ThreadData.cpp
src/core/Utils.cpp
src/cli/Main.cpp)
target_link_libraries(cppack ${CMAKE_THREAD_LIBS_INIT})
......@@ -44,6 +45,7 @@ if(Qt5Core_FOUND)
src/core/Statsgen.cpp
src/core/Policy.cpp
src/core/ThreadData.cpp
src/core/Utils.cpp
ressources/logos.qrc
)
......@@ -58,5 +60,6 @@ add_executable(cppack-test
src/core/Statsgen.cpp
src/core/Policy.cpp
src/core/ThreadData.cpp
src/core/Utils.cpp
src/test/cppack-tests.cpp)
target_link_libraries(cppack-test ${CMAKE_THREAD_LIBS_INIT})
\ No newline at end of file
......@@ -18,7 +18,7 @@
#include <fstream>
#include <unordered_map>
#include <iomanip>
#include <utility>
#include <sstream>
inline float percentage(const float& num, const float& den){
return 100 * num / den;
......
......@@ -332,24 +332,6 @@ void* generate_stats_thread(void* threadarg) {
pthread_exit(NULL);
}
uint64_t nbline_file(const string & filename) {
ifstream readfile(filename);
string line;
uint64_t nb = 0;
while(getline(readfile, line)){
++nb;
}
// we have not read the whole file
if (readfile.fail() && !readfile.eof()){
cerr << "[ERROR] There was an error reading the file at line " << nb << endl;
return 0;
}
return nb;
}
bool Statsgen::operator==(const Statsgen& o) const {
return results == o.results;
}
......
#include "Utils.h"
uint64_t nbline_file(const std::string& filename) {
std::ifstream readfile(filename);
std::string line;
uint64_t nb = 0;
while(std::getline(readfile, line)){
++nb;
}
// we have not read the whole file
if (readfile.fail() && !readfile.eof()){
std::cerr << "[ERROR] There was an error reading the file at line " << nb << std::endl;
return 0;
}
return nb;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment