Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6704533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:17:59+00:00 2026-05-26T07:17:59+00:00

I am writing a program that downloads multiple files (at the moment its only

  • 0

I am writing a program that downloads multiple files (at the moment its only 2). I am trying to get it to display a progress bar for each download using the ProgressFunction callback. The problem I am running into is I cannot figure out a way to differentiate between the progress between the two files. Right now it is switching between the two. I have tried looking for any further documentation but it seems the API link is broken on their site and there is not much other than some basic examples.

    //ProgressCalback
    double ProgressCallBack(double dltotal, double dlnow, double ultotal, double ulnow){
       double progress = (dlnow/dltotal) * 100;
       std::ostringstream strs;
       float percent = floorf(progress * 100) / 100;
       strs << percent;
       printf("%s\t%d\t%d\t%d\t%d\n", strs.str().c_str(),dltotal, dlnow, ultotal, ulnow);
       return 0;
    };

    curlpp::options::ProgressFunction progressBar(ProgressCallBack);
    request1.setOpt(new curlpp::options::Url(url1));
    request1.setOpt(new curlpp::options::Verbose(false));
    request1.setOpt(new curlpp::options::NoProgress(0));
    request1.setOpt(progressBar);

I am not entirely sure what part of my code would be relevant so here are the parts pertaining to the progress callback. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:18:00+00:00Added an answer on May 26, 2026 at 7:18 am

    Disclaimer: My C++ is rusty, and I have never used curlpp before, so the code below may need a bit of massaging.

    What you need in your callback function is something that can differentiate between the two downloads. Since curlpp doesn’t give you that, you probably need to use a functor instead. So, for your progress callback, make a class similar to:

    class ProgressCallback
    {
    public:
        ProgressCallback(int index) : downloadIndex(downloadIndex)
        {
        }
    
        double operator()(double dltotal, double dlnow, double ultotal, double ulnow)
        {
           double progress = (dlnow/dltotal) * 100;
           std::ostringstream strs;
           float percent = floorf(progress * 100) / 100;
           strs << percent;
           printf("%d: %s\t%d\t%d\t%d\t%d\n", downloadIndex,
                  strs.str().c_str(),dltotal, dlnow, ultotal, ulnow);
           return 0;
        }
    
    private:
        int downloadIndex;
    };
    

    Now, you should be able to use this like:

    ProgressCallback callback1(1);
    curlpp::options::ProgressFunction progressBar(callback1);
    

    Of course, you will need to think about the lifetime of these callback functors. Probably leaving them on stack would be a bad idea.


    EDIT: There seems to be an easier way to do this. in utilspp/functor.h, there are two template functions defined: make_functor() and BindFirst(). So you could simply add a downloadIndex parameter to your ProgressCallback:

    double ProgressCallBack(int dlIdx,
                            double dltotal, double dlnow,
                            double ultotal, double ulnow);
    

    And register as:

    curlpp::options::ProgressFunction
        progressBar(BindFirst(make_functor(ProgressCallback), 1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a .NET program in C# that makes GET requests and downloads pages
I am writing a program that downloads tar.xz files from a server and extracts
I have a program I'm writing that downloads to files. The second file is
I'm writing a program that downloads information from the web and part of that
I'm writing a program that will watch a particular directory for new files containing
I'm writing a test program that use a Tab Controller with multiple tab views.
I am writing a Java program that downloads and then processes many webpages. What
I'm writing a program in Ruby that downloads a file from an RSS feed
im writing an application that downloads and installs addons for programs which needs to
Im writing a program that should read input via stdin, so I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.