PageRenderTime 130ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/libtunepimp-0.5.3/plugins/tta/ttafile.h

#
C Header | 178 lines | 44 code | 27 blank | 107 comment | 0 complexity | 64a1f03fc571a5fe87cf597a71a9534a MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, GPL-2.0, LGPL-2.0
  1. /***************************************************************************
  2. copyright : (C) 2006 by LukᚠLalinský
  3. email : lalinsky@gmail.com
  4. copyright : (C) 2004 by Allan Sandfeld Jensen
  5. email : kde@carewolf.org
  6. (original MPC implementation)
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * This library is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU Lesser General Public License version *
  11. * 2.1 as published by the Free Software Foundation. *
  12. * *
  13. * This library is distributed in the hope that it will be useful, but *
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  16. * Lesser General Public License for more details. *
  17. * *
  18. * You should have received a copy of the GNU Lesser General Public *
  19. * License along with this library; if not, write to the Free Software *
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
  21. * USA *
  22. ***************************************************************************/
  23. #ifndef TAGLIB_TTAFILE_H
  24. #define TAGLIB_TTAFILE_H
  25. #include "tfile.h"
  26. #include "ttaproperties.h"
  27. namespace TagLib {
  28. class Tag;
  29. namespace ID3v2 { class Tag; class FrameFactory; }
  30. namespace ID3v1 { class Tag; }
  31. //! An implementation of TTA metadata
  32. /*!
  33. * This is implementation of TTA metadata.
  34. *
  35. * This supports ID3v1 and ID3v2 tags as well as reading stream
  36. * properties from the file.
  37. */
  38. namespace TTA {
  39. //! An implementation of TagLib::File with TTA specific methods
  40. /*!
  41. * This implements and provides an interface for TTA files to the
  42. * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
  43. * the abstract TagLib::File API as well as providing some additional
  44. * information specific to TTA files.
  45. */
  46. class File : public TagLib::File
  47. {
  48. public:
  49. /*!
  50. * This set of flags is used for various operations and is suitable for
  51. * being OR-ed together.
  52. */
  53. enum TagTypes {
  54. //! Empty set. Matches no tag types.
  55. NoTags = 0x0000,
  56. //! Matches ID3v1 tags.
  57. ID3v1 = 0x0001,
  58. //! Matches ID3v2 tags.
  59. ID3v2 = 0x0002,
  60. //! Matches all tag types.
  61. AllTags = 0xffff
  62. };
  63. /*!
  64. * Contructs an MPC file from \a file. If \a readProperties is true the
  65. * file's audio properties will also be read using \a propertiesStyle. If
  66. * false, \a propertiesStyle is ignored.
  67. */
  68. File(const char *file, bool readProperties = true,
  69. Properties::ReadStyle propertiesStyle = Properties::Average);
  70. /*!
  71. * Contructs an MPC file from \a file. If \a readProperties is true the
  72. * file's audio properties will also be read using \a propertiesStyle. If
  73. * false, \a propertiesStyle is ignored. The frames will be created using
  74. * \a frameFactory.
  75. */
  76. File(const char *file, ID3v2::FrameFactory *frameFactory,
  77. bool readProperties = true,
  78. Properties::ReadStyle propertiesStyle = Properties::Average);
  79. /*!
  80. * Destroys this instance of the File.
  81. */
  82. virtual ~File();
  83. /*!
  84. * Returns the Tag for this file. This will be an APE tag, an ID3v1 tag
  85. * or a combination of the two.
  86. */
  87. virtual TagLib::Tag *tag() const;
  88. /*!
  89. * Returns the MPC::Properties for this file. If no audio properties
  90. * were read then this will return a null pointer.
  91. */
  92. virtual Properties *audioProperties() const;
  93. /*!
  94. * Set the ID3v2::FrameFactory to something other than the default.
  95. *
  96. * \see ID3v2FrameFactory
  97. */
  98. void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
  99. /*!
  100. * Saves the file.
  101. */
  102. virtual bool save();
  103. /*!
  104. * Returns a pointer to the ID3v2 tag of the file.
  105. *
  106. * If \a create is false (the default) this will return a null pointer
  107. * if there is no valid ID3v2 tag. If \a create is true it will create
  108. * an ID3v1 tag if one does not exist. If there is already an APE tag, the
  109. * new ID3v1 tag will be placed after it.
  110. *
  111. * \note The Tag <b>is still</b> owned by the TTA::File and should not be
  112. * deleted by the user. It will be deleted when the file (object) is
  113. * destroyed.
  114. */
  115. ID3v1::Tag *ID3v1Tag(bool create = false);
  116. /*!
  117. * Returns a pointer to the ID3v1 tag of the file.
  118. *
  119. * If \a create is false (the default) this will return a null pointer
  120. * if there is no valid ID3v1 tag. If \a create is true it will create
  121. * an ID3v1 tag if one does not exist. If there is already an APE tag, the
  122. * new ID3v1 tag will be placed after it.
  123. *
  124. * \note The Tag <b>is still</b> owned by the TTA::File and should not be
  125. * deleted by the user. It will be deleted when the file (object) is
  126. * destroyed.
  127. */
  128. ID3v2::Tag *ID3v2Tag(bool create = false);
  129. /*!
  130. * This will remove the tags that match the OR-ed together TagTypes from the
  131. * file. By default it removes all tags.
  132. *
  133. * \note This will also invalidate pointers to the tags
  134. * as their memory will be freed.
  135. * \note In order to make the removal permanent save() still needs to be called
  136. */
  137. void remove(int tags = AllTags);
  138. private:
  139. File(const File &);
  140. File &operator=(const File &);
  141. void read(bool readProperties, Properties::ReadStyle propertiesStyle);
  142. void scan();
  143. long findID3v1();
  144. long findID3v2();
  145. class FilePrivate;
  146. FilePrivate *d;
  147. };
  148. }
  149. }
  150. #endif