diff --git a/CMakeLists.txt b/CMakeLists.txt index bbcf8d89..91e1901d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,11 @@ if(WITH_MP4) set(TAGLIB_WITH_MP4 TRUE) endif() +option(TRACE_IN_RELEASE "Output debug messages even in release mode" OFF) +if(TRACE_IN_RELEASE) + set(TRACE_IN_RELEASE TRUE) +endif() + configure_file(taglib/taglib_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h) add_subdirectory(taglib) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake old mode 100644 new mode 100755 index 3fd5c687..37550371 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -270,6 +270,7 @@ endif() # Determine whether CppUnit is installed. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) + find_package(CppUnit) if(NOT CppUnit_FOUND AND BUILD_TESTS) message(STATUS "CppUnit not found, disabling tests.") diff --git a/config.h.cmake b/config.h.cmake index b182589e..9ffb4d4f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -48,5 +48,8 @@ /* Defined if you have libz */ #cmakedefine HAVE_ZLIB 1 +/* Indicates whether debug messages are shown even in release mode */ +#cmakedefine TRACE_IN_RELEASE 1 + #cmakedefine TESTS_DIR "@TESTS_DIR@" diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt old mode 100644 new mode 100755 index a36bd867..5315c0b7 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -54,6 +54,7 @@ set(tag_HDRS toolkit/tmap.tcc toolkit/tpropertymap.h toolkit/trefcounter.h + toolkit/tdebuglistener.h mpeg/mpegfile.h mpeg/mpegproperties.h mpeg/mpegheader.h @@ -301,6 +302,7 @@ set(toolkit_SRCS toolkit/tdebug.cpp toolkit/tpropertymap.cpp toolkit/trefcounter.cpp + toolkit/tdebuglistener.cpp toolkit/unicode.cpp ) diff --git a/taglib/ape/apefile.h b/taglib/ape/apefile.h index 13fdbe24..cbf6d810 100644 --- a/taglib/ape/apefile.h +++ b/taglib/ape/apefile.h @@ -59,7 +59,7 @@ namespace TagLib { //! An implementation of TagLib::File with APE specific methods /*! - * This implements and provides an interface APE WavPack files to the + * This implements and provides an interface for APE files to the * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing * the abstract TagLib::File API as well as providing some additional * information specific to APE files. @@ -84,20 +84,22 @@ namespace TagLib { }; /*! - * Contructs an WavPack file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an APE file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an WavPack file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an APE file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/asf/asffile.h b/taglib/asf/asffile.h index e199c8bc..bbd666ff 100644 --- a/taglib/asf/asffile.h +++ b/taglib/asf/asffile.h @@ -54,11 +54,9 @@ namespace TagLib { * * \note In the current implementation, both \a readProperties and * \a propertiesStyle are ignored. - * - * \note TagLib will *not* take ownership of the stream, the caller is - * responsible for deleting it after the File object. */ - File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); + File(FileName file, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! * Contructs an ASF file from \a file. If \a readProperties is true the @@ -71,7 +69,8 @@ namespace TagLib { * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); + File(IOStream *stream, bool readProperties = true, + AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! * Destroys this instance of the File. diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 51dd390b..5434ae44 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -29,10 +29,6 @@ #include "taglib_config.h" -#ifdef _WIN32 -# include -#endif - #include "tfile.h" #include "tstring.h" #include "tdebug.h" diff --git a/taglib/fileref.h b/taglib/fileref.h old mode 100644 new mode 100755 index c0b4607a..d1fab51c --- a/taglib/fileref.h +++ b/taglib/fileref.h @@ -32,10 +32,6 @@ #include "tpropertymap.h" #include "audioproperties.h" -#if _WIN32 -# pragma comment(lib, "shlwapi.lib") -#endif - namespace TagLib { class Tag; diff --git a/taglib/flac/flacfile.h b/taglib/flac/flacfile.h index 062ec770..8c680a32 100644 --- a/taglib/flac/flacfile.h +++ b/taglib/flac/flacfile.h @@ -67,12 +67,13 @@ namespace TagLib { { public: /*! - * Contructs a FLAC file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a FLAC file from \a file. If \a readProperties is true the + * file's audio properties will also be read. * * If this file contains and ID3v2 tag the frames will be created using * \a frameFactory. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, @@ -80,13 +81,14 @@ namespace TagLib { ID3v2::FrameFactory *frameFactory = 0); /*! - * Contructs a FLAC file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a FLAC file from \a file. If \a readProperties is true the + * file's audio properties will also be read. * * If this file contains and ID3v2 tag the frames will be created using * \a frameFactory. * + * \note In the current implementation, \a propertiesStyle is ignored. + * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ diff --git a/taglib/it/itfile.h b/taglib/it/itfile.h index 4f33fb6f..25828b03 100644 --- a/taglib/it/itfile.h +++ b/taglib/it/itfile.h @@ -36,23 +36,25 @@ namespace TagLib { class TAGLIB_EXPORT File : public Mod::FileBase { public: /*! - * Contructs a Impulse Tracker file from \a file. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs a Impulse Tracker file from \a file. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a Impulse Tracker file from \a stream. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs a Impulse Tracker file from \a stream. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stram, bool readProperties = true, + File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/mod/modfile.h b/taglib/mod/modfile.h index 474cc256..04a38a73 100644 --- a/taglib/mod/modfile.h +++ b/taglib/mod/modfile.h @@ -37,18 +37,20 @@ namespace TagLib { { public: /*! - * Contructs a Protracker file from \a file. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs a Protracker file from \a file. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a Protracker file from \a stream. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs a Protracker file from \a stream. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. diff --git a/taglib/mp4/mp4file.h b/taglib/mp4/mp4file.h index ba76aa4f..09374bf6 100644 --- a/taglib/mp4/mp4file.h +++ b/taglib/mp4/mp4file.h @@ -49,27 +49,25 @@ namespace TagLib { { public: /*! - * Contructs a MP4 file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an MP4 file from \a file. If \a readProperties is true the + * file's audio properties will also be read. * - * \note In the current implementation, both \a readProperties and - * \a propertiesStyle are ignored. + * \note In the current implementation, \a propertiesStyle is ignored. */ - File(FileName file, bool readProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); + File(FileName file, bool readProperties = true, + AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); /*! - * Contructs a MP4 file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an MP4 file from \a file. If \a readProperties is true the + * file's audio properties will also be read. * - * \note In the current implementation, both \a readProperties and - * \a propertiesStyle are ignored. + * \note In the current implementation, \a propertiesStyle is ignored. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. */ - File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); + File(IOStream *stream, bool readProperties = true, + AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); /*! * Destroys this instance of the File. diff --git a/taglib/mpc/mpcfile.h b/taglib/mpc/mpcfile.h index dbb0d0cb..e1665690 100644 --- a/taglib/mpc/mpcfile.h +++ b/taglib/mpc/mpcfile.h @@ -84,20 +84,22 @@ namespace TagLib { }; /*! - * Contructs an MPC file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an MPC file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an MPC file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an MPC file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/mpeg/mpegfile.h b/taglib/mpeg/mpegfile.h index 8db2b85e..03b6cab1 100644 --- a/taglib/mpeg/mpegfile.h +++ b/taglib/mpeg/mpegfile.h @@ -71,9 +71,10 @@ namespace TagLib { }; /*! - * Contructs an MPEG file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an MPEG file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. * * \deprecated This constructor will be dropped in favor of the one below * in a future version. @@ -82,28 +83,31 @@ namespace TagLib { AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an MPEG file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. The frames will be created using + * Constructs an MPEG file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * If this file contains and ID3v2 tag the frames will be created using * \a frameFactory. * - * \deprecated This constructor will be dropped in favor of the one below - * in a future version. + * \note In the current implementation, \a propertiesStyle is ignored. */ + // BIC: merge with the above constructor File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an MPEG file from \a stream. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. The frames will be created using - * \a frameFactory. + * Constructs an MPEG file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * If this file contains and ID3v2 tag the frames will be created using + * \a frameFactory. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/ogg/flac/oggflacfile.h b/taglib/ogg/flac/oggflacfile.h index ee49a879..148743a0 100644 --- a/taglib/ogg/flac/oggflacfile.h +++ b/taglib/ogg/flac/oggflacfile.h @@ -64,20 +64,22 @@ namespace TagLib { { public: /*! - * Contructs an Ogg/FLAC file from \a file. If \a readProperties is true - * the file's audio properties will also be read using \a propertiesStyle. - * If false, \a propertiesStyle is ignored. + * Constructs an Ogg/FLAC file from \a file. If \a readProperties is true + * the file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an Ogg/FLAC file from \a file. If \a readProperties is true - * the file's audio properties will also be read using \a propertiesStyle. - * If false, \a propertiesStyle is ignored. + * Constructs an Ogg/FLAC file from \a stream. If \a readProperties is true + * the file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/ogg/opus/opusfile.h b/taglib/ogg/opus/opusfile.h index f42e861d..2658648a 100644 --- a/taglib/ogg/opus/opusfile.h +++ b/taglib/ogg/opus/opusfile.h @@ -56,20 +56,22 @@ namespace TagLib { { public: /*! - * Contructs a Opus file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an Opus file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a Opus file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an Opus file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/ogg/speex/speexfile.h b/taglib/ogg/speex/speexfile.h index 844eecac..8073cd6f 100644 --- a/taglib/ogg/speex/speexfile.h +++ b/taglib/ogg/speex/speexfile.h @@ -56,20 +56,22 @@ namespace TagLib { { public: /*! - * Contructs a Speex file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a Speex file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a Speex file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a Speex file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/ogg/vorbis/vorbisfile.h b/taglib/ogg/vorbis/vorbisfile.h index c0da30d0..2a054a2c 100644 --- a/taglib/ogg/vorbis/vorbisfile.h +++ b/taglib/ogg/vorbis/vorbisfile.h @@ -54,20 +54,22 @@ namespace TagLib { { public: /*! - * Contructs a Vorbis file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a Vorbis file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a Vorbis file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a Vorbis file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/riff/aiff/aifffile.h b/taglib/riff/aiff/aifffile.h index df0ebcaf..cd584b18 100644 --- a/taglib/riff/aiff/aifffile.h +++ b/taglib/riff/aiff/aifffile.h @@ -58,20 +58,22 @@ namespace TagLib { { public: /*! - * Contructs an AIFF file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an AIFF file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an AIFF file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs an AIFF file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/riff/wav/wavfile.h b/taglib/riff/wav/wavfile.h index 476e030b..961703d0 100644 --- a/taglib/riff/wav/wavfile.h +++ b/taglib/riff/wav/wavfile.h @@ -70,20 +70,22 @@ namespace TagLib { }; /*! - * Contructs an WAV file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a WAV file from \a file. If \a readProperties is true the + * file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an WAV file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a WAV file from \a stream. If \a readProperties is true the + * file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); diff --git a/taglib/s3m/s3mfile.h b/taglib/s3m/s3mfile.h index 48577f10..5fedc92e 100644 --- a/taglib/s3m/s3mfile.h +++ b/taglib/s3m/s3mfile.h @@ -36,18 +36,20 @@ namespace TagLib { class TAGLIB_EXPORT File : public Mod::FileBase { public: /*! - * Contructs a ScreamTracker III file from \a file. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs a ScreamTracker III from \a file. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a ScreamTracker III file from \a stream. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs a ScreamTracker III file from \a stream. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. diff --git a/taglib/taglib_config.h.cmake b/taglib/taglib_config.h.cmake index 8b4c89df..f789bc8b 100644 --- a/taglib/taglib_config.h.cmake +++ b/taglib/taglib_config.h.cmake @@ -1,3 +1,2 @@ /* taglib_config.h. Generated by cmake from taglib_config.h.cmake */ - diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 6f1efd26..d5f1bdaf 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -566,11 +566,11 @@ bool ByteVector::containsAt( patternLength = pattern.size(); // do some sanity checking -- all of these things are needed for the search to be valid - - if(offset + patternLength > size() || patternOffset >= pattern.size() || patternLength == 0) + const uint compareLength = patternLength - patternOffset; + if(offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0) return false; - return (::memcmp(data() + offset, pattern.data() + patternOffset, patternLength - patternOffset) == 0); + return (::memcmp(data() + offset, pattern.data() + patternOffset, compareLength) == 0); } bool ByteVector::startsWith(const ByteVector &pattern) const diff --git a/taglib/toolkit/tdebug.cpp b/taglib/toolkit/tdebug.cpp index 522b68c9..65c51efe 100644 --- a/taglib/toolkit/tdebug.cpp +++ b/taglib/toolkit/tdebug.cpp @@ -23,33 +23,75 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#ifndef NDEBUG -#include -#include +#include "config.h" #include "tdebug.h" #include "tstring.h" +#include "tdebuglistener.h" + +#include +#include +#include using namespace TagLib; -void TagLib::debug(const String &s) +namespace { - std::cerr << "TagLib: " << s << std::endl; -} + String format(const char *fmt, ...) + { + va_list args; + va_start(args, fmt); -void TagLib::debugData(const ByteVector &v) -{ - for(uint i = 0; i < v.size(); i++) { + char buf[256]; - std::cout << "*** [" << i << "] - '" << char(v[i]) << "' - int " << int(v[i]) - << std::endl; +#if defined(HAVE_SNPRINTF) - std::bitset<8> b(v[i]); + vsnprintf(buf, sizeof(buf), fmt, args); - for(int j = 0; j < 8; j++) - std::cout << i << ":" << j << " " << b.test(j) << std::endl; +#elif defined(HAVE_SPRINTF_S) - std::cout << std::endl; + vsprintf_s(buf, fmt, args); + +#else + + // Be careful. May cause a buffer overflow. + vsprintf(buf, fmt, args); + +#endif + + va_end(args); + + return String(buf); } } + +namespace TagLib +{ + // The instance is defined in tdebuglistener.cpp. + extern DebugListener *debugListener; + + void debug(const String &s) + { +#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) + + debugListener->printMessage("TagLib: " + s + "\n"); + #endif + } + + void debugData(const ByteVector &v) + { +#if !defined(NDEBUG) || defined(TRACE_IN_RELEASE) + + for(size_t i = 0; i < v.size(); ++i) + { + std::string bits = std::bitset<8>(v[i]).to_string(); + String msg = format("*** [%d] - char '%c' - int %d, 0x%02x, 0b%s\n", + i, v[i], v[i], v[i], bits.c_str()); + + debugListener->printMessage(msg); + } + +#endif + } +} diff --git a/taglib/toolkit/tdebug.h b/taglib/toolkit/tdebug.h index 5204fe70..bd94d159 100644 --- a/taglib/toolkit/tdebug.h +++ b/taglib/toolkit/tdebug.h @@ -32,11 +32,11 @@ namespace TagLib { class ByteVector; #ifndef DO_NOT_DOCUMENT -#ifndef NDEBUG /*! - * A simple function that prints debugging output to cerr if debugging is - * not disabled. + * A simple function that outputs the debug messages to the listener. + * The default listener redirects the messages to \a stderr when NDEBUG is + * not defined. * * \warning Do not use this outside of TagLib, it could lead to undefined * symbols in your build if TagLib is built with NDEBUG defined and your @@ -45,7 +45,7 @@ namespace TagLib { * \internal */ void debug(const String &s); - + /*! * For debugging binary data. * @@ -56,16 +56,7 @@ namespace TagLib { * \internal */ void debugData(const ByteVector &v); - -#else - - // Define these to an empty statement if debugging is disabled. - -#define debug(x) -#define debugData(x) - -#endif -#endif } #endif +#endif diff --git a/taglib/toolkit/tdebuglistener.cpp b/taglib/toolkit/tdebuglistener.cpp new file mode 100644 index 00000000..48912222 --- /dev/null +++ b/taglib/toolkit/tdebuglistener.cpp @@ -0,0 +1,85 @@ +/*************************************************************************** + copyright : (C) 2013 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + +#include "tdebuglistener.h" + +#include +#include + +#ifdef _WIN32 +# include +#endif + +using namespace TagLib; + +namespace +{ + class DefaultListener : public DebugListener + { + public: + virtual void printMessage(const String &msg) + { +#ifdef _WIN32 + + const wstring wstr = msg.toWString(); + const int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); + if(len != 0) { + std::vector buf(len); + WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, &buf[0], len, NULL, NULL); + + std::cerr << std::string(&buf[0]); + } + +#else + + std::cerr << msg; + +#endif + } + }; + + DefaultListener defaultListener; +} + +namespace TagLib +{ + DebugListener *debugListener = &defaultListener; + + DebugListener::DebugListener() + { + } + + DebugListener::~DebugListener() + { + } + + void setDebugListener(DebugListener *listener) + { + if(listener) + debugListener = listener; + else + debugListener = &defaultListener; + } +} diff --git a/taglib/toolkit/tdebuglistener.h b/taglib/toolkit/tdebuglistener.h new file mode 100644 index 00000000..a32f285f --- /dev/null +++ b/taglib/toolkit/tdebuglistener.h @@ -0,0 +1,74 @@ +/*************************************************************************** + copyright : (C) 2013 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + +#ifndef TAGLIB_DEBUGLISTENER_H +#define TAGLIB_DEBUGLISTENER_H + +#include "taglib_export.h" +#include "tstring.h" + +namespace TagLib +{ + //! An abstraction for the listener to the debug messages. + + /*! + * This class enables you to handle the debug messages in your preferred + * way by subclassing this class, reimplementing printMessage() and setting + * your reimplementation as the default with setDebugListener(). + * + * \see setDebugListener() + */ + class TAGLIB_EXPORT DebugListener + { + public: + DebugListener(); + virtual ~DebugListener(); + + /*! + * When overridden in a derived class, redirects \a msg to your preferred + * channel such as stderr, Windows debugger or so forth. + */ + virtual void printMessage(const String &msg) = 0; + + private: + // Noncopyable + DebugListener(const DebugListener &); + DebugListener &operator=(const DebugListener &); + }; + + /*! + * Sets the listener that decides how the debug messages are redirected. + * If the parameter \a listener is null, the previous listener is released + * and default stderr listener is restored. + * + * \note The caller is responsible for deleting the previous listener + * as needed after it is released. + * + * \see DebugListener + */ + TAGLIB_EXPORT void setDebugListener(DebugListener *listener); +} + +#endif diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index dcd3808d..b90dada1 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -83,35 +83,6 @@ namespace return 0; } -# ifndef NDEBUG - - // Convert a string in a local encoding into a UTF-16 string. - - // Debugging use only. In actual use, file names in local encodings are passed to - // CreateFileA() without any conversions. - - String fileNameToString(const FileName &name) - { - if(!name.wstr().empty()) { - return String(name.wstr()); - } - else if(!name.str().empty()) { - const int len = MultiByteToWideChar(CP_ACP, 0, name.str().c_str(), -1, NULL, 0); - if(len == 0) - return String::null; - - std::wstring wstr(len, L'\0'); - MultiByteToWideChar(CP_ACP, 0, name.str().c_str(), -1, &wstr[0], len); - - return String(wstr); - } - else { - return String::null; - } - } - -# endif - #else // _WIN32 struct FileNameHandle : public std::string @@ -183,7 +154,7 @@ FileStream::FileStream(FileName fileName, bool openReadOnly) if(d->file == InvalidFileHandle) { # ifdef _WIN32 - debug("Could not open file " + fileNameToString(fileName)); + debug("Could not open file " + fileName.toString()); # else debug("Could not open file " + String(static_cast(d->name))); # endif diff --git a/taglib/toolkit/tiostream.cpp b/taglib/toolkit/tiostream.cpp index 9f6f97ed..0e7ea8cc 100644 --- a/taglib/toolkit/tiostream.cpp +++ b/taglib/toolkit/tiostream.cpp @@ -137,6 +137,27 @@ const std::string &FileName::str() const return d->data->name; } +String FileName::toString() const +{ + if(!m_wname.empty()) { + return String(m_wname); + } + else if(!m_name.empty()) { + const int len = MultiByteToWideChar(CP_ACP, 0, m_name.c_str(), -1, NULL, 0); + if(len == 0) + return String::null; + + std::vector buf(len); + MultiByteToWideChar(CP_ACP, 0, m_name.c_str(), -1, &buf[0], len); + + return String(&buf[0]); + } + else { + return String::null; + } +} + + #endif // _WIN32 //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/toolkit/tiostream.h b/taglib/toolkit/tiostream.h index c3eed4b3..571019a0 100644 --- a/taglib/toolkit/tiostream.h +++ b/taglib/toolkit/tiostream.h @@ -51,7 +51,9 @@ namespace TagLib { const std::wstring &wstr() const; const std::string &str() const; - + + String toString() const; + private: class FileNamePrivate; FileNamePrivate *d; diff --git a/taglib/toolkit/trefcounter.h b/taglib/toolkit/trefcounter.h index 1b7fe4a0..9c927e81 100644 --- a/taglib/toolkit/trefcounter.h +++ b/taglib/toolkit/trefcounter.h @@ -26,6 +26,7 @@ #ifndef TAGLIB_REFCOUNTER_H #define TAGLIB_REFCOUNTER_H +#include "taglib_export.h" #include "taglib.h" #ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class. @@ -34,7 +35,7 @@ */ namespace TagLib { - class RefCounter + class TAGLIB_EXPORT RefCounter { public: RefCounter(); diff --git a/taglib/trueaudio/trueaudiofile.h b/taglib/trueaudio/trueaudiofile.h index de15ce03..d9fa5a4f 100644 --- a/taglib/trueaudio/trueaudiofile.h +++ b/taglib/trueaudio/trueaudiofile.h @@ -79,42 +79,50 @@ namespace TagLib { }; /*! - * Contructs an TrueAudio file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a TrueAudio file from \a file. If \a readProperties is true + * the file's audio properties will also be read. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an TrueAudio file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. The frames will be created using + * Constructs a TrueAudio file from \a file. If \a readProperties is true + * the file's audio properties will also be read. + * + * If this file contains and ID3v2 tag the frames will be created using * \a frameFactory. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an TrueAudio file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * Constructs a TrueAudio file from \a stream. If \a readProperties is true + * the file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an TrueAudio file from \a file. If \a readProperties is true the - * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. The frames will be created using - * \a frameFactory. + * Constructs a TrueAudio file from \a stream. If \a readProperties is true + * the file's audio properties will also be read. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. + * + * If this file contains and ID3v2 tag the frames will be created using + * \a frameFactory. + * + * \note In the current implementation, \a propertiesStyle is ignored. */ File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties = true, diff --git a/taglib/wavpack/wavpackfile.h b/taglib/wavpack/wavpackfile.h index 417bc39c..e10c651d 100644 --- a/taglib/wavpack/wavpackfile.h +++ b/taglib/wavpack/wavpackfile.h @@ -80,15 +80,16 @@ namespace TagLib { }; /*! - * Contructs an WavPack file from \a file. If \a readProperties is true the + * Constructs a WavPack file from \a file. If \a readProperties is true the * file's audio properties will also be read using \a propertiesStyle. If - * false, \a propertiesStyle is ignored. + * false, \a propertiesStyle is ignored */ + File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs an WavPack file from \a file. If \a readProperties is true the + * Constructs an WavPack file from \a file. If \a readProperties is true the * file's audio properties will also be read using \a propertiesStyle. If * false, \a propertiesStyle is ignored. * diff --git a/taglib/xm/xmfile.h b/taglib/xm/xmfile.h index d383d993..a8f8f1e6 100644 --- a/taglib/xm/xmfile.h +++ b/taglib/xm/xmfile.h @@ -36,18 +36,20 @@ namespace TagLib { class TAGLIB_EXPORT File : public Mod::FileBase { public: /*! - * Contructs a Extended Module file from \a file. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs an Extended Module file from \a file. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. */ File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average); /*! - * Contructs a Extended Module file from \a stream. If \a readProperties - * is true the file's audio properties will also be read using - * \a propertiesStyle. If false, \a propertiesStyle is ignored. + * Constructs an Extended Module file from \a stream. + * + * \note In the current implementation, both \a readProperties and + * \a propertiesStyle are ignored. * * \note TagLib will *not* take ownership of the stream, the caller is * responsible for deleting it after the File object. diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 555ae72b..7965f531 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -69,12 +69,17 @@ public: ByteVector s2("f"); CPPUNIT_ASSERT(ByteVectorList::split(s2, " ").size() == 1); - CPPUNIT_ASSERT(ByteVector().size() == 0); CPPUNIT_ASSERT(ByteVector("asdf").clear().size() == 0); CPPUNIT_ASSERT(ByteVector("asdf").clear() == ByteVector()); - } + ByteVector i("blah blah"); + ByteVector j("blah"); + CPPUNIT_ASSERT(i.containsAt(j, 5, 0)); + CPPUNIT_ASSERT(i.containsAt(j, 6, 1)); + CPPUNIT_ASSERT(i.containsAt(j, 6, 1, 3)); + } + void testFind1() { CPPUNIT_ASSERT_EQUAL((size_t)4, ByteVector("....SggO."). find("SggO"));