Merge branch 'master' into merge-master

Conflicts:
	ConfigureChecks.cmake
	config.h.cmake
	taglib/CMakeLists.txt
	taglib/toolkit/taglib.h
	taglib/toolkit/tbytevector.cpp
	taglib/toolkit/tmap.tcc
	taglib/toolkit/tstring.h
This commit is contained in:
Tsuda Kageyu
2013-05-04 01:38:49 +09:00
42 changed files with 415 additions and 441 deletions

View File

@ -81,13 +81,13 @@ if(NOT WIN32 AND NOT BUILD_FRAMEWORK)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
configure_file(config-taglib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
if(WITH_ASF)
set(TAGLIB_WITH_ASF TRUE)
set(TAGLIB_WITH_ASF TRUE)
endif()
if(WITH_MP4)
set(TAGLIB_WITH_MP4 TRUE)
set(TAGLIB_WITH_MP4 TRUE)
endif()
configure_file(taglib/taglib_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h)

View File

@ -7,41 +7,44 @@ include(CheckTypeSize)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
# Determine the CPU byte order.
test_big_endian(TAGLIB_BIG_ENDIAN)
# Check if the size of integral types are suitable.
if(NOT TAGLIB_BIG_ENDIAN)
set(TAGLIB_LITTLE_ENDIAN 1)
check_type_size("short" SIZEOF_SHORT)
if(NOT ${SIZEOF_SHORT} EQUAL 2)
MESSAGE(FATAL_ERROR "TagLib requires that short is 16-bit wide.")
endif()
# Determine the size of numeric types.
check_type_size("short" SIZEOF_SHORT)
check_type_size("int" SIZEOF_INT)
check_type_size("long long" SIZEOF_LONGLONG)
check_type_size("wchar_t" SIZEOF_WCHAR_T)
check_type_size("int" SIZEOF_INT)
if(NOT ${SIZEOF_INT} EQUAL 4)
MESSAGE(FATAL_ERROR "TagLib requires that int is 32-bit wide.")
endif()
check_type_size("long long" SIZEOF_LONGLONG)
if(NOT ${SIZEOF_LONGLONG} EQUAL 8)
MESSAGE(FATAL_ERROR "TagLib requires that long long is 64-bit wide.")
endif()
check_type_size("wchar_t" SIZEOF_WCHAR_T)
if(${SIZEOF_WCHAR_T} LESS 2)
MESSAGE(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.")
endif()
# Determine the CPU byte order.
test_big_endian(IS_BIG_ENDIAN)
if(NOT IS_BIG_ENDIAN)
set(SYSTEM_BYTEORDER 1)
else()
set(SYSTEM_BYTEORDER 2)
endif()
# Determine the size of floating point types.
check_type_size("float" SIZEOF_FLOAT)
check_type_size("double" SIZEOF_DOUBLE)
check_type_size("long double" SIZEOF_LONGDOUBLE)
# Determine whether or not your compiler supports move semantics.
check_cxx_source_compiles("
#ifdef __clang__
# pragma clang diagnostic error \"-Wc++11-extensions\"
#endif
#include <utility>
int func(int &&x) { return x - 1; }
int main() { return func(std::move(1)); }
" SUPPORT_MOVE_SEMANTICS)
# Determine if your compiler supports std::wstring.
check_cxx_source_compiles("
#include <string>
int main() {
std::wstring x(L\"ABC\");
return 0;
}
" HAVE_STD_WSTRING)
# Determine which kind of byte swap functions your compiler supports.
# GCC's __builtin_bswap* should be checked individually
@ -115,75 +118,8 @@ if(NOT HAVE_GCC_BYTESWAP_16 OR NOT HAVE_GCC_BYTESWAP_32 OR NOT HAVE_GCC_BYTESWAP
endif()
endif()
# Determine where shared_ptr<T> is defined regardless of C++11 support.
check_cxx_source_compiles("
#include <memory>
int main() { std::tr1::shared_ptr<int> x; return 0; }
" HAVE_STD_SHARED_PTR)
if(NOT HAVE_STD_SHARED_PTR)
check_cxx_source_compiles("
#include <tr1/memory>
int main() { std::tr1::shared_ptr<int> x; return 0; }
" HAVE_TR1_SHARED_PTR)
if(NOT HAVE_TR1_SHARED_PTR)
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
int main() { boost::shared_ptr<int> x; return 0; }
" HAVE_BOOST_SHARED_PTR)
endif()
endif()
# Determine which kind of atomic operations your compiler supports.
if(NOT HAVE_STD_SHARED_PTR AND NOT HAVE_TR1_SHARED_PTR AND NOT HAVE_BOOST_SHARED_PTR)
check_cxx_source_compiles("
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" HAVE_GCC_ATOMIC)
if(NOT HAVE_GCC_ATOMIC)
check_cxx_source_compiles("
#include <libkern/OSAtomic.h>
int main() {
volatile int32_t x;
OSAtomicIncrement32Barrier(&x);
int32_t y = OSAtomicDecrement32Barrier(&x);
return 0;
}
" HAVE_MAC_ATOMIC)
if(NOT HAVE_MAC_ATOMIC)
check_cxx_source_compiles("
#include <windows.h>
int main() {
volatile LONG x;
InterlockedIncrement(&x);
LONG y = InterlockedDecrement(&x);
return 0;
}
" HAVE_WIN_ATOMIC)
if(NOT HAVE_WIN_ATOMIC)
check_cxx_source_compiles("
#include <ia64intrin.h>
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" HAVE_IA64_ATOMIC)
endif()
endif()
endif()
endif()
# Determine whether your compiler supports some safer version of sprintf.
check_cxx_source_compiles("
#include <cstdio>
int main() { char buf[20]; snprintf(buf, 20, \"%d\", 1); return 0; }
@ -197,6 +133,7 @@ if(NOT HAVE_SNPRINTF)
endif()
# Determine whether your compiler supports codecvt.
check_cxx_source_compiles("
#include <codecvt>
int main() {
@ -205,7 +142,8 @@ check_cxx_source_compiles("
}
" HAVE_STD_CODECVT)
# Check for libz using the cmake supplied FindZLIB.cmake
# Determine whether zlib is installed.
find_package(ZLIB)
if(ZLIB_FOUND)
set(HAVE_ZLIB 1)
@ -213,6 +151,88 @@ else()
set(HAVE_ZLIB 0)
endif()
# Determine whether your compiler supports move semantics.
check_cxx_source_compiles("
#ifdef __clang__
# pragma clang diagnostic error \"-Wc++11-extensions\"
#endif
#include <utility>
int func(int &&x) { return x - 1; }
int main() { return func(std::move(1)); }
" TAGLIB_USE_MOVE_SEMANTICS)
# Determine where shared_ptr<T> is defined regardless of C++11 support.
check_cxx_source_compiles("
#include <memory>
int main() { std::tr1::shared_ptr<int> x; return 0; }
" TAGLIB_USE_STD_SHARED_PTR)
if(NOT TAGLIB_USE_STD_SHARED_PTR)
check_cxx_source_compiles("
#include <tr1/memory>
int main() { std::tr1::shared_ptr<int> x; return 0; }
" TAGLIB_USE_TR1_SHARED_PTR)
if(NOT TAGLIB_USE_TR1_SHARED_PTR)
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
int main() { boost::shared_ptr<int> x; return 0; }
" TAGLIB_USE_BOOST_SHARED_PTR)
endif()
endif()
# Determine which kind of atomic operations your compiler supports.
if(NOT TAGLIB_USE_STD_SHARED_PTR AND NOT TAGLIB_USE_TR1_SHARED_PTR AND NOT TAGLIB_USE_BOOST_SHARED_PTR)
check_cxx_source_compiles("
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" TAGLIB_USE_GCC_ATOMIC)
if(NOT TAGLIB_USE_GCC_ATOMIC)
check_cxx_source_compiles("
#include <libkern/OSAtomic.h>
int main() {
volatile int32_t x;
OSAtomicIncrement32Barrier(&x);
int32_t y = OSAtomicDecrement32Barrier(&x);
return 0;
}
" TAGLIB_USE_MAC_ATOMIC)
if(NOT TAGLIB_USE_MAC_ATOMIC)
check_cxx_source_compiles("
#include <windows.h>
int main() {
volatile LONG x;
InterlockedIncrement(&x);
LONG y = InterlockedDecrement(&x);
return 0;
}
" TAGLIB_USE_WIN_ATOMIC)
if(NOT TAGLIB_USE_WIN_ATOMIC)
check_cxx_source_compiles("
#include <ia64intrin.h>
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" TAGLIB_USE_IA64_ATOMIC)
endif()
endif()
endif()
endif()
# Determine whether CppUnit is installed.
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
find_package(CppUnit)

View File

@ -19,10 +19,7 @@
* USA *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "taglib_config.h"
#include <stdlib.h>
#include <fileref.h>
#include <tfile.h>

View File

@ -1,56 +0,0 @@
/* config-taglib.h. Generated by cmake from config-taglib.h.cmake */
/* Indicates the endianness of your target system */
#cmakedefine TAGLIB_LITTLE_ENDIAN 1
#cmakedefine TAGLIB_BIG_ENDIAN 1
/* Size of integral types */
#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT}
#cmakedefine SIZEOF_INT ${SIZEOF_INT}
#cmakedefine SIZEOF_LONGLONG ${SIZEOF_LONGLONG}
#cmakedefine SIZEOF_WCHAR_T ${SIZEOF_WCHAR_T}
#cmakedefine SIZEOF_FLOAT ${SIZEOF_FLOAT}
#cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE}
#cmakedefine SIZEOF_LONGDOUBLE ${SIZEOF_LONGDOUBLE}
/* Defined if your compiler supports the move semantics */
#cmakedefine SUPPORT_MOVE_SEMANTICS 1
/* Defined if your compiler supports std::wstring */
#cmakedefine HAVE_STD_WSTRING 1
/* Defined if your compiler supports some byte swap functions */
#cmakedefine HAVE_GCC_BYTESWAP_16 1
#cmakedefine HAVE_GCC_BYTESWAP_32 1
#cmakedefine HAVE_GCC_BYTESWAP_64 1
#cmakedefine HAVE_GLIBC_BYTESWAP 1
#cmakedefine HAVE_MSC_BYTESWAP 1
#cmakedefine HAVE_MAC_BYTESWAP 1
#cmakedefine HAVE_OPENBSD_BYTESWAP 1
/* Defined if your compiler supports shared_ptr */
#cmakedefine HAVE_STD_SHARED_PTR 1
#cmakedefine HAVE_TR1_SHARED_PTR 1
#cmakedefine HAVE_BOOST_SHARED_PTR 1
/* Defined if your compiler supports some atomic operations */
#cmakedefine HAVE_GCC_ATOMIC 1
#cmakedefine HAVE_MAC_ATOMIC 1
#cmakedefine HAVE_WIN_ATOMIC 1
#cmakedefine HAVE_IA64_ATOMIC 1
/* Defined if your compiler supports some safer version of sprintf */
#cmakedefine HAVE_SNPRINTF 1
#cmakedefine HAVE_SPRINTF_S 1
/* Defined if your compiler supports codecvt */
#cmakedefine HAVE_STD_CODECVT 1
/* Defined if you have libz */
#cmakedefine HAVE_ZLIB 1
#cmakedefine NO_ITUNES_HACKS 1
#cmakedefine WITH_ASF 1
#cmakedefine WITH_MP4 1
#cmakedefine TESTS_DIR "@TESTS_DIR@"

32
config.h.cmake Normal file
View File

@ -0,0 +1,32 @@
/* config.h. Generated by cmake from config.h.cmake */
/* Indicates the byte order of your target system */
/* 1 if little-endian, 2 if big-endian. */
#cmakedefine SYSTEM_BYTEORDER ${SYSTEM_BYTEORDER}
/* Size of floating point types */
#cmakedefine SIZEOF_FLOAT ${SIZEOF_FLOAT}
#cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE}
#cmakedefine SIZEOF_LONGDOUBLE ${SIZEOF_LONGDOUBLE}
/* Defined if your compiler supports some byte swap functions */
#cmakedefine HAVE_GCC_BYTESWAP_16 1
#cmakedefine HAVE_GCC_BYTESWAP_32 1
#cmakedefine HAVE_GCC_BYTESWAP_64 1
#cmakedefine HAVE_GLIBC_BYTESWAP 1
#cmakedefine HAVE_MSC_BYTESWAP 1
#cmakedefine HAVE_MAC_BYTESWAP 1
#cmakedefine HAVE_OPENBSD_BYTESWAP 1
/* Defined if your compiler supports some safer version of sprintf */
#cmakedefine HAVE_SNPRINTF 1
#cmakedefine HAVE_SPRINTF_S 1
/* Defined if your compiler supports codecvt */
#cmakedefine HAVE_STD_CODECVT 1
/* Defined if you have libz */
#cmakedefine HAVE_ZLIB 1
#cmakedefine TESTS_DIR "@TESTS_DIR@"

View File

@ -125,7 +125,7 @@ ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ASF::Attribute &ASF::Attribute::operator=(ASF::Attribute &&other)
{

View File

@ -115,12 +115,12 @@ namespace TagLib
*/
ASF::Attribute &operator=(const Attribute &other);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves the contents of \a other into this item.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
ASF::Attribute &operator=(Attribute &&other);

View File

@ -56,7 +56,7 @@ ASF::Picture::Picture(const Picture& other)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ASF::Picture::Picture(Picture &&other)
: d(std::move(other.d))
@ -127,7 +127,7 @@ ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ASF::Picture& ASF::Picture::operator=(ASF::Picture &&other)
{

View File

@ -107,12 +107,12 @@ namespace TagLib
*/
Picture(const Picture& other);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Constructs an picture equivalent to \a other.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Picture(Picture &&other);
@ -128,12 +128,12 @@ namespace TagLib
*/
Picture& operator=(const Picture& other);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves the contents of \a other into this picture.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Picture& operator=(Picture &&other);

View File

@ -23,8 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "config.h"
#include "taglib_config.h"
#include <tdebug.h>
#include <tstring.h>
#include "asfproperties.h"

View File

@ -23,8 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "config.h"
#include "taglib_config.h"
#include <tpropertymap.h>
#include "asftag.h"

View File

@ -27,7 +27,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <config.h>
#include "taglib_config.h"
#ifdef _WIN32
# include <Shlwapi.h>
@ -96,7 +96,7 @@ FileRef::FileRef(const FileRef &ref)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
FileRef::FileRef(FileRef &&ref)
: d(std::move(ref.d))
@ -193,7 +193,7 @@ FileRef &FileRef::operator=(const FileRef &ref)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
FileRef &FileRef::operator=(FileRef &&ref)
{

View File

@ -143,12 +143,12 @@ namespace TagLib {
*/
FileRef(const FileRef &ref);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Move \a ref into the FileRef.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
FileRef(FileRef &&ref);
@ -242,12 +242,12 @@ namespace TagLib {
*/
FileRef &operator=(const FileRef &ref);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a ref into this FileRef.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
FileRef &operator=(FileRef &&ref);

View File

@ -56,7 +56,7 @@ MP4::CoverArt &
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
MP4::CoverArt &
MP4::CoverArt::operator=(CoverArt &&item)

View File

@ -54,7 +54,7 @@ namespace TagLib {
CoverArt(const CoverArt &item);
CoverArt &operator=(const CoverArt &item);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
CoverArt &operator=(CoverArt &&item);
#endif

View File

@ -36,7 +36,7 @@ namespace
String format(const char *fmt, ...)
{
va_list args;
va_start(args,fmt);
va_start(args, fmt);
char buf[256];
@ -93,7 +93,7 @@ MP4::Item::Item(const Item &item)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
MP4::Item::Item(Item &&item)
: d(std::move(item.d))
@ -109,7 +109,7 @@ MP4::Item &
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
MP4::Item &
MP4::Item::operator=(Item &&item)

View File

@ -56,12 +56,12 @@ namespace TagLib {
Item();
Item(const Item &item);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
Item(Item &&item);
#endif
Item &operator=(const Item &item);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
Item &operator=(Item &&item);
#endif
~Item();

View File

@ -23,8 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "config.h"
#include "taglib_config.h"
#include <tdebug.h>
#include <tstring.h>
#include "mp4file.h"

View File

@ -23,8 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "config.h"
#include "taglib_config.h"
#include <tdebug.h>
#include <tstring.h>
#include <tpropertymap.h>

View File

@ -24,6 +24,7 @@
***************************************************************************/
#include "config.h"
#include "taglib_config.h"
#if HAVE_ZLIB
#include <zlib.h>

View File

@ -24,7 +24,7 @@
***************************************************************************/
#include "config.h"
#include "taglib_config.h"
#include <tdebug.h>
#include "id3v2framefactory.h"
@ -134,7 +134,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader)
// TagLib doesn't mess with encrypted frames, so just treat them
// as unknown frames.
#if HAVE_ZLIB == 0
#if !defined(HAVE_ZLIB) || HAVE_ZLIB == 0
if(header->compression()) {
debug("Compressed frames are currently not supported.");
return new UnknownFrame(data, header);

View File

@ -28,7 +28,6 @@
#include <tbytevector.h>
#include <tstring.h>
#include <tdebug.h>
#include "mpegheader.h"
using namespace TagLib;
@ -78,7 +77,7 @@ MPEG::Header::Header(const Header &h)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
MPEG::Header::Header(Header &&h)
: d(std::move(h.d))
@ -157,7 +156,7 @@ MPEG::Header &MPEG::Header::operator=(const Header &h)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
MPEG::Header &MPEG::Header::operator=(Header &&h)
{

View File

@ -57,12 +57,12 @@ namespace TagLib {
*/
Header(const Header &h);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a h into this Header.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Header(Header &&h);
@ -166,12 +166,12 @@ namespace TagLib {
*/
Header &operator=(const Header &h);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a h into this Header.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Header &operator=(Header &&h);

View File

@ -1,4 +1,19 @@
/* taglib_config.h. Generated by cmake from taglib_config.h.cmake */
#define TAGLIB_WITH_ASF 1
#define TAGLIB_WITH_MP4 1
/* The variables below indicate the compiler capability. */
/* DO NOT MODIFY them manually. It may break the binary compatibility. */
/* Defined if your compiler supports the move semantics */
#cmakedefine TAGLIB_USE_MOVE_SEMANTICS 1
/* Defined if your compiler supports shared_ptr */
#cmakedefine TAGLIB_USE_STD_SHARED_PTR 1
#cmakedefine TAGLIB_USE_TR1_SHARED_PTR 1
#cmakedefine TAGLIB_USE_BOOST_SHARED_PTR 1
/* Defined if your compiler supports some atomic operations */
#cmakedefine TAGLIB_USE_GCC_ATOMIC 1
#cmakedefine TAGLIB_USE_MAC_ATOMIC 1
#cmakedefine TAGLIB_USE_WIN_ATOMIC 1
#cmakedefine TAGLIB_USE_IA64_ATOMIC 1

View File

@ -40,8 +40,4 @@
#define TAGLIB_EXPORT
#endif
#ifndef TAGLIB_NO_CONFIG
#include "taglib_config.h"
#endif
#endif

View File

@ -26,7 +26,7 @@
#ifndef TAGLIB_H
#define TAGLIB_H
#include "config.h"
#include "taglib_config.h"
#define TAGLIB_MAJOR_VERSION 1
#define TAGLIB_MINOR_VERSION 8
@ -38,8 +38,6 @@
#define TAGLIB_CONSTRUCT_BITSET(x) static_cast<unsigned long>(x)
#endif
#include <string>
#ifdef _WIN32
# if !defined(NOMINMAX)
# define NOMINMAX
@ -53,72 +51,6 @@
# include <sys/types.h>
#endif
// Check the widths of integral types.
#if SIZEOF_SHORT != 2
# error TagLib requires that short is 16-bit wide.
#endif
#if SIZEOF_INT != 4
# error TagLib requires that int is 32-bit wide.
#endif
#if SIZEOF_LONGLONG != 8
# error TagLib requires that long long is 64-bit wide.
#endif
#if SIZEOF_WCHAR_T < 2
# error TagLib requires that wchar_t is sufficient to store a UTF-16 char.
#endif
// Optimized byte swap functions.
#if defined(HAVE_MSC_BYTESWAP)
# include <stdlib.h>
#elif defined(HAVE_GLIBC_BYTESWAP)
# include <byteswap.h>
#elif defined(HAVE_MAC_BYTESWAP)
# include <libkern/OSByteOrder.h>
#elif defined(HAVE_OPENBSD_BYTESWAP)
# include <sys/endian.h>
#endif
#if defined(HAVE_GCC_BYTESWAP_16)
# define TAGLIB_BYTESWAP_16(x) __builtin_bswap16(x)
#elif defined(HAVE_MSC_BYTESWAP)
# define TAGLIB_BYTESWAP_16(x) _byteswap_ushort(x)
#elif defined(HAVE_GLIBC_BYTESWAP)
# define TAGLIB_BYTESWAP_16(x) __bswap_16(x)
#elif defined(HAVE_MAC_BYTESWAP)
# define TAGLIB_BYTESWAP_16(x) OSSwapInt16(x)
#elif defined(HAVE_OPENBSD_BYTESWAP)
# define TAGLIB_BYTESWAP_16(x) swap16(x)
#endif
#if defined(HAVE_GCC_BYTESWAP_32)
# define TAGLIB_BYTESWAP_32(x) __builtin_bswap32(x)
#elif defined(HAVE_MSC_BYTESWAP)
# define TAGLIB_BYTESWAP_32(x) _byteswap_ulong(x)
#elif defined(HAVE_GLIBC_BYTESWAP)
# define TAGLIB_BYTESWAP_32(x) __bswap_32(x)
#elif defined(HAVE_MAC_BYTESWAP)
# define TAGLIB_BYTESWAP_32(x) OSSwapInt32(x)
#elif defined(HAVE_OPENBSD_BYTESWAP)
# define TAGLIB_BYTESWAP_32(x) swap32(x)
#endif
#if defined(HAVE_GCC_BYTESWAP_64)
# define TAGLIB_BYTESWAP_64(x) __builtin_bswap64(x)
#elif defined(HAVE_MSC_BYTESWAP)
# define TAGLIB_BYTESWAP_64(x) _byteswap_uint64(x)
#elif defined(HAVE_GLIBC_BYTESWAP)
# define TAGLIB_BYTESWAP_64(x) __bswap_64(x)
#elif defined(HAVE_MAC_BYTESWAP)
# define TAGLIB_BYTESWAP_64(x) OSSwapInt64(x)
#elif defined(HAVE_OPENBSD_BYTESWAP)
# define TAGLIB_BYTESWAP_64(x) swap64(x)
#endif
//! A namespace for all TagLib related classes and functions
/*!
@ -143,22 +75,12 @@ namespace TagLib {
typedef unsigned long ulong;
// Offset or length type for I/O streams.
// In Win32, always 64bit. Otherwise, equivalent to off_t.
// In Win32, always signed 64-bit. Otherwise, equivalent to off_t.
#ifdef _WIN32
typedef LONGLONG offset_t;
#else
typedef off_t offset_t;
#endif
/*!
* Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3)
* so I'm providing something here that should be constant.
*/
#ifdef HAVE_STD_WSTRING
typedef std::wstring wstring;
#else
typedef std::basic_string<wchar> wstring;
#endif
}
/*!

View File

@ -23,14 +23,26 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "config.h"
#include <iostream>
#include <limits>
#include <cmath>
#include <cstdio>
#include <cstring>
#if defined(HAVE_MSC_BYTESWAP)
# include <stdlib.h>
#elif defined(HAVE_GLIBC_BYTESWAP)
# include <byteswap.h>
#elif defined(HAVE_MAC_BYTESWAP)
# include <libkern/OSByteOrder.h>
#elif defined(HAVE_OPENBSD_BYTESWAP)
# include <sys/endian.h>
#endif
#include <tstring.h>
#include <tdebug.h>
#include "tbytevector.h"
// This is a bit ugly to keep writing over and over again.
@ -187,9 +199,25 @@ inline T byteSwap(T x)
template <>
inline ushort byteSwap<ushort>(ushort x)
{
#ifdef TAGLIB_BYTESWAP_16
#if defined(HAVE_GCC_BYTESWAP_16)
return TAGLIB_BYTESWAP_16(x);
return __builtin_bswap16(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_ushort(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_16(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt16(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap16(x);
#else
@ -201,9 +229,25 @@ inline ushort byteSwap<ushort>(ushort x)
template <>
inline uint byteSwap<uint>(uint x)
{
#ifdef TAGLIB_BYTESWAP_32
#if defined(HAVE_GCC_BYTESWAP_32)
return TAGLIB_BYTESWAP_32(x);
return __builtin_bswap32(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_ulong(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_32(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt32(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap32(x);
#else
@ -218,9 +262,25 @@ inline uint byteSwap<uint>(uint x)
template <>
inline ulonglong byteSwap<ulonglong>(ulonglong x)
{
#ifdef TAGLIB_BYTESWAP_64
#if defined(HAVE_GCC_BYTESWAP_64)
return TAGLIB_BYTESWAP_64(x);
return __builtin_bswap64(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_uint64(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_64(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt64(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap64(x);
#else
@ -246,7 +306,7 @@ namespace {
template <typename T, size_t LENGTH, Endianness ENDIAN>
inline T toNumber(const ByteVector &v, size_t offset)
{
#ifdef TAGLIB_LITTLE_ENDIAN
#if SYSTEM_BYTEORDER == 1
static const bool swap = (ENDIAN == BigEndian);
#else
static const bool swap = (ENDIAN == LittleEndian);
@ -281,7 +341,7 @@ inline T toNumber(const ByteVector &v, size_t offset)
template <typename T, Endianness ENDIAN>
inline ByteVector fromNumber(T value)
{
#ifdef TAGLIB_LITTLE_ENDIAN
#if SYSTEM_BYTEORDER == 1
static const bool swap = (ENDIAN == BigEndian);
#else
static const bool swap = (ENDIAN == LittleEndian);
@ -293,23 +353,6 @@ inline ByteVector fromNumber(T value)
return ByteVector(reinterpret_cast<const char *>(&value), sizeof(T));
}
template <class T, bool IS_LITTLE_ENDIAN>
inline void appendNumber(ByteVector &v, T value)
{
#ifdef TAGLIB_LITTLE_ENDIAN
static const bool swap = !IS_LITTLE_ENDIAN;
#else
static const bool swap = IS_LITTLE_ENDIAN;
#endif
if(swap)
value = byteSwap<T>(value);
const size_t offset = v.size();
v.resize(offset + sizeof(T));
::memcpy(v.data() + offset, reinterpret_cast<const char *>(&value), sizeof(T));
}
class ByteVector::ByteVectorPrivate
{
public:
@ -443,7 +486,7 @@ ByteVector::ByteVector(const ByteVector &v, size_t offset, size_t length)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ByteVector::ByteVector(ByteVector &&v)
: d(std::move(v.d))
@ -809,7 +852,7 @@ float ByteVector::toFloat32BE(size_t offset) const
uint tmp;
::memcpy(&tmp, data() + offset, 4);
# ifdef TAGLIB_LITTLE_ENDIAN
# if SYSTEM_BYTEORDER == 1
tmp = byteSwap<uint>(tmp);
# endif
@ -867,7 +910,7 @@ double ByteVector::toFloat64BE(size_t offset) const
ulonglong tmp;
::memcpy(&tmp, data() + offset, 8);
# ifdef TAGLIB_LITTLE_ENDIAN
# if SYSTEM_BYTEORDER == 1
tmp = byteSwap<ulonglong>(tmp);
# endif
@ -1022,7 +1065,7 @@ ByteVector &ByteVector::operator=(const ByteVector &v)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ByteVector &ByteVector::operator=(ByteVector &&v)
{

View File

@ -68,12 +68,12 @@ namespace TagLib {
*/
ByteVector(const ByteVector &v);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Constructs a byte vector equivalent to \a v.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
ByteVector(ByteVector &&v);
@ -502,12 +502,12 @@ namespace TagLib {
*/
ByteVector &operator=(const ByteVector &v);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a v into this ByteVector.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
ByteVector &operator=(ByteVector &&v);

View File

@ -73,7 +73,7 @@ ByteVectorList::ByteVectorList(const ByteVectorList &l) : List<ByteVector>(l)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ByteVectorList::ByteVectorList(ByteVectorList &&l) : List<ByteVector>(l)
{
@ -87,7 +87,7 @@ ByteVectorList &ByteVectorList::operator=(const ByteVectorList &l)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ByteVectorList &ByteVectorList::operator=(ByteVectorList &&l)
{

View File

@ -54,12 +54,12 @@ namespace TagLib {
*/
ByteVectorList(const ByteVectorList &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a l into this ByteVectorList.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
ByteVectorList(ByteVectorList &&l);
@ -72,12 +72,12 @@ namespace TagLib {
*/
ByteVectorList &operator=(const ByteVectorList &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a l into this ByteVectorList.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
ByteVectorList &operator=(ByteVectorList &&l);

View File

@ -98,7 +98,7 @@ namespace
if(len == 0)
return String::null;
wstring wstr(len, L'\0');
std::wstring wstr(len, L'\0');
MultiByteToWideChar(CP_ACP, 0, name.str().c_str(), -1, &wstr[0], len);
return String(wstr);

View File

@ -70,12 +70,12 @@ namespace TagLib {
*/
List(const List<T> &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a l into this List.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
List(List<T> &&l);
@ -135,13 +135,13 @@ namespace TagLib {
*/
List<T> &append(const List<T> &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Appends \a item to the end of the list and returns a reference to the
* list.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
List<T> &append(T &&item);
@ -149,7 +149,7 @@ namespace TagLib {
* Appends all of the values in \a l to the end of the list and returns a
* reference to the list.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
List<T> &append(List<T> &&l);
@ -167,13 +167,13 @@ namespace TagLib {
*/
List<T> &prepend(const List<T> &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Prepends \a item to the beginning list and returns a reference to the
* list.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
List<T> &prepend(T &&item);
@ -181,7 +181,7 @@ namespace TagLib {
* Prepends all of the items in \a l to the beginning list and returns a
* reference to the list.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
List<T> &prepend(List<T> &&l);
@ -272,12 +272,12 @@ namespace TagLib {
*/
List<T> &operator=(const List<T> &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a l into this List.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
List<T> &operator=(List<T> &&l);

View File

@ -55,7 +55,7 @@ public:
ListPrivate() : ListPrivateBase() {}
ListPrivate(const std::list<TP> &l) : ListPrivateBase(), list(l) {}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ListPrivate(std::list<TP> &&l) : ListPrivateBase(), list(l) {}
@ -77,7 +77,7 @@ public:
ListPrivate() : ListPrivateBase() {}
ListPrivate(const std::list<TP *> &l) : ListPrivateBase(), list(l) {}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
ListPrivate(std::list<TP *> &&l) : ListPrivateBase(), list(l) {}
@ -121,7 +121,7 @@ List<T>::List(const List<T> &l)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class T>
List<T>::List(List<T> &&l)
@ -198,7 +198,7 @@ List<T> &List<T>::append(const List<T> &l)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class T>
List<T> &List<T>::append(T &&item)
@ -237,7 +237,7 @@ List<T> &List<T>::prepend(const List<T> &l)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class T>
List<T> &List<T>::prepend(T &&item)
@ -365,7 +365,7 @@ List<T> &List<T>::operator=(const List<T> &l)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class T>
List<T> &List<T>::operator=(List<T> &&l)

View File

@ -73,12 +73,12 @@ namespace TagLib {
*/
Map(const Map<Key, T> &m);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a m into this Map.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Map(Map<Key, T> &&m);
@ -119,13 +119,13 @@ namespace TagLib {
*/
Map<Key, T> &insert(const Key &key, const T &value);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Inserts \a value under \a key in the map. If a value for \a key already
* exists it will be overwritten.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Map<Key, T> &insert(const Key &key, T &&value);
@ -197,12 +197,12 @@ namespace TagLib {
*/
Map<Key, T> &operator=(const Map<Key, T> &m);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a m into this Map.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
Map<Key, T> &operator=(Map<Key, T> &&m);

View File

@ -23,8 +23,6 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <config.h>
namespace TagLib {
////////////////////////////////////////////////////////////////////////////////
@ -42,7 +40,7 @@ public:
MapPrivate(const std::map<class KeyP, class TP> &m) : RefCounter(), map(m) {}
# ifdef SUPPORT_MOVE_SEMANTICS
# ifdef TAGLIB_USE_MOVE_SEMANTICS
MapPrivate(std::map<class KeyP, class TP> &&m) : RefCounter(), map(m) {}
@ -58,7 +56,7 @@ public:
MapPrivate(const std::map<KeyP, TP>& m) : map(m) {}
# ifdef SUPPORT_MOVE_SEMANTICS
# ifdef TAGLIB_USE_MOVE_SEMANTICS
MapPrivate(std::map<KeyP, TP> &&m) : map(m) {}
@ -85,7 +83,7 @@ Map<Key, T>::Map(const Map<Key, T> &m)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class Key, class T>
TagLib::Map<Key, T>::Map(Map<Key, T> &&m)
@ -134,7 +132,7 @@ Map<Key, T> &Map<Key, T>::insert(const Key &key, const T &value)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class Key, class T>
Map<Key, T> &Map<Key, T>::insert(const Key &key, T &&value)
@ -223,7 +221,7 @@ Map<Key, T> &Map<Key, T>::operator=(const Map<Key, T> &m)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
template <class Key, class T>
Map<Key, T> &Map<Key, T>::operator=(Map<Key, T> &&m)

View File

@ -26,21 +26,21 @@
#ifndef TAGLIB_REFCOUNTPTR_H
#define TAGLIB_REFCOUNTPTR_H
#include "config.h"
#include "taglib_config.h"
#if defined(HAVE_STD_SHARED_PTR)
#if defined(TAGLIB_USE_STD_SHARED_PTR)
# include <memory>
#elif defined(HAVE_TR1_SHARED_PTR)
#elif defined(TAGLIB_USE_TR1_SHARED_PTR)
# include <tr1/memory>
#elif defined(HAVE_BOOST_SHARED_PTR)
#elif defined(TAGLIB_USE_BOOST_SHARED_PTR)
# include <boost/shared_ptr.hpp>
#else
# include <algorithm>
# if defined(HAVE_GCC_ATOMIC)
# if defined(TAGLIB_USE_GCC_ATOMIC)
# define TAGLIB_ATOMIC_INT int
# define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
# define TAGLIB_ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
# elif defined(HAVE_WIN_ATOMIC)
# elif defined(TAGLIB_USE_WIN_ATOMIC)
# if !defined(NOMINMAX)
# define NOMINMAX
# endif
@ -48,12 +48,12 @@
# define TAGLIB_ATOMIC_INT long
# define TAGLIB_ATOMIC_INC(x) InterlockedIncrement(&x)
# define TAGLIB_ATOMIC_DEC(x) InterlockedDecrement(&x)
# elif defined(HAVE_MAC_ATOMIC)
# elif defined(TAGLIB_USE_MAC_ATOMIC)
# include <libkern/OSAtomic.h>
# define TAGLIB_ATOMIC_INT int32_t
# define TAGLIB_ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x)
# define TAGLIB_ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x)
# elif defined(HAVE_IA64_ATOMIC)
# elif defined(TAGLIB_USE_IA64_ATOMIC)
# include <ia64intrin.h>
# define TAGLIB_ATOMIC_INT int
# define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
@ -75,15 +75,15 @@
namespace TagLib {
#if defined(HAVE_STD_SHARED_PTR) || defined(HAVE_TR1_SHARED_PTR)
#if defined(TAGLIB_USE_STD_SHARED_PTR) || defined(TAGLIB_USE_TR1_SHARED_PTR)
#define TAGLIB_SHARED_PTR std::tr1::shared_ptr
#elif defined(HAVE_BOOST_SHARED_PTR)
#elif defined(TAGLIB_USE_BOOST_SHARED_PTR)
#define TAGLIB_SHARED_PTR boost::shared_ptr
#else // HAVE_*_SHARED_PTR
#else // TAGLIB_USE_*_SHARED_PTR
// Self-implements RefCountPtr<T> if shared_ptr<T> is not available.
// I STRONGLY RECOMMEND using standard shared_ptr<T> rather than this class.
@ -295,7 +295,7 @@ namespace TagLib {
a.swap(b);
}
#endif // HAVE_*_SHARED_PTR
#endif // TAGLIB_USE_*_SHARED_PTR
}
#endif // DO_NOT_DOCUMENT

View File

@ -25,16 +25,23 @@
// This class assumes that std::basic_string<T> has a contiguous and null-terminated buffer.
#include <cstring>
#include "config.h"
#include "tstring.h"
#include "tdebug.h"
#include "tstringlist.h"
#include <string.h>
// x86 CPUs are alignment-tolerant or allow pointer casts from smaller types to larger types.
#if defined(__i386__) || defined(_M_IX86) || defined(__amd64) || defined(__amd64__) \
|| defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)
# define TAGLIB_ALIGNMENT_TOLERANT 1
#if defined(HAVE_MSC_BYTESWAP)
# include <stdlib.h>
#elif defined(HAVE_GLIBC_BYTESWAP)
# include <byteswap.h>
#elif defined(HAVE_MAC_BYTESWAP)
# include <libkern/OSByteOrder.h>
#elif defined(HAVE_OPENBSD_BYTESWAP)
# include <sys/endian.h>
#endif
#ifdef HAVE_STD_CODECVT
@ -47,13 +54,29 @@ namespace
{
inline TagLib::ushort byteSwap(TagLib::ushort x)
{
#ifdef TAGLIB_BYTESWAP_16
#if defined(HAVE_GCC_BYTESWAP_16)
return TAGLIB_BYTESWAP_16(x);
return __builtin_bswap16(x);
#elif defined(HAVE_MSC_BYTESWAP)
return _byteswap_ushort(x);
#elif defined(HAVE_GLIBC_BYTESWAP)
return __bswap_16(x);
#elif defined(HAVE_MAC_BYTESWAP)
return OSSwapInt16(x);
#elif defined(HAVE_OPENBSD_BYTESWAP)
return swap16(x);
#else
return((x >> 8) & 0xff) | ((x & 0xff) << 8);
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
#endif
}
@ -165,14 +188,14 @@ public:
{
}
StringPrivate(const wstring &s)
StringPrivate(const std::wstring &s)
: data(s)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
StringPrivate(wstring &&s)
StringPrivate(std::wstring &&s)
: data(s)
{
}
@ -187,7 +210,7 @@ public:
/*!
* Stores string in UTF-16. The byte order depends on the CPU endian.
*/
TagLib::wstring data;
std::wstring data;
/*!
* This is only used to hold the the most recent value of toCString().
@ -198,7 +221,7 @@ public:
const String String::null;
// Actual value is -1.
const size_t String::npos = wstring::npos;
const size_t String::npos = std::wstring::npos;
////////////////////////////////////////////////////////////////////////////////
@ -212,7 +235,7 @@ String::String(const String &s)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
String::String(String &&s)
: d(std::move(s.d))
@ -233,13 +256,13 @@ String::String(const std::string &s, Type t)
}
}
String::String(const wstring &s, Type t)
String::String(const std::wstring &s, Type t)
: d(new StringPrivate())
{
if(t == UTF16 || t == UTF16BE || t == UTF16LE)
copyFromUTF16(s.c_str(), s.length(), t);
else {
debug("String::String() -- A TagLib::wstring should not contain Latin1 or UTF-8.");
debug("String::String() -- A TagLib::std::wstring should not contain Latin1 or UTF-8.");
}
}
@ -311,7 +334,7 @@ std::string String::to8Bit(bool unicode) const
s.resize(d->data.size());
std::string::iterator targetIt = s.begin();
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
*targetIt = static_cast<char>(*it);
++targetIt;
}
@ -326,7 +349,7 @@ std::string String::to8Bit(bool unicode) const
return s;
}
const TagLib::wstring &String::toWString() const
const std::wstring &String::toWString() const
{
return d->data;
}
@ -415,7 +438,7 @@ String String::upper() const
s.d->data.resize(d->data.size());
wchar_t *p = &s.d->data[0];
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); ++it) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); ++it) {
if(*it >= 'a' && *it <= 'z')
*p++ = *it + shift;
else
@ -454,7 +477,7 @@ ByteVector String::data(Type t) const
ByteVector v(size(), 0);
char *p = v.data();
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
*p++ = static_cast<char>(*it);
return v;
@ -479,7 +502,7 @@ ByteVector String::data(Type t) const
*p++ = '\xff';
*p++ = '\xfe';
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
*p++ = static_cast<char>(*it & 0xff);
*p++ = static_cast<char>(*it >> 8);
}
@ -491,7 +514,7 @@ ByteVector String::data(Type t) const
ByteVector v(size() * 2, 0);
char *p = v.data();
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
*p++ = static_cast<char>(*it >> 8);
*p++ = static_cast<char>(*it & 0xff);
}
@ -503,7 +526,7 @@ ByteVector String::data(Type t) const
ByteVector v(size() * 2, 0);
char *p = v.data();
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
*p++ = static_cast<char>(*it & 0xff);
*p++ = static_cast<char>(*it >> 8);
}
@ -541,8 +564,8 @@ int String::toInt(bool *ok) const
String String::stripWhiteSpace() const
{
wstring::const_iterator begin = d->data.begin();
wstring::const_iterator end = d->data.end();
std::wstring::const_iterator begin = d->data.begin();
std::wstring::const_iterator end = d->data.end();
while(begin != end &&
(*begin == '\t' || *begin == '\n' || *begin == '\f' ||
@ -562,12 +585,12 @@ String String::stripWhiteSpace() const
} while(*end == '\t' || *end == '\n' ||
*end == '\f' || *end == '\r' || *end == ' ');
return String(wstring(begin, end + 1));
return String(std::wstring(begin, end + 1));
}
bool String::isLatin1() const
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
if(*it >= 256)
return false;
}
@ -576,7 +599,7 @@ bool String::isLatin1() const
bool String::isAscii() const
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
if(*it >= 128)
return false;
}
@ -630,7 +653,7 @@ bool String::operator==(const String &s) const
bool String::operator==(const char *s) const
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
if(*it != static_cast<uchar>(*s))
return false;
@ -697,7 +720,7 @@ String &String::operator=(const String &s)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
String &String::operator=(String &&s)
{
@ -715,15 +738,15 @@ String &String::operator=(const std::string &s)
return *this;
}
String &String::operator=(const wstring &s)
String &String::operator=(const std::wstring &s)
{
d.reset(new StringPrivate(s));
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
String &String::operator=(wstring &&s)
String &String::operator=(std::wstring &&s)
{
d.reset(new StringPrivate(s));
return *this;
@ -835,12 +858,6 @@ void String::copyFromUTF16(const wchar_t *s, size_t length, Type t)
void String::copyFromUTF16(const char *s, size_t length, Type t)
{
#if SIZEOF_WCHAR_T == 2 && defined(TAGLIB_ALIGNMENT_TOLERANT)
copyFromUTF16(reinterpret_cast<const wchar_t*>(s), length / 2, t);
#else
bool swap;
if(t == UTF16) {
if(length < 2) {
@ -872,11 +889,9 @@ void String::copyFromUTF16(const char *s, size_t length, Type t)
d->data[i] = swap ? combine(*s, *(s + 1)) : combine(*(s + 1), *s);
s += 2;
}
#endif
}
#ifdef TAGLIB_LITTLE_ENDIAN
#if SYSTEM_BYTEORDER == 1
const String::Type String::WCharByteOrder = String::UTF16LE;

View File

@ -58,9 +58,9 @@ namespace TagLib {
/*!
* This is an implicitly shared \e wide string. For storage it uses
* TagLib::wstring, but as this is an <i>implementation detail</i> this of
* course could change. Strings are stored internally as UTF-16BE. (Without
* the BOM (Byte Order Mark)
* TagLib::std::wstring, but as this is an <i>implementation detail</i> this of
* course could change. Strings are stored internally as UTF-16(without BOM/
* CPU byte order)
*
* The use of implicit sharing means that copying a string is cheap, the only
* \e cost comes into play when the copy is modified. Prior to that the string
@ -119,12 +119,12 @@ namespace TagLib {
*/
String(const String &s);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Constructs a String equivalent to \a s.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
String(String &&s);
@ -141,7 +141,7 @@ namespace TagLib {
/*!
* Makes a deep copy of the data in \a s.
*/
String(const wstring &s, Type t = WCharByteOrder);
String(const std::wstring &s, Type t = WCharByteOrder);
/*!
* Makes a deep copy of the data in \a s.
@ -185,15 +185,15 @@ namespace TagLib {
/*!
* If \a unicode if false (the default) this will return a \e Latin1 encoded
* std::string. If it is true the returned std::wstring will be UTF-8
* std::string. If it is true the returned std::std::wstring will be UTF-8
* encoded.
*/
std::string to8Bit(bool unicode = false) const;
/*!
* Returns a wstring version of the TagLib string as a wide string.
* Returns a std::wstring version of the TagLib string as a wide string.
*/
const TagLib::wstring &toWString() const;
const std::wstring &toWString() const;
/*!
* Creates and returns a C-String based on the data. This string is still
@ -403,12 +403,12 @@ namespace TagLib {
*/
String &operator=(const String &s);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a s into this String.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
String &operator=(String &&s);
@ -422,16 +422,16 @@ namespace TagLib {
/*!
* Performs a deep copy of the data in \a s.
*/
String &operator=(const wstring &s);
String &operator=(const std::wstring &s);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a s into this String.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
String &operator=(wstring &&s);
String &operator=(std::wstring &&s);
#endif

View File

@ -61,7 +61,7 @@ StringList::StringList(const StringList &l) : List<String>(l)
{
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
StringList::StringList(StringList &&l) : List<String>(l)
{
@ -111,7 +111,7 @@ StringList &StringList::append(const StringList &l)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
StringList &StringList::append(String &&s)
{
@ -133,7 +133,7 @@ StringList &StringList::operator=(const StringList &l)
return *this;
}
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
StringList &StringList::operator=(StringList &&l)
{

View File

@ -58,12 +58,12 @@ namespace TagLib {
*/
StringList(const StringList &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Constructs a StringList equivalent to \a l.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
StringList(StringList &&l);
@ -99,13 +99,13 @@ namespace TagLib {
*/
StringList &append(const StringList &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Appends \a s to the end of the list and returns a reference to the
* list.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
StringList &append(String &&s);
@ -113,7 +113,7 @@ namespace TagLib {
* Appends all of the values in \a l to the end of the list and returns a
* reference to the list.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
StringList &append(StringList &&l);
@ -126,12 +126,12 @@ namespace TagLib {
*/
StringList &operator=(const StringList &l);
#ifdef SUPPORT_MOVE_SEMANTICS
#ifdef TAGLIB_USE_MOVE_SEMANTICS
/*!
* Moves \a l into this StringList.
*
* \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined.
* \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined.
*/
StringList &operator=(StringList &&l);

View File

@ -6,9 +6,6 @@
#include <vorbisfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
using namespace std;
using namespace TagLib;

View File

@ -1,6 +1,5 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "config.h"
#ifdef _WIN32
#include <windows.h>
#else