id3lib  3.8.3
tag.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: tag.h,v 1.63 2003/03/02 13:35:59 t1mpy Exp $
3 
4 // id3lib: a software library for creating and manipulating id3v1/v2 tags
5 // Copyright 1999, 2000 Scott Thomas Haug
6 // Copyright 2002 Thijmen Klok (thijmen@id3lib.org)
7 
8 // This library is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU Library General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or (at your
11 // option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16 // License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public License
19 // along with this library; if not, write to the Free Software Foundation,
20 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22 // The id3lib authors encourage improvements and optimisations to be sent to
23 // the id3lib coordinator. Please see the README file for details on where to
24 // send such submissions. See the AUTHORS file for a list of people who have
25 // contributed to id3lib. See the ChangeLog file for a list of changes to
26 // id3lib. These files are distributed with id3lib at
27 // http://download.sourceforge.net/id3lib/
28 
29 #ifndef _ID3LIB_TAG_H_
30 #define _ID3LIB_TAG_H_
31 
32 #include <id3/id3lib_frame.h>
33 #include <id3/field.h>
34 #include <id3/utils.h>//for ID3_PATH_LENGTH
35 
36 class ID3_Reader;
37 class ID3_Writer;
38 class ID3_TagImpl;
39 class ID3_Tag;
40 
42 {
43  ID3_TagImpl* _impl;
44  char _tmp_filename[ID3_PATH_LENGTH];
45 public:
46 
47  class Iterator
48  {
49  public:
50  virtual ID3_Frame* GetNext() = 0;
51  };
52 
54  {
55  public:
56  virtual const ID3_Frame* GetNext() = 0;
57  };
58 
59 public:
60 
61  ID3_Tag(const char *name = NULL);
62  ID3_Tag(const ID3_Tag &tag);
63  virtual ~ID3_Tag();
64 
65  void Clear();
66  bool HasChanged() const;
67  size_t Size() const;
68 
69  bool SetUnsync(bool);
70  bool SetExtendedHeader(bool);
71  bool SetExperimental(bool);
72 
73  bool GetUnsync() const;
74  bool GetExtendedHeader() const;
75  bool GetExperimental() const;
76 
77  bool SetPadding(bool);
78 
79  void AddFrame(const ID3_Frame&);
80  void AddFrame(const ID3_Frame*);
81  bool AttachFrame(ID3_Frame*);
82  ID3_Frame* RemoveFrame(const ID3_Frame *);
83 
84  size_t Parse(const uchar*, size_t);
85  bool Parse(ID3_Reader& reader);
86  size_t Render(uchar*, ID3_TagType = ID3TT_ID3V2) const;
87  size_t Render(ID3_Writer&, ID3_TagType = ID3TT_ID3V2) const;
88 
89  size_t Link(const char *fileInfo, flags_t = (flags_t) ID3TT_ALL);
90  size_t Link(ID3_Reader &reader, flags_t = (flags_t) ID3TT_ALL);
91  flags_t Update(flags_t = (flags_t) ID3TT_ALL);
92  flags_t Strip(flags_t = (flags_t) ID3TT_ALL);
93 
94  size_t GetPrependedBytes() const;
95  size_t GetAppendedBytes() const;
96  size_t GetFileSize() const;
97  const char* GetFileName() const;
98 
99  ID3_Frame* Find(ID3_FrameID) const;
100  ID3_Frame* Find(ID3_FrameID, ID3_FieldID, uint32) const;
101  ID3_Frame* Find(ID3_FrameID, ID3_FieldID, const char*) const;
102  ID3_Frame* Find(ID3_FrameID, ID3_FieldID, const unicode_t*) const;
103 
104  size_t NumFrames() const;
105 
106  const Mp3_Headerinfo* GetMp3HeaderInfo() const;
107 
108  Iterator* CreateIterator();
109  ConstIterator* CreateIterator() const;
110 
111  ID3_Tag& operator=( const ID3_Tag & );
112 
113  bool HasTagType(ID3_TagType tt) const;
114  ID3_V2Spec GetSpec() const;
115  bool SetSpec(ID3_V2Spec);
116 
117  static size_t IsV2Tag(const uchar*);
118  static size_t IsV2Tag(ID3_Reader&);
119 
120  /* Deprecated! */
121  void AddNewFrame(ID3_Frame* f);
122  size_t Link(const char *fileInfo, bool parseID3v1, bool parseLyrics3);
123  void SetCompression(bool);
124  void AddFrames(const ID3_Frame *, size_t);
125  bool HasLyrics() const;
126  bool HasV2Tag() const;
127  bool HasV1Tag() const;
128  size_t Parse(const uchar header[ID3_TAGHEADERSIZE], const uchar *buffer);
129  //ID3_Frame* operator[](size_t) const;
130  //ID3_Frame* GetFrameNum(size_t) const;
131 
132  ID3_Tag& operator<<(const ID3_Frame &);
133  ID3_Tag& operator<<(const ID3_Frame *);
134 };
135 
136 // deprecated!
138 
139 
140 #endif /* _ID3LIB_TAG_H_ */
141 
The representative class of an id3v2 frame.
virtual const ID3_Frame * GetNext()=0
virtual ID3_Frame * GetNext()=0
The representative class of an id3 tag.
Definition: tag.h:42
#define NULL
Definition: globals.h:743
ID3_FieldID
Enumeration of the different types of fields in a frame.
Definition: globals.h:198
ID3_TagType
The various types of tags that id3lib can handle.
Definition: globals.h:175
@ ID3TT_ID3V2
Represents an id3v2 tag.
Definition: globals.h:178
@ ID3TT_ALL
Represents all possible types of tags.
Definition: globals.h:187
#define ID3_C_EXPORT
This file defines common macros, types, constants, and enums used throughout id3lib.
Definition: globals.h:78
ID3_V2Spec
Definition: globals.h:162
unsigned char uchar
Definition: globals.h:114
uint16 unicode_t
Definition: globals.h:117
ID3_FrameID
Enumeration of the different types of frames recognized by id3lib.
Definition: globals.h:230
#define ID3_CPP_EXPORT
Definition: globals.h:79
uint16 flags_t
Definition: globals.h:118
#define ID3_TAGHEADERSIZE
Definition: globals.h:104
int32 ID3_C_EXPORT ID3_IsTagHeader(const uchar header[ID3_TAGHEADERSIZE])
Definition: tag.cpp:1054
#define ID3_PATH_LENGTH
Definition: utils.h:46