curl WRITEFUNCTION and classes(curl WRITEFUNCTION 和类)
问题描述
class Filter{
private:
string contents;
bool Server(void);
public:
void handle(void *, size_t, size_t, void *);
};
我有一个这样的类标题.我想在函数 Server 中调用 curl WRITEFUNCTION ,该函数将使用句柄写入字符串内容.虽然它一直给我错误
i have a class header like this. i want to call curl WRITEFUNCTION inside the function Server which would use handle to write to the string contents. although it keeps giveng me the error
error: invalid use of member (did you forget the ‘&’ ?)
错误指向的那一行是 CURLOPT_WRITEFUNCTION.... 我的 curl 请求看起来像这样...
the line pointed by error is that of CURLOPT_WRITEFUNCTION.... My curl request looks something like this...
curl_easy_setopt(curl,CURLOPT_URL, address.c_str());
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,handle);
curl_easy_perform(curl);
这意味着它无法访问 handle()..我该如何纠正?
that means its unable to access the handle().. how can i rectify this?
推荐答案
string temp;
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,handle);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,&temp);
size_t Filter::handle(void *ptr, size_t size, size_t nmemb, string stream)
{
string temp(static_cast<const char*>(ptr), size * nmemb);
stream = temp;
return size*nmemb;
}
这就是我让它工作的方式..这会将网站保存到名为 temp 的字符串中.
thats how i got it to work.. this will save the website to the string named temp.
这篇关于curl WRITEFUNCTION 和类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:curl WRITEFUNCTION 和类
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 从python回调到c++的选项 2022-11-16
- Stroustrup 的 Simple_window.h 2022-01-01
- C++ 协变模板 2021-01-01
- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01