On Jul 26, 2006, at 1:07 AM, Erik de Castro Lopo wrote:

Taybin Rutkin wrote:

On Jul 13, 2006, at 4:48 PM, Erik de Castro Lopo wrote:


I have for some time been looking for someone to write a
lightweight C++ wrapper for libsndfile that I can distribute
with libsndfile.

My own rather feeble first attempt is here:

    http://www.mega-nerd.com/tmp/sndfile.hh

but I am not a fan nor a great user of C++. The wrapper should
really be written by someone with a love for the language.

I use C++ a lot, and I gotta say, this wrapper isn't bad at all.  I
prefer lower case method names, but that's about it.

Oh, cool, a response at last :-).

Well first off, it isn't quite complete and it hasn't been
properly tested either.

Secondly, with regard to the method names, which do you prefer:

    - OpenRead
    - openRead
    - open_read

I prefer the unix-y open_read(). I don't think method names should ever start with a capital, unless it's the ctor or dtor.

    - something else

Since you're the only person who actually responded to the real
meat of my email, I have to assume that you are the only person
on this list with a love for C++ and hence the only one who
should have any real input on this issue ;-).

I noticed that the constructor SndFile::SndFile (const char *path, int mode, SF_INFO *sfinfo) isn't declared in the class. Also, since this constructor can fail if sf_open() fails up, it should throw an exception. Maybe containing the results of sf_strerror().

Something like

SndFile::SndFile (const char *path, int mode, SF_INFO *sfinfo)
{
    psf = sf_open (path, mode, sfinfo) ;
    if (!psf) {
        throw sf_error(psf);
    }
}

Taybin

Reply via email to