diff --git a/src/svf_jtag.cpp b/src/svf_jtag.cpp index f21dc50..ab857a3 100644 --- a/src/svf_jtag.cpp +++ b/src/svf_jtag.cpp @@ -18,6 +18,7 @@ #include #include "jtag.hpp" +#include "progressBar.hpp" void SVF_jtag::split_str(std::string const &str, std::vector &vparse) @@ -379,6 +380,14 @@ void SVF_jtag::parse(std::string filename) return; } unsigned int lineno = 0; + int lines_total = std::count(std::istreambuf_iterator(fs), + std::istreambuf_iterator(), '\n') + 1; + fs.clear(); + fs.seekg(0,std::ios::beg); + printf("Reading %s with %d lines", filename.c_str(), lines_total); + + ProgressBar progress("Writing SVF " + filename, lines_total, 50, _verbose); + try { while (getline(fs, str)) { if(str.empty()){ @@ -409,13 +418,16 @@ void SVF_jtag::parse(std::string filename) handle_instruction(vstr); vstr.clear(); } + progress.display(lineno); } } catch (std::exception &e) { - std::cerr << "Cannot proceed because of error(s) at line " << lineno << std::endl; + std::cerr << "Cannot proceed because of error(s) at line " << std::dec << lineno << std::endl; + progress.fail(); throw; } + progress.done(); std::cout << "end of SVF file" << std::endl; }