taglib.h
Go to the documentation of this file.
1 /***************************************************************************
2  copyright : (C) 2002 - 2008 by Scott Wheeler
3  email : wheeler@kde.org
4  ***************************************************************************/
5 
6 /***************************************************************************
7  * This library is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU Lesser General Public License version *
9  * 2.1 as published by the Free Software Foundation. *
10  * *
11  * This library is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the Free Software *
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19  * 02110-1301 USA *
20  * *
21  * Alternatively, this file is available under the Mozilla Public *
22  * License Version 1.1. You may obtain a copy of the License at *
23  * http://www.mozilla.org/MPL/ *
24  ***************************************************************************/
25 
26 #ifndef TAGLIB_H
27 #define TAGLIB_H
28 
29 #define TAGLIB_MAJOR_VERSION 1
30 #define TAGLIB_MINOR_VERSION 8
31 #define TAGLIB_PATCH_VERSION 0
32 
33 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1))
34 #define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")
35 #else
36 #define TAGLIB_IGNORE_MISSING_DESTRUCTOR
37 #endif
38 
39 #if (defined(_MSC_VER) && _MSC_VER >= 1600)
40 #define TAGLIB_CONSTRUCT_BITSET(x) static_cast<unsigned long long>(x)
41 #else
42 #define TAGLIB_CONSTRUCT_BITSET(x) static_cast<unsigned long>(x)
43 #endif
44 
45 #include <string>
46 
47 #ifdef __APPLE__
48 # include <libkern/OSAtomic.h>
49 # define TAGLIB_ATOMIC_MAC
50 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
51 # if !defined(NOMINMAX)
52 # define NOMINMAX
53 # endif
54 # include <windows.h>
55 # define TAGLIB_ATOMIC_WIN
56 #elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
57  && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
58  defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
59  && !defined(__INTEL_COMPILER)
60 # define TAGLIB_ATOMIC_GCC
61 #elif defined(__ia64) && defined(__INTEL_COMPILER)
62 # include <ia64intrin.h>
63 # define TAGLIB_ATOMIC_GCC
64 #endif
65 
67 
76 namespace TagLib {
77 
78  class String;
79 
80  typedef wchar_t wchar;
81  typedef unsigned char uchar;
82  typedef unsigned short ushort;
83  typedef unsigned int uint;
84  typedef unsigned long ulong;
85 
90  typedef std::basic_string<wchar> wstring;
91 
92 #ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
93 
100  class RefCounter
101  {
102  public:
103  RefCounter() : refCount(1) {}
104 
105 #ifdef TAGLIB_ATOMIC_MAC
106  void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); }
107  bool deref() { return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); }
108  int32_t count() { return refCount; }
109  private:
110  volatile int32_t refCount;
111 #elif defined(TAGLIB_ATOMIC_WIN)
112  void ref() { InterlockedIncrement(&refCount); }
113  bool deref() { return ! InterlockedDecrement(&refCount); }
114  long count() { return refCount; }
115  private:
116  volatile long refCount;
117 #elif defined(TAGLIB_ATOMIC_GCC)
118  void ref() { __sync_add_and_fetch(&refCount, 1); }
119  bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); }
120  int count() { return refCount; }
121  private:
122  volatile int refCount;
123 #else
124  void ref() { refCount++; }
125  bool deref() { return ! --refCount; }
126  int count() { return refCount; }
127  private:
128  uint refCount;
129 #endif
130 
131  };
132 
133 #endif // DO_NOT_DOCUMENT
134 
135 }
136 
228 #endif