0

Hi Guys,
I need your help again. There is a project I'm working on for my job attatchment. It requires that I use a progress bar to show the progress of the file I am currently uploading to the database. The program's code also contains a line counter which counts the lines in the file imported to see how many lines will be added to the database. I am wondering : is it possible that I could somehow use the values created by this "LineCount" function to set mininmum and maximum values for the progress bar? If so, how would I get those values from this constantly incremented integer?

Thanks,
KemarS

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by daviddoria
0

you could use boost::progress_display http://www.boost.org/libs/timer/timer.htm

#include <boost/progress.hpp>
#include <iostream>
#include <unistd.h>

int main()
{
  enum { LINES_IN_FILE = 1000 } ;
  boost::progress_display display( LINES_IN_FILE, std::cout ) ;
  for( int i=0 ; i<LINES_IN_FILE ; ++i )
  {
    // process one line, add to database
    usleep( 10 ) ; // simulate taking 10 microsecs for this
    ++display ;
  }
}
0

Is there a way to declare the progress_display before initializing it, so you can do something like this:

void MyFunc(const bool progressbar)
{
boost::progress_display display;
if(progressbar)
  display = boost::progress_display(LINES_IN_FILE);
  for( int i=0 ; i<LINES_IN_FILE ; ++i )
  {
    //do something
    if(progressbar)
       ++display ;
  }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.