diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-09-24 07:39:42 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-09-24 07:39:42 +0000 |
commit | 22059858fe21655263ebb217bbe0561806d7a95f (patch) | |
tree | 0ed3957e7d98ced169cac92f6c625528bed7c1a0 /docs | |
parent | 82107a02f5eb97087b58ac1f932f068ec685d150 (diff) |
Added "5.14 Using C++ non-static functions for callbacks?"
Diffstat (limited to 'docs')
-rw-r--r-- | docs/FAQ | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -1,4 +1,4 @@ -Updated: Feb 18, 2008 (http://curl.haxx.se/docs/faq.html) +Updated: Sep 24, 2008 (http://curl.haxx.se/docs/faq.html) _ _ ____ _ ___| | | | _ \| | / __| | | | |_) | | @@ -85,6 +85,7 @@ FAQ 5.11 How do I make libcurl not receive the whole HTTP response? 5.12 Can I make libcurl fake or hide my real IP address? 5.13 How do I stop an ongoing transfer? + 5.14 Using C++ non-static functions for callbacks? 6. License Issues 6.1 I have a GPL program, can I use the libcurl library? @@ -1070,6 +1071,24 @@ FAQ If you're using the multi interface, you also stop a transfer by removing the particular easy handle from the multi stack. + 5.14 Using C++ non-static functions for callbacks? + + libcurl is a C library, it doesn't know anything about C++ member functions. + + You can overcome this "limitation" with a relative ease using a static + member function that is passed a pointer to the class: + + // f is the pointer to your object. + static YourClass::staticFunction(void *buffer, size_t sz, size_t n, void *f) + { + // Call non-static member function. + static_cast<YourClass*>(f)->nonStaticFunction(); + } + + // This is how you pass pointer to the static function: + curl_easy_setopt(hcurl, CURLOPT_WRITEFUNCTION, YourClass:staticFunction); + curl_easy_setopt(hcurl, CURLOPT_WRITEDATA, this); + 6. License Issues Curl and libcurl are released under a MIT/X derivate license. The license is |