[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Alternative C++ API

From: Scott Lamb <slamb_at_slamb.org>
Date: 2002-12-15 06:56:46 CET

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

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

Received on Sun Dec 15 06:57:09 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.