TagLib  2.0.2
fileref.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_FILEREF_H
27 #define TAGLIB_FILEREF_H
28 
29 #include "tfile.h"
30 #include "tstringlist.h"
31 
32 #include "taglib_export.h"
33 #include "audioproperties.h"
34 
35 namespace TagLib {
36 
37  class Tag;
38 
40 
60  {
61  public:
62 
64 
71  {
72  public:
77  virtual ~FileTypeResolver() = 0;
78 
79  FileTypeResolver(const FileTypeResolver &) = delete;
80  FileTypeResolver &operator=(const FileTypeResolver &) = delete;
81 
91  virtual File *createFile(FileName fileName,
92  bool readAudioProperties = true,
94  audioPropertiesStyle = AudioProperties::Average) const = 0;
95  private:
96  class FileTypeResolverPrivate;
98  std::unique_ptr<FileTypeResolverPrivate> d;
99  };
100 
102 
140  {
141  public:
146  virtual ~StreamTypeResolver() override = 0; // virtual is needed by SWIG
147 
148  StreamTypeResolver(const StreamTypeResolver &) = delete;
149  StreamTypeResolver &operator=(const StreamTypeResolver &) = delete;
150 
162  virtual File *createFileFromStream(IOStream *stream,
163  bool readAudioProperties = true,
165  audioPropertiesStyle = AudioProperties::Average) const = 0;
166  private:
167  class StreamTypeResolverPrivate;
169  std::unique_ptr<StreamTypeResolverPrivate> d;
170  };
171 
175  FileRef();
176 
186  explicit FileRef(FileName fileName,
187  bool readAudioProperties = true,
189  audioPropertiesStyle = AudioProperties::Average);
190 
203  explicit FileRef(IOStream* stream,
204  bool readAudioProperties = true,
206  audioPropertiesStyle = AudioProperties::Average);
207 
212  explicit FileRef(File *file);
213 
217  FileRef(const FileRef &ref);
218 
222  ~FileRef();
223 
235  Tag *tag() const;
236 
248  PropertyMap properties() const;
249 
255  void removeUnsupportedProperties(const StringList& properties);
256 
268  PropertyMap setProperties(const PropertyMap &properties);
269 
279  StringList complexPropertyKeys() const;
280 
306  List<VariantMap> complexProperties(const String &key) const;
307 
313  bool setComplexProperties(const String &key, const List<VariantMap> &value);
314 
319  AudioProperties *audioProperties() const;
320 
336  File *file() const;
337 
341  bool save();
342 
355  static const FileTypeResolver *addFileTypeResolver(const FileTypeResolver *resolver);
356 
360  static void clearFileTypeResolvers();
361 
378  static StringList defaultFileExtensions();
379 
383  bool isNull() const;
384 
388  FileRef &operator=(const FileRef &ref);
389 
393  void swap(FileRef &ref) noexcept;
394 
398  bool operator==(const FileRef &ref) const;
399 
404  bool operator!=(const FileRef &ref) const;
405 
406  private:
407  void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
408  void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
409 
410  class FileRefPrivate;
412  std::shared_ptr<FileRefPrivate> d;
413  };
414 
415 } // namespace TagLib
416 
417 #endif
A generic, implicitly shared list.
Definition: tlist.h:53
A map for format-independent <key,values> tag representations.
Definition: tpropertymap.h:122
An abstract class that provides operations on a sequence of bytes.
Definition: tiostream.h:64
A simple, generic interface to common audio metadata fields.
Definition: tag.h:48
A class for pluggable file type resolution.
Definition: fileref.h:70
A file class with some useful methods for tag manipulation.
Definition: tfile.h:50
A class for pluggable stream type resolution.
Definition: fileref.h:139
A wide string class suitable for unicode.
Definition: tstring.h:82
This class provides a simple abstraction for creating and handling files.
Definition: fileref.h:59
Read more of the file and make better values guesses.
Definition: audioproperties.h:60
const char * FileName
Definition: tiostream.h:59
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition: taglib_export.h:55
A list of strings.
Definition: tstringlist.h:43
ReadStyle
Definition: audioproperties.h:56
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
A simple, abstract interface to common audio properties.
Definition: audioproperties.h:45
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41