id3lib
3.8.3
Main Page
Namespaces
Classes
Files
File List
File Members
src
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
Generated for id3lib by
1.8.1.1