cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: C++ streams interface for libcurl

From: Jean-Philippe Barrette-LaPierre <jpb_at_rrette.com>
Date: Fri, 18 Jul 2003 09:50:21 -0400

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On July 18, 2003 08:20 am, RBramante_at_on.com wrote:
> Hi,
>
> Yes I looked at curlpp awhile back and my initial impressions (please
> correct me if I am wrong) was that it was still very much callback-driven.
> That is, the function-pointers had been replaced by stream straits but the
> io was still driven via callback.
>

curlpp output/input is driven by traits. You're right when you say that traits
are driven by callback, but they are just a low level interface to
output/input. All input/output is managed by a trait, but curlpp permit to
use a "plus more good" interface for output/input: curlpp::ostream_trait,
curlpp::ofile_trait, for example. Those are traits implemented in order to be
able to use output/input easely, without requiring to manage all the callback
interface.

      curlpp::easy request;
      request.url( "http://myurl.org" );
      
      std::ofstream my_file( "./body.html" );
      curlpp::ostream_trait my_trait( &my_file );
      request.m_body_storage.trait( &my_trait, false );
      
      request.perform();
 
In my opinion, the traits are better than implementing directly the interface
with std:iostreams, 'cause they permit to keep the flexibility and the "easy
to use" aspect without restricting the use of the callback facility. curlpp
is a wrapper arround libcurl, but is as flexible as libcurl. The main goal of
curlpp is to be exception safe, type safe and to use the standard library as
much it can (example: replacing curl_slist by std::list).

> Concepually, I'd be looking to do something along the lines of:
>
> curlobj.connect();
> if(curlobj.getResponse() == HTTP_OK)
> {
> ostream& os = curlobj.getOutputStream();
> .....
> os << "blah blah blah";
> os.write(buffer, size);
> ......
> }
>
> This would be loosely based on Java's HttpURLConnection is anyone is
> familiar with that. This basically would allow the client to have much
> more control over thr read/write a la the multi interface coupled with the
> added benefits that streams have to offer.
>
> Perhaps I've missed something and curlpp does allow for this. Please let
> me know if that is in fact the case.

>
> Thanks.
>
> |---------+---------------------------------------->
> |
> | | Jean-Philippe |
> | | Barrette-LaPierre |
> | | <jpb_at_rrette.com> |
> | | Sent by: |
> | | curl-library-admin_at_lists.sour|
> | | ceforge.net |
> | |
> | |
> | | 07/17/2003 10:18 PM |
> | | Please respond to |
> | | curl-library |
> |
> |---------+---------------------------------------->
> |
> >------------------------------------------------------------------------
> >----------------------------------|
> >
> | To: curl-library_at_lists.sourceforge.net
> | | cc:
> | |
> | Subject: Re: C++ streams interface for libcurl
> | |
> |
> >------------------------------------------------------------------------
> >----------------------------------|
>
> On Thursday 17 July 2003 09:08 pm, RBramante_at_on.com wrote:
> > Hello All,
> >
> > I have a C++ wrapper class around curl that I have been using and I've
> > always kicked around the idea of implementing an istream/ostream type
> > interface for the data portions of the io (i.e take the place of the
> > read/write callbacks)
> >
> > A while back I did some quick prototypes and my results were somewhat
>
> mixed
>
> > (either turned out using platform-specific code or seemed unduly complex)
> > so I didn't really pursue it.
> >
> > I'm considering taking another look at it again, but this time I figured
> > I'd check if anyone else has already tackled this issue with good results
> > and have anything they'd like to share.
>
> look at curlpp that I'm develloping. www.sf.net/projects/curlpp.
>
> tell me what you think.
>
> > -------------------------------------------------------
> > This SF.net email is sponsored by: VM Ware
> > With VMware you can run multiple operating systems on a single machine.
> > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
>
> --
> Jean-Philippe Barrette-LaPierre
> Programmer-Analyst
> Maintainer of curlpp
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

- --
Jean-Philippe Barrette-LaPierre
Maintainer of curlpp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/F/sd/yHhCaWWuc8RAigQAJ95//LHAC5MkTXC/OuYXuDP94BASQCdHeTc
K3+DCDl4Tuxt3DiGQg2K03s=
=/WYb
-----END PGP SIGNATURE-----

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
Received on 2003-07-18