Some API comments and questions
nerochiaro at gmail.com
Tue Jan 17 12:54:02 CET 2006
I'm writing Ruby bindings for TagLib 1.4 (full API) and so far I got
most of Xiph and APE tags to work and I'm moving on to wrap the ID3
tags handling. I have some questions and comments I would like to
share before finishing this.
Keep in mind that my C++ is somewhat rusty at the moment and that most
of the work is being done in SWIG and Ruby, so pardon me if something
I say doesn't make much sense.
1) Files get opened in the constructor and get closed in the
destructor. While this is fine for C++ use, it does become
inconvenient when used from languages that rely on garbage collection.
With GC objects can be deleted at any point in time after going out of
scope, thus potentially leaving files open much longer than needed.
In my bindings i have handled this with an hack on the Ruby GC, but
having a File::close function to just close the underlying file handle
(fclose) would be much more cleaner.
2) I see that in many places Map-based objects are returned by
reference (e.g. Ogg::XiphComment::fieldListMap or
APE::Tag::itemListMap), while List-based objects are always returned
by value (e.g. ID3v2::TextIdentificationFrame::fieldList or
This seems to have the drawback that we're accessing a different copy
of the List each time, while it would be more convenient to be
accessing the same List instance across calls.
It even probably resulted in a bug already, in APE::Tag::setValue (see
KDE bug #120256), and in general makes working with the APE tags more
cumbersome (especially from bindings).
3) Finally, a minor nitpick: the docs for TagLib::Map< Key, T
>::insert(const Key & key,const T & value) state that if the key
exists, the value gets overwritten. Instead, if the key exists,
nothing is done, at least the STL implementation i use (GNU).
Am I getting anything wrong ? Comments are welcome.
More information about the taglib-devel