bug encoding multibyte?

Lukáš Lalinský lalinsky at gmail.com
Tue Feb 6 17:24:14 CET 2007

On Ut, 2007-02-06 at 16:40 +0100, Xavier Duret wrote:
> How to do things in C++ is very clear to me. I am having trouble to
> imagine the C bindings. Remember that there is no overloading
> mechanism in C.
> The following 3 declarations are a problem:
> - TagLib_File_Type: this is an enum declared in C so it cannot be extended.
> - taglib_file_new: use the base FileRef::create method which does not
> know of the types declared in taglibext.
> - taglib_file_new_type: this is dependent on TagLib_File_Type and also
> use the "new" operator which would lead to a #include <m4afile.h>
> inside tag_c.cpp which is not acceptable.
> What I can imagine is:
> - TagLib_File_Type is replaced by something that can be extended like
> an int with DEFINE statements or TagLib_File_Type is extended to
> support even types that are not supported by taglib.
> - An initialization function like taglib_file_init is added to
> libtag_c for registering new types. A new type is defined by a
> File_Type, a FileTypeResolver (needed by taglib_file_new) and a
> FileTypeFactory (needed by taglib_file_new_type). This function adds
> the FileTypeResolver to a FileRef object.
> - Each extension library like libtagext needs to provide a function
> (e.g. taglibext_getm4a_info) to provide the input to
> taglib_file_init.
> - taglib_file_new uses the FileRef object initialized by
> taglib_file_init instead of using the base class directly.
> - taglib_file_new_type is adapted to use the replacement of TagLib_File_Type.
> - taglib_file_new_type does a lookup of the proper FileTypeFactory
> using the File_Type as index.
> - the main program includes "tag_c.h" and the different "tagext_c.h".
> It calls the different
> taglib*_get*_info function and feed the result to taglib_file_init.

You are looking at it from the wrong side. Here are two code samples for
both options how to create a new TagLib_File. Using taglib_file_new:

#include <tag_c.h>
#include <tagext_c.h>

int main(int argc, char **argv)
  taglibext_init(); /* this registers new FileTypeResolvers */
  TagLib_File *file = taglib_file_new("/path/to/file/file.m4a");
  printf("Title: %s\n", taglib_tag_title(file));

Using taglib_file_new_type/taglibext_file_new_type:

#include <tag_c.h>
#include <tagext_c.h>

int main(int argc, char **argv)
  TagLib_File *file = taglibext_file_new_type("/path/to/file/file.m4a",
  printf("Title: %s\n", taglib_tag_title(file));

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.kde.org/pipermail/taglib-devel/attachments/20070206/c4d42aad/attachment.pgp 

More information about the taglib-devel mailing list