cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: C++ design for curlpp

From: Dave Halbakken <YetAnotherDev_at_netscape.net>
Date: Mon, 03 Feb 2003 13:13:26 -0800

Hello Jean-Philippe,

I'm not sure yet whether my code would be relevant or whether our
corporate lawyers will allow me to share my code (I haven't heard back
from them yet). But here's an idea of what I've done so far.

I've got a class that represents a curl connection. It has methods, each
of which performs a single operation including all the curl setup,
easy_perform, and error checking. Each method is implemented internally
by instantiating an operation class and invoking a run() on that class.
The operation class knows the particulars of the operation and maintains
state specific to that operation while it is running.

The connection class has static functions that it registers with libcurl
for curl callbacks, and each of these static functions is passed a this
pointer to the connection class. The connection class maintains
collections of callback interfaces that get registered and unregistered
by the operation classes plus any registered by the connection class
itself. So the actual curl callback handler becomes just a routing
mechanism to invoke a virtual method on each of the callback interfaces
that got registered. The interface declarations just have a single, pure
virtual method, which the routing mechanism calls. In this way, the curl
callback handler knows nothing about what it is calling. So, each of the
operation classes derives (using multiple inheritance) from the callback
interfaces it wishes to implement, and, when the operation is invoked,
the operation object registers its this pointer with the routing
mechanism, and when the operation is done, the operation object
unregisters itself.

This may be too specific to my application to be general purpose because
it hides many of the libcurl internals. But maybe (or maybe not) the
general idea will be useful to you.

Dave Halbakken

----
Jean-Philippe Barrette-LaPierre wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> At this time I'm trying to improve the design in curlpp (the "official" C++ 
> wrapper of libcURL) of what's related to the storage callback options 
> (HEADER_CALLBACK, BODY_CALLBACK, etc.). At this time I really don't like how 
> it's designed. If someone has allready did this, or have a good idea how to 
> wrap this, it would be very appreciated if you be willing to share your 
> ideas, or code, with me.
> 
> If you want to check how it's done at this time, take a look at the curlpp web 
> page at http://www.sourceforge.net/projects/curlpp. 
> 
> P.S. : at this time in the CVS, all the storage is disabled.
>
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
Received on 2003-02-03