You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Scott Lamb <sl...@slamb.org> on 2002/12/15 05:56:46 UTC

Alternative C++ API

I've been working for a bit on an alternative C++ API, because of two 
things I didn't like about SvnCpp:

- I couldn't understand what the classes represent / the inheritance 
hierarchy. What doess a single "Client" object represent? Why does it 
keep a revision? What does Auth inherit from Client? etc. I'd expected 
something more closely mirroring the structures in the C API, just with 
added object-oriented goodness.

- I didn't like how the callbacks were handled. I've found a clean, 
C++-friendly way to do this with boost's function objects. They are a 
generalization of function pointers that have the idea of batons built 
in. If you've ever played with SigC++ or Qt's signals/slots, it's the 
same general idea.

So I've started a new (unnamed) API. Usage is pretty simple:

     using namespace std;
     using namespace svn;
     try {
         client::AuthBaton authBaton;
         authBaton.setStoreAuthInfo(true);
         client::update(authBaton, "/tmp/primes",
                 client::RevisionSpecifier::HEAD, true, notify, top);
     } catch (exception &e) {
         cerr << "Error: " << e.what() << endl;
     }

Where notify - through the magic of boost::function - can be a simple 
function, a function with one argument bound (much like a baton), a 
member function with the object bound, etc.

It has very basic code for translating between svn::Exception (derived 
from std::exception) and svn_error_t*s. Ideally, users can throw 
exceptions in callbacks and receive them from my wrappers of Subversion 
functions and not worry about what happens between.

I've just been playing around with this for myself. Are other people 
interested in such a thing?

The tarball's only 7K, so it's attached.

Thanks,
Scott

Re: Alternative C++ API

Posted by Justin Erenkrantz <je...@apache.org>.
--On Saturday, December 14, 2002 11:56 PM -0600 Scott Lamb 
<sl...@slamb.org> wrote:

> Where notify - through the magic of boost::function - can be a
> simple function, a function with one argument bound (much like a
> baton), a member function with the object bound, etc.

I know that there are a lot of C++ compilers that don't compile boost 
quite right:

http://www.boost.org/status/compiler_status.html

Therefore, you should watch out for portability issues.  -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Alternative C++ API

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On Sunday, December 15, 2002, at 12:56 AM, Scott Lamb wrote:
>
> - I couldn't understand what the classes represent / the inheritance 
> hierarchy. What doess a single "Client" object represent? Why does it 
> keep a revision? What does Auth inherit from Client? etc. I'd expected 
> something more closely mirroring the structures in the C API, just 
> with added object-oriented goodness.

for what it's worth, i've never really understood the class hierarchy 
in the svncpp stuff either.  it all seemed pretty arbitrary and didn't 
really follow any rhyme or reason as far as i could tell.

> So I've started a new (unnamed) API. Usage is pretty simple:
>
>     using namespace std;
>     using namespace svn;
>     try {
>         client::AuthBaton authBaton;
>         authBaton.setStoreAuthInfo(true);
>         client::update(authBaton, "/tmp/primes",
>                 client::RevisionSpecifier::HEAD, true, notify, top);
>     } catch (exception &e) {
>         cerr << "Error: " << e.what() << endl;
>     }

that looks pretty much like what i'd envisioned a c++ binding for svn 
to look like.

> It has very basic code for translating between svn::Exception (derived 
> from std::exception) and svn_error_t*s. Ideally, users can throw 
> exceptions in callbacks and receive them from my wrappers of 
> Subversion functions and not worry about what happens between.

*laugh*  i've got similar stuff sitting in a local svn repository from 
when i was playing with some c++ bindings for svn.  mine never got 
further than playing around though.  it's definately the way i'd go 
with it though.

> I've just been playing around with this for myself. Are other people 
> interested in such a thing?
>
> The tarball's only 7K, so it's attached.

thanks, i'll take a look at it tomorrow sometime, it sounds promising.

-garrett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org