1 | #include <cpr/callback.h> |
---|---|
2 | #include <curl/curl.h> |
3 | #include <functional> |
4 | |
5 | namespace cpr { |
6 | |
7 | void CancellationCallback::SetProgressCallback(ProgressCallback& u_cb) { |
8 | user_cb.emplace(args: std::reference_wrapper{u_cb}); |
9 | } |
10 | bool CancellationCallback::operator()(cpr_pf_arg_t dltotal, cpr_pf_arg_t dlnow, cpr_pf_arg_t ultotal, cpr_pf_arg_t ulnow) const { |
11 | const bool cont_operation{!cancellation_state->load()}; |
12 | return user_cb ? (cont_operation && (*user_cb)(dltotal, dlnow, ultotal, ulnow)) : cont_operation; |
13 | } |
14 | } // namespace cpr |
15 |