taglib/mpc/apetag.h
Allan Sandfeld Jensen 2025c4e9e5 Large update:
* Give access to APEv2 features like lists and read-only fields (not enforced by TagLib).
* Support one common mistake: ID3v1 tags placed after an APE-tag. In this case both tags are now read and maintained. APE-tags after an ID3v1 tag is not supported.


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@332903 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2004-07-26 12:58:59 +00:00

157 lines
4.4 KiB
C++

/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************/
#ifndef TAGLIB_APETAG_H
#define TAGLIB_APETAG_H
#include "tag.h"
#include "tbytevector.h"
#include "tmap.h"
#include "tstring.h"
#include "tstringlist.h"
namespace TagLib {
class File;
namespace APE {
/*!
* A non-binary APE-item.
*/
struct Item {
Item() {};
explicit Item(const String&);
explicit Item(const StringList&);
bool readOnly;
bool locator; // URL to external data
StringList value;
bool isEmpty() const;
};
/*!
* A mapping between a list of item names, or keys, and the associated item.
*
* \see APE::Tag::itemListMap()
*/
typedef Map<const String, Item> FieldListMap;
//! An APE tag implementation
class Tag : public TagLib::Tag
{
public:
/*!
* Create an APE tag with default values.
*/
Tag();
/*!
* Create an APE tag and parse the data in \a file with APE footer at
* \a tagOffset.
*/
Tag(File *file, long tagOffset);
/*!
* Destroys this Tag instance.
*/
virtual ~Tag();
/*!
* Renders the in memory values to a ByteVector suitable for writing to
* the file.
*/
ByteVector render() const;
/*!
* Returns the string "APETAGEX" suitable for usage in locating the tag in a
* file.
*/
static ByteVector fileIdentifier();
/*!
* Returns the size of the tag calculated based on the footer.
*/
static uint tagSize(const ByteVector &footer);
// Reimplementations.
virtual String title() const;
virtual String artist() const;
virtual String album() const;
virtual String comment() const;
virtual String genre() const;
virtual uint year() const;
virtual uint track() const;
virtual void setTitle(const String &s);
virtual void setArtist(const String &s);
virtual void setAlbum(const String &s);
virtual void setComment(const String &s);
virtual void setGenre(const String &s);
virtual void setYear(uint i);
virtual void setTrack(uint i);
const FieldListMap &fieldListMap() const;
/*!
* Removes the \a key comment from the tag
*/
void removeField(const String &key);
/*!
* Adds the \a key comment with \a value
*/
void addField(const String &key, const String &value, bool replace = true);
/*!
* Adds the \a key comment with \a values
*/
void addField(const String &key, const StringList &values);
protected:
/*!
* Adds the \a key comment with \a item
*/
void addItem(const String &key, const Item &item);
/*!
* Reads from the file specified in the constructor.
*/
void read();
/*!
* Parses the body of the tag in \a data with \a count items.
*/
void parse(const ByteVector &data, uint count);
private:
Tag(const Tag &);
Tag &operator=(const Tag &);
class TagPrivate;
TagPrivate *d;
};
}
}
#endif