id3lib 3.8.3

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

tag_impl.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: tag_impl.h,v 1.10 2002/11/02 17:35:56 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_IMPL_H_
30 #define _ID3LIB_TAG_IMPL_H_
31
32 #include <list>
33 #include <stdio.h>
34 #include "tag.h" // has frame.h, field.h
35 #include "header_tag.h"
36 #include "mp3_header.h" //has io_decorators.h
37
38 class ID3_Reader;
39 class ID3_Writer;
40
41 namespace dami
42 {
43 namespace id3
44 {
45 namespace v1
46 {
47 bool parse(ID3_TagImpl&, ID3_Reader&);
48 void render(ID3_Writer&, const ID3_TagImpl&);
49 };
50 namespace v2
51 {
52 bool parse(ID3_TagImpl& tag, ID3_Reader& rdr);
53 void render(ID3_Writer& writer, const ID3_TagImpl& tag);
54 };
55 };
56 namespace lyr3
57 {
58 namespace v1
59 {
60 bool parse(ID3_TagImpl&, ID3_Reader&);
61 };
62 namespace v2
63 {
64 bool parse(ID3_TagImpl&, ID3_Reader&);
65 };
66 };
67 namespace mm
68 {
69 bool parse(ID3_TagImpl&, ID3_Reader&);
70 };
71 };
72
73 class ID3_TagImpl
74 {
75 typedef std::list<ID3_Frame *> Frames;
76 public:
77 typedef Frames::iterator iterator;
78 typedef Frames::const_iterator const_iterator;
79 public:
80 ID3_TagImpl(const char *name = NULL);
81 ID3_TagImpl(const ID3_Tag &tag);
82 virtual ~ID3_TagImpl();
83
84 void Clear();
85 bool HasChanged() const;
86 void SetChanged(bool b) { _changed = b; }
87 size_t Size() const;
88
89 bool SetUnsync(bool);
90 bool SetExtended(bool);
91 bool SetExperimental(bool);
92 bool SetPadding(bool);
93
94 bool GetUnsync() const;
95 bool GetExtended() const;
96 bool GetExperimental() const;
97 bool GetFooter() const;
98
99 size_t GetExtendedBytes() const;
100
101 void AddFrame(const ID3_Frame&);
102 void AddFrame(const ID3_Frame*);
103 bool AttachFrame(ID3_Frame*);
104 ID3_Frame* RemoveFrame(const ID3_Frame *);
105
106 size_t Link(const char *fileInfo, flags_t = (flags_t) ID3TT_ALL);
107 size_t Link(ID3_Reader &reader, flags_t = (flags_t) ID3TT_ALL);
108 flags_t Update(flags_t = (flags_t) ID3TT_ALL);
109 flags_t Strip(flags_t = (flags_t) ID3TT_ALL);
110
111 size_t GetPrependedBytes() const { return _prepended_bytes; }
112 size_t GetAppendedBytes() const { return _appended_bytes; }
113 size_t GetFileSize() const { return _file_size; }
114 dami::String GetFileName() const { return _file_name; }
115
116 ID3_Frame* Find(ID3_FrameID id) const;
117 ID3_Frame* Find(ID3_FrameID id, ID3_FieldID fld, uint32 data) const;
118 ID3_Frame* Find(ID3_FrameID id, ID3_FieldID fld, dami::String) const;
119 ID3_Frame* Find(ID3_FrameID id, ID3_FieldID fld, dami::WString) const;
120
121 size_t NumFrames() const { return _frames.size(); }
122 ID3_TagImpl& operator=( const ID3_Tag & );
123
124 bool HasTagType(ID3_TagType tt) const { return _file_tags.test(tt); }
125 ID3_V2Spec GetSpec() const;
126 bool SetSpec(ID3_V2Spec);
127
128 static size_t IsV2Tag(ID3_Reader&);
129
130 const Mp3_Headerinfo* GetMp3HeaderInfo() const { if (_mp3_info) return _mp3_info->GetMp3HeaderInfo(); else return NULL; }
131
132 iterator begin() { return _frames.begin(); }
133 iterator end() { return _frames.end(); }
134 const_iterator begin() const { return _frames.begin(); }
135 const_iterator end() const { return _frames.end(); }
136
137 /* Deprecated! */
138 void AddNewFrame(ID3_Frame* f) { this->AttachFrame(f); }
139 size_t Link(const char *fileInfo, bool parseID3v1, bool parseLyrics3);
140 void SetCompression(bool) { ; }
141 void AddFrames(const ID3_Frame *, size_t);
142 bool HasLyrics() const { return this->HasTagType(ID3TT_LYRICS); }
143 bool HasV2Tag() const { return this->HasTagType(ID3TT_ID3V2); }
144 bool HasV1Tag() const { return this->HasTagType(ID3TT_ID3V1); }
145 size_t PaddingSize(size_t) const;
146
147 protected:
148 const_iterator Find(const ID3_Frame *) const;
149 iterator Find(const ID3_Frame *);
150
151 void RenderExtHeader(uchar *);
152
153 void ParseFile();
154 void ParseReader(ID3_Reader &reader);
155
156 private:
157 ID3_TagHeader _hdr; // information relevant to the tag header
158 bool _is_padded; // add padding to tags?
159
160 Frames _frames;
161
162 mutable const_iterator _cursor; // which frame in list are we at
163 mutable bool _changed; // has tag changed since last parse or render?
164
165 // file-related member variables
166 dami::String _file_name; // name of the file we are linked to
167 size_t _file_size; // the size of the file (without any tag(s))
168 size_t _prepended_bytes; // number of tag bytes at start of file
169 size_t _appended_bytes; // number of tag bytes at end of file
170 bool _is_file_writable;// is the associated file (via Link) writable?
171 ID3_Flags _tags_to_parse; // which tag types should attempt to be parsed
172 ID3_Flags _file_tags; // which tag types does the file contain
173 Mp3Info *_mp3_info; // class used to retrieve _mp3_header
174 };
175
176 size_t ID3_GetDataSize(const ID3_TagImpl&);
177
178 #endif /* _ID3LIB_TAG_IMPL_H_ */
179
tag.h
ID3_TagImpl::ParseFile
void ParseFile()
Definition: tag_parse.cpp:205
ID3_TagImpl::GetExtendedBytes
size_t GetExtendedBytes() const
Definition: tag_impl.cpp:278
ID3_TagImpl::GetExtended
bool GetExtended() const
Definition: tag_impl.cpp:263
ID3_TagImpl::HasV2Tag
bool HasV2Tag() const
Definition: tag_impl.h:143
dami::mm::parse
bool parse(ID3_TagImpl &, ID3_Reader &)
Definition: tag_parse_musicmatch.cpp:115
ID3_TagImpl::end
iterator end()
Definition: tag_impl.h:133
ID3_TagImpl::begin
iterator begin()
Definition: tag_impl.h:132
header_tag.h
ID3_Flags::test
bool test(TYPE f) const
Definition: flags.h:42
ID3_TagImpl::GetFileName
dami::String GetFileName() const
Definition: tag_impl.h:114
ID3_TagImpl::SetCompression
void SetCompression(bool)
Definition: tag_impl.h:140
ID3_TagImpl::SetChanged
void SetChanged(bool b)
Definition: tag_impl.h:86
ID3_TagType
ID3_TagType
The various types of tags that id3lib can handle.
Definition: globals.h:174
ID3_TagImpl::SetExperimental
bool SetExperimental(bool)
Definition: tag_impl.cpp:251
dami::String
std::basic_string< char > String
Definition: id3lib_strings.h:198
ID3_TagImpl
Definition: tag_impl.h:73
ID3_TagImpl::GetFooter
bool GetFooter() const
Definition: tag_impl.cpp:273
ID3_Tag
The representative class of an id3 tag.
Definition: tag.h:41
ID3_TagImpl::Clear
void Clear()
Definition: tag_impl.cpp:126
flags_t
uint16 flags_t
Definition: globals.h:118
ID3_TagImpl::Link
size_t Link(const char *fileInfo, flags_t=(flags_t) ID3TT_ALL)
Definition: tag_file.cpp:131
ID3_TagImpl::begin
const_iterator begin() const
Definition: tag_impl.h:134
ID3_GetDataSize
size_t ID3_GetDataSize(const ID3_TagImpl &tag)
Definition: tag_impl.cpp:323
ID3_TagImpl::AddFrame
void AddFrame(const ID3_Frame &)
Definition: tag_impl.cpp:153
dami::id3::v2::render
void render(ID3_Writer &writer, const ID3_TagImpl &tag)
Definition: tag_render.cpp:78
ID3_TagImpl::NumFrames
size_t NumFrames() const
Definition: tag_impl.h:121
ID3_TagImpl::PaddingSize
size_t PaddingSize(size_t) const
Definition: tag_render.cpp:192
ID3_TagImpl::GetExperimental
bool GetExperimental() const
Definition: tag_impl.cpp:268
ID3_TagImpl::SetExtended
bool SetExtended(bool)
Definition: tag_impl.cpp:244
ID3_TagHeader
Definition: header_tag.h:34
ID3_FrameID
ID3_FrameID
Enumeration of the different types of frames recognized by id3lib.
Definition: globals.h:229
ID3_TagImpl::GetPrependedBytes
size_t GetPrependedBytes() const
Definition: tag_impl.h:111
uchar
unsigned char uchar
Definition: globals.h:114
ID3TT_ALL
Represents all possible types of tags.
Definition: globals.h:187
dami::id3::v1::render
void render(ID3_Writer &, const ID3_TagImpl &)
Definition: tag_render.cpp:42
ID3_TagImpl::Find
ID3_Frame * Find(ID3_FrameID id) const
Definition: tag_find.cpp:61
dami::id3::v2::parse
bool parse(ID3_TagImpl &tag, ID3_Reader &rdr)
Definition: tag_parse.cpp:137
mp3_header.h
ID3_TagImpl::~ID3_TagImpl
virtual ~ID3_TagImpl()
Definition: tag_impl.cpp:121
ID3_TagImpl::Update
flags_t Update(flags_t=(flags_t) ID3TT_ALL)
Definition: tag_file.cpp:323
dami::id3::v1::parse
bool parse(ID3_TagImpl &, ID3_Reader &)
Definition: tag_parse_v1.cpp:35
ID3_TagImpl::GetFileSize
size_t GetFileSize() const
Definition: tag_impl.h:113
ID3_TagImpl::SetPadding
bool SetPadding(bool)
Definition: tag_impl.cpp:291
ID3_Reader
Definition: reader.h:33
ID3_TagImpl::HasLyrics
bool HasLyrics() const
Definition: tag_impl.h:142
ID3_TagImpl::GetUnsync
bool GetUnsync() const
Definition: tag_impl.cpp:258
ID3_TagImpl::AttachFrame
bool AttachFrame(ID3_Frame *)
Definition: tag_impl.cpp:167
Mp3_Headerinfo
Definition: globals.h:521
ID3_V2Spec
ID3_V2Spec
Definition: globals.h:161
dami::lyr3::v2::parse
bool parse(ID3_TagImpl &, ID3_Reader &)
Definition: tag_parse_lyrics3.cpp:222
ID3_TagImpl::RenderExtHeader
void RenderExtHeader(uchar *)
Definition: tag_render.cpp:178
ID3_TagImpl::GetMp3HeaderInfo
const Mp3_Headerinfo * GetMp3HeaderInfo() const
Definition: tag_impl.h:130
ID3_TagImpl::GetSpec
ID3_V2Spec GetSpec() const
Definition: tag_impl.cpp:232
ID3_Frame
The representative class of an id3v2 frame.
Definition: id3lib_frame.h:38
ID3_TagImpl::operator=
ID3_TagImpl & operator=(const ID3_Tag &)
Definition: tag_impl.cpp:305
ID3TT_ID3V2
Represents an id3v2 tag.
Definition: globals.h:178
ID3_TagImpl::const_iterator
Frames::const_iterator const_iterator
Definition: tag_impl.h:78
dami::WString
std::basic_string< wchar_t > WString
Definition: id3lib_strings.h:200
ID3_TagImpl::IsV2Tag
static size_t IsV2Tag(ID3_Reader &)
Definition: tag_impl.cpp:38
dami::lyr3::v1::parse
bool parse(ID3_TagImpl &, ID3_Reader &)
Definition: tag_parse_lyrics3.cpp:171
ID3_TagImpl::RemoveFrame
ID3_Frame * RemoveFrame(const ID3_Frame *)
Definition: tag_impl.cpp:185
ID3_TagImpl::iterator
Frames::iterator iterator
Definition: tag_impl.h:77
ID3_TagImpl::end
const_iterator end() const
Definition: tag_impl.h:135
ID3_TagImpl::ParseReader
void ParseReader(ID3_Reader &reader)
Definition: tag_parse.cpp:219
ID3_TagImpl::AddFrames
void AddFrames(const ID3_Frame *, size_t)
NULL
#define NULL
Definition: globals.h:743
ID3_TagImpl::HasV1Tag
bool HasV1Tag() const
Definition: tag_impl.h:144
ID3_TagImpl::GetAppendedBytes
size_t GetAppendedBytes() const
Definition: tag_impl.h:112
ID3_TagImpl::HasChanged
bool HasChanged() const
Definition: tag_impl.cpp:202
ID3_TagImpl::AddNewFrame
void AddNewFrame(ID3_Frame *f)
Definition: tag_impl.h:138
ID3TT_LYRICS
Definition: globals.h:183
ID3_Writer
Definition: writer.h:33
ID3_TagImpl::HasTagType
bool HasTagType(ID3_TagType tt) const
Definition: tag_impl.h:124
Mp3Info::GetMp3HeaderInfo
const Mp3_Headerinfo * GetMp3HeaderInfo() const
Definition: mp3_header.h:40
ID3_TagImpl::Size
size_t Size() const
Definition: tag_render.cpp:140
Mp3Info
Definition: mp3_header.h:33
ID3_TagImpl::ID3_TagImpl
ID3_TagImpl(const char *name=NULL)
Definition: tag_impl.cpp:91
ID3_TagImpl::SetUnsync
bool SetUnsync(bool)
Definition: tag_impl.cpp:237
ID3TT_ID3V1
Represents an id3v1 or id3v1.1 tag.
Definition: globals.h:177
ID3_FieldID
ID3_FieldID
Enumeration of the different types of fields in a frame.
Definition: globals.h:197
ID3_TagImpl::SetSpec
bool SetSpec(ID3_V2Spec)
Definition: tag_impl.cpp:225
ID3_Flags
Definition: flags.h:33
ID3_TagImpl::Strip
flags_t Strip(flags_t=(flags_t) ID3TT_ALL)
Definition: tag_file.cpp:371